documentation.d.ts 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static get Now(): number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /**
  583. * @hidden
  584. **/
  585. export class _TimeToken {
  586. _startTimeQuery: Nullable<WebGLQuery>;
  587. _endTimeQuery: Nullable<WebGLQuery>;
  588. _timeElapsedQuery: Nullable<WebGLQuery>;
  589. _timeElapsedQueryEnded: boolean;
  590. }
  591. }
  592. declare module BABYLON {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module BABYLON {
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module BABYLON {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module BABYLON {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. get underlyingResource(): any;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export interface ProcessingOptions {
  1150. defines: string[];
  1151. indexParameters: any;
  1152. isFragment: boolean;
  1153. shouldUseHighPrecisionShader: boolean;
  1154. supportsUniformBuffers: boolean;
  1155. shadersRepository: string;
  1156. includesShadersStore: {
  1157. [key: string]: string;
  1158. };
  1159. processor?: IShaderProcessor;
  1160. version: string;
  1161. platformName: string;
  1162. lookForClosingBracketForUniformBuffer?: boolean;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderCodeNode {
  1168. line: string;
  1169. children: ShaderCodeNode[];
  1170. additionalDefineKey?: string;
  1171. additionalDefineValue?: string;
  1172. isValid(preprocessors: {
  1173. [key: string]: string;
  1174. }): boolean;
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderCodeCursor {
  1183. private _lines;
  1184. lineIndex: number;
  1185. get currentLine(): string;
  1186. get canRead(): boolean;
  1187. set lines(value: string[]);
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1193. process(preprocessors: {
  1194. [key: string]: string;
  1195. }, options: ProcessingOptions): string;
  1196. }
  1197. }
  1198. declare module BABYLON {
  1199. /** @hidden */
  1200. export class ShaderDefineExpression {
  1201. isTrue(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeTestNode extends ShaderCodeNode {
  1209. testExpression: ShaderDefineExpression;
  1210. isValid(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1218. define: string;
  1219. not: boolean;
  1220. constructor(define: string, not?: boolean);
  1221. isTrue(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module BABYLON {
  1237. /** @hidden */
  1238. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1239. leftOperand: ShaderDefineExpression;
  1240. rightOperand: ShaderDefineExpression;
  1241. isTrue(preprocessors: {
  1242. [key: string]: string;
  1243. }): boolean;
  1244. }
  1245. }
  1246. declare module BABYLON {
  1247. /** @hidden */
  1248. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1249. define: string;
  1250. operand: string;
  1251. testValue: string;
  1252. constructor(define: string, operand: string, testValue: string);
  1253. isTrue(preprocessors: {
  1254. [key: string]: string;
  1255. }): boolean;
  1256. }
  1257. }
  1258. declare module BABYLON {
  1259. /**
  1260. * Class used to enable access to offline support
  1261. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1262. */
  1263. export interface IOfflineProvider {
  1264. /**
  1265. * Gets a boolean indicating if scene must be saved in the database
  1266. */
  1267. enableSceneOffline: boolean;
  1268. /**
  1269. * Gets a boolean indicating if textures must be saved in the database
  1270. */
  1271. enableTexturesOffline: boolean;
  1272. /**
  1273. * Open the offline support and make it available
  1274. * @param successCallback defines the callback to call on success
  1275. * @param errorCallback defines the callback to call on error
  1276. */
  1277. open(successCallback: () => void, errorCallback: () => void): void;
  1278. /**
  1279. * Loads an image from the offline support
  1280. * @param url defines the url to load from
  1281. * @param image defines the target DOM image
  1282. */
  1283. loadImage(url: string, image: HTMLImageElement): void;
  1284. /**
  1285. * Loads a file from offline support
  1286. * @param url defines the URL to load from
  1287. * @param sceneLoaded defines a callback to call on success
  1288. * @param progressCallBack defines a callback to call when progress changed
  1289. * @param errorCallback defines a callback to call on error
  1290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1291. */
  1292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to help managing file picking and drag'n'drop
  1298. * File Storage
  1299. */
  1300. export class FilesInputStore {
  1301. /**
  1302. * List of files ready to be loaded
  1303. */
  1304. static FilesToLoad: {
  1305. [key: string]: File;
  1306. };
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * Class used to define a retry strategy when error happens while loading assets
  1312. */
  1313. export class RetryStrategy {
  1314. /**
  1315. * Function used to defines an exponential back off strategy
  1316. * @param maxRetries defines the maximum number of retries (3 by default)
  1317. * @param baseInterval defines the interval between retries
  1318. * @returns the strategy function to use
  1319. */
  1320. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /**
  1325. * @ignore
  1326. * Application error to support additional information when loading a file
  1327. */
  1328. export abstract class BaseError extends Error {
  1329. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1330. }
  1331. }
  1332. declare module BABYLON {
  1333. /** @ignore */
  1334. export class LoadFileError extends BaseError {
  1335. request?: WebRequest;
  1336. file?: File;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. * @param file defines the optional file
  1342. */
  1343. constructor(message: string, object?: WebRequest | File);
  1344. }
  1345. /** @ignore */
  1346. export class RequestFileError extends BaseError {
  1347. request: WebRequest;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. */
  1353. constructor(message: string, request: WebRequest);
  1354. }
  1355. /** @ignore */
  1356. export class ReadFileError extends BaseError {
  1357. file: File;
  1358. /**
  1359. * Creates a new ReadFileError
  1360. * @param message defines the message of the error
  1361. * @param file defines the optional file
  1362. */
  1363. constructor(message: string, file: File);
  1364. }
  1365. /**
  1366. * @hidden
  1367. */
  1368. export class FileTools {
  1369. /**
  1370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1371. */
  1372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1373. /**
  1374. * Gets or sets the base URL to use to load assets
  1375. */
  1376. static BaseUrl: string;
  1377. /**
  1378. * Default behaviour for cors in the application.
  1379. * It can be a string if the expected behavior is identical in the entire app.
  1380. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1381. */
  1382. static CorsBehavior: string | ((url: string | string[]) => string);
  1383. /**
  1384. * Gets or sets a function used to pre-process url before using them to load assets
  1385. */
  1386. static PreprocessUrl: (url: string) => string;
  1387. /**
  1388. * Removes unwanted characters from an url
  1389. * @param url defines the url to clean
  1390. * @returns the cleaned url
  1391. */
  1392. private static _CleanUrl;
  1393. /**
  1394. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1395. * @param url define the url we are trying
  1396. * @param element define the dom element where to configure the cors policy
  1397. */
  1398. static SetCorsBehavior(url: string | string[], element: {
  1399. crossOrigin: string | null;
  1400. }): void;
  1401. /**
  1402. * Loads an image as an HTMLImageElement.
  1403. * @param input url string, ArrayBuffer, or Blob to load
  1404. * @param onLoad callback called when the image successfully loads
  1405. * @param onError callback called when the image fails to load
  1406. * @param offlineProvider offline provider for caching
  1407. * @param mimeType optional mime type
  1408. * @returns the HTMLImageElement of the loaded image
  1409. */
  1410. 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>;
  1411. /**
  1412. * Reads a file from a File object
  1413. * @param file defines the file to load
  1414. * @param onSuccess defines the callback to call when data is loaded
  1415. * @param onProgress defines the callback to call during loading process
  1416. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1417. * @param onError defines the callback to call when an error occurs
  1418. * @returns a file request object
  1419. */
  1420. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1421. /**
  1422. * Loads a file from a url
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param offlineProvider defines the offline provider for caching
  1427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1428. * @param onError callback called when the file fails to load
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Loads a file
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1438. * @param onError callback called when the file fails to load
  1439. * @param onOpened callback called when the web request is opened
  1440. * @returns a file request object
  1441. */
  1442. 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;
  1443. /**
  1444. * Checks if the loaded document was accessed via `file:`-Protocol.
  1445. * @returns boolean
  1446. */
  1447. static IsFileURL(): boolean;
  1448. }
  1449. }
  1450. declare module BABYLON {
  1451. /** @hidden */
  1452. export class ShaderProcessor {
  1453. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1454. private static _ProcessPrecision;
  1455. private static _ExtractOperation;
  1456. private static _BuildSubExpression;
  1457. private static _BuildExpression;
  1458. private static _MoveCursorWithinIf;
  1459. private static _MoveCursor;
  1460. private static _EvaluatePreProcessors;
  1461. private static _PreparePreProcessors;
  1462. private static _ProcessShaderConversion;
  1463. private static _ProcessIncludes;
  1464. /**
  1465. * Loads a file from a url
  1466. * @param url url to load
  1467. * @param onSuccess callback called when the file successfully loads
  1468. * @param onProgress callback called while file is loading (if the server supports this mode)
  1469. * @param offlineProvider defines the offline provider for caching
  1470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1471. * @param onError callback called when the file fails to load
  1472. * @returns a file request object
  1473. * @hidden
  1474. */
  1475. 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;
  1476. }
  1477. }
  1478. declare module BABYLON {
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor4Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. a: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IColor3Like {
  1492. r: float;
  1493. g: float;
  1494. b: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector4Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. w: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IVector3Like {
  1509. x: float;
  1510. y: float;
  1511. z: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector2Like {
  1517. x: float;
  1518. y: float;
  1519. }
  1520. /**
  1521. * @hidden
  1522. */
  1523. export interface IMatrixLike {
  1524. toArray(): DeepImmutable<Float32Array>;
  1525. updateFlag: int;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IViewportLike {
  1531. x: float;
  1532. y: float;
  1533. width: float;
  1534. height: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IPlaneLike {
  1540. normal: IVector3Like;
  1541. d: float;
  1542. normalize(): void;
  1543. }
  1544. }
  1545. declare module BABYLON {
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module BABYLON {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module BABYLON {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. }
  1850. declare module BABYLON {
  1851. /**
  1852. * Class used to represent a viewport on screen
  1853. */
  1854. export class Viewport {
  1855. /** viewport left coordinate */
  1856. x: number;
  1857. /** viewport top coordinate */
  1858. y: number;
  1859. /**viewport width */
  1860. width: number;
  1861. /** viewport height */
  1862. height: number;
  1863. /**
  1864. * Creates a Viewport object located at (x, y) and sized (width, height)
  1865. * @param x defines viewport left coordinate
  1866. * @param y defines viewport top coordinate
  1867. * @param width defines the viewport width
  1868. * @param height defines the viewport height
  1869. */
  1870. constructor(
  1871. /** viewport left coordinate */
  1872. x: number,
  1873. /** viewport top coordinate */
  1874. y: number,
  1875. /**viewport width */
  1876. width: number,
  1877. /** viewport height */
  1878. height: number);
  1879. /**
  1880. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1881. * @param renderWidth defines the rendering width
  1882. * @param renderHeight defines the rendering height
  1883. * @returns a new Viewport
  1884. */
  1885. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1886. /**
  1887. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1888. * @param renderWidth defines the rendering width
  1889. * @param renderHeight defines the rendering height
  1890. * @param ref defines the target viewport
  1891. * @returns the current viewport
  1892. */
  1893. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1894. /**
  1895. * Returns a new Viewport copied from the current one
  1896. * @returns a new Viewport
  1897. */
  1898. clone(): Viewport;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class containing a set of static utilities functions for arrays.
  1904. */
  1905. export class ArrayTools {
  1906. /**
  1907. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1908. * @param size the number of element to construct and put in the array
  1909. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1910. * @returns a new array filled with new objects
  1911. */
  1912. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1913. }
  1914. }
  1915. declare module BABYLON {
  1916. /**
  1917. * Class representing a vector containing 2 coordinates
  1918. */
  1919. export class Vector2 {
  1920. /** defines the first coordinate */
  1921. x: number;
  1922. /** defines the second coordinate */
  1923. y: number;
  1924. /**
  1925. * Creates a new Vector2 from the given x and y coordinates
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. */
  1929. constructor(
  1930. /** defines the first coordinate */
  1931. x?: number,
  1932. /** defines the second coordinate */
  1933. y?: number);
  1934. /**
  1935. * Gets a string with the Vector2 coordinates
  1936. * @returns a string with the Vector2 coordinates
  1937. */
  1938. toString(): string;
  1939. /**
  1940. * Gets class name
  1941. * @returns the string "Vector2"
  1942. */
  1943. getClassName(): string;
  1944. /**
  1945. * Gets current vector hash code
  1946. * @returns the Vector2 hash code as a number
  1947. */
  1948. getHashCode(): number;
  1949. /**
  1950. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1951. * @param array defines the source array
  1952. * @param index defines the offset in source array
  1953. * @returns the current Vector2
  1954. */
  1955. toArray(array: FloatArray, index?: number): Vector2;
  1956. /**
  1957. * Copy the current vector to an array
  1958. * @returns a new array with 2 elements: the Vector2 coordinates.
  1959. */
  1960. asArray(): number[];
  1961. /**
  1962. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1963. * @param source defines the source Vector2
  1964. * @returns the current updated Vector2
  1965. */
  1966. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1967. /**
  1968. * Sets the Vector2 coordinates with the given floats
  1969. * @param x defines the first coordinate
  1970. * @param y defines the second coordinate
  1971. * @returns the current updated Vector2
  1972. */
  1973. copyFromFloats(x: number, y: number): Vector2;
  1974. /**
  1975. * Sets the Vector2 coordinates with the given floats
  1976. * @param x defines the first coordinate
  1977. * @param y defines the second coordinate
  1978. * @returns the current updated Vector2
  1979. */
  1980. set(x: number, y: number): Vector2;
  1981. /**
  1982. * Add another vector with the current one
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1985. */
  1986. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1987. /**
  1988. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1989. * @param otherVector defines the other vector
  1990. * @param result defines the target vector
  1991. * @returns the unmodified current Vector2
  1992. */
  1993. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1994. /**
  1995. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1996. * @param otherVector defines the other vector
  1997. * @returns the current updated Vector2
  1998. */
  1999. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2000. /**
  2001. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2
  2004. */
  2005. addVector3(otherVector: Vector3): Vector2;
  2006. /**
  2007. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. subtract(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Multiplies in place the current Vector2 coordinates by the given ones
  2027. * @param otherVector defines the other vector
  2028. * @returns the current updated Vector2
  2029. */
  2030. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2031. /**
  2032. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2033. * @param otherVector defines the other vector
  2034. * @returns a new Vector2
  2035. */
  2036. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2037. /**
  2038. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @param result defines the target vector
  2041. * @returns the unmodified current Vector2
  2042. */
  2043. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2044. /**
  2045. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2046. * @param x defines the first coordinate
  2047. * @param y defines the second coordinate
  2048. * @returns a new Vector2
  2049. */
  2050. multiplyByFloats(x: number, y: number): Vector2;
  2051. /**
  2052. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2053. * @param otherVector defines the other vector
  2054. * @returns a new Vector2
  2055. */
  2056. divide(otherVector: Vector2): Vector2;
  2057. /**
  2058. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2059. * @param otherVector defines the other vector
  2060. * @param result defines the target vector
  2061. * @returns the unmodified current Vector2
  2062. */
  2063. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2064. /**
  2065. * Divides the current Vector2 coordinates by the given ones
  2066. * @param otherVector defines the other vector
  2067. * @returns the current updated Vector2
  2068. */
  2069. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2070. /**
  2071. * Gets a new Vector2 with current Vector2 negated coordinates
  2072. * @returns a new Vector2
  2073. */
  2074. negate(): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * 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".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Multiplies the Vector3 coordinates by the float "scale"
  2433. * @param scale defines the multiplier factor
  2434. * @returns the current updated Vector3
  2435. */
  2436. scaleInPlace(scale: number): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns a new Vector3
  2441. */
  2442. scale(scale: number): Vector3;
  2443. /**
  2444. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2445. * @param scale defines the multiplier factor
  2446. * @param result defines the Vector3 object where to store the result
  2447. * @returns the current Vector3
  2448. */
  2449. scaleToRef(scale: number, result: Vector3): Vector3;
  2450. /**
  2451. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2452. * @param scale defines the scale factor
  2453. * @param result defines the Vector3 object where to store the result
  2454. * @returns the unmodified current Vector3
  2455. */
  2456. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2457. /**
  2458. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2459. * @param otherVector defines the second operand
  2460. * @returns true if both vectors are equals
  2461. */
  2462. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2465. * @param otherVector defines the second operand
  2466. * @param epsilon defines the minimal distance to define values as equals
  2467. * @returns true if both vectors are distant less than epsilon
  2468. */
  2469. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2470. /**
  2471. * Returns true if the current Vector3 coordinates equals the given floats
  2472. * @param x defines the x coordinate of the operand
  2473. * @param y defines the y coordinate of the operand
  2474. * @param z defines the z coordinate of the operand
  2475. * @returns true if both vectors are equals
  2476. */
  2477. equalsToFloats(x: number, y: number, z: number): boolean;
  2478. /**
  2479. * Multiplies the current Vector3 coordinates by the given ones
  2480. * @param otherVector defines the second operand
  2481. * @returns the current updated Vector3
  2482. */
  2483. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2484. /**
  2485. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2486. * @param otherVector defines the second operand
  2487. * @returns the new Vector3
  2488. */
  2489. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2492. * @param otherVector defines the second operand
  2493. * @param result defines the Vector3 object where to store the result
  2494. * @returns the current Vector3
  2495. */
  2496. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2497. /**
  2498. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2499. * @param x defines the x coordinate of the operand
  2500. * @param y defines the y coordinate of the operand
  2501. * @param z defines the z coordinate of the operand
  2502. * @returns the new Vector3
  2503. */
  2504. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Divides the current Vector3 coordinates by the given ones.
  2520. * @param otherVector defines the second operand
  2521. * @returns the current updated Vector3
  2522. */
  2523. divideInPlace(otherVector: Vector3): Vector3;
  2524. /**
  2525. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2526. * @param other defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2554. * Check if is non uniform within a certain amount of decimal places to account for this
  2555. * @param epsilon the amount the values can differ
  2556. * @returns if the the vector is non uniform to a certain number of decimal places
  2557. */
  2558. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2559. /**
  2560. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2561. */
  2562. get isNonUniform(): boolean;
  2563. /**
  2564. * Gets a new Vector3 from current Vector3 floored values
  2565. * @returns a new Vector3
  2566. */
  2567. floor(): Vector3;
  2568. /**
  2569. * Gets a new Vector3 from current Vector3 floored values
  2570. * @returns a new Vector3
  2571. */
  2572. fract(): Vector3;
  2573. /**
  2574. * Gets the length of the Vector3
  2575. * @returns the length of the Vector3
  2576. */
  2577. length(): number;
  2578. /**
  2579. * Gets the squared length of the Vector3
  2580. * @returns squared length of the Vector3
  2581. */
  2582. lengthSquared(): number;
  2583. /**
  2584. * Normalize the current Vector3.
  2585. * Please note that this is an in place operation.
  2586. * @returns the current updated Vector3
  2587. */
  2588. normalize(): Vector3;
  2589. /**
  2590. * Reorders the x y z properties of the vector in place
  2591. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2592. * @returns the current updated vector
  2593. */
  2594. reorderInPlace(order: string): this;
  2595. /**
  2596. * Rotates the vector around 0,0,0 by a quaternion
  2597. * @param quaternion the rotation quaternion
  2598. * @param result vector to store the result
  2599. * @returns the resulting vector
  2600. */
  2601. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2602. /**
  2603. * Rotates a vector around a given point
  2604. * @param quaternion the rotation quaternion
  2605. * @param point the point to rotate around
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2610. /**
  2611. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2612. * The cross product is then orthogonal to both current and "other"
  2613. * @param other defines the right operand
  2614. * @returns the cross product
  2615. */
  2616. cross(other: Vector3): Vector3;
  2617. /**
  2618. * Normalize the current Vector3 with the given input length.
  2619. * Please note that this is an in place operation.
  2620. * @param len the length of the vector
  2621. * @returns the current updated Vector3
  2622. */
  2623. normalizeFromLength(len: number): Vector3;
  2624. /**
  2625. * Normalize the current Vector3 to a new vector
  2626. * @returns the new Vector3
  2627. */
  2628. normalizeToNew(): Vector3;
  2629. /**
  2630. * Normalize the current Vector3 to the reference
  2631. * @param reference define the Vector3 to update
  2632. * @returns the updated Vector3
  2633. */
  2634. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2635. /**
  2636. * Creates a new Vector3 copied from the current Vector3
  2637. * @returns the new Vector3
  2638. */
  2639. clone(): Vector3;
  2640. /**
  2641. * Copies the given vector coordinates to the current Vector3 ones
  2642. * @param source defines the source Vector3
  2643. * @returns the current updated Vector3
  2644. */
  2645. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Copies the given floats to the current Vector3 coordinates
  2648. * @param x defines the x coordinate of the operand
  2649. * @param y defines the y coordinate of the operand
  2650. * @param z defines the z coordinate of the operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFromFloats(x: number, y: number, z: number): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. set(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given float to the current Vector3 coordinates
  2664. * @param v defines the x, y and z coordinates of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. setAll(v: number): Vector3;
  2668. /**
  2669. * Get the clip factor between two vectors
  2670. * @param vector0 defines the first operand
  2671. * @param vector1 defines the second operand
  2672. * @param axis defines the axis to use
  2673. * @param size defines the size along the axis
  2674. * @returns the clip factor
  2675. */
  2676. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2677. /**
  2678. * Get angle between two vectors
  2679. * @param vector0 angle between vector0 and vector1
  2680. * @param vector1 angle between vector0 and vector1
  2681. * @param normal direction of the normal
  2682. * @return the angle between vector0 and vector1
  2683. */
  2684. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2685. /**
  2686. * Returns a new Vector3 set from the index "offset" of the given array
  2687. * @param array defines the source array
  2688. * @param offset defines the offset in the source array
  2689. * @returns the new Vector3
  2690. */
  2691. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2692. /**
  2693. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2694. * @param array defines the source array
  2695. * @param offset defines the offset in the source array
  2696. * @returns the new Vector3
  2697. * @deprecated Please use FromArray instead.
  2698. */
  2699. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2700. /**
  2701. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @param result defines the Vector3 where to store the result
  2705. */
  2706. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2707. /**
  2708. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2709. * @param array defines the source array
  2710. * @param offset defines the offset in the source array
  2711. * @param result defines the Vector3 where to store the result
  2712. * @deprecated Please use FromArrayToRef instead.
  2713. */
  2714. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the given floats.
  2717. * @param x defines the x coordinate of the source
  2718. * @param y defines the y coordinate of the source
  2719. * @param z defines the z coordinate of the source
  2720. * @param result defines the Vector3 where to store the result
  2721. */
  2722. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2723. /**
  2724. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2725. * @returns a new empty Vector3
  2726. */
  2727. static Zero(): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2730. * @returns a new unit Vector3
  2731. */
  2732. static One(): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2735. * @returns a new up Vector3
  2736. */
  2737. static Up(): Vector3;
  2738. /**
  2739. * Gets a up Vector3 that must not be updated
  2740. */
  2741. static get UpReadOnly(): DeepImmutable<Vector3>;
  2742. /**
  2743. * Gets a zero Vector3 that must not be updated
  2744. */
  2745. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2746. /**
  2747. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2748. * @returns a new down Vector3
  2749. */
  2750. static Down(): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2753. * @returns a new forward Vector3
  2754. */
  2755. static Forward(): Vector3;
  2756. /**
  2757. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2758. * @returns a new forward Vector3
  2759. */
  2760. static Backward(): Vector3;
  2761. /**
  2762. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2763. * @returns a new right Vector3
  2764. */
  2765. static Right(): Vector3;
  2766. /**
  2767. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2768. * @returns a new left Vector3
  2769. */
  2770. static Left(): Vector3;
  2771. /**
  2772. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2773. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2774. * @param vector defines the Vector3 to transform
  2775. * @param transformation defines the transformation matrix
  2776. * @returns the transformed Vector3
  2777. */
  2778. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2779. /**
  2780. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @param result defines the Vector3 where to store the result
  2785. */
  2786. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2789. * This method computes tranformed coordinates only, not transformed direction vectors
  2790. * @param x define the x coordinate of the source vector
  2791. * @param y define the y coordinate of the source vector
  2792. * @param z define the z coordinate of the source vector
  2793. * @param transformation defines the transformation matrix
  2794. * @param result defines the Vector3 where to store the result
  2795. */
  2796. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2797. /**
  2798. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2799. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2800. * @param vector defines the Vector3 to transform
  2801. * @param transformation defines the transformation matrix
  2802. * @returns the new Vector3
  2803. */
  2804. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2805. /**
  2806. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @param result defines the Vector3 where to store the result
  2811. */
  2812. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param x define the x coordinate of the source vector
  2817. * @param y define the y coordinate of the source vector
  2818. * @param z define the z coordinate of the source vector
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2825. * @param value1 defines the first control point
  2826. * @param value2 defines the second control point
  2827. * @param value3 defines the third control point
  2828. * @param value4 defines the fourth control point
  2829. * @param amount defines the amount on the spline to use
  2830. * @returns the new Vector3
  2831. */
  2832. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2833. /**
  2834. * 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"
  2835. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2836. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2837. * @param value defines the current value
  2838. * @param min defines the lower range value
  2839. * @param max defines the upper range value
  2840. * @returns the new Vector3
  2841. */
  2842. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2843. /**
  2844. * 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"
  2845. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2846. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2847. * @param value defines the current value
  2848. * @param min defines the lower range value
  2849. * @param max defines the upper range value
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2853. /**
  2854. * Checks if a given vector is inside a specific range
  2855. * @param v defines the vector to test
  2856. * @param min defines the minimum range
  2857. * @param max defines the maximum range
  2858. */
  2859. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2860. /**
  2861. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2862. * @param value1 defines the first control point
  2863. * @param tangent1 defines the first tangent vector
  2864. * @param value2 defines the second control point
  2865. * @param tangent2 defines the second tangent vector
  2866. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2867. * @returns the new Vector3
  2868. */
  2869. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2870. /**
  2871. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2872. * @param start defines the start value
  2873. * @param end defines the end value
  2874. * @param amount max defines amount between both (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @param result defines the Vector3 where to store the result
  2884. */
  2885. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2886. /**
  2887. * Returns the dot product (float) between the vectors "left" and "right"
  2888. * @param left defines the left operand
  2889. * @param right defines the right operand
  2890. * @returns the dot product
  2891. */
  2892. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2895. * The cross product is then orthogonal to both "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the cross product
  2899. */
  2900. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2901. /**
  2902. * Sets the given vector "result" with the cross product of "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @param result defines the Vector3 where to store the result
  2907. */
  2908. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2909. /**
  2910. * Returns a new Vector3 as the normalization of the given vector
  2911. * @param vector defines the Vector3 to normalize
  2912. * @returns the new Vector3
  2913. */
  2914. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2915. /**
  2916. * Sets the given vector "result" with the normalization of the given first vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @param result defines the Vector3 where to store the result
  2919. */
  2920. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2921. /**
  2922. * Project a Vector3 onto screen space
  2923. * @param vector defines the Vector3 to project
  2924. * @param world defines the world matrix to use
  2925. * @param transform defines the transform (view x projection) matrix to use
  2926. * @param viewport defines the screen viewport to use
  2927. * @returns the new Vector3
  2928. */
  2929. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2930. /** @hidden */
  2931. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2932. /**
  2933. * Unproject from screen space to object space
  2934. * @param source defines the screen space Vector3 to use
  2935. * @param viewportWidth defines the current width of the viewport
  2936. * @param viewportHeight defines the current height of the viewport
  2937. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2938. * @param transform defines the transform (view x projection) matrix to use
  2939. * @returns the new Vector3
  2940. */
  2941. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2942. /**
  2943. * Unproject from screen space to object space
  2944. * @param source defines the screen space Vector3 to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @param result defines the Vector3 where to store the result
  2962. */
  2963. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param sourceX defines the screen space x coordinate to use
  2967. * @param sourceY defines the screen space y coordinate to use
  2968. * @param sourceZ defines the screen space z coordinate to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param view defines the view matrix to use
  2973. * @param projection defines the projection matrix to use
  2974. * @param result defines the Vector3 where to store the result
  2975. */
  2976. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2977. /**
  2978. * Gets the minimal coordinate values between two Vector3
  2979. * @param left defines the first operand
  2980. * @param right defines the second operand
  2981. * @returns the new Vector3
  2982. */
  2983. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2984. /**
  2985. * Gets the maximal coordinate values between two Vector3
  2986. * @param left defines the first operand
  2987. * @param right defines the second operand
  2988. * @returns the new Vector3
  2989. */
  2990. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2991. /**
  2992. * Returns the distance between the vectors "value1" and "value2"
  2993. * @param value1 defines the first operand
  2994. * @param value2 defines the second operand
  2995. * @returns the distance
  2996. */
  2997. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2998. /**
  2999. * Returns the squared distance between the vectors "value1" and "value2"
  3000. * @param value1 defines the first operand
  3001. * @param value2 defines the second operand
  3002. * @returns the squared distance
  3003. */
  3004. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3005. /**
  3006. * Returns a new Vector3 located at the center between "value1" and "value2"
  3007. * @param value1 defines the first operand
  3008. * @param value2 defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3014. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3015. * to something in order to rotate it from its local system to the given target system
  3016. * Note: axis1, axis2 and axis3 are normalized during this operation
  3017. * @param axis1 defines the first axis
  3018. * @param axis2 defines the second axis
  3019. * @param axis3 defines the third axis
  3020. * @returns a new Vector3
  3021. */
  3022. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @param ref defines the Vector3 where to store the result
  3029. */
  3030. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3031. }
  3032. /**
  3033. * Vector4 class created for EulerAngle class conversion to Quaternion
  3034. */
  3035. export class Vector4 {
  3036. /** x value of the vector */
  3037. x: number;
  3038. /** y value of the vector */
  3039. y: number;
  3040. /** z value of the vector */
  3041. z: number;
  3042. /** w value of the vector */
  3043. w: number;
  3044. /**
  3045. * Creates a Vector4 object from the given floats.
  3046. * @param x x value of the vector
  3047. * @param y y value of the vector
  3048. * @param z z value of the vector
  3049. * @param w w value of the vector
  3050. */
  3051. constructor(
  3052. /** x value of the vector */
  3053. x: number,
  3054. /** y value of the vector */
  3055. y: number,
  3056. /** z value of the vector */
  3057. z: number,
  3058. /** w value of the vector */
  3059. w: number);
  3060. /**
  3061. * Returns the string with the Vector4 coordinates.
  3062. * @returns a string containing all the vector values
  3063. */
  3064. toString(): string;
  3065. /**
  3066. * Returns the string "Vector4".
  3067. * @returns "Vector4"
  3068. */
  3069. getClassName(): string;
  3070. /**
  3071. * Returns the Vector4 hash code.
  3072. * @returns a unique hash code
  3073. */
  3074. getHashCode(): number;
  3075. /**
  3076. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3077. * @returns the resulting array
  3078. */
  3079. asArray(): number[];
  3080. /**
  3081. * Populates the given array from the given index with the Vector4 coordinates.
  3082. * @param array array to populate
  3083. * @param index index of the array to start at (default: 0)
  3084. * @returns the Vector4.
  3085. */
  3086. toArray(array: FloatArray, index?: number): Vector4;
  3087. /**
  3088. * Adds the given vector to the current Vector4.
  3089. * @param otherVector the vector to add
  3090. * @returns the updated Vector4.
  3091. */
  3092. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3093. /**
  3094. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3095. * @param otherVector the vector to add
  3096. * @returns the resulting vector
  3097. */
  3098. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @param result the vector to store the result
  3103. * @returns the current Vector4.
  3104. */
  3105. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3106. /**
  3107. * Subtract in place the given vector from the current Vector4.
  3108. * @param otherVector the vector to subtract
  3109. * @returns the updated Vector4.
  3110. */
  3111. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3112. /**
  3113. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3114. * @param otherVector the vector to add
  3115. * @returns the new vector with the result
  3116. */
  3117. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to subtract
  3121. * @param result the vector to store the result
  3122. * @returns the current Vector4.
  3123. */
  3124. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3125. /**
  3126. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3127. */
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. * @param x value to subtract
  3131. * @param y value to subtract
  3132. * @param z value to subtract
  3133. * @param w value to subtract
  3134. * @returns new vector containing the result
  3135. */
  3136. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3137. /**
  3138. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3139. * @param x value to subtract
  3140. * @param y value to subtract
  3141. * @param z value to subtract
  3142. * @param w value to subtract
  3143. * @param result the vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3147. /**
  3148. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3149. * @returns a new vector with the negated values
  3150. */
  3151. negate(): Vector4;
  3152. /**
  3153. * Multiplies the current Vector4 coordinates by scale (float).
  3154. * @param scale the number to scale with
  3155. * @returns the updated Vector4.
  3156. */
  3157. scaleInPlace(scale: number): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns a new vector with the result
  3162. */
  3163. scale(scale: number): Vector4;
  3164. /**
  3165. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @param result a vector to store the result in
  3168. * @returns the current Vector4.
  3169. */
  3170. scaleToRef(scale: number, result: Vector4): Vector4;
  3171. /**
  3172. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3173. * @param scale defines the scale factor
  3174. * @param result defines the Vector4 object where to store the result
  3175. * @returns the unmodified current Vector4
  3176. */
  3177. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3178. /**
  3179. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3180. * @param otherVector the vector to compare against
  3181. * @returns true if they are equal
  3182. */
  3183. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3186. * @param otherVector vector to compare against
  3187. * @param epsilon (Default: very small number)
  3188. * @returns true if they are equal
  3189. */
  3190. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3191. /**
  3192. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3193. * @param x x value to compare against
  3194. * @param y y value to compare against
  3195. * @param z z value to compare against
  3196. * @param w w value to compare against
  3197. * @returns true if equal
  3198. */
  3199. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3200. /**
  3201. * Multiplies in place the current Vector4 by the given one.
  3202. * @param otherVector vector to multiple with
  3203. * @returns the updated Vector4.
  3204. */
  3205. multiplyInPlace(otherVector: Vector4): Vector4;
  3206. /**
  3207. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns resulting new vector
  3210. */
  3211. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3212. /**
  3213. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @param result vector to store the result
  3216. * @returns the current Vector4.
  3217. */
  3218. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3219. /**
  3220. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3221. * @param x x value multiply with
  3222. * @param y y value multiply with
  3223. * @param z z value multiply with
  3224. * @param w w value multiply with
  3225. * @returns resulting new vector
  3226. */
  3227. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3228. /**
  3229. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3230. * @param otherVector vector to devide with
  3231. * @returns resulting new vector
  3232. */
  3233. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3234. /**
  3235. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @param result vector to store the result
  3238. * @returns the current Vector4.
  3239. */
  3240. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3241. /**
  3242. * Divides the current Vector3 coordinates by the given ones.
  3243. * @param otherVector vector to devide with
  3244. * @returns the updated Vector3.
  3245. */
  3246. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3247. /**
  3248. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3249. * @param other defines the second operand
  3250. * @returns the current updated Vector4
  3251. */
  3252. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Gets a new Vector4 from current Vector4 floored values
  3261. * @returns a new Vector4
  3262. */
  3263. floor(): Vector4;
  3264. /**
  3265. * Gets a new Vector4 from current Vector3 floored values
  3266. * @returns a new Vector4
  3267. */
  3268. fract(): Vector4;
  3269. /**
  3270. * Returns the Vector4 length (float).
  3271. * @returns the length
  3272. */
  3273. length(): number;
  3274. /**
  3275. * Returns the Vector4 squared length (float).
  3276. * @returns the length squared
  3277. */
  3278. lengthSquared(): number;
  3279. /**
  3280. * Normalizes in place the Vector4.
  3281. * @returns the updated Vector4.
  3282. */
  3283. normalize(): Vector4;
  3284. /**
  3285. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3286. * @returns this converted to a new vector3
  3287. */
  3288. toVector3(): Vector3;
  3289. /**
  3290. * Returns a new Vector4 copied from the current one.
  3291. * @returns the new cloned vector
  3292. */
  3293. clone(): Vector4;
  3294. /**
  3295. * Updates the current Vector4 with the given one coordinates.
  3296. * @param source the source vector to copy from
  3297. * @returns the updated Vector4.
  3298. */
  3299. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the current Vector4 coordinates with the given floats.
  3302. * @param x float to copy from
  3303. * @param y float to copy from
  3304. * @param z float to copy from
  3305. * @param w float to copy from
  3306. * @returns the updated Vector4.
  3307. */
  3308. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3309. /**
  3310. * Updates the current Vector4 coordinates with the given floats.
  3311. * @param x float to set from
  3312. * @param y float to set from
  3313. * @param z float to set from
  3314. * @param w float to set from
  3315. * @returns the updated Vector4.
  3316. */
  3317. set(x: number, y: number, z: number, w: number): Vector4;
  3318. /**
  3319. * Copies the given float to the current Vector3 coordinates
  3320. * @param v defines the x, y, z and w coordinates of the operand
  3321. * @returns the current updated Vector3
  3322. */
  3323. setAll(v: number): Vector4;
  3324. /**
  3325. * Returns a new Vector4 set from the starting index of the given array.
  3326. * @param array the array to pull values from
  3327. * @param offset the offset into the array to start at
  3328. * @returns the new vector
  3329. */
  3330. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3331. /**
  3332. * Updates the given vector "result" from the starting index of the given array.
  3333. * @param array the array to pull values from
  3334. * @param offset the offset into the array to start at
  3335. * @param result the vector to store the result in
  3336. */
  3337. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3338. /**
  3339. * Updates the given vector "result" from the starting index of the given Float32Array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @param result the vector to store the result in
  3343. */
  3344. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3345. /**
  3346. * Updates the given vector "result" coordinates from the given floats.
  3347. * @param x float to set from
  3348. * @param y float to set from
  3349. * @param z float to set from
  3350. * @param w float to set from
  3351. * @param result the vector to the floats in
  3352. */
  3353. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3354. /**
  3355. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3356. * @returns the new vector
  3357. */
  3358. static Zero(): Vector4;
  3359. /**
  3360. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3361. * @returns the new vector
  3362. */
  3363. static One(): Vector4;
  3364. /**
  3365. * Returns a new normalized Vector4 from the given one.
  3366. * @param vector the vector to normalize
  3367. * @returns the vector
  3368. */
  3369. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3370. /**
  3371. * Updates the given vector "result" from the normalization of the given one.
  3372. * @param vector the vector to normalize
  3373. * @param result the vector to store the result in
  3374. */
  3375. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3376. /**
  3377. * Returns a vector with the minimum values from the left and right vectors
  3378. * @param left left vector to minimize
  3379. * @param right right vector to minimize
  3380. * @returns a new vector with the minimum of the left and right vector values
  3381. */
  3382. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Returns a vector with the maximum values from the left and right vectors
  3385. * @param left left vector to maximize
  3386. * @param right right vector to maximize
  3387. * @returns a new vector with the maximum of the left and right vector values
  3388. */
  3389. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Returns the distance (float) between the vectors "value1" and "value2".
  3392. * @param value1 value to calulate the distance between
  3393. * @param value2 value to calulate the distance between
  3394. * @return the distance between the two vectors
  3395. */
  3396. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3397. /**
  3398. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3399. * @param value1 value to calulate the distance between
  3400. * @param value2 value to calulate the distance between
  3401. * @return the distance between the two vectors squared
  3402. */
  3403. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3404. /**
  3405. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the center between
  3407. * @param value2 value to calulate the center between
  3408. * @return the center between the two vectors
  3409. */
  3410. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3411. /**
  3412. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3413. * This methods computes transformed normalized direction vectors only.
  3414. * @param vector the vector to transform
  3415. * @param transformation the transformation matrix to apply
  3416. * @returns the new vector
  3417. */
  3418. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3419. /**
  3420. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3421. * This methods computes transformed normalized direction vectors only.
  3422. * @param vector the vector to transform
  3423. * @param transformation the transformation matrix to apply
  3424. * @param result the vector to store the result in
  3425. */
  3426. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3427. /**
  3428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3429. * This methods computes transformed normalized direction vectors only.
  3430. * @param x value to transform
  3431. * @param y value to transform
  3432. * @param z value to transform
  3433. * @param w value to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the results in
  3436. */
  3437. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Creates a new Vector4 from a Vector3
  3440. * @param source defines the source data
  3441. * @param w defines the 4th component (default is 0)
  3442. * @returns a new Vector4
  3443. */
  3444. static FromVector3(source: Vector3, w?: number): Vector4;
  3445. }
  3446. /**
  3447. * Class used to store quaternion data
  3448. * @see https://en.wikipedia.org/wiki/Quaternion
  3449. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3450. */
  3451. export class Quaternion {
  3452. /** defines the first component (0 by default) */
  3453. x: number;
  3454. /** defines the second component (0 by default) */
  3455. y: number;
  3456. /** defines the third component (0 by default) */
  3457. z: number;
  3458. /** defines the fourth component (1.0 by default) */
  3459. w: number;
  3460. /**
  3461. * Creates a new Quaternion from the given floats
  3462. * @param x defines the first component (0 by default)
  3463. * @param y defines the second component (0 by default)
  3464. * @param z defines the third component (0 by default)
  3465. * @param w defines the fourth component (1.0 by default)
  3466. */
  3467. constructor(
  3468. /** defines the first component (0 by default) */
  3469. x?: number,
  3470. /** defines the second component (0 by default) */
  3471. y?: number,
  3472. /** defines the third component (0 by default) */
  3473. z?: number,
  3474. /** defines the fourth component (1.0 by default) */
  3475. w?: number);
  3476. /**
  3477. * Gets a string representation for the current quaternion
  3478. * @returns a string with the Quaternion coordinates
  3479. */
  3480. toString(): string;
  3481. /**
  3482. * Gets the class name of the quaternion
  3483. * @returns the string "Quaternion"
  3484. */
  3485. getClassName(): string;
  3486. /**
  3487. * Gets a hash code for this quaternion
  3488. * @returns the quaternion hash code
  3489. */
  3490. getHashCode(): number;
  3491. /**
  3492. * Copy the quaternion to an array
  3493. * @returns a new array populated with 4 elements from the quaternion coordinates
  3494. */
  3495. asArray(): number[];
  3496. /**
  3497. * Check if two quaternions are equals
  3498. * @param otherQuaternion defines the second operand
  3499. * @return true if the current quaternion and the given one coordinates are strictly equals
  3500. */
  3501. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3502. /**
  3503. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3504. * @param otherQuaternion defines the other quaternion
  3505. * @param epsilon defines the minimal distance to consider equality
  3506. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3507. */
  3508. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3509. /**
  3510. * Clone the current quaternion
  3511. * @returns a new quaternion copied from the current one
  3512. */
  3513. clone(): Quaternion;
  3514. /**
  3515. * Copy a quaternion to the current one
  3516. * @param other defines the other quaternion
  3517. * @returns the updated current quaternion
  3518. */
  3519. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3520. /**
  3521. * Updates the current quaternion with the given float coordinates
  3522. * @param x defines the x coordinate
  3523. * @param y defines the y coordinate
  3524. * @param z defines the z coordinate
  3525. * @param w defines the w coordinate
  3526. * @returns the updated current quaternion
  3527. */
  3528. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3529. /**
  3530. * Updates the current quaternion from the given float coordinates
  3531. * @param x defines the x coordinate
  3532. * @param y defines the y coordinate
  3533. * @param z defines the z coordinate
  3534. * @param w defines the w coordinate
  3535. * @returns the updated current quaternion
  3536. */
  3537. set(x: number, y: number, z: number, w: number): Quaternion;
  3538. /**
  3539. * Adds two quaternions
  3540. * @param other defines the second operand
  3541. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3542. */
  3543. add(other: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Add a quaternion to the current one
  3546. * @param other defines the quaternion to add
  3547. * @returns the current quaternion
  3548. */
  3549. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3550. /**
  3551. * Subtract two quaternions
  3552. * @param other defines the second operand
  3553. * @returns a new quaternion as the subtraction result of the given one from the current one
  3554. */
  3555. subtract(other: Quaternion): Quaternion;
  3556. /**
  3557. * Multiplies the current quaternion by a scale factor
  3558. * @param value defines the scale factor
  3559. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3560. */
  3561. scale(value: number): Quaternion;
  3562. /**
  3563. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3564. * @param scale defines the scale factor
  3565. * @param result defines the Quaternion object where to store the result
  3566. * @returns the unmodified current quaternion
  3567. */
  3568. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3569. /**
  3570. * Multiplies in place the current quaternion by a scale factor
  3571. * @param value defines the scale factor
  3572. * @returns the current modified quaternion
  3573. */
  3574. scaleInPlace(value: number): Quaternion;
  3575. /**
  3576. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3577. * @param scale defines the scale factor
  3578. * @param result defines the Quaternion object where to store the result
  3579. * @returns the unmodified current quaternion
  3580. */
  3581. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3582. /**
  3583. * Multiplies two quaternions
  3584. * @param q1 defines the second operand
  3585. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3586. */
  3587. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3588. /**
  3589. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3590. * @param q1 defines the second operand
  3591. * @param result defines the target quaternion
  3592. * @returns the current quaternion
  3593. */
  3594. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3595. /**
  3596. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3597. * @param q1 defines the second operand
  3598. * @returns the currentupdated quaternion
  3599. */
  3600. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3601. /**
  3602. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3603. * @param ref defines the target quaternion
  3604. * @returns the current quaternion
  3605. */
  3606. conjugateToRef(ref: Quaternion): Quaternion;
  3607. /**
  3608. * Conjugates in place (1-q) the current quaternion
  3609. * @returns the current updated quaternion
  3610. */
  3611. conjugateInPlace(): Quaternion;
  3612. /**
  3613. * Conjugates in place (1-q) the current quaternion
  3614. * @returns a new quaternion
  3615. */
  3616. conjugate(): Quaternion;
  3617. /**
  3618. * Gets length of current quaternion
  3619. * @returns the quaternion length (float)
  3620. */
  3621. length(): number;
  3622. /**
  3623. * Normalize in place the current quaternion
  3624. * @returns the current updated quaternion
  3625. */
  3626. normalize(): Quaternion;
  3627. /**
  3628. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3629. * @param order is a reserved parameter and is ignore for now
  3630. * @returns a new Vector3 containing the Euler angles
  3631. */
  3632. toEulerAngles(order?: string): Vector3;
  3633. /**
  3634. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3635. * @param result defines the vector which will be filled with the Euler angles
  3636. * @param order is a reserved parameter and is ignore for now
  3637. * @returns the current unchanged quaternion
  3638. */
  3639. toEulerAnglesToRef(result: Vector3): Quaternion;
  3640. /**
  3641. * Updates the given rotation matrix with the current quaternion values
  3642. * @param result defines the target matrix
  3643. * @returns the current unchanged quaternion
  3644. */
  3645. toRotationMatrix(result: Matrix): Quaternion;
  3646. /**
  3647. * Updates the current quaternion from the given rotation matrix values
  3648. * @param matrix defines the source matrix
  3649. * @returns the current updated quaternion
  3650. */
  3651. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3652. /**
  3653. * Creates a new quaternion from a rotation matrix
  3654. * @param matrix defines the source matrix
  3655. * @returns a new quaternion created from the given rotation matrix values
  3656. */
  3657. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3658. /**
  3659. * Updates the given quaternion with the given rotation matrix values
  3660. * @param matrix defines the source matrix
  3661. * @param result defines the target quaternion
  3662. */
  3663. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3664. /**
  3665. * Returns the dot product (float) between the quaternions "left" and "right"
  3666. * @param left defines the left operand
  3667. * @param right defines the right operand
  3668. * @returns the dot product
  3669. */
  3670. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3671. /**
  3672. * Checks if the two quaternions are close to each other
  3673. * @param quat0 defines the first quaternion to check
  3674. * @param quat1 defines the second quaternion to check
  3675. * @returns true if the two quaternions are close to each other
  3676. */
  3677. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3678. /**
  3679. * Creates an empty quaternion
  3680. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3681. */
  3682. static Zero(): Quaternion;
  3683. /**
  3684. * Inverse a given quaternion
  3685. * @param q defines the source quaternion
  3686. * @returns a new quaternion as the inverted current quaternion
  3687. */
  3688. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3689. /**
  3690. * Inverse a given quaternion
  3691. * @param q defines the source quaternion
  3692. * @param result the quaternion the result will be stored in
  3693. * @returns the result quaternion
  3694. */
  3695. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3696. /**
  3697. * Creates an identity quaternion
  3698. * @returns the identity quaternion
  3699. */
  3700. static Identity(): Quaternion;
  3701. /**
  3702. * Gets a boolean indicating if the given quaternion is identity
  3703. * @param quaternion defines the quaternion to check
  3704. * @returns true if the quaternion is identity
  3705. */
  3706. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3707. /**
  3708. * Creates a quaternion from a rotation around an axis
  3709. * @param axis defines the axis to use
  3710. * @param angle defines the angle to use
  3711. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3712. */
  3713. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3714. /**
  3715. * Creates a rotation around an axis and stores it into the given quaternion
  3716. * @param axis defines the axis to use
  3717. * @param angle defines the angle to use
  3718. * @param result defines the target quaternion
  3719. * @returns the target quaternion
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3722. /**
  3723. * Creates a new quaternion from data stored into an array
  3724. * @param array defines the data source
  3725. * @param offset defines the offset in the source array where the data starts
  3726. * @returns a new quaternion
  3727. */
  3728. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3729. /**
  3730. * Create a quaternion from Euler rotation angles
  3731. * @param x Pitch
  3732. * @param y Yaw
  3733. * @param z Roll
  3734. * @returns the new Quaternion
  3735. */
  3736. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3737. /**
  3738. * Updates a quaternion from Euler rotation angles
  3739. * @param x Pitch
  3740. * @param y Yaw
  3741. * @param z Roll
  3742. * @param result the quaternion to store the result
  3743. * @returns the updated quaternion
  3744. */
  3745. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation vector
  3748. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3749. * @returns the new Quaternion
  3750. */
  3751. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3752. /**
  3753. * Updates a quaternion from Euler rotation vector
  3754. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3755. * @param result the quaternion to store the result
  3756. * @returns the updated quaternion
  3757. */
  3758. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3759. /**
  3760. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3761. * @param yaw defines the rotation around Y axis
  3762. * @param pitch defines the rotation around X axis
  3763. * @param roll defines the rotation around Z axis
  3764. * @returns the new quaternion
  3765. */
  3766. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3767. /**
  3768. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3769. * @param yaw defines the rotation around Y axis
  3770. * @param pitch defines the rotation around X axis
  3771. * @param roll defines the rotation around Z axis
  3772. * @param result defines the target quaternion
  3773. */
  3774. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3775. /**
  3776. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3777. * @param alpha defines the rotation around first axis
  3778. * @param beta defines the rotation around second axis
  3779. * @param gamma defines the rotation around third axis
  3780. * @returns the new quaternion
  3781. */
  3782. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3783. /**
  3784. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3785. * @param alpha defines the rotation around first axis
  3786. * @param beta defines the rotation around second axis
  3787. * @param gamma defines the rotation around third axis
  3788. * @param result defines the target quaternion
  3789. */
  3790. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3791. /**
  3792. * 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)
  3793. * @param axis1 defines the first axis
  3794. * @param axis2 defines the second axis
  3795. * @param axis3 defines the third axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3799. /**
  3800. * 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
  3801. * @param axis1 defines the first axis
  3802. * @param axis2 defines the second axis
  3803. * @param axis3 defines the third axis
  3804. * @param ref defines the target quaternion
  3805. */
  3806. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3807. /**
  3808. * Interpolates between two quaternions
  3809. * @param left defines first quaternion
  3810. * @param right defines second quaternion
  3811. * @param amount defines the gradient to use
  3812. * @returns the new interpolated quaternion
  3813. */
  3814. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3815. /**
  3816. * Interpolates between two quaternions and stores it into a target quaternion
  3817. * @param left defines first quaternion
  3818. * @param right defines second quaternion
  3819. * @param amount defines the gradient to use
  3820. * @param result defines the target quaternion
  3821. */
  3822. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3823. /**
  3824. * Interpolate between two quaternions using Hermite interpolation
  3825. * @param value1 defines first quaternion
  3826. * @param tangent1 defines the incoming tangent
  3827. * @param value2 defines second quaternion
  3828. * @param tangent2 defines the outgoing tangent
  3829. * @param amount defines the target quaternion
  3830. * @returns the new interpolated quaternion
  3831. */
  3832. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3833. }
  3834. /**
  3835. * Class used to store matrix data (4x4)
  3836. */
  3837. export class Matrix {
  3838. private static _updateFlagSeed;
  3839. private static _identityReadOnly;
  3840. private _isIdentity;
  3841. private _isIdentityDirty;
  3842. private _isIdentity3x2;
  3843. private _isIdentity3x2Dirty;
  3844. /**
  3845. * Gets the update flag of the matrix which is an unique number for the matrix.
  3846. * It will be incremented every time the matrix data change.
  3847. * You can use it to speed the comparison between two versions of the same matrix.
  3848. */
  3849. updateFlag: number;
  3850. private readonly _m;
  3851. /**
  3852. * Gets the internal data of the matrix
  3853. */
  3854. get m(): DeepImmutable<Float32Array>;
  3855. /** @hidden */
  3856. _markAsUpdated(): void;
  3857. /** @hidden */
  3858. private _updateIdentityStatus;
  3859. /**
  3860. * Creates an empty matrix (filled with zeros)
  3861. */
  3862. constructor();
  3863. /**
  3864. * Check if the current matrix is identity
  3865. * @returns true is the matrix is the identity matrix
  3866. */
  3867. isIdentity(): boolean;
  3868. /**
  3869. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3870. * @returns true is the matrix is the identity matrix
  3871. */
  3872. isIdentityAs3x2(): boolean;
  3873. /**
  3874. * Gets the determinant of the matrix
  3875. * @returns the matrix determinant
  3876. */
  3877. determinant(): number;
  3878. /**
  3879. * Returns the matrix as a Float32Array
  3880. * @returns the matrix underlying array
  3881. */
  3882. toArray(): DeepImmutable<Float32Array>;
  3883. /**
  3884. * Returns the matrix as a Float32Array
  3885. * @returns the matrix underlying array.
  3886. */
  3887. asArray(): DeepImmutable<Float32Array>;
  3888. /**
  3889. * Inverts the current matrix in place
  3890. * @returns the current inverted matrix
  3891. */
  3892. invert(): Matrix;
  3893. /**
  3894. * Sets all the matrix elements to zero
  3895. * @returns the current matrix
  3896. */
  3897. reset(): Matrix;
  3898. /**
  3899. * Adds the current matrix with a second one
  3900. * @param other defines the matrix to add
  3901. * @returns a new matrix as the addition of the current matrix and the given one
  3902. */
  3903. add(other: DeepImmutable<Matrix>): Matrix;
  3904. /**
  3905. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3906. * @param other defines the matrix to add
  3907. * @param result defines the target matrix
  3908. * @returns the current matrix
  3909. */
  3910. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3911. /**
  3912. * Adds in place the given matrix to the current matrix
  3913. * @param other defines the second operand
  3914. * @returns the current updated matrix
  3915. */
  3916. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3917. /**
  3918. * Sets the given matrix to the current inverted Matrix
  3919. * @param other defines the target matrix
  3920. * @returns the unmodified current matrix
  3921. */
  3922. invertToRef(other: Matrix): Matrix;
  3923. /**
  3924. * add a value at the specified position in the current Matrix
  3925. * @param index the index of the value within the matrix. between 0 and 15.
  3926. * @param value the value to be added
  3927. * @returns the current updated matrix
  3928. */
  3929. addAtIndex(index: number, value: number): Matrix;
  3930. /**
  3931. * mutiply the specified position in the current Matrix by a value
  3932. * @param index the index of the value within the matrix. between 0 and 15.
  3933. * @param value the value to be added
  3934. * @returns the current updated matrix
  3935. */
  3936. multiplyAtIndex(index: number, value: number): Matrix;
  3937. /**
  3938. * Inserts the translation vector (using 3 floats) in the current matrix
  3939. * @param x defines the 1st component of the translation
  3940. * @param y defines the 2nd component of the translation
  3941. * @param z defines the 3rd component of the translation
  3942. * @returns the current updated matrix
  3943. */
  3944. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3945. /**
  3946. * Adds the translation vector (using 3 floats) in the current matrix
  3947. * @param x defines the 1st component of the translation
  3948. * @param y defines the 2nd component of the translation
  3949. * @param z defines the 3rd component of the translation
  3950. * @returns the current updated matrix
  3951. */
  3952. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3953. /**
  3954. * Inserts the translation vector in the current matrix
  3955. * @param vector3 defines the translation to insert
  3956. * @returns the current updated matrix
  3957. */
  3958. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3959. /**
  3960. * Gets the translation value of the current matrix
  3961. * @returns a new Vector3 as the extracted translation from the matrix
  3962. */
  3963. getTranslation(): Vector3;
  3964. /**
  3965. * Fill a Vector3 with the extracted translation from the matrix
  3966. * @param result defines the Vector3 where to store the translation
  3967. * @returns the current matrix
  3968. */
  3969. getTranslationToRef(result: Vector3): Matrix;
  3970. /**
  3971. * Remove rotation and scaling part from the matrix
  3972. * @returns the updated matrix
  3973. */
  3974. removeRotationAndScaling(): Matrix;
  3975. /**
  3976. * Multiply two matrices
  3977. * @param other defines the second operand
  3978. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3979. */
  3980. multiply(other: DeepImmutable<Matrix>): Matrix;
  3981. /**
  3982. * Copy the current matrix from the given one
  3983. * @param other defines the source matrix
  3984. * @returns the current updated matrix
  3985. */
  3986. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Populates the given array from the starting index with the current matrix values
  3989. * @param array defines the target array
  3990. * @param offset defines the offset in the target array where to start storing values
  3991. * @returns the current matrix
  3992. */
  3993. copyToArray(array: Float32Array, offset?: number): Matrix;
  3994. /**
  3995. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3996. * @param other defines the second operand
  3997. * @param result defines the matrix where to store the multiplication
  3998. * @returns the current matrix
  3999. */
  4000. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4001. /**
  4002. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4003. * @param other defines the second operand
  4004. * @param result defines the array where to store the multiplication
  4005. * @param offset defines the offset in the target array where to start storing values
  4006. * @returns the current matrix
  4007. */
  4008. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4009. /**
  4010. * Check equality between this matrix and a second one
  4011. * @param value defines the second matrix to compare
  4012. * @returns true is the current matrix and the given one values are strictly equal
  4013. */
  4014. equals(value: DeepImmutable<Matrix>): boolean;
  4015. /**
  4016. * Clone the current matrix
  4017. * @returns a new matrix from the current matrix
  4018. */
  4019. clone(): Matrix;
  4020. /**
  4021. * Returns the name of the current matrix class
  4022. * @returns the string "Matrix"
  4023. */
  4024. getClassName(): string;
  4025. /**
  4026. * Gets the hash code of the current matrix
  4027. * @returns the hash code
  4028. */
  4029. getHashCode(): number;
  4030. /**
  4031. * Decomposes the current Matrix into a translation, rotation and scaling components
  4032. * @param scale defines the scale vector3 given as a reference to update
  4033. * @param rotation defines the rotation quaternion given as a reference to update
  4034. * @param translation defines the translation vector3 given as a reference to update
  4035. * @returns true if operation was successful
  4036. */
  4037. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4038. /**
  4039. * Gets specific row of the matrix
  4040. * @param index defines the number of the row to get
  4041. * @returns the index-th row of the current matrix as a new Vector4
  4042. */
  4043. getRow(index: number): Nullable<Vector4>;
  4044. /**
  4045. * Sets the index-th row of the current matrix to the vector4 values
  4046. * @param index defines the number of the row to set
  4047. * @param row defines the target vector4
  4048. * @returns the updated current matrix
  4049. */
  4050. setRow(index: number, row: Vector4): Matrix;
  4051. /**
  4052. * Compute the transpose of the matrix
  4053. * @returns the new transposed matrix
  4054. */
  4055. transpose(): Matrix;
  4056. /**
  4057. * Compute the transpose of the matrix and store it in a given matrix
  4058. * @param result defines the target matrix
  4059. * @returns the current matrix
  4060. */
  4061. transposeToRef(result: Matrix): Matrix;
  4062. /**
  4063. * Sets the index-th row of the current matrix with the given 4 x float values
  4064. * @param index defines the row index
  4065. * @param x defines the x component to set
  4066. * @param y defines the y component to set
  4067. * @param z defines the z component to set
  4068. * @param w defines the w component to set
  4069. * @returns the updated current matrix
  4070. */
  4071. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4072. /**
  4073. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4074. * @param scale defines the scale factor
  4075. * @returns a new matrix
  4076. */
  4077. scale(scale: number): Matrix;
  4078. /**
  4079. * Scale the current matrix values by a factor to a given result matrix
  4080. * @param scale defines the scale factor
  4081. * @param result defines the matrix to store the result
  4082. * @returns the current matrix
  4083. */
  4084. scaleToRef(scale: number, result: Matrix): Matrix;
  4085. /**
  4086. * Scale the current matrix values by a factor and add the result to a given matrix
  4087. * @param scale defines the scale factor
  4088. * @param result defines the Matrix to store the result
  4089. * @returns the current matrix
  4090. */
  4091. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4092. /**
  4093. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4094. * @param ref matrix to store the result
  4095. */
  4096. toNormalMatrix(ref: Matrix): void;
  4097. /**
  4098. * Gets only rotation part of the current matrix
  4099. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4100. */
  4101. getRotationMatrix(): Matrix;
  4102. /**
  4103. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4104. * @param result defines the target matrix to store data to
  4105. * @returns the current matrix
  4106. */
  4107. getRotationMatrixToRef(result: Matrix): Matrix;
  4108. /**
  4109. * Toggles model matrix from being right handed to left handed in place and vice versa
  4110. */
  4111. toggleModelMatrixHandInPlace(): void;
  4112. /**
  4113. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleProjectionMatrixHandInPlace(): void;
  4116. /**
  4117. * Creates a matrix from an array
  4118. * @param array defines the source array
  4119. * @param offset defines an offset in the source array
  4120. * @returns a new Matrix set from the starting index of the given array
  4121. */
  4122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4123. /**
  4124. * Copy the content of an array into a given matrix
  4125. * @param array defines the source array
  4126. * @param offset defines an offset in the source array
  4127. * @param result defines the target matrix
  4128. */
  4129. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4130. /**
  4131. * Stores an array into a matrix after having multiplied each component by a given factor
  4132. * @param array defines the source array
  4133. * @param offset defines the offset in the source array
  4134. * @param scale defines the scaling factor
  4135. * @param result defines the target matrix
  4136. */
  4137. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4138. /**
  4139. * Gets an identity matrix that must not be updated
  4140. */
  4141. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4142. /**
  4143. * Stores a list of values (16) inside a given matrix
  4144. * @param initialM11 defines 1st value of 1st row
  4145. * @param initialM12 defines 2nd value of 1st row
  4146. * @param initialM13 defines 3rd value of 1st row
  4147. * @param initialM14 defines 4th value of 1st row
  4148. * @param initialM21 defines 1st value of 2nd row
  4149. * @param initialM22 defines 2nd value of 2nd row
  4150. * @param initialM23 defines 3rd value of 2nd row
  4151. * @param initialM24 defines 4th value of 2nd row
  4152. * @param initialM31 defines 1st value of 3rd row
  4153. * @param initialM32 defines 2nd value of 3rd row
  4154. * @param initialM33 defines 3rd value of 3rd row
  4155. * @param initialM34 defines 4th value of 3rd row
  4156. * @param initialM41 defines 1st value of 4th row
  4157. * @param initialM42 defines 2nd value of 4th row
  4158. * @param initialM43 defines 3rd value of 4th row
  4159. * @param initialM44 defines 4th value of 4th row
  4160. * @param result defines the target matrix
  4161. */
  4162. 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;
  4163. /**
  4164. * Creates new matrix from a list of values (16)
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @returns the new matrix
  4182. */
  4183. 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;
  4184. /**
  4185. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4186. * @param scale defines the scale vector3
  4187. * @param rotation defines the rotation quaternion
  4188. * @param translation defines the translation vector3
  4189. * @returns a new matrix
  4190. */
  4191. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4192. /**
  4193. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4194. * @param scale defines the scale vector3
  4195. * @param rotation defines the rotation quaternion
  4196. * @param translation defines the translation vector3
  4197. * @param result defines the target matrix
  4198. */
  4199. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4200. /**
  4201. * Creates a new identity matrix
  4202. * @returns a new identity matrix
  4203. */
  4204. static Identity(): Matrix;
  4205. /**
  4206. * Creates a new identity matrix and stores the result in a given matrix
  4207. * @param result defines the target matrix
  4208. */
  4209. static IdentityToRef(result: Matrix): void;
  4210. /**
  4211. * Creates a new zero matrix
  4212. * @returns a new zero matrix
  4213. */
  4214. static Zero(): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the X axis
  4217. * @param angle defines the angle (in radians) to use
  4218. * @return the new matrix
  4219. */
  4220. static RotationX(angle: number): Matrix;
  4221. /**
  4222. * Creates a new matrix as the invert of a given matrix
  4223. * @param source defines the source matrix
  4224. * @returns the new matrix
  4225. */
  4226. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4227. /**
  4228. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4229. * @param angle defines the angle (in radians) to use
  4230. * @param result defines the target matrix
  4231. */
  4232. static RotationXToRef(angle: number, result: Matrix): void;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the Y axis
  4235. * @param angle defines the angle (in radians) to use
  4236. * @return the new matrix
  4237. */
  4238. static RotationY(angle: number): Matrix;
  4239. /**
  4240. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4241. * @param angle defines the angle (in radians) to use
  4242. * @param result defines the target matrix
  4243. */
  4244. static RotationYToRef(angle: number, result: Matrix): void;
  4245. /**
  4246. * Creates a new rotation matrix for "angle" radians around the Z axis
  4247. * @param angle defines the angle (in radians) to use
  4248. * @return the new matrix
  4249. */
  4250. static RotationZ(angle: number): Matrix;
  4251. /**
  4252. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4253. * @param angle defines the angle (in radians) to use
  4254. * @param result defines the target matrix
  4255. */
  4256. static RotationZToRef(angle: number, result: Matrix): void;
  4257. /**
  4258. * Creates a new rotation matrix for "angle" radians around the given axis
  4259. * @param axis defines the axis to use
  4260. * @param angle defines the angle (in radians) to use
  4261. * @return the new matrix
  4262. */
  4263. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4264. /**
  4265. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4266. * @param axis defines the axis to use
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4271. /**
  4272. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4273. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4274. * @param from defines the vector to align
  4275. * @param to defines the vector to align to
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4279. /**
  4280. * Creates a rotation matrix
  4281. * @param yaw defines the yaw angle in radians (Y axis)
  4282. * @param pitch defines the pitch angle in radians (X axis)
  4283. * @param roll defines the roll angle in radians (X axis)
  4284. * @returns the new rotation matrix
  4285. */
  4286. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4287. /**
  4288. * Creates a rotation matrix and stores it in a given matrix
  4289. * @param yaw defines the yaw angle in radians (Y axis)
  4290. * @param pitch defines the pitch angle in radians (X axis)
  4291. * @param roll defines the roll angle in radians (X axis)
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4295. /**
  4296. * Creates a scaling matrix
  4297. * @param x defines the scale factor on X axis
  4298. * @param y defines the scale factor on Y axis
  4299. * @param z defines the scale factor on Z axis
  4300. * @returns the new matrix
  4301. */
  4302. static Scaling(x: number, y: number, z: number): Matrix;
  4303. /**
  4304. * Creates a scaling matrix and stores it in a given matrix
  4305. * @param x defines the scale factor on X axis
  4306. * @param y defines the scale factor on Y axis
  4307. * @param z defines the scale factor on Z axis
  4308. * @param result defines the target matrix
  4309. */
  4310. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4311. /**
  4312. * Creates a translation matrix
  4313. * @param x defines the translation on X axis
  4314. * @param y defines the translation on Y axis
  4315. * @param z defines the translationon Z axis
  4316. * @returns the new matrix
  4317. */
  4318. static Translation(x: number, y: number, z: number): Matrix;
  4319. /**
  4320. * Creates a translation matrix and stores it in a given matrix
  4321. * @param x defines the translation on X axis
  4322. * @param y defines the translation on Y axis
  4323. * @param z defines the translationon Z axis
  4324. * @param result defines the target matrix
  4325. */
  4326. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4327. /**
  4328. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4329. * @param startValue defines the start value
  4330. * @param endValue defines the end value
  4331. * @param gradient defines the gradient factor
  4332. * @returns the new matrix
  4333. */
  4334. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4335. /**
  4336. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4337. * @param startValue defines the start value
  4338. * @param endValue defines the end value
  4339. * @param gradient defines the gradient factor
  4340. * @param result defines the Matrix object where to store data
  4341. */
  4342. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4343. /**
  4344. * Builds a new matrix whose values are computed by:
  4345. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4346. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4347. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4348. * @param startValue defines the first matrix
  4349. * @param endValue defines the second matrix
  4350. * @param gradient defines the gradient between the two matrices
  4351. * @returns the new matrix
  4352. */
  4353. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4354. /**
  4355. * Update a matrix to values which are computed by:
  4356. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4357. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4358. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4359. * @param startValue defines the first matrix
  4360. * @param endValue defines the second matrix
  4361. * @param gradient defines the gradient between the two matrices
  4362. * @param result defines the target matrix
  4363. */
  4364. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4365. /**
  4366. * 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"
  4367. * This function works in left handed mode
  4368. * @param eye defines the final position of the entity
  4369. * @param target defines where the entity should look at
  4370. * @param up defines the up vector for the entity
  4371. * @returns the new matrix
  4372. */
  4373. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4374. /**
  4375. * 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".
  4376. * This function works in left handed mode
  4377. * @param eye defines the final position of the entity
  4378. * @param target defines where the entity should look at
  4379. * @param up defines the up vector for the entity
  4380. * @param result defines the target matrix
  4381. */
  4382. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4383. /**
  4384. * 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"
  4385. * This function works in right handed mode
  4386. * @param eye defines the final position of the entity
  4387. * @param target defines where the entity should look at
  4388. * @param up defines the up vector for the entity
  4389. * @returns the new matrix
  4390. */
  4391. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4392. /**
  4393. * 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".
  4394. * This function works in right handed mode
  4395. * @param eye defines the final position of the entity
  4396. * @param target defines where the entity should look at
  4397. * @param up defines the up vector for the entity
  4398. * @param result defines the target matrix
  4399. */
  4400. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4401. /**
  4402. * Create a left-handed orthographic projection matrix
  4403. * @param width defines the viewport width
  4404. * @param height defines the viewport height
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @returns a new matrix as a left-handed orthographic projection matrix
  4408. */
  4409. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4410. /**
  4411. * Store a left-handed orthographic projection to a given matrix
  4412. * @param width defines the viewport width
  4413. * @param height defines the viewport height
  4414. * @param znear defines the near clip plane
  4415. * @param zfar defines the far clip plane
  4416. * @param result defines the target matrix
  4417. */
  4418. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4419. /**
  4420. * Create a left-handed orthographic projection matrix
  4421. * @param left defines the viewport left coordinate
  4422. * @param right defines the viewport right coordinate
  4423. * @param bottom defines the viewport bottom coordinate
  4424. * @param top defines the viewport top coordinate
  4425. * @param znear defines the near clip plane
  4426. * @param zfar defines the far clip plane
  4427. * @returns a new matrix as a left-handed orthographic projection matrix
  4428. */
  4429. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4430. /**
  4431. * Stores a left-handed orthographic projection into a given matrix
  4432. * @param left defines the viewport left coordinate
  4433. * @param right defines the viewport right coordinate
  4434. * @param bottom defines the viewport bottom coordinate
  4435. * @param top defines the viewport top coordinate
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @param result defines the target matrix
  4439. */
  4440. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4441. /**
  4442. * Creates a right-handed orthographic projection matrix
  4443. * @param left defines the viewport left coordinate
  4444. * @param right defines the viewport right coordinate
  4445. * @param bottom defines the viewport bottom coordinate
  4446. * @param top defines the viewport top coordinate
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @returns a new matrix as a right-handed orthographic projection matrix
  4450. */
  4451. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4452. /**
  4453. * Stores a right-handed orthographic projection into a given matrix
  4454. * @param left defines the viewport left coordinate
  4455. * @param right defines the viewport right coordinate
  4456. * @param bottom defines the viewport bottom coordinate
  4457. * @param top defines the viewport top coordinate
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. */
  4462. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4463. /**
  4464. * Creates a left-handed perspective projection matrix
  4465. * @param width defines the viewport width
  4466. * @param height defines the viewport height
  4467. * @param znear defines the near clip plane
  4468. * @param zfar defines the far clip plane
  4469. * @returns a new matrix as a left-handed perspective projection matrix
  4470. */
  4471. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4472. /**
  4473. * Creates a left-handed perspective projection matrix
  4474. * @param fov defines the horizontal field of view
  4475. * @param aspect defines the aspect ratio
  4476. * @param znear defines the near clip plane
  4477. * @param zfar defines the far clip plane
  4478. * @returns a new matrix as a left-handed perspective projection matrix
  4479. */
  4480. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4481. /**
  4482. * Stores a left-handed perspective projection into a given matrix
  4483. * @param fov defines the horizontal field of view
  4484. * @param aspect defines the aspect ratio
  4485. * @param znear defines the near clip plane
  4486. * @param zfar defines the far clip plane
  4487. * @param result defines the target matrix
  4488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4489. */
  4490. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4491. /**
  4492. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4493. * @param fov defines the horizontal field of view
  4494. * @param aspect defines the aspect ratio
  4495. * @param znear defines the near clip plane
  4496. * @param zfar not used as infinity is used as far clip
  4497. * @param result defines the target matrix
  4498. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4499. */
  4500. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4501. /**
  4502. * Creates a right-handed perspective projection matrix
  4503. * @param fov defines the horizontal field of view
  4504. * @param aspect defines the aspect ratio
  4505. * @param znear defines the near clip plane
  4506. * @param zfar defines the far clip plane
  4507. * @returns a new matrix as a right-handed perspective projection matrix
  4508. */
  4509. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4510. /**
  4511. * Stores a right-handed perspective projection into a given matrix
  4512. * @param fov defines the horizontal field of view
  4513. * @param aspect defines the aspect ratio
  4514. * @param znear defines the near clip plane
  4515. * @param zfar defines the far clip plane
  4516. * @param result defines the target matrix
  4517. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4518. */
  4519. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4520. /**
  4521. * Stores a right-handed perspective projection into a given matrix
  4522. * @param fov defines the horizontal field of view
  4523. * @param aspect defines the aspect ratio
  4524. * @param znear defines the near clip plane
  4525. * @param zfar not used as infinity is used as far clip
  4526. * @param result defines the target matrix
  4527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4528. */
  4529. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4530. /**
  4531. * Stores a perspective projection for WebVR info a given matrix
  4532. * @param fov defines the field of view
  4533. * @param znear defines the near clip plane
  4534. * @param zfar defines the far clip plane
  4535. * @param result defines the target matrix
  4536. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4537. */
  4538. static PerspectiveFovWebVRToRef(fov: {
  4539. upDegrees: number;
  4540. downDegrees: number;
  4541. leftDegrees: number;
  4542. rightDegrees: number;
  4543. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4544. /**
  4545. * Computes a complete transformation matrix
  4546. * @param viewport defines the viewport to use
  4547. * @param world defines the world matrix
  4548. * @param view defines the view matrix
  4549. * @param projection defines the projection matrix
  4550. * @param zmin defines the near clip plane
  4551. * @param zmax defines the far clip plane
  4552. * @returns the transformation matrix
  4553. */
  4554. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4555. /**
  4556. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4557. * @param matrix defines the matrix to use
  4558. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4559. */
  4560. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4561. /**
  4562. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4563. * @param matrix defines the matrix to use
  4564. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4565. */
  4566. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4567. /**
  4568. * Compute the transpose of a given matrix
  4569. * @param matrix defines the matrix to transpose
  4570. * @returns the new matrix
  4571. */
  4572. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4573. /**
  4574. * Compute the transpose of a matrix and store it in a target matrix
  4575. * @param matrix defines the matrix to transpose
  4576. * @param result defines the target matrix
  4577. */
  4578. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4579. /**
  4580. * Computes a reflection matrix from a plane
  4581. * @param plane defines the reflection plane
  4582. * @returns a new matrix
  4583. */
  4584. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4585. /**
  4586. * Computes a reflection matrix from a plane
  4587. * @param plane defines the reflection plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4591. /**
  4592. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4593. * @param xaxis defines the value of the 1st axis
  4594. * @param yaxis defines the value of the 2nd axis
  4595. * @param zaxis defines the value of the 3rd axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4599. /**
  4600. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4601. * @param quat defines the quaternion to use
  4602. * @param result defines the target matrix
  4603. */
  4604. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4605. }
  4606. /**
  4607. * @hidden
  4608. */
  4609. export class TmpVectors {
  4610. static Vector2: Vector2[];
  4611. static Vector3: Vector3[];
  4612. static Vector4: Vector4[];
  4613. static Quaternion: Quaternion[];
  4614. static Matrix: Matrix[];
  4615. }
  4616. }
  4617. declare module BABYLON {
  4618. /**
  4619. * Defines potential orientation for back face culling
  4620. */
  4621. export enum Orientation {
  4622. /**
  4623. * Clockwise
  4624. */
  4625. CW = 0,
  4626. /** Counter clockwise */
  4627. CCW = 1
  4628. }
  4629. /** Class used to represent a Bezier curve */
  4630. export class BezierCurve {
  4631. /**
  4632. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4633. * @param t defines the time
  4634. * @param x1 defines the left coordinate on X axis
  4635. * @param y1 defines the left coordinate on Y axis
  4636. * @param x2 defines the right coordinate on X axis
  4637. * @param y2 defines the right coordinate on Y axis
  4638. * @returns the interpolated value
  4639. */
  4640. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4641. }
  4642. /**
  4643. * Defines angle representation
  4644. */
  4645. export class Angle {
  4646. private _radians;
  4647. /**
  4648. * Creates an Angle object of "radians" radians (float).
  4649. * @param radians the angle in radians
  4650. */
  4651. constructor(radians: number);
  4652. /**
  4653. * Get value in degrees
  4654. * @returns the Angle value in degrees (float)
  4655. */
  4656. degrees(): number;
  4657. /**
  4658. * Get value in radians
  4659. * @returns the Angle value in radians (float)
  4660. */
  4661. radians(): number;
  4662. /**
  4663. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4664. * @param a defines first vector
  4665. * @param b defines second vector
  4666. * @returns a new Angle
  4667. */
  4668. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4669. /**
  4670. * Gets a new Angle object from the given float in radians
  4671. * @param radians defines the angle value in radians
  4672. * @returns a new Angle
  4673. */
  4674. static FromRadians(radians: number): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in degrees
  4677. * @param degrees defines the angle value in degrees
  4678. * @returns a new Angle
  4679. */
  4680. static FromDegrees(degrees: number): Angle;
  4681. }
  4682. /**
  4683. * This represents an arc in a 2d space.
  4684. */
  4685. export class Arc2 {
  4686. /** Defines the start point of the arc */
  4687. startPoint: Vector2;
  4688. /** Defines the mid point of the arc */
  4689. midPoint: Vector2;
  4690. /** Defines the end point of the arc */
  4691. endPoint: Vector2;
  4692. /**
  4693. * Defines the center point of the arc.
  4694. */
  4695. centerPoint: Vector2;
  4696. /**
  4697. * Defines the radius of the arc.
  4698. */
  4699. radius: number;
  4700. /**
  4701. * Defines the angle of the arc (from mid point to end point).
  4702. */
  4703. angle: Angle;
  4704. /**
  4705. * Defines the start angle of the arc (from start point to middle point).
  4706. */
  4707. startAngle: Angle;
  4708. /**
  4709. * Defines the orientation of the arc (clock wise/counter clock wise).
  4710. */
  4711. orientation: Orientation;
  4712. /**
  4713. * Creates an Arc object from the three given points : start, middle and end.
  4714. * @param startPoint Defines the start point of the arc
  4715. * @param midPoint Defines the midlle point of the arc
  4716. * @param endPoint Defines the end point of the arc
  4717. */
  4718. constructor(
  4719. /** Defines the start point of the arc */
  4720. startPoint: Vector2,
  4721. /** Defines the mid point of the arc */
  4722. midPoint: Vector2,
  4723. /** Defines the end point of the arc */
  4724. endPoint: Vector2);
  4725. }
  4726. /**
  4727. * Represents a 2D path made up of multiple 2D points
  4728. */
  4729. export class Path2 {
  4730. private _points;
  4731. private _length;
  4732. /**
  4733. * If the path start and end point are the same
  4734. */
  4735. closed: boolean;
  4736. /**
  4737. * Creates a Path2 object from the starting 2D coordinates x and y.
  4738. * @param x the starting points x value
  4739. * @param y the starting points y value
  4740. */
  4741. constructor(x: number, y: number);
  4742. /**
  4743. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4744. * @param x the added points x value
  4745. * @param y the added points y value
  4746. * @returns the updated Path2.
  4747. */
  4748. addLineTo(x: number, y: number): Path2;
  4749. /**
  4750. * 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.
  4751. * @param midX middle point x value
  4752. * @param midY middle point y value
  4753. * @param endX end point x value
  4754. * @param endY end point y value
  4755. * @param numberOfSegments (default: 36)
  4756. * @returns the updated Path2.
  4757. */
  4758. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4759. /**
  4760. * Closes the Path2.
  4761. * @returns the Path2.
  4762. */
  4763. close(): Path2;
  4764. /**
  4765. * Gets the sum of the distance between each sequential point in the path
  4766. * @returns the Path2 total length (float).
  4767. */
  4768. length(): number;
  4769. /**
  4770. * Gets the points which construct the path
  4771. * @returns the Path2 internal array of points.
  4772. */
  4773. getPoints(): Vector2[];
  4774. /**
  4775. * Retreives the point at the distance aways from the starting point
  4776. * @param normalizedLengthPosition the length along the path to retreive the point from
  4777. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4778. */
  4779. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4780. /**
  4781. * Creates a new path starting from an x and y position
  4782. * @param x starting x value
  4783. * @param y starting y value
  4784. * @returns a new Path2 starting at the coordinates (x, y).
  4785. */
  4786. static StartingAt(x: number, y: number): Path2;
  4787. }
  4788. /**
  4789. * Represents a 3D path made up of multiple 3D points
  4790. */
  4791. export class Path3D {
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[];
  4796. private _curve;
  4797. private _distances;
  4798. private _tangents;
  4799. private _normals;
  4800. private _binormals;
  4801. private _raw;
  4802. private _alignTangentsWithPath;
  4803. private readonly _pointAtData;
  4804. /**
  4805. * new Path3D(path, normal, raw)
  4806. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4807. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4808. * @param path an array of Vector3, the curve axis of the Path3D
  4809. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4810. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4812. */
  4813. constructor(
  4814. /**
  4815. * an array of Vector3, the curve axis of the Path3D
  4816. */
  4817. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4818. /**
  4819. * Returns the Path3D array of successive Vector3 designing its curve.
  4820. * @returns the Path3D array of successive Vector3 designing its curve.
  4821. */
  4822. getCurve(): Vector3[];
  4823. /**
  4824. * Returns the Path3D array of successive Vector3 designing its curve.
  4825. * @returns the Path3D array of successive Vector3 designing its curve.
  4826. */
  4827. getPoints(): Vector3[];
  4828. /**
  4829. * @returns the computed length (float) of the path.
  4830. */
  4831. length(): number;
  4832. /**
  4833. * Returns an array populated with tangent vectors on each Path3D curve point.
  4834. * @returns an array populated with tangent vectors on each Path3D curve point.
  4835. */
  4836. getTangents(): Vector3[];
  4837. /**
  4838. * Returns an array populated with normal vectors on each Path3D curve point.
  4839. * @returns an array populated with normal vectors on each Path3D curve point.
  4840. */
  4841. getNormals(): Vector3[];
  4842. /**
  4843. * Returns an array populated with binormal vectors on each Path3D curve point.
  4844. * @returns an array populated with binormal vectors on each Path3D curve point.
  4845. */
  4846. getBinormals(): Vector3[];
  4847. /**
  4848. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4849. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. */
  4851. getDistances(): number[];
  4852. /**
  4853. * Returns an interpolated point along this path
  4854. * @param position the position of the point along this path, from 0.0 to 1.0
  4855. * @returns a new Vector3 as the point
  4856. */
  4857. getPointAt(position: number): Vector3;
  4858. /**
  4859. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4862. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4863. */
  4864. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4865. /**
  4866. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4867. * @param position the position of the point along this path, from 0.0 to 1.0
  4868. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4869. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4870. */
  4871. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4872. /**
  4873. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4874. * @param position the position of the point along this path, from 0.0 to 1.0
  4875. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4876. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4877. */
  4878. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4879. /**
  4880. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4883. */
  4884. getDistanceAt(position: number): number;
  4885. /**
  4886. * Returns the array index of the previous point of an interpolated point along this path
  4887. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4888. * @returns the array index
  4889. */
  4890. getPreviousPointIndexAt(position: number): number;
  4891. /**
  4892. * 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)
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the sub position
  4895. */
  4896. getSubPositionAt(position: number): number;
  4897. /**
  4898. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4899. * @param target the vector of which to get the closest position to
  4900. * @returns the position of the closest virtual point on this path to the target vector
  4901. */
  4902. getClosestPositionTo(target: Vector3): number;
  4903. /**
  4904. * Returns a sub path (slice) of this path
  4905. * @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
  4906. * @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
  4907. * @returns a sub path (slice) of this path
  4908. */
  4909. slice(start?: number, end?: number): Path3D;
  4910. /**
  4911. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4912. * @param path path which all values are copied into the curves points
  4913. * @param firstNormal which should be projected onto the curve
  4914. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4915. * @returns the same object updated.
  4916. */
  4917. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4918. private _compute;
  4919. private _getFirstNonNullVector;
  4920. private _getLastNonNullVector;
  4921. private _normalVector;
  4922. /**
  4923. * Updates the point at data for an interpolated point along this curve
  4924. * @param position the position of the point along this curve, from 0.0 to 1.0
  4925. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4926. * @returns the (updated) point at data
  4927. */
  4928. private _updatePointAtData;
  4929. /**
  4930. * Updates the point at data from the specified parameters
  4931. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4932. * @param point the interpolated point
  4933. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4934. */
  4935. private _setPointAtData;
  4936. /**
  4937. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4938. */
  4939. private _updateInterpolationMatrix;
  4940. }
  4941. /**
  4942. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4943. * A Curve3 is designed from a series of successive Vector3.
  4944. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4945. */
  4946. export class Curve3 {
  4947. private _points;
  4948. private _length;
  4949. /**
  4950. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4951. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4952. * @param v1 (Vector3) the control point
  4953. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4954. * @param nbPoints (integer) the wanted number of points in the curve
  4955. * @returns the created Curve3
  4956. */
  4957. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4958. /**
  4959. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4960. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4961. * @param v1 (Vector3) the first control point
  4962. * @param v2 (Vector3) the second control point
  4963. * @param v3 (Vector3) the end point of the Cubic Bezier
  4964. * @param nbPoints (integer) the wanted number of points in the curve
  4965. * @returns the created Curve3
  4966. */
  4967. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4968. /**
  4969. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4970. * @param p1 (Vector3) the origin point of the Hermite Spline
  4971. * @param t1 (Vector3) the tangent vector at the origin point
  4972. * @param p2 (Vector3) the end point of the Hermite Spline
  4973. * @param t2 (Vector3) the tangent vector at the end point
  4974. * @param nbPoints (integer) the wanted number of points in the curve
  4975. * @returns the created Curve3
  4976. */
  4977. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4978. /**
  4979. * Returns a Curve3 object along a CatmullRom Spline curve :
  4980. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4981. * @param nbPoints (integer) the wanted number of points between each curve control points
  4982. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4983. * @returns the created Curve3
  4984. */
  4985. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4986. /**
  4987. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4988. * A Curve3 is designed from a series of successive Vector3.
  4989. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4990. * @param points points which make up the curve
  4991. */
  4992. constructor(points: Vector3[]);
  4993. /**
  4994. * @returns the Curve3 stored array of successive Vector3
  4995. */
  4996. getPoints(): Vector3[];
  4997. /**
  4998. * @returns the computed length (float) of the curve.
  4999. */
  5000. length(): number;
  5001. /**
  5002. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5003. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5004. * curveA and curveB keep unchanged.
  5005. * @param curve the curve to continue from this curve
  5006. * @returns the newly constructed curve
  5007. */
  5008. continue(curve: DeepImmutable<Curve3>): Curve3;
  5009. private _computeLength;
  5010. }
  5011. }
  5012. declare module BABYLON {
  5013. /**
  5014. * This represents the main contract an easing function should follow.
  5015. * Easing functions are used throughout the animation system.
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export interface IEasingFunction {
  5019. /**
  5020. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5021. * of the easing function.
  5022. * The link below provides some of the most common examples of easing functions.
  5023. * @see https://easings.net/
  5024. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5025. * @returns the corresponding value on the curve defined by the easing function
  5026. */
  5027. ease(gradient: number): number;
  5028. }
  5029. /**
  5030. * Base class used for every default easing function.
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class EasingFunction implements IEasingFunction {
  5034. /**
  5035. * Interpolation follows the mathematical formula associated with the easing function.
  5036. */
  5037. static readonly EASINGMODE_EASEIN: number;
  5038. /**
  5039. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5040. */
  5041. static readonly EASINGMODE_EASEOUT: number;
  5042. /**
  5043. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5044. */
  5045. static readonly EASINGMODE_EASEINOUT: number;
  5046. private _easingMode;
  5047. /**
  5048. * Sets the easing mode of the current function.
  5049. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5050. */
  5051. setEasingMode(easingMode: number): void;
  5052. /**
  5053. * Gets the current easing mode.
  5054. * @returns the easing mode
  5055. */
  5056. getEasingMode(): number;
  5057. /**
  5058. * @hidden
  5059. */
  5060. easeInCore(gradient: number): number;
  5061. /**
  5062. * Given an input gradient between 0 and 1, this returns the corresponding value
  5063. * of the easing function.
  5064. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5065. * @returns the corresponding value on the curve defined by the easing function
  5066. */
  5067. ease(gradient: number): number;
  5068. }
  5069. /**
  5070. * Easing function with a circle shape (see link below).
  5071. * @see https://easings.net/#easeInCirc
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export class CircleEase extends EasingFunction implements IEasingFunction {
  5075. /** @hidden */
  5076. easeInCore(gradient: number): number;
  5077. }
  5078. /**
  5079. * Easing function with a ease back shape (see link below).
  5080. * @see https://easings.net/#easeInBack
  5081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5082. */
  5083. export class BackEase extends EasingFunction implements IEasingFunction {
  5084. /** Defines the amplitude of the function */
  5085. amplitude: number;
  5086. /**
  5087. * Instantiates a back ease easing
  5088. * @see https://easings.net/#easeInBack
  5089. * @param amplitude Defines the amplitude of the function
  5090. */
  5091. constructor(
  5092. /** Defines the amplitude of the function */
  5093. amplitude?: number);
  5094. /** @hidden */
  5095. easeInCore(gradient: number): number;
  5096. }
  5097. /**
  5098. * Easing function with a bouncing shape (see link below).
  5099. * @see https://easings.net/#easeInBounce
  5100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5101. */
  5102. export class BounceEase extends EasingFunction implements IEasingFunction {
  5103. /** Defines the number of bounces */
  5104. bounces: number;
  5105. /** Defines the amplitude of the bounce */
  5106. bounciness: number;
  5107. /**
  5108. * Instantiates a bounce easing
  5109. * @see https://easings.net/#easeInBounce
  5110. * @param bounces Defines the number of bounces
  5111. * @param bounciness Defines the amplitude of the bounce
  5112. */
  5113. constructor(
  5114. /** Defines the number of bounces */
  5115. bounces?: number,
  5116. /** Defines the amplitude of the bounce */
  5117. bounciness?: number);
  5118. /** @hidden */
  5119. easeInCore(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a power of 3 shape (see link below).
  5123. * @see https://easings.net/#easeInCubic
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CubicEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with an elastic shape (see link below).
  5132. * @see https://easings.net/#easeInElastic
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the number of oscillations*/
  5137. oscillations: number;
  5138. /** Defines the amplitude of the oscillations*/
  5139. springiness: number;
  5140. /**
  5141. * Instantiates an elastic easing function
  5142. * @see https://easings.net/#easeInElastic
  5143. * @param oscillations Defines the number of oscillations
  5144. * @param springiness Defines the amplitude of the oscillations
  5145. */
  5146. constructor(
  5147. /** Defines the number of oscillations*/
  5148. oscillations?: number,
  5149. /** Defines the amplitude of the oscillations*/
  5150. springiness?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with an exponential shape (see link below).
  5156. * @see https://easings.net/#easeInExpo
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the exponent of the function */
  5161. exponent: number;
  5162. /**
  5163. * Instantiates an exponential easing function
  5164. * @see https://easings.net/#easeInExpo
  5165. * @param exponent Defines the exponent of the function
  5166. */
  5167. constructor(
  5168. /** Defines the exponent of the function */
  5169. exponent?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power shape (see link below).
  5175. * @see https://easings.net/#easeInQuad
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class PowerEase extends EasingFunction implements IEasingFunction {
  5179. /** Defines the power of the function */
  5180. power: number;
  5181. /**
  5182. * Instantiates an power base easing function
  5183. * @see https://easings.net/#easeInQuad
  5184. * @param power Defines the power of the function
  5185. */
  5186. constructor(
  5187. /** Defines the power of the function */
  5188. power?: number);
  5189. /** @hidden */
  5190. easeInCore(gradient: number): number;
  5191. }
  5192. /**
  5193. * Easing function with a power of 2 shape (see link below).
  5194. * @see https://easings.net/#easeInQuad
  5195. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5196. */
  5197. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5198. /** @hidden */
  5199. easeInCore(gradient: number): number;
  5200. }
  5201. /**
  5202. * Easing function with a power of 4 shape (see link below).
  5203. * @see https://easings.net/#easeInQuart
  5204. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5205. */
  5206. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5207. /** @hidden */
  5208. easeInCore(gradient: number): number;
  5209. }
  5210. /**
  5211. * Easing function with a power of 5 shape (see link below).
  5212. * @see https://easings.net/#easeInQuint
  5213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5214. */
  5215. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5216. /** @hidden */
  5217. easeInCore(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a sin shape (see link below).
  5221. * @see https://easings.net/#easeInSine
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class SineEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a bezier shape (see link below).
  5230. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the x component of the start tangent in the bezier curve */
  5235. x1: number;
  5236. /** Defines the y component of the start tangent in the bezier curve */
  5237. y1: number;
  5238. /** Defines the x component of the end tangent in the bezier curve */
  5239. x2: number;
  5240. /** Defines the y component of the end tangent in the bezier curve */
  5241. y2: number;
  5242. /**
  5243. * Instantiates a bezier function
  5244. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5245. * @param x1 Defines the x component of the start tangent in the bezier curve
  5246. * @param y1 Defines the y component of the start tangent in the bezier curve
  5247. * @param x2 Defines the x component of the end tangent in the bezier curve
  5248. * @param y2 Defines the y component of the end tangent in the bezier curve
  5249. */
  5250. constructor(
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1?: number,
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1?: number,
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2?: number,
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2?: number);
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. }
  5263. declare module BABYLON {
  5264. /**
  5265. * Class used to hold a RBG color
  5266. */
  5267. export class Color3 {
  5268. /**
  5269. * Defines the red component (between 0 and 1, default is 0)
  5270. */
  5271. r: number;
  5272. /**
  5273. * Defines the green component (between 0 and 1, default is 0)
  5274. */
  5275. g: number;
  5276. /**
  5277. * Defines the blue component (between 0 and 1, default is 0)
  5278. */
  5279. b: number;
  5280. /**
  5281. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5282. * @param r defines the red component (between 0 and 1, default is 0)
  5283. * @param g defines the green component (between 0 and 1, default is 0)
  5284. * @param b defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. constructor(
  5287. /**
  5288. * Defines the red component (between 0 and 1, default is 0)
  5289. */
  5290. r?: number,
  5291. /**
  5292. * Defines the green component (between 0 and 1, default is 0)
  5293. */
  5294. g?: number,
  5295. /**
  5296. * Defines the blue component (between 0 and 1, default is 0)
  5297. */
  5298. b?: number);
  5299. /**
  5300. * Creates a string with the Color3 current values
  5301. * @returns the string representation of the Color3 object
  5302. */
  5303. toString(): string;
  5304. /**
  5305. * Returns the string "Color3"
  5306. * @returns "Color3"
  5307. */
  5308. getClassName(): string;
  5309. /**
  5310. * Compute the Color3 hash code
  5311. * @returns an unique number that can be used to hash Color3 objects
  5312. */
  5313. getHashCode(): number;
  5314. /**
  5315. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5316. * @param array defines the array where to store the r,g,b components
  5317. * @param index defines an optional index in the target array to define where to start storing values
  5318. * @returns the current Color3 object
  5319. */
  5320. toArray(array: FloatArray, index?: number): Color3;
  5321. /**
  5322. * Returns a new Color4 object from the current Color3 and the given alpha
  5323. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5324. * @returns a new Color4 object
  5325. */
  5326. toColor4(alpha?: number): Color4;
  5327. /**
  5328. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5329. * @returns the new array
  5330. */
  5331. asArray(): number[];
  5332. /**
  5333. * Returns the luminance value
  5334. * @returns a float value
  5335. */
  5336. toLuminance(): number;
  5337. /**
  5338. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5339. * @param otherColor defines the second operand
  5340. * @returns the new Color3 object
  5341. */
  5342. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5343. /**
  5344. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5345. * @param otherColor defines the second operand
  5346. * @param result defines the Color3 object where to store the result
  5347. * @returns the current Color3
  5348. */
  5349. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5350. /**
  5351. * Determines equality between Color3 objects
  5352. * @param otherColor defines the second operand
  5353. * @returns true if the rgb values are equal to the given ones
  5354. */
  5355. equals(otherColor: DeepImmutable<Color3>): boolean;
  5356. /**
  5357. * Determines equality between the current Color3 object and a set of r,b,g values
  5358. * @param r defines the red component to check
  5359. * @param g defines the green component to check
  5360. * @param b defines the blue component to check
  5361. * @returns true if the rgb values are equal to the given ones
  5362. */
  5363. equalsFloats(r: number, g: number, b: number): boolean;
  5364. /**
  5365. * Multiplies in place each rgb value by scale
  5366. * @param scale defines the scaling factor
  5367. * @returns the updated Color3
  5368. */
  5369. scale(scale: number): Color3;
  5370. /**
  5371. * Multiplies the rgb values by scale and stores the result into "result"
  5372. * @param scale defines the scaling factor
  5373. * @param result defines the Color3 object where to store the result
  5374. * @returns the unmodified current Color3
  5375. */
  5376. scaleToRef(scale: number, result: Color3): Color3;
  5377. /**
  5378. * Scale the current Color3 values by a factor and add the result to a given Color3
  5379. * @param scale defines the scale factor
  5380. * @param result defines color to store the result into
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Clamps the rgb values by the min and max values and stores the result into "result"
  5386. * @param min defines minimum clamping value (default is 0)
  5387. * @param max defines maximum clamping value (default is 1)
  5388. * @param result defines color to store the result into
  5389. * @returns the original Color3
  5390. */
  5391. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5392. /**
  5393. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5394. * @param otherColor defines the second operand
  5395. * @returns the new Color3
  5396. */
  5397. add(otherColor: DeepImmutable<Color3>): Color3;
  5398. /**
  5399. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5400. * @param otherColor defines the second operand
  5401. * @param result defines Color3 object to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5405. /**
  5406. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5407. * @param otherColor defines the second operand
  5408. * @returns the new Color3
  5409. */
  5410. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5411. /**
  5412. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5413. * @param otherColor defines the second operand
  5414. * @param result defines Color3 object to store the result into
  5415. * @returns the unmodified current Color3
  5416. */
  5417. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5418. /**
  5419. * Copy the current object
  5420. * @returns a new Color3 copied the current one
  5421. */
  5422. clone(): Color3;
  5423. /**
  5424. * Copies the rgb values from the source in the current Color3
  5425. * @param source defines the source Color3 object
  5426. * @returns the updated Color3 object
  5427. */
  5428. copyFrom(source: DeepImmutable<Color3>): Color3;
  5429. /**
  5430. * Updates the Color3 rgb values from the given floats
  5431. * @param r defines the red component to read from
  5432. * @param g defines the green component to read from
  5433. * @param b defines the blue component to read from
  5434. * @returns the current Color3 object
  5435. */
  5436. copyFromFloats(r: number, g: number, b: number): Color3;
  5437. /**
  5438. * Updates the Color3 rgb values from the given floats
  5439. * @param r defines the red component to read from
  5440. * @param g defines the green component to read from
  5441. * @param b defines the blue component to read from
  5442. * @returns the current Color3 object
  5443. */
  5444. set(r: number, g: number, b: number): Color3;
  5445. /**
  5446. * Compute the Color3 hexadecimal code as a string
  5447. * @returns a string containing the hexadecimal representation of the Color3 object
  5448. */
  5449. toHexString(): string;
  5450. /**
  5451. * Computes a new Color3 converted from the current one to linear space
  5452. * @returns a new Color3 object
  5453. */
  5454. toLinearSpace(): Color3;
  5455. /**
  5456. * Converts current color in rgb space to HSV values
  5457. * @returns a new color3 representing the HSV values
  5458. */
  5459. toHSV(): Color3;
  5460. /**
  5461. * Converts current color in rgb space to HSV values
  5462. * @param result defines the Color3 where to store the HSV values
  5463. */
  5464. toHSVToRef(result: Color3): void;
  5465. /**
  5466. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5467. * @param convertedColor defines the Color3 object where to store the linear space version
  5468. * @returns the unmodified Color3
  5469. */
  5470. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to gamma space
  5473. * @returns a new Color3 object
  5474. */
  5475. toGammaSpace(): Color3;
  5476. /**
  5477. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5478. * @param convertedColor defines the Color3 object where to store the gamma space version
  5479. * @returns the unmodified Color3
  5480. */
  5481. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5482. private static _BlackReadOnly;
  5483. /**
  5484. * Convert Hue, saturation and value to a Color3 (RGB)
  5485. * @param hue defines the hue
  5486. * @param saturation defines the saturation
  5487. * @param value defines the value
  5488. * @param result defines the Color3 where to store the RGB values
  5489. */
  5490. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5491. /**
  5492. * Creates a new Color3 from the string containing valid hexadecimal values
  5493. * @param hex defines a string containing valid hexadecimal values
  5494. * @returns a new Color3 object
  5495. */
  5496. static FromHexString(hex: string): Color3;
  5497. /**
  5498. * Creates a new Color3 from the starting index of the given array
  5499. * @param array defines the source array
  5500. * @param offset defines an offset in the source array
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5504. /**
  5505. * Creates a new Color3 from integer values (< 256)
  5506. * @param r defines the red component to read from (value between 0 and 255)
  5507. * @param g defines the green component to read from (value between 0 and 255)
  5508. * @param b defines the blue component to read from (value between 0 and 255)
  5509. * @returns a new Color3 object
  5510. */
  5511. static FromInts(r: number, g: number, b: number): Color3;
  5512. /**
  5513. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5514. * @param start defines the start Color3 value
  5515. * @param end defines the end Color3 value
  5516. * @param amount defines the gradient value between start and end
  5517. * @returns a new Color3 object
  5518. */
  5519. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5520. /**
  5521. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5522. * @param left defines the start value
  5523. * @param right defines the end value
  5524. * @param amount defines the gradient factor
  5525. * @param result defines the Color3 object where to store the result
  5526. */
  5527. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5528. /**
  5529. * Returns a Color3 value containing a red color
  5530. * @returns a new Color3 object
  5531. */
  5532. static Red(): Color3;
  5533. /**
  5534. * Returns a Color3 value containing a green color
  5535. * @returns a new Color3 object
  5536. */
  5537. static Green(): Color3;
  5538. /**
  5539. * Returns a Color3 value containing a blue color
  5540. * @returns a new Color3 object
  5541. */
  5542. static Blue(): Color3;
  5543. /**
  5544. * Returns a Color3 value containing a black color
  5545. * @returns a new Color3 object
  5546. */
  5547. static Black(): Color3;
  5548. /**
  5549. * Gets a Color3 value containing a black color that must not be updated
  5550. */
  5551. static get BlackReadOnly(): DeepImmutable<Color3>;
  5552. /**
  5553. * Returns a Color3 value containing a white color
  5554. * @returns a new Color3 object
  5555. */
  5556. static White(): Color3;
  5557. /**
  5558. * Returns a Color3 value containing a purple color
  5559. * @returns a new Color3 object
  5560. */
  5561. static Purple(): Color3;
  5562. /**
  5563. * Returns a Color3 value containing a magenta color
  5564. * @returns a new Color3 object
  5565. */
  5566. static Magenta(): Color3;
  5567. /**
  5568. * Returns a Color3 value containing a yellow color
  5569. * @returns a new Color3 object
  5570. */
  5571. static Yellow(): Color3;
  5572. /**
  5573. * Returns a Color3 value containing a gray color
  5574. * @returns a new Color3 object
  5575. */
  5576. static Gray(): Color3;
  5577. /**
  5578. * Returns a Color3 value containing a teal color
  5579. * @returns a new Color3 object
  5580. */
  5581. static Teal(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a random color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Random(): Color3;
  5587. }
  5588. /**
  5589. * Class used to hold a RBGA color
  5590. */
  5591. export class Color4 {
  5592. /**
  5593. * Defines the red component (between 0 and 1, default is 0)
  5594. */
  5595. r: number;
  5596. /**
  5597. * Defines the green component (between 0 and 1, default is 0)
  5598. */
  5599. g: number;
  5600. /**
  5601. * Defines the blue component (between 0 and 1, default is 0)
  5602. */
  5603. b: number;
  5604. /**
  5605. * Defines the alpha component (between 0 and 1, default is 1)
  5606. */
  5607. a: number;
  5608. /**
  5609. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5610. * @param r defines the red component (between 0 and 1, default is 0)
  5611. * @param g defines the green component (between 0 and 1, default is 0)
  5612. * @param b defines the blue component (between 0 and 1, default is 0)
  5613. * @param a defines the alpha component (between 0 and 1, default is 1)
  5614. */
  5615. constructor(
  5616. /**
  5617. * Defines the red component (between 0 and 1, default is 0)
  5618. */
  5619. r?: number,
  5620. /**
  5621. * Defines the green component (between 0 and 1, default is 0)
  5622. */
  5623. g?: number,
  5624. /**
  5625. * Defines the blue component (between 0 and 1, default is 0)
  5626. */
  5627. b?: number,
  5628. /**
  5629. * Defines the alpha component (between 0 and 1, default is 1)
  5630. */
  5631. a?: number);
  5632. /**
  5633. * Adds in place the given Color4 values to the current Color4 object
  5634. * @param right defines the second operand
  5635. * @returns the current updated Color4 object
  5636. */
  5637. addInPlace(right: DeepImmutable<Color4>): Color4;
  5638. /**
  5639. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5640. * @returns the new array
  5641. */
  5642. asArray(): number[];
  5643. /**
  5644. * Stores from the starting index in the given array the Color4 successive values
  5645. * @param array defines the array where to store the r,g,b components
  5646. * @param index defines an optional index in the target array to define where to start storing values
  5647. * @returns the current Color4 object
  5648. */
  5649. toArray(array: number[], index?: number): Color4;
  5650. /**
  5651. * Determines equality between Color4 objects
  5652. * @param otherColor defines the second operand
  5653. * @returns true if the rgba values are equal to the given ones
  5654. */
  5655. equals(otherColor: DeepImmutable<Color4>): boolean;
  5656. /**
  5657. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5658. * @param right defines the second operand
  5659. * @returns a new Color4 object
  5660. */
  5661. add(right: DeepImmutable<Color4>): Color4;
  5662. /**
  5663. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5664. * @param right defines the second operand
  5665. * @returns a new Color4 object
  5666. */
  5667. subtract(right: DeepImmutable<Color4>): Color4;
  5668. /**
  5669. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5670. * @param right defines the second operand
  5671. * @param result defines the Color4 object where to store the result
  5672. * @returns the current Color4 object
  5673. */
  5674. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5675. /**
  5676. * Creates a new Color4 with the current Color4 values multiplied by scale
  5677. * @param scale defines the scaling factor to apply
  5678. * @returns a new Color4 object
  5679. */
  5680. scale(scale: number): Color4;
  5681. /**
  5682. * Multiplies the current Color4 values by scale and stores the result in "result"
  5683. * @param scale defines the scaling factor to apply
  5684. * @param result defines the Color4 object where to store the result
  5685. * @returns the current unmodified Color4
  5686. */
  5687. scaleToRef(scale: number, result: Color4): Color4;
  5688. /**
  5689. * Scale the current Color4 values by a factor and add the result to a given Color4
  5690. * @param scale defines the scale factor
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the unmodified current Color4
  5693. */
  5694. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Clamps the rgb values by the min and max values and stores the result into "result"
  5697. * @param min defines minimum clamping value (default is 0)
  5698. * @param max defines maximum clamping value (default is 1)
  5699. * @param result defines color to store the result into.
  5700. * @returns the cuurent Color4
  5701. */
  5702. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5703. /**
  5704. * Multipy an Color4 value by another and return a new Color4 object
  5705. * @param color defines the Color4 value to multiply by
  5706. * @returns a new Color4 object
  5707. */
  5708. multiply(color: Color4): Color4;
  5709. /**
  5710. * Multipy a Color4 value by another and push the result in a reference value
  5711. * @param color defines the Color4 value to multiply by
  5712. * @param result defines the Color4 to fill the result in
  5713. * @returns the result Color4
  5714. */
  5715. multiplyToRef(color: Color4, result: Color4): Color4;
  5716. /**
  5717. * Creates a string with the Color4 current values
  5718. * @returns the string representation of the Color4 object
  5719. */
  5720. toString(): string;
  5721. /**
  5722. * Returns the string "Color4"
  5723. * @returns "Color4"
  5724. */
  5725. getClassName(): string;
  5726. /**
  5727. * Compute the Color4 hash code
  5728. * @returns an unique number that can be used to hash Color4 objects
  5729. */
  5730. getHashCode(): number;
  5731. /**
  5732. * Creates a new Color4 copied from the current one
  5733. * @returns a new Color4 object
  5734. */
  5735. clone(): Color4;
  5736. /**
  5737. * Copies the given Color4 values into the current one
  5738. * @param source defines the source Color4 object
  5739. * @returns the current updated Color4 object
  5740. */
  5741. copyFrom(source: Color4): Color4;
  5742. /**
  5743. * Copies the given float values into the current one
  5744. * @param r defines the red component to read from
  5745. * @param g defines the green component to read from
  5746. * @param b defines the blue component to read from
  5747. * @param a defines the alpha component to read from
  5748. * @returns the current updated Color4 object
  5749. */
  5750. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5751. /**
  5752. * Copies the given float values into the current one
  5753. * @param r defines the red component to read from
  5754. * @param g defines the green component to read from
  5755. * @param b defines the blue component to read from
  5756. * @param a defines the alpha component to read from
  5757. * @returns the current updated Color4 object
  5758. */
  5759. set(r: number, g: number, b: number, a: number): Color4;
  5760. /**
  5761. * Compute the Color4 hexadecimal code as a string
  5762. * @returns a string containing the hexadecimal representation of the Color4 object
  5763. */
  5764. toHexString(): string;
  5765. /**
  5766. * Computes a new Color4 converted from the current one to linear space
  5767. * @returns a new Color4 object
  5768. */
  5769. toLinearSpace(): Color4;
  5770. /**
  5771. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5772. * @param convertedColor defines the Color4 object where to store the linear space version
  5773. * @returns the unmodified Color4
  5774. */
  5775. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5776. /**
  5777. * Computes a new Color4 converted from the current one to gamma space
  5778. * @returns a new Color4 object
  5779. */
  5780. toGammaSpace(): Color4;
  5781. /**
  5782. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5783. * @param convertedColor defines the Color4 object where to store the gamma space version
  5784. * @returns the unmodified Color4
  5785. */
  5786. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5787. /**
  5788. * Creates a new Color4 from the string containing valid hexadecimal values
  5789. * @param hex defines a string containing valid hexadecimal values
  5790. * @returns a new Color4 object
  5791. */
  5792. static FromHexString(hex: string): Color4;
  5793. /**
  5794. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5795. * @param left defines the start value
  5796. * @param right defines the end value
  5797. * @param amount defines the gradient factor
  5798. * @returns a new Color4 object
  5799. */
  5800. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5801. /**
  5802. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5803. * @param left defines the start value
  5804. * @param right defines the end value
  5805. * @param amount defines the gradient factor
  5806. * @param result defines the Color4 object where to store data
  5807. */
  5808. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5809. /**
  5810. * Creates a new Color4 from a Color3 and an alpha value
  5811. * @param color3 defines the source Color3 to read from
  5812. * @param alpha defines the alpha component (1.0 by default)
  5813. * @returns a new Color4 object
  5814. */
  5815. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5816. /**
  5817. * Creates a new Color4 from the starting index element of the given array
  5818. * @param array defines the source array to read from
  5819. * @param offset defines the offset in the source array
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5823. /**
  5824. * Creates a new Color3 from integer values (< 256)
  5825. * @param r defines the red component to read from (value between 0 and 255)
  5826. * @param g defines the green component to read from (value between 0 and 255)
  5827. * @param b defines the blue component to read from (value between 0 and 255)
  5828. * @param a defines the alpha component to read from (value between 0 and 255)
  5829. * @returns a new Color3 object
  5830. */
  5831. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5832. /**
  5833. * Check the content of a given array and convert it to an array containing RGBA data
  5834. * If the original array was already containing count * 4 values then it is returned directly
  5835. * @param colors defines the array to check
  5836. * @param count defines the number of RGBA data to expect
  5837. * @returns an array containing count * 4 values (RGBA)
  5838. */
  5839. static CheckColors4(colors: number[], count: number): number[];
  5840. }
  5841. /**
  5842. * @hidden
  5843. */
  5844. export class TmpColors {
  5845. static Color3: Color3[];
  5846. static Color4: Color4[];
  5847. }
  5848. }
  5849. declare module BABYLON {
  5850. /**
  5851. * Defines an interface which represents an animation key frame
  5852. */
  5853. export interface IAnimationKey {
  5854. /**
  5855. * Frame of the key frame
  5856. */
  5857. frame: number;
  5858. /**
  5859. * Value at the specifies key frame
  5860. */
  5861. value: any;
  5862. /**
  5863. * The input tangent for the cubic hermite spline
  5864. */
  5865. inTangent?: any;
  5866. /**
  5867. * The output tangent for the cubic hermite spline
  5868. */
  5869. outTangent?: any;
  5870. /**
  5871. * The animation interpolation type
  5872. */
  5873. interpolation?: AnimationKeyInterpolation;
  5874. }
  5875. /**
  5876. * Enum for the animation key frame interpolation type
  5877. */
  5878. export enum AnimationKeyInterpolation {
  5879. /**
  5880. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5881. */
  5882. STEP = 1
  5883. }
  5884. }
  5885. declare module BABYLON {
  5886. /**
  5887. * Represents the range of an animation
  5888. */
  5889. export class AnimationRange {
  5890. /**The name of the animation range**/
  5891. name: string;
  5892. /**The starting frame of the animation */
  5893. from: number;
  5894. /**The ending frame of the animation*/
  5895. to: number;
  5896. /**
  5897. * Initializes the range of an animation
  5898. * @param name The name of the animation range
  5899. * @param from The starting frame of the animation
  5900. * @param to The ending frame of the animation
  5901. */
  5902. constructor(
  5903. /**The name of the animation range**/
  5904. name: string,
  5905. /**The starting frame of the animation */
  5906. from: number,
  5907. /**The ending frame of the animation*/
  5908. to: number);
  5909. /**
  5910. * Makes a copy of the animation range
  5911. * @returns A copy of the animation range
  5912. */
  5913. clone(): AnimationRange;
  5914. }
  5915. }
  5916. declare module BABYLON {
  5917. /**
  5918. * Composed of a frame, and an action function
  5919. */
  5920. export class AnimationEvent {
  5921. /** The frame for which the event is triggered **/
  5922. frame: number;
  5923. /** The event to perform when triggered **/
  5924. action: (currentFrame: number) => void;
  5925. /** Specifies if the event should be triggered only once**/
  5926. onlyOnce?: boolean | undefined;
  5927. /**
  5928. * Specifies if the animation event is done
  5929. */
  5930. isDone: boolean;
  5931. /**
  5932. * Initializes the animation event
  5933. * @param frame The frame for which the event is triggered
  5934. * @param action The event to perform when triggered
  5935. * @param onlyOnce Specifies if the event should be triggered only once
  5936. */
  5937. constructor(
  5938. /** The frame for which the event is triggered **/
  5939. frame: number,
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void,
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined);
  5944. /** @hidden */
  5945. _clone(): AnimationEvent;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Interface used to define a behavior
  5951. */
  5952. export interface Behavior<T> {
  5953. /** gets or sets behavior's name */
  5954. name: string;
  5955. /**
  5956. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5957. */
  5958. init(): void;
  5959. /**
  5960. * Called when the behavior is attached to a target
  5961. * @param target defines the target where the behavior is attached to
  5962. */
  5963. attach(target: T): void;
  5964. /**
  5965. * Called when the behavior is detached from its target
  5966. */
  5967. detach(): void;
  5968. }
  5969. /**
  5970. * Interface implemented by classes supporting behaviors
  5971. */
  5972. export interface IBehaviorAware<T> {
  5973. /**
  5974. * Attach a behavior
  5975. * @param behavior defines the behavior to attach
  5976. * @returns the current host
  5977. */
  5978. addBehavior(behavior: Behavior<T>): T;
  5979. /**
  5980. * Remove a behavior from the current object
  5981. * @param behavior defines the behavior to detach
  5982. * @returns the current host
  5983. */
  5984. removeBehavior(behavior: Behavior<T>): T;
  5985. /**
  5986. * Gets a behavior using its name to search
  5987. * @param name defines the name to search
  5988. * @returns the behavior or null if not found
  5989. */
  5990. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5991. }
  5992. }
  5993. declare module BABYLON {
  5994. /**
  5995. * Defines an array and its length.
  5996. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5997. */
  5998. export interface ISmartArrayLike<T> {
  5999. /**
  6000. * The data of the array.
  6001. */
  6002. data: Array<T>;
  6003. /**
  6004. * The active length of the array.
  6005. */
  6006. length: number;
  6007. }
  6008. /**
  6009. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6010. */
  6011. export class SmartArray<T> implements ISmartArrayLike<T> {
  6012. /**
  6013. * The full set of data from the array.
  6014. */
  6015. data: Array<T>;
  6016. /**
  6017. * The active length of the array.
  6018. */
  6019. length: number;
  6020. protected _id: number;
  6021. /**
  6022. * Instantiates a Smart Array.
  6023. * @param capacity defines the default capacity of the array.
  6024. */
  6025. constructor(capacity: number);
  6026. /**
  6027. * Pushes a value at the end of the active data.
  6028. * @param value defines the object to push in the array.
  6029. */
  6030. push(value: T): void;
  6031. /**
  6032. * Iterates over the active data and apply the lambda to them.
  6033. * @param func defines the action to apply on each value.
  6034. */
  6035. forEach(func: (content: T) => void): void;
  6036. /**
  6037. * Sorts the full sets of data.
  6038. * @param compareFn defines the comparison function to apply.
  6039. */
  6040. sort(compareFn: (a: T, b: T) => number): void;
  6041. /**
  6042. * Resets the active data to an empty array.
  6043. */
  6044. reset(): void;
  6045. /**
  6046. * Releases all the data from the array as well as the array.
  6047. */
  6048. dispose(): void;
  6049. /**
  6050. * Concats the active data with a given array.
  6051. * @param array defines the data to concatenate with.
  6052. */
  6053. concat(array: any): void;
  6054. /**
  6055. * Returns the position of a value in the active data.
  6056. * @param value defines the value to find the index for
  6057. * @returns the index if found in the active data otherwise -1
  6058. */
  6059. indexOf(value: T): number;
  6060. /**
  6061. * Returns whether an element is part of the active data.
  6062. * @param value defines the value to look for
  6063. * @returns true if found in the active data otherwise false
  6064. */
  6065. contains(value: T): boolean;
  6066. private static _GlobalId;
  6067. }
  6068. /**
  6069. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6070. * The data in this array can only be present once
  6071. */
  6072. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6073. private _duplicateId;
  6074. /**
  6075. * Pushes a value at the end of the active data.
  6076. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6077. * @param value defines the object to push in the array.
  6078. */
  6079. push(value: T): void;
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * If the data is already present, it won t be added again
  6083. * @param value defines the object to push in the array.
  6084. * @returns true if added false if it was already present
  6085. */
  6086. pushNoDuplicate(value: T): boolean;
  6087. /**
  6088. * Resets the active data to an empty array.
  6089. */
  6090. reset(): void;
  6091. /**
  6092. * Concats the active data with a given array.
  6093. * This ensures no dupplicate will be present in the result.
  6094. * @param array defines the data to concatenate with.
  6095. */
  6096. concatWithNoDuplicate(array: any): void;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * @ignore
  6102. * This is a list of all the different input types that are available in the application.
  6103. * Fo instance: ArcRotateCameraGamepadInput...
  6104. */
  6105. export var CameraInputTypes: {};
  6106. /**
  6107. * This is the contract to implement in order to create a new input class.
  6108. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6109. */
  6110. export interface ICameraInput<TCamera extends Camera> {
  6111. /**
  6112. * Defines the camera the input is attached to.
  6113. */
  6114. camera: Nullable<TCamera>;
  6115. /**
  6116. * Gets the class name of the current intput.
  6117. * @returns the class name
  6118. */
  6119. getClassName(): string;
  6120. /**
  6121. * Get the friendly name associated with the input class.
  6122. * @returns the input friendly name
  6123. */
  6124. getSimpleName(): string;
  6125. /**
  6126. * Attach the input controls to a specific dom element to get the input from.
  6127. * @param element Defines the element the controls should be listened from
  6128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6129. */
  6130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6131. /**
  6132. * Detach the current controls from the specified dom element.
  6133. * @param element Defines the element to stop listening the inputs from
  6134. */
  6135. detachControl(element: Nullable<HTMLElement>): void;
  6136. /**
  6137. * Update the current camera state depending on the inputs that have been used this frame.
  6138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6139. */
  6140. checkInputs?: () => void;
  6141. }
  6142. /**
  6143. * Represents a map of input types to input instance or input index to input instance.
  6144. */
  6145. export interface CameraInputsMap<TCamera extends Camera> {
  6146. /**
  6147. * Accessor to the input by input type.
  6148. */
  6149. [name: string]: ICameraInput<TCamera>;
  6150. /**
  6151. * Accessor to the input by input index.
  6152. */
  6153. [idx: number]: ICameraInput<TCamera>;
  6154. }
  6155. /**
  6156. * This represents the input manager used within a camera.
  6157. * It helps dealing with all the different kind of input attached to a camera.
  6158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6159. */
  6160. export class CameraInputsManager<TCamera extends Camera> {
  6161. /**
  6162. * Defines the list of inputs attahed to the camera.
  6163. */
  6164. attached: CameraInputsMap<TCamera>;
  6165. /**
  6166. * Defines the dom element the camera is collecting inputs from.
  6167. * This is null if the controls have not been attached.
  6168. */
  6169. attachedElement: Nullable<HTMLElement>;
  6170. /**
  6171. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6172. */
  6173. noPreventDefault: boolean;
  6174. /**
  6175. * Defined the camera the input manager belongs to.
  6176. */
  6177. camera: TCamera;
  6178. /**
  6179. * Update the current camera state depending on the inputs that have been used this frame.
  6180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6181. */
  6182. checkInputs: () => void;
  6183. /**
  6184. * Instantiate a new Camera Input Manager.
  6185. * @param camera Defines the camera the input manager blongs to
  6186. */
  6187. constructor(camera: TCamera);
  6188. /**
  6189. * Add an input method to a camera
  6190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6191. * @param input camera input method
  6192. */
  6193. add(input: ICameraInput<TCamera>): void;
  6194. /**
  6195. * Remove a specific input method from a camera
  6196. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6197. * @param inputToRemove camera input method
  6198. */
  6199. remove(inputToRemove: ICameraInput<TCamera>): void;
  6200. /**
  6201. * Remove a specific input type from a camera
  6202. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6203. * @param inputType the type of the input to remove
  6204. */
  6205. removeByType(inputType: string): void;
  6206. private _addCheckInputs;
  6207. /**
  6208. * Attach the input controls to the currently attached dom element to listen the events from.
  6209. * @param input Defines the input to attach
  6210. */
  6211. attachInput(input: ICameraInput<TCamera>): void;
  6212. /**
  6213. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6214. * @param element Defines the dom element to collect the events from
  6215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6216. */
  6217. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6218. /**
  6219. * Detach the current manager inputs controls from a specific dom element.
  6220. * @param element Defines the dom element to collect the events from
  6221. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6222. */
  6223. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6224. /**
  6225. * Rebuild the dynamic inputCheck function from the current list of
  6226. * defined inputs in the manager.
  6227. */
  6228. rebuildInputCheck(): void;
  6229. /**
  6230. * Remove all attached input methods from a camera
  6231. */
  6232. clear(): void;
  6233. /**
  6234. * Serialize the current input manager attached to a camera.
  6235. * This ensures than once parsed,
  6236. * the input associated to the camera will be identical to the current ones
  6237. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6238. */
  6239. serialize(serializedCamera: any): void;
  6240. /**
  6241. * Parses an input manager serialized JSON to restore the previous list of inputs
  6242. * and states associated to a camera.
  6243. * @param parsedCamera Defines the JSON to parse
  6244. */
  6245. parse(parsedCamera: any): void;
  6246. }
  6247. }
  6248. declare module BABYLON {
  6249. /**
  6250. * Class used to store data that will be store in GPU memory
  6251. */
  6252. export class Buffer {
  6253. private _engine;
  6254. private _buffer;
  6255. /** @hidden */
  6256. _data: Nullable<DataArray>;
  6257. private _updatable;
  6258. private _instanced;
  6259. private _divisor;
  6260. /**
  6261. * Gets the byte stride.
  6262. */
  6263. readonly byteStride: number;
  6264. /**
  6265. * Constructor
  6266. * @param engine the engine
  6267. * @param data the data to use for this buffer
  6268. * @param updatable whether the data is updatable
  6269. * @param stride the stride (optional)
  6270. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6271. * @param instanced whether the buffer is instanced (optional)
  6272. * @param useBytes set to true if the stride in in bytes (optional)
  6273. * @param divisor sets an optional divisor for instances (1 by default)
  6274. */
  6275. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6276. /**
  6277. * Create a new VertexBuffer based on the current buffer
  6278. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6279. * @param offset defines offset in the buffer (0 by default)
  6280. * @param size defines the size in floats of attributes (position is 3 for instance)
  6281. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6282. * @param instanced defines if the vertex buffer contains indexed data
  6283. * @param useBytes defines if the offset and stride are in bytes *
  6284. * @param divisor sets an optional divisor for instances (1 by default)
  6285. * @returns the new vertex buffer
  6286. */
  6287. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6288. /**
  6289. * Gets a boolean indicating if the Buffer is updatable?
  6290. * @returns true if the buffer is updatable
  6291. */
  6292. isUpdatable(): boolean;
  6293. /**
  6294. * Gets current buffer's data
  6295. * @returns a DataArray or null
  6296. */
  6297. getData(): Nullable<DataArray>;
  6298. /**
  6299. * Gets underlying native buffer
  6300. * @returns underlying native buffer
  6301. */
  6302. getBuffer(): Nullable<DataBuffer>;
  6303. /**
  6304. * Gets the stride in float32 units (i.e. byte stride / 4).
  6305. * May not be an integer if the byte stride is not divisible by 4.
  6306. * @returns the stride in float32 units
  6307. * @deprecated Please use byteStride instead.
  6308. */
  6309. getStrideSize(): number;
  6310. /**
  6311. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6312. * @param data defines the data to store
  6313. */
  6314. create(data?: Nullable<DataArray>): void;
  6315. /** @hidden */
  6316. _rebuild(): void;
  6317. /**
  6318. * Update current buffer data
  6319. * @param data defines the data to store
  6320. */
  6321. update(data: DataArray): void;
  6322. /**
  6323. * Updates the data directly.
  6324. * @param data the new data
  6325. * @param offset the new offset
  6326. * @param vertexCount the vertex count (optional)
  6327. * @param useBytes set to true if the offset is in bytes
  6328. */
  6329. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6330. /**
  6331. * Release all resources
  6332. */
  6333. dispose(): void;
  6334. }
  6335. /**
  6336. * Specialized buffer used to store vertex data
  6337. */
  6338. export class VertexBuffer {
  6339. /** @hidden */
  6340. _buffer: Buffer;
  6341. private _kind;
  6342. private _size;
  6343. private _ownsBuffer;
  6344. private _instanced;
  6345. private _instanceDivisor;
  6346. /**
  6347. * The byte type.
  6348. */
  6349. static readonly BYTE: number;
  6350. /**
  6351. * The unsigned byte type.
  6352. */
  6353. static readonly UNSIGNED_BYTE: number;
  6354. /**
  6355. * The short type.
  6356. */
  6357. static readonly SHORT: number;
  6358. /**
  6359. * The unsigned short type.
  6360. */
  6361. static readonly UNSIGNED_SHORT: number;
  6362. /**
  6363. * The integer type.
  6364. */
  6365. static readonly INT: number;
  6366. /**
  6367. * The unsigned integer type.
  6368. */
  6369. static readonly UNSIGNED_INT: number;
  6370. /**
  6371. * The float type.
  6372. */
  6373. static readonly FLOAT: number;
  6374. /**
  6375. * Gets or sets the instance divisor when in instanced mode
  6376. */
  6377. get instanceDivisor(): number;
  6378. set instanceDivisor(value: number);
  6379. /**
  6380. * Gets the byte stride.
  6381. */
  6382. readonly byteStride: number;
  6383. /**
  6384. * Gets the byte offset.
  6385. */
  6386. readonly byteOffset: number;
  6387. /**
  6388. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6389. */
  6390. readonly normalized: boolean;
  6391. /**
  6392. * Gets the data type of each component in the array.
  6393. */
  6394. readonly type: number;
  6395. /**
  6396. * Constructor
  6397. * @param engine the engine
  6398. * @param data the data to use for this vertex buffer
  6399. * @param kind the vertex buffer kind
  6400. * @param updatable whether the data is updatable
  6401. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6402. * @param stride the stride (optional)
  6403. * @param instanced whether the buffer is instanced (optional)
  6404. * @param offset the offset of the data (optional)
  6405. * @param size the number of components (optional)
  6406. * @param type the type of the component (optional)
  6407. * @param normalized whether the data contains normalized data (optional)
  6408. * @param useBytes set to true if stride and offset are in bytes (optional)
  6409. * @param divisor defines the instance divisor to use (1 by default)
  6410. */
  6411. 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);
  6412. /** @hidden */
  6413. _rebuild(): void;
  6414. /**
  6415. * Returns the kind of the VertexBuffer (string)
  6416. * @returns a string
  6417. */
  6418. getKind(): string;
  6419. /**
  6420. * Gets a boolean indicating if the VertexBuffer is updatable?
  6421. * @returns true if the buffer is updatable
  6422. */
  6423. isUpdatable(): boolean;
  6424. /**
  6425. * Gets current buffer's data
  6426. * @returns a DataArray or null
  6427. */
  6428. getData(): Nullable<DataArray>;
  6429. /**
  6430. * Gets underlying native buffer
  6431. * @returns underlying native buffer
  6432. */
  6433. getBuffer(): Nullable<DataBuffer>;
  6434. /**
  6435. * Gets the stride in float32 units (i.e. byte stride / 4).
  6436. * May not be an integer if the byte stride is not divisible by 4.
  6437. * @returns the stride in float32 units
  6438. * @deprecated Please use byteStride instead.
  6439. */
  6440. getStrideSize(): number;
  6441. /**
  6442. * Returns the offset as a multiple of the type byte length.
  6443. * @returns the offset in bytes
  6444. * @deprecated Please use byteOffset instead.
  6445. */
  6446. getOffset(): number;
  6447. /**
  6448. * Returns the number of components per vertex attribute (integer)
  6449. * @returns the size in float
  6450. */
  6451. getSize(): number;
  6452. /**
  6453. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6454. * @returns true if this buffer is instanced
  6455. */
  6456. getIsInstanced(): boolean;
  6457. /**
  6458. * Returns the instancing divisor, zero for non-instanced (integer).
  6459. * @returns a number
  6460. */
  6461. getInstanceDivisor(): number;
  6462. /**
  6463. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6464. * @param data defines the data to store
  6465. */
  6466. create(data?: DataArray): void;
  6467. /**
  6468. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6469. * This function will create a new buffer if the current one is not updatable
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6475. * Returns the directly updated WebGLBuffer.
  6476. * @param data the new data
  6477. * @param offset the new offset
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6481. /**
  6482. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6483. */
  6484. dispose(): void;
  6485. /**
  6486. * Enumerates each value of this vertex buffer as numbers.
  6487. * @param count the number of values to enumerate
  6488. * @param callback the callback function called for each value
  6489. */
  6490. forEach(count: number, callback: (value: number, index: number) => void): void;
  6491. /**
  6492. * Positions
  6493. */
  6494. static readonly PositionKind: string;
  6495. /**
  6496. * Normals
  6497. */
  6498. static readonly NormalKind: string;
  6499. /**
  6500. * Tangents
  6501. */
  6502. static readonly TangentKind: string;
  6503. /**
  6504. * Texture coordinates
  6505. */
  6506. static readonly UVKind: string;
  6507. /**
  6508. * Texture coordinates 2
  6509. */
  6510. static readonly UV2Kind: string;
  6511. /**
  6512. * Texture coordinates 3
  6513. */
  6514. static readonly UV3Kind: string;
  6515. /**
  6516. * Texture coordinates 4
  6517. */
  6518. static readonly UV4Kind: string;
  6519. /**
  6520. * Texture coordinates 5
  6521. */
  6522. static readonly UV5Kind: string;
  6523. /**
  6524. * Texture coordinates 6
  6525. */
  6526. static readonly UV6Kind: string;
  6527. /**
  6528. * Colors
  6529. */
  6530. static readonly ColorKind: string;
  6531. /**
  6532. * Matrix indices (for bones)
  6533. */
  6534. static readonly MatricesIndicesKind: string;
  6535. /**
  6536. * Matrix weights (for bones)
  6537. */
  6538. static readonly MatricesWeightsKind: string;
  6539. /**
  6540. * Additional matrix indices (for bones)
  6541. */
  6542. static readonly MatricesIndicesExtraKind: string;
  6543. /**
  6544. * Additional matrix weights (for bones)
  6545. */
  6546. static readonly MatricesWeightsExtraKind: string;
  6547. /**
  6548. * Deduces the stride given a kind.
  6549. * @param kind The kind string to deduce
  6550. * @returns The deduced stride
  6551. */
  6552. static DeduceStride(kind: string): number;
  6553. /**
  6554. * Gets the byte length of the given type.
  6555. * @param type the type
  6556. * @returns the number of bytes
  6557. */
  6558. static GetTypeByteLength(type: number): number;
  6559. /**
  6560. * Enumerates each value of the given parameters as numbers.
  6561. * @param data the data to enumerate
  6562. * @param byteOffset the byte offset of the data
  6563. * @param byteStride the byte stride of the data
  6564. * @param componentCount the number of components per element
  6565. * @param componentType the type of the component
  6566. * @param count the number of values to enumerate
  6567. * @param normalized whether the data is normalized
  6568. * @param callback the callback function called for each value
  6569. */
  6570. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6571. private static _GetFloatValue;
  6572. }
  6573. }
  6574. declare module BABYLON {
  6575. /**
  6576. * @hidden
  6577. */
  6578. export class IntersectionInfo {
  6579. bu: Nullable<number>;
  6580. bv: Nullable<number>;
  6581. distance: number;
  6582. faceId: number;
  6583. subMeshId: number;
  6584. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6585. }
  6586. }
  6587. declare module BABYLON {
  6588. /**
  6589. * Represens a plane by the equation ax + by + cz + d = 0
  6590. */
  6591. export class Plane {
  6592. private static _TmpMatrix;
  6593. /**
  6594. * Normal of the plane (a,b,c)
  6595. */
  6596. normal: Vector3;
  6597. /**
  6598. * d component of the plane
  6599. */
  6600. d: number;
  6601. /**
  6602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6603. * @param a a component of the plane
  6604. * @param b b component of the plane
  6605. * @param c c component of the plane
  6606. * @param d d component of the plane
  6607. */
  6608. constructor(a: number, b: number, c: number, d: number);
  6609. /**
  6610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6611. */
  6612. asArray(): number[];
  6613. /**
  6614. * @returns a new plane copied from the current Plane.
  6615. */
  6616. clone(): Plane;
  6617. /**
  6618. * @returns the string "Plane".
  6619. */
  6620. getClassName(): string;
  6621. /**
  6622. * @returns the Plane hash code.
  6623. */
  6624. getHashCode(): number;
  6625. /**
  6626. * Normalize the current Plane in place.
  6627. * @returns the updated Plane.
  6628. */
  6629. normalize(): Plane;
  6630. /**
  6631. * Applies a transformation the plane and returns the result
  6632. * @param transformation the transformation matrix to be applied to the plane
  6633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6634. */
  6635. transform(transformation: DeepImmutable<Matrix>): Plane;
  6636. /**
  6637. * Calcualtte the dot product between the point and the plane normal
  6638. * @param point point to calculate the dot product with
  6639. * @returns the dot product (float) of the point coordinates and the plane normal.
  6640. */
  6641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6642. /**
  6643. * Updates the current Plane from the plane defined by the three given points.
  6644. * @param point1 one of the points used to contruct the plane
  6645. * @param point2 one of the points used to contruct the plane
  6646. * @param point3 one of the points used to contruct the plane
  6647. * @returns the updated Plane.
  6648. */
  6649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6650. /**
  6651. * Checks if the plane is facing a given direction
  6652. * @param direction the direction to check if the plane is facing
  6653. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6654. * @returns True is the vector "direction" is the same side than the plane normal.
  6655. */
  6656. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6657. /**
  6658. * Calculates the distance to a point
  6659. * @param point point to calculate distance to
  6660. * @returns the signed distance (float) from the given point to the Plane.
  6661. */
  6662. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6663. /**
  6664. * Creates a plane from an array
  6665. * @param array the array to create a plane from
  6666. * @returns a new Plane from the given array.
  6667. */
  6668. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6669. /**
  6670. * Creates a plane from three points
  6671. * @param point1 point used to create the plane
  6672. * @param point2 point used to create the plane
  6673. * @param point3 point used to create the plane
  6674. * @returns a new Plane defined by the three given points.
  6675. */
  6676. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Creates a plane from an origin point and a normal
  6679. * @param origin origin of the plane to be constructed
  6680. * @param normal normal of the plane to be constructed
  6681. * @returns a new Plane the normal vector to this plane at the given origin point.
  6682. * Note : the vector "normal" is updated because normalized.
  6683. */
  6684. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6685. /**
  6686. * Calculates the distance from a plane and a point
  6687. * @param origin origin of the plane to be constructed
  6688. * @param normal normal of the plane to be constructed
  6689. * @param point point to calculate distance to
  6690. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6691. */
  6692. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. /**
  6697. * Class used to store bounding sphere information
  6698. */
  6699. export class BoundingSphere {
  6700. /**
  6701. * Gets the center of the bounding sphere in local space
  6702. */
  6703. readonly center: Vector3;
  6704. /**
  6705. * Radius of the bounding sphere in local space
  6706. */
  6707. radius: number;
  6708. /**
  6709. * Gets the center of the bounding sphere in world space
  6710. */
  6711. readonly centerWorld: Vector3;
  6712. /**
  6713. * Radius of the bounding sphere in world space
  6714. */
  6715. radiusWorld: number;
  6716. /**
  6717. * Gets the minimum vector in local space
  6718. */
  6719. readonly minimum: Vector3;
  6720. /**
  6721. * Gets the maximum vector in local space
  6722. */
  6723. readonly maximum: Vector3;
  6724. private _worldMatrix;
  6725. private static readonly TmpVector3;
  6726. /**
  6727. * Creates a new bounding sphere
  6728. * @param min defines the minimum vector (in local space)
  6729. * @param max defines the maximum vector (in local space)
  6730. * @param worldMatrix defines the new world matrix
  6731. */
  6732. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6733. /**
  6734. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6735. * @param min defines the new minimum vector (in local space)
  6736. * @param max defines the new maximum vector (in local space)
  6737. * @param worldMatrix defines the new world matrix
  6738. */
  6739. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6740. /**
  6741. * Scale the current bounding sphere by applying a scale factor
  6742. * @param factor defines the scale factor to apply
  6743. * @returns the current bounding box
  6744. */
  6745. scale(factor: number): BoundingSphere;
  6746. /**
  6747. * Gets the world matrix of the bounding box
  6748. * @returns a matrix
  6749. */
  6750. getWorldMatrix(): DeepImmutable<Matrix>;
  6751. /** @hidden */
  6752. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6753. /**
  6754. * Tests if the bounding sphere is intersecting the frustum planes
  6755. * @param frustumPlanes defines the frustum planes to test
  6756. * @returns true if there is an intersection
  6757. */
  6758. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6759. /**
  6760. * Tests if the bounding sphere center is in between the frustum planes.
  6761. * Used for optimistic fast inclusion.
  6762. * @param frustumPlanes defines the frustum planes to test
  6763. * @returns true if the sphere center is in between the frustum planes
  6764. */
  6765. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6766. /**
  6767. * Tests if a point is inside the bounding sphere
  6768. * @param point defines the point to test
  6769. * @returns true if the point is inside the bounding sphere
  6770. */
  6771. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6772. /**
  6773. * Checks if two sphere intersct
  6774. * @param sphere0 sphere 0
  6775. * @param sphere1 sphere 1
  6776. * @returns true if the speres intersect
  6777. */
  6778. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6779. }
  6780. }
  6781. declare module BABYLON {
  6782. /**
  6783. * Class used to store bounding box information
  6784. */
  6785. export class BoundingBox implements ICullable {
  6786. /**
  6787. * Gets the 8 vectors representing the bounding box in local space
  6788. */
  6789. readonly vectors: Vector3[];
  6790. /**
  6791. * Gets the center of the bounding box in local space
  6792. */
  6793. readonly center: Vector3;
  6794. /**
  6795. * Gets the center of the bounding box in world space
  6796. */
  6797. readonly centerWorld: Vector3;
  6798. /**
  6799. * Gets the extend size in local space
  6800. */
  6801. readonly extendSize: Vector3;
  6802. /**
  6803. * Gets the extend size in world space
  6804. */
  6805. readonly extendSizeWorld: Vector3;
  6806. /**
  6807. * Gets the OBB (object bounding box) directions
  6808. */
  6809. readonly directions: Vector3[];
  6810. /**
  6811. * Gets the 8 vectors representing the bounding box in world space
  6812. */
  6813. readonly vectorsWorld: Vector3[];
  6814. /**
  6815. * Gets the minimum vector in world space
  6816. */
  6817. readonly minimumWorld: Vector3;
  6818. /**
  6819. * Gets the maximum vector in world space
  6820. */
  6821. readonly maximumWorld: Vector3;
  6822. /**
  6823. * Gets the minimum vector in local space
  6824. */
  6825. readonly minimum: Vector3;
  6826. /**
  6827. * Gets the maximum vector in local space
  6828. */
  6829. readonly maximum: Vector3;
  6830. private _worldMatrix;
  6831. private static readonly TmpVector3;
  6832. /**
  6833. * @hidden
  6834. */
  6835. _tag: number;
  6836. /**
  6837. * Creates a new bounding box
  6838. * @param min defines the minimum vector (in local space)
  6839. * @param max defines the maximum vector (in local space)
  6840. * @param worldMatrix defines the new world matrix
  6841. */
  6842. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6843. /**
  6844. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6845. * @param min defines the new minimum vector (in local space)
  6846. * @param max defines the new maximum vector (in local space)
  6847. * @param worldMatrix defines the new world matrix
  6848. */
  6849. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Scale the current bounding box by applying a scale factor
  6852. * @param factor defines the scale factor to apply
  6853. * @returns the current bounding box
  6854. */
  6855. scale(factor: number): BoundingBox;
  6856. /**
  6857. * Gets the world matrix of the bounding box
  6858. * @returns a matrix
  6859. */
  6860. getWorldMatrix(): DeepImmutable<Matrix>;
  6861. /** @hidden */
  6862. _update(world: DeepImmutable<Matrix>): void;
  6863. /**
  6864. * Tests if the bounding box is intersecting the frustum planes
  6865. * @param frustumPlanes defines the frustum planes to test
  6866. * @returns true if there is an intersection
  6867. */
  6868. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6869. /**
  6870. * Tests if the bounding box is entirely inside the frustum planes
  6871. * @param frustumPlanes defines the frustum planes to test
  6872. * @returns true if there is an inclusion
  6873. */
  6874. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6875. /**
  6876. * Tests if a point is inside the bounding box
  6877. * @param point defines the point to test
  6878. * @returns true if the point is inside the bounding box
  6879. */
  6880. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6881. /**
  6882. * Tests if the bounding box intersects with a bounding sphere
  6883. * @param sphere defines the sphere to test
  6884. * @returns true if there is an intersection
  6885. */
  6886. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6887. /**
  6888. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6889. * @param min defines the min vector to use
  6890. * @param max defines the max vector to use
  6891. * @returns true if there is an intersection
  6892. */
  6893. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6894. /**
  6895. * Tests if two bounding boxes are intersections
  6896. * @param box0 defines the first box to test
  6897. * @param box1 defines the second box to test
  6898. * @returns true if there is an intersection
  6899. */
  6900. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6901. /**
  6902. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6903. * @param minPoint defines the minimum vector of the bounding box
  6904. * @param maxPoint defines the maximum vector of the bounding box
  6905. * @param sphereCenter defines the sphere center
  6906. * @param sphereRadius defines the sphere radius
  6907. * @returns true if there is an intersection
  6908. */
  6909. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6910. /**
  6911. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6912. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6913. * @param frustumPlanes defines the frustum planes to test
  6914. * @return true if there is an inclusion
  6915. */
  6916. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6917. /**
  6918. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6919. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6920. * @param frustumPlanes defines the frustum planes to test
  6921. * @return true if there is an intersection
  6922. */
  6923. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6924. }
  6925. }
  6926. declare module BABYLON {
  6927. /** @hidden */
  6928. export class Collider {
  6929. /** Define if a collision was found */
  6930. collisionFound: boolean;
  6931. /**
  6932. * Define last intersection point in local space
  6933. */
  6934. intersectionPoint: Vector3;
  6935. /**
  6936. * Define last collided mesh
  6937. */
  6938. collidedMesh: Nullable<AbstractMesh>;
  6939. private _collisionPoint;
  6940. private _planeIntersectionPoint;
  6941. private _tempVector;
  6942. private _tempVector2;
  6943. private _tempVector3;
  6944. private _tempVector4;
  6945. private _edge;
  6946. private _baseToVertex;
  6947. private _destinationPoint;
  6948. private _slidePlaneNormal;
  6949. private _displacementVector;
  6950. /** @hidden */
  6951. _radius: Vector3;
  6952. /** @hidden */
  6953. _retry: number;
  6954. private _velocity;
  6955. private _basePoint;
  6956. private _epsilon;
  6957. /** @hidden */
  6958. _velocityWorldLength: number;
  6959. /** @hidden */
  6960. _basePointWorld: Vector3;
  6961. private _velocityWorld;
  6962. private _normalizedVelocity;
  6963. /** @hidden */
  6964. _initialVelocity: Vector3;
  6965. /** @hidden */
  6966. _initialPosition: Vector3;
  6967. private _nearestDistance;
  6968. private _collisionMask;
  6969. get collisionMask(): number;
  6970. set collisionMask(mask: number);
  6971. /**
  6972. * Gets the plane normal used to compute the sliding response (in local space)
  6973. */
  6974. get slidePlaneNormal(): Vector3;
  6975. /** @hidden */
  6976. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6977. /** @hidden */
  6978. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6979. /** @hidden */
  6980. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6981. /** @hidden */
  6982. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6983. /** @hidden */
  6984. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _getResponse(pos: Vector3, vel: Vector3): void;
  6987. }
  6988. }
  6989. declare module BABYLON {
  6990. /**
  6991. * Interface for cullable objects
  6992. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6993. */
  6994. export interface ICullable {
  6995. /**
  6996. * Checks if the object or part of the object is in the frustum
  6997. * @param frustumPlanes Camera near/planes
  6998. * @returns true if the object is in frustum otherwise false
  6999. */
  7000. isInFrustum(frustumPlanes: Plane[]): boolean;
  7001. /**
  7002. * Checks if a cullable object (mesh...) is in the camera frustum
  7003. * Unlike isInFrustum this cheks the full bounding box
  7004. * @param frustumPlanes Camera near/planes
  7005. * @returns true if the object is in frustum otherwise false
  7006. */
  7007. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7008. }
  7009. /**
  7010. * Info for a bounding data of a mesh
  7011. */
  7012. export class BoundingInfo implements ICullable {
  7013. /**
  7014. * Bounding box for the mesh
  7015. */
  7016. readonly boundingBox: BoundingBox;
  7017. /**
  7018. * Bounding sphere for the mesh
  7019. */
  7020. readonly boundingSphere: BoundingSphere;
  7021. private _isLocked;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * Constructs bounding info
  7025. * @param minimum min vector of the bounding box/sphere
  7026. * @param maximum max vector of the bounding box/sphere
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7030. /**
  7031. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7032. * @param min defines the new minimum vector (in local space)
  7033. * @param max defines the new maximum vector (in local space)
  7034. * @param worldMatrix defines the new world matrix
  7035. */
  7036. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7037. /**
  7038. * min vector of the bounding box/sphere
  7039. */
  7040. get minimum(): Vector3;
  7041. /**
  7042. * max vector of the bounding box/sphere
  7043. */
  7044. get maximum(): Vector3;
  7045. /**
  7046. * If the info is locked and won't be updated to avoid perf overhead
  7047. */
  7048. get isLocked(): boolean;
  7049. set isLocked(value: boolean);
  7050. /**
  7051. * Updates the bounding sphere and box
  7052. * @param world world matrix to be used to update
  7053. */
  7054. update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7057. * @param center New center of the bounding info
  7058. * @param extend New extend of the bounding info
  7059. * @returns the current bounding info
  7060. */
  7061. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7062. /**
  7063. * Scale the current bounding info by applying a scale factor
  7064. * @param factor defines the scale factor to apply
  7065. * @returns the current bounding info
  7066. */
  7067. scale(factor: number): BoundingInfo;
  7068. /**
  7069. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7070. * @param frustumPlanes defines the frustum to test
  7071. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7072. * @returns true if the bounding info is in the frustum planes
  7073. */
  7074. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7075. /**
  7076. * Gets the world distance between the min and max points of the bounding box
  7077. */
  7078. get diagonalLength(): number;
  7079. /**
  7080. * Checks if a cullable object (mesh...) is in the camera frustum
  7081. * Unlike isInFrustum this cheks the full bounding box
  7082. * @param frustumPlanes Camera near/planes
  7083. * @returns true if the object is in frustum otherwise false
  7084. */
  7085. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7086. /** @hidden */
  7087. _checkCollision(collider: Collider): boolean;
  7088. /**
  7089. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7090. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7091. * @param point the point to check intersection with
  7092. * @returns if the point intersects
  7093. */
  7094. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7095. /**
  7096. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param boundingInfo the bounding info to check intersection with
  7099. * @param precise if the intersection should be done using OBB
  7100. * @returns if the bounding info intersects
  7101. */
  7102. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7103. }
  7104. }
  7105. declare module BABYLON {
  7106. /**
  7107. * Extracts minimum and maximum values from a list of indexed positions
  7108. * @param positions defines the positions to use
  7109. * @param indices defines the indices to the positions
  7110. * @param indexStart defines the start index
  7111. * @param indexCount defines the end index
  7112. * @param bias defines bias value to add to the result
  7113. * @return minimum and maximum values
  7114. */
  7115. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7116. minimum: Vector3;
  7117. maximum: Vector3;
  7118. };
  7119. /**
  7120. * Extracts minimum and maximum values from a list of positions
  7121. * @param positions defines the positions to use
  7122. * @param start defines the start index in the positions array
  7123. * @param count defines the number of positions to handle
  7124. * @param bias defines bias value to add to the result
  7125. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7126. * @return minimum and maximum values
  7127. */
  7128. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7129. minimum: Vector3;
  7130. maximum: Vector3;
  7131. };
  7132. }
  7133. declare module BABYLON {
  7134. /** @hidden */
  7135. export class WebGLDataBuffer extends DataBuffer {
  7136. private _buffer;
  7137. constructor(resource: WebGLBuffer);
  7138. get underlyingResource(): any;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class WebGLPipelineContext implements IPipelineContext {
  7144. engine: ThinEngine;
  7145. program: Nullable<WebGLProgram>;
  7146. context?: WebGLRenderingContext;
  7147. vertexShader?: WebGLShader;
  7148. fragmentShader?: WebGLShader;
  7149. isParallelCompiled: boolean;
  7150. onCompiled?: () => void;
  7151. transformFeedback?: WebGLTransformFeedback | null;
  7152. vertexCompilationError: Nullable<string>;
  7153. fragmentCompilationError: Nullable<string>;
  7154. programLinkError: Nullable<string>;
  7155. programValidationError: Nullable<string>;
  7156. get isAsync(): boolean;
  7157. get isReady(): boolean;
  7158. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7159. }
  7160. }
  7161. declare module BABYLON {
  7162. interface ThinEngine {
  7163. /**
  7164. * Create an uniform buffer
  7165. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7166. * @param elements defines the content of the uniform buffer
  7167. * @returns the webGL uniform buffer
  7168. */
  7169. createUniformBuffer(elements: FloatArray): DataBuffer;
  7170. /**
  7171. * Create a dynamic uniform buffer
  7172. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7173. * @param elements defines the content of the uniform buffer
  7174. * @returns the webGL uniform buffer
  7175. */
  7176. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7177. /**
  7178. * Update an existing uniform buffer
  7179. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7180. * @param uniformBuffer defines the target uniform buffer
  7181. * @param elements defines the content to update
  7182. * @param offset defines the offset in the uniform buffer where update should start
  7183. * @param count defines the size of the data to update
  7184. */
  7185. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7186. /**
  7187. * Bind an uniform buffer to the current webGL context
  7188. * @param buffer defines the buffer to bind
  7189. */
  7190. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7191. /**
  7192. * Bind a buffer to the current webGL context at a given location
  7193. * @param buffer defines the buffer to bind
  7194. * @param location defines the index where to bind the buffer
  7195. */
  7196. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7197. /**
  7198. * Bind a specific block at a given index in a specific shader program
  7199. * @param pipelineContext defines the pipeline context to use
  7200. * @param blockName defines the block name
  7201. * @param index defines the index where to bind the block
  7202. */
  7203. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. /**
  7208. * Uniform buffer objects.
  7209. *
  7210. * Handles blocks of uniform on the GPU.
  7211. *
  7212. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7213. *
  7214. * For more information, please refer to :
  7215. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7216. */
  7217. export class UniformBuffer {
  7218. private _engine;
  7219. private _buffer;
  7220. private _data;
  7221. private _bufferData;
  7222. private _dynamic?;
  7223. private _uniformLocations;
  7224. private _uniformSizes;
  7225. private _uniformLocationPointer;
  7226. private _needSync;
  7227. private _noUBO;
  7228. private _currentEffect;
  7229. /** @hidden */
  7230. _alreadyBound: boolean;
  7231. private static _MAX_UNIFORM_SIZE;
  7232. private static _tempBuffer;
  7233. /**
  7234. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7235. * This is dynamic to allow compat with webgl 1 and 2.
  7236. * You will need to pass the name of the uniform as well as the value.
  7237. */
  7238. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7239. /**
  7240. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7241. * This is dynamic to allow compat with webgl 1 and 2.
  7242. * You will need to pass the name of the uniform as well as the value.
  7243. */
  7244. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7245. /**
  7246. * Lambda to Update a single float in a uniform buffer.
  7247. * This is dynamic to allow compat with webgl 1 and 2.
  7248. * You will need to pass the name of the uniform as well as the value.
  7249. */
  7250. updateFloat: (name: string, x: number) => void;
  7251. /**
  7252. * Lambda to Update a vec2 of float in a uniform buffer.
  7253. * This is dynamic to allow compat with webgl 1 and 2.
  7254. * You will need to pass the name of the uniform as well as the value.
  7255. */
  7256. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7257. /**
  7258. * Lambda to Update a vec3 of float in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7263. /**
  7264. * Lambda to Update a vec4 of float in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7269. /**
  7270. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateMatrix: (name: string, mat: Matrix) => void;
  7275. /**
  7276. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateVector3: (name: string, vector: Vector3) => void;
  7281. /**
  7282. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateVector4: (name: string, vector: Vector4) => void;
  7287. /**
  7288. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7299. /**
  7300. * Instantiates a new Uniform buffer objects.
  7301. *
  7302. * Handles blocks of uniform on the GPU.
  7303. *
  7304. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7305. *
  7306. * For more information, please refer to :
  7307. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7308. * @param engine Define the engine the buffer is associated with
  7309. * @param data Define the data contained in the buffer
  7310. * @param dynamic Define if the buffer is updatable
  7311. */
  7312. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7313. /**
  7314. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7315. * or just falling back on setUniformXXX calls.
  7316. */
  7317. get useUbo(): boolean;
  7318. /**
  7319. * Indicates if the WebGL underlying uniform buffer is in sync
  7320. * with the javascript cache data.
  7321. */
  7322. get isSync(): boolean;
  7323. /**
  7324. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7325. * Also, a dynamic UniformBuffer will disable cache verification and always
  7326. * update the underlying WebGL uniform buffer to the GPU.
  7327. * @returns if Dynamic, otherwise false
  7328. */
  7329. isDynamic(): boolean;
  7330. /**
  7331. * The data cache on JS side.
  7332. * @returns the underlying data as a float array
  7333. */
  7334. getData(): Float32Array;
  7335. /**
  7336. * The underlying WebGL Uniform buffer.
  7337. * @returns the webgl buffer
  7338. */
  7339. getBuffer(): Nullable<DataBuffer>;
  7340. /**
  7341. * std140 layout specifies how to align data within an UBO structure.
  7342. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7343. * for specs.
  7344. */
  7345. private _fillAlignment;
  7346. /**
  7347. * Adds an uniform in the buffer.
  7348. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7349. * for the layout to be correct !
  7350. * @param name Name of the uniform, as used in the uniform block in the shader.
  7351. * @param size Data size, or data directly.
  7352. */
  7353. addUniform(name: string, size: number | number[]): void;
  7354. /**
  7355. * Adds a Matrix 4x4 to the uniform buffer.
  7356. * @param name Name of the uniform, as used in the uniform block in the shader.
  7357. * @param mat A 4x4 matrix.
  7358. */
  7359. addMatrix(name: string, mat: Matrix): void;
  7360. /**
  7361. * Adds a vec2 to the uniform buffer.
  7362. * @param name Name of the uniform, as used in the uniform block in the shader.
  7363. * @param x Define the x component value of the vec2
  7364. * @param y Define the y component value of the vec2
  7365. */
  7366. addFloat2(name: string, x: number, y: number): void;
  7367. /**
  7368. * Adds a vec3 to the uniform buffer.
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param x Define the x component value of the vec3
  7371. * @param y Define the y component value of the vec3
  7372. * @param z Define the z component value of the vec3
  7373. */
  7374. addFloat3(name: string, x: number, y: number, z: number): void;
  7375. /**
  7376. * Adds a vec3 to the uniform buffer.
  7377. * @param name Name of the uniform, as used in the uniform block in the shader.
  7378. * @param color Define the vec3 from a Color
  7379. */
  7380. addColor3(name: string, color: Color3): void;
  7381. /**
  7382. * Adds a vec4 to the uniform buffer.
  7383. * @param name Name of the uniform, as used in the uniform block in the shader.
  7384. * @param color Define the rgb components from a Color
  7385. * @param alpha Define the a component of the vec4
  7386. */
  7387. addColor4(name: string, color: Color3, alpha: number): void;
  7388. /**
  7389. * Adds a vec3 to the uniform buffer.
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param vector Define the vec3 components from a Vector
  7392. */
  7393. addVector3(name: string, vector: Vector3): void;
  7394. /**
  7395. * Adds a Matrix 3x3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. */
  7398. addMatrix3x3(name: string): void;
  7399. /**
  7400. * Adds a Matrix 2x2 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. */
  7403. addMatrix2x2(name: string): void;
  7404. /**
  7405. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7406. */
  7407. create(): void;
  7408. /** @hidden */
  7409. _rebuild(): void;
  7410. /**
  7411. * Updates the WebGL Uniform Buffer on the GPU.
  7412. * If the `dynamic` flag is set to true, no cache comparison is done.
  7413. * Otherwise, the buffer will be updated only if the cache differs.
  7414. */
  7415. update(): void;
  7416. /**
  7417. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7418. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7419. * @param data Define the flattened data
  7420. * @param size Define the size of the data.
  7421. */
  7422. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7423. private _valueCache;
  7424. private _cacheMatrix;
  7425. private _updateMatrix3x3ForUniform;
  7426. private _updateMatrix3x3ForEffect;
  7427. private _updateMatrix2x2ForEffect;
  7428. private _updateMatrix2x2ForUniform;
  7429. private _updateFloatForEffect;
  7430. private _updateFloatForUniform;
  7431. private _updateFloat2ForEffect;
  7432. private _updateFloat2ForUniform;
  7433. private _updateFloat3ForEffect;
  7434. private _updateFloat3ForUniform;
  7435. private _updateFloat4ForEffect;
  7436. private _updateFloat4ForUniform;
  7437. private _updateMatrixForEffect;
  7438. private _updateMatrixForUniform;
  7439. private _updateVector3ForEffect;
  7440. private _updateVector3ForUniform;
  7441. private _updateVector4ForEffect;
  7442. private _updateVector4ForUniform;
  7443. private _updateColor3ForEffect;
  7444. private _updateColor3ForUniform;
  7445. private _updateColor4ForEffect;
  7446. private _updateColor4ForUniform;
  7447. /**
  7448. * Sets a sampler uniform on the effect.
  7449. * @param name Define the name of the sampler.
  7450. * @param texture Define the texture to set in the sampler
  7451. */
  7452. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7453. /**
  7454. * Directly updates the value of the uniform in the cache AND on the GPU.
  7455. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7456. * @param data Define the flattened data
  7457. */
  7458. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7459. /**
  7460. * Binds this uniform buffer to an effect.
  7461. * @param effect Define the effect to bind the buffer to
  7462. * @param name Name of the uniform block in the shader.
  7463. */
  7464. bindToEffect(effect: Effect, name: string): void;
  7465. /**
  7466. * Disposes the uniform buffer.
  7467. */
  7468. dispose(): void;
  7469. }
  7470. }
  7471. declare module BABYLON {
  7472. /**
  7473. * Enum that determines the text-wrapping mode to use.
  7474. */
  7475. export enum InspectableType {
  7476. /**
  7477. * Checkbox for booleans
  7478. */
  7479. Checkbox = 0,
  7480. /**
  7481. * Sliders for numbers
  7482. */
  7483. Slider = 1,
  7484. /**
  7485. * Vector3
  7486. */
  7487. Vector3 = 2,
  7488. /**
  7489. * Quaternions
  7490. */
  7491. Quaternion = 3,
  7492. /**
  7493. * Color3
  7494. */
  7495. Color3 = 4,
  7496. /**
  7497. * String
  7498. */
  7499. String = 5
  7500. }
  7501. /**
  7502. * Interface used to define custom inspectable properties.
  7503. * This interface is used by the inspector to display custom property grids
  7504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7505. */
  7506. export interface IInspectable {
  7507. /**
  7508. * Gets the label to display
  7509. */
  7510. label: string;
  7511. /**
  7512. * Gets the name of the property to edit
  7513. */
  7514. propertyName: string;
  7515. /**
  7516. * Gets the type of the editor to use
  7517. */
  7518. type: InspectableType;
  7519. /**
  7520. * Gets the minimum value of the property when using in "slider" mode
  7521. */
  7522. min?: number;
  7523. /**
  7524. * Gets the maximum value of the property when using in "slider" mode
  7525. */
  7526. max?: number;
  7527. /**
  7528. * Gets the setp to use when using in "slider" mode
  7529. */
  7530. step?: number;
  7531. }
  7532. }
  7533. declare module BABYLON {
  7534. /**
  7535. * Class used to provide helper for timing
  7536. */
  7537. export class TimingTools {
  7538. /**
  7539. * Polyfill for setImmediate
  7540. * @param action defines the action to execute after the current execution block
  7541. */
  7542. static SetImmediate(action: () => void): void;
  7543. }
  7544. }
  7545. declare module BABYLON {
  7546. /**
  7547. * Class used to enable instatition of objects by class name
  7548. */
  7549. export class InstantiationTools {
  7550. /**
  7551. * Use this object to register external classes like custom textures or material
  7552. * to allow the laoders to instantiate them
  7553. */
  7554. static RegisteredExternalClasses: {
  7555. [key: string]: Object;
  7556. };
  7557. /**
  7558. * Tries to instantiate a new object from a given class name
  7559. * @param className defines the class name to instantiate
  7560. * @returns the new object or null if the system was not able to do the instantiation
  7561. */
  7562. static Instantiate(className: string): any;
  7563. }
  7564. }
  7565. declare module BABYLON {
  7566. /**
  7567. * Define options used to create a depth texture
  7568. */
  7569. export class DepthTextureCreationOptions {
  7570. /** Specifies whether or not a stencil should be allocated in the texture */
  7571. generateStencil?: boolean;
  7572. /** Specifies whether or not bilinear filtering is enable on the texture */
  7573. bilinearFiltering?: boolean;
  7574. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7575. comparisonFunction?: number;
  7576. /** Specifies if the created texture is a cube texture */
  7577. isCube?: boolean;
  7578. }
  7579. }
  7580. declare module BABYLON {
  7581. interface ThinEngine {
  7582. /**
  7583. * Creates a depth stencil cube texture.
  7584. * This is only available in WebGL 2.
  7585. * @param size The size of face edge in the cube texture.
  7586. * @param options The options defining the cube texture.
  7587. * @returns The cube texture
  7588. */
  7589. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7590. /**
  7591. * Creates a cube texture
  7592. * @param rootUrl defines the url where the files to load is located
  7593. * @param scene defines the current scene
  7594. * @param files defines the list of files to load (1 per face)
  7595. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7596. * @param onLoad defines an optional callback raised when the texture is loaded
  7597. * @param onError defines an optional callback raised if there is an issue to load the texture
  7598. * @param format defines the format of the data
  7599. * @param forcedExtension defines the extension to use to pick the right loader
  7600. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7601. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7602. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7603. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7604. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7605. * @returns the cube texture as an InternalTexture
  7606. */
  7607. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7608. /**
  7609. * Creates a cube texture
  7610. * @param rootUrl defines the url where the files to load is located
  7611. * @param scene defines the current scene
  7612. * @param files defines the list of files to load (1 per face)
  7613. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7614. * @param onLoad defines an optional callback raised when the texture is loaded
  7615. * @param onError defines an optional callback raised if there is an issue to load the texture
  7616. * @param format defines the format of the data
  7617. * @param forcedExtension defines the extension to use to pick the right loader
  7618. * @returns the cube texture as an InternalTexture
  7619. */
  7620. 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;
  7621. /**
  7622. * Creates a cube texture
  7623. * @param rootUrl defines the url where the files to load is located
  7624. * @param scene defines the current scene
  7625. * @param files defines the list of files to load (1 per face)
  7626. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7627. * @param onLoad defines an optional callback raised when the texture is loaded
  7628. * @param onError defines an optional callback raised if there is an issue to load the texture
  7629. * @param format defines the format of the data
  7630. * @param forcedExtension defines the extension to use to pick the right loader
  7631. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @returns the cube texture as an InternalTexture
  7635. */
  7636. 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;
  7637. /** @hidden */
  7638. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7641. /** @hidden */
  7642. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7643. /** @hidden */
  7644. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7645. /**
  7646. * @hidden
  7647. */
  7648. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7649. }
  7650. }
  7651. declare module BABYLON {
  7652. /**
  7653. * Class for creating a cube texture
  7654. */
  7655. export class CubeTexture extends BaseTexture {
  7656. private _delayedOnLoad;
  7657. /**
  7658. * The url of the texture
  7659. */
  7660. url: string;
  7661. /**
  7662. * Gets or sets the center of the bounding box associated with the cube texture.
  7663. * It must define where the camera used to render the texture was set
  7664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7665. */
  7666. boundingBoxPosition: Vector3;
  7667. private _boundingBoxSize;
  7668. /**
  7669. * Gets or sets the size of the bounding box associated with the cube texture
  7670. * When defined, the cubemap will switch to local mode
  7671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7672. * @example https://www.babylonjs-playground.com/#RNASML
  7673. */
  7674. set boundingBoxSize(value: Vector3);
  7675. /**
  7676. * Returns the bounding box size
  7677. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7678. */
  7679. get boundingBoxSize(): Vector3;
  7680. protected _rotationY: number;
  7681. /**
  7682. * Sets texture matrix rotation angle around Y axis in radians.
  7683. */
  7684. set rotationY(value: number);
  7685. /**
  7686. * Gets texture matrix rotation angle around Y axis radians.
  7687. */
  7688. get rotationY(): number;
  7689. /**
  7690. * Are mip maps generated for this texture or not.
  7691. */
  7692. get noMipmap(): boolean;
  7693. private _noMipmap;
  7694. private _files;
  7695. protected _forcedExtension: Nullable<string>;
  7696. private _extensions;
  7697. private _textureMatrix;
  7698. private _format;
  7699. private _createPolynomials;
  7700. /** @hidden */
  7701. _prefiltered: boolean;
  7702. /**
  7703. * Creates a cube texture from an array of image urls
  7704. * @param files defines an array of image urls
  7705. * @param scene defines the hosting scene
  7706. * @param noMipmap specifies if mip maps are not used
  7707. * @returns a cube texture
  7708. */
  7709. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7710. /**
  7711. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7712. * @param url defines the url of the prefiltered texture
  7713. * @param scene defines the scene the texture is attached to
  7714. * @param forcedExtension defines the extension of the file if different from the url
  7715. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7716. * @return the prefiltered texture
  7717. */
  7718. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7719. /**
  7720. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7721. * as prefiltered data.
  7722. * @param rootUrl defines the url of the texture or the root name of the six images
  7723. * @param scene defines the scene the texture is attached to
  7724. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7725. * @param noMipmap defines if mipmaps should be created or not
  7726. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7727. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7728. * @param onError defines a callback triggered in case of error during load
  7729. * @param format defines the internal format to use for the texture once loaded
  7730. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7731. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7732. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7735. * @return the cube texture
  7736. */
  7737. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7738. /**
  7739. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7740. */
  7741. get isPrefiltered(): boolean;
  7742. /**
  7743. * Get the current class name of the texture useful for serialization or dynamic coding.
  7744. * @returns "CubeTexture"
  7745. */
  7746. getClassName(): string;
  7747. /**
  7748. * Update the url (and optional buffer) of this texture if url was null during construction.
  7749. * @param url the url of the texture
  7750. * @param forcedExtension defines the extension to use
  7751. * @param onLoad callback called when the texture is loaded (defaults to null)
  7752. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7753. */
  7754. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7755. /**
  7756. * Delays loading of the cube texture
  7757. * @param forcedExtension defines the extension to use
  7758. */
  7759. delayLoad(forcedExtension?: string): void;
  7760. /**
  7761. * Returns the reflection texture matrix
  7762. * @returns the reflection texture matrix
  7763. */
  7764. getReflectionTextureMatrix(): Matrix;
  7765. /**
  7766. * Sets the reflection texture matrix
  7767. * @param value Reflection texture matrix
  7768. */
  7769. setReflectionTextureMatrix(value: Matrix): void;
  7770. /**
  7771. * Parses text to create a cube texture
  7772. * @param parsedTexture define the serialized text to read from
  7773. * @param scene defines the hosting scene
  7774. * @param rootUrl defines the root url of the cube texture
  7775. * @returns a cube texture
  7776. */
  7777. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7778. /**
  7779. * Makes a clone, or deep copy, of the cube texture
  7780. * @returns a new cube texture
  7781. */
  7782. clone(): CubeTexture;
  7783. }
  7784. }
  7785. declare module BABYLON {
  7786. /**
  7787. * Manages the defines for the Material
  7788. */
  7789. export class MaterialDefines {
  7790. /** @hidden */
  7791. protected _keys: string[];
  7792. private _isDirty;
  7793. /** @hidden */
  7794. _renderId: number;
  7795. /** @hidden */
  7796. _areLightsDirty: boolean;
  7797. /** @hidden */
  7798. _areLightsDisposed: boolean;
  7799. /** @hidden */
  7800. _areAttributesDirty: boolean;
  7801. /** @hidden */
  7802. _areTexturesDirty: boolean;
  7803. /** @hidden */
  7804. _areFresnelDirty: boolean;
  7805. /** @hidden */
  7806. _areMiscDirty: boolean;
  7807. /** @hidden */
  7808. _areImageProcessingDirty: boolean;
  7809. /** @hidden */
  7810. _normals: boolean;
  7811. /** @hidden */
  7812. _uvs: boolean;
  7813. /** @hidden */
  7814. _needNormals: boolean;
  7815. /** @hidden */
  7816. _needUVs: boolean;
  7817. [id: string]: any;
  7818. /**
  7819. * Specifies if the material needs to be re-calculated
  7820. */
  7821. get isDirty(): boolean;
  7822. /**
  7823. * Marks the material to indicate that it has been re-calculated
  7824. */
  7825. markAsProcessed(): void;
  7826. /**
  7827. * Marks the material to indicate that it needs to be re-calculated
  7828. */
  7829. markAsUnprocessed(): void;
  7830. /**
  7831. * Marks the material to indicate all of its defines need to be re-calculated
  7832. */
  7833. markAllAsDirty(): void;
  7834. /**
  7835. * Marks the material to indicate that image processing needs to be re-calculated
  7836. */
  7837. markAsImageProcessingDirty(): void;
  7838. /**
  7839. * Marks the material to indicate the lights need to be re-calculated
  7840. * @param disposed Defines whether the light is dirty due to dispose or not
  7841. */
  7842. markAsLightDirty(disposed?: boolean): void;
  7843. /**
  7844. * Marks the attribute state as changed
  7845. */
  7846. markAsAttributesDirty(): void;
  7847. /**
  7848. * Marks the texture state as changed
  7849. */
  7850. markAsTexturesDirty(): void;
  7851. /**
  7852. * Marks the fresnel state as changed
  7853. */
  7854. markAsFresnelDirty(): void;
  7855. /**
  7856. * Marks the misc state as changed
  7857. */
  7858. markAsMiscDirty(): void;
  7859. /**
  7860. * Rebuilds the material defines
  7861. */
  7862. rebuild(): void;
  7863. /**
  7864. * Specifies if two material defines are equal
  7865. * @param other - A material define instance to compare to
  7866. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7867. */
  7868. isEqual(other: MaterialDefines): boolean;
  7869. /**
  7870. * Clones this instance's defines to another instance
  7871. * @param other - material defines to clone values to
  7872. */
  7873. cloneTo(other: MaterialDefines): void;
  7874. /**
  7875. * Resets the material define values
  7876. */
  7877. reset(): void;
  7878. /**
  7879. * Converts the material define values to a string
  7880. * @returns - String of material define information
  7881. */
  7882. toString(): string;
  7883. }
  7884. }
  7885. declare module BABYLON {
  7886. /**
  7887. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7888. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7889. * 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;
  7890. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7891. */
  7892. export class ColorCurves {
  7893. private _dirty;
  7894. private _tempColor;
  7895. private _globalCurve;
  7896. private _highlightsCurve;
  7897. private _midtonesCurve;
  7898. private _shadowsCurve;
  7899. private _positiveCurve;
  7900. private _negativeCurve;
  7901. private _globalHue;
  7902. private _globalDensity;
  7903. private _globalSaturation;
  7904. private _globalExposure;
  7905. /**
  7906. * Gets the global Hue value.
  7907. * 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).
  7908. */
  7909. get globalHue(): number;
  7910. /**
  7911. * Sets the global Hue value.
  7912. * 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).
  7913. */
  7914. set globalHue(value: number);
  7915. /**
  7916. * Gets the global Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. get globalDensity(): number;
  7921. /**
  7922. * Sets the global Density value.
  7923. * 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.
  7924. * Values less than zero provide a filter of opposite hue.
  7925. */
  7926. set globalDensity(value: number);
  7927. /**
  7928. * Gets the global Saturation value.
  7929. * 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.
  7930. */
  7931. get globalSaturation(): number;
  7932. /**
  7933. * Sets the global Saturation value.
  7934. * 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.
  7935. */
  7936. set globalSaturation(value: number);
  7937. /**
  7938. * Gets the global Exposure value.
  7939. * 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.
  7940. */
  7941. get globalExposure(): number;
  7942. /**
  7943. * Sets the global Exposure value.
  7944. * 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.
  7945. */
  7946. set globalExposure(value: number);
  7947. private _highlightsHue;
  7948. private _highlightsDensity;
  7949. private _highlightsSaturation;
  7950. private _highlightsExposure;
  7951. /**
  7952. * Gets the highlights Hue value.
  7953. * 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).
  7954. */
  7955. get highlightsHue(): number;
  7956. /**
  7957. * Sets the highlights Hue value.
  7958. * 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).
  7959. */
  7960. set highlightsHue(value: number);
  7961. /**
  7962. * Gets the highlights Density value.
  7963. * 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.
  7964. * Values less than zero provide a filter of opposite hue.
  7965. */
  7966. get highlightsDensity(): number;
  7967. /**
  7968. * Sets the highlights Density value.
  7969. * 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.
  7970. * Values less than zero provide a filter of opposite hue.
  7971. */
  7972. set highlightsDensity(value: number);
  7973. /**
  7974. * Gets the highlights Saturation value.
  7975. * 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.
  7976. */
  7977. get highlightsSaturation(): number;
  7978. /**
  7979. * Sets the highlights Saturation value.
  7980. * 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.
  7981. */
  7982. set highlightsSaturation(value: number);
  7983. /**
  7984. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  7986. */
  7987. get highlightsExposure(): number;
  7988. /**
  7989. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  7991. */
  7992. set highlightsExposure(value: number);
  7993. private _midtonesHue;
  7994. private _midtonesDensity;
  7995. private _midtonesSaturation;
  7996. private _midtonesExposure;
  7997. /**
  7998. * Gets the midtones Hue value.
  7999. * 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).
  8000. */
  8001. get midtonesHue(): number;
  8002. /**
  8003. * Sets the midtones Hue value.
  8004. * 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).
  8005. */
  8006. set midtonesHue(value: number);
  8007. /**
  8008. * Gets the midtones Density value.
  8009. * 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.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. get midtonesDensity(): number;
  8013. /**
  8014. * Sets the midtones Density value.
  8015. * 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.
  8016. * Values less than zero provide a filter of opposite hue.
  8017. */
  8018. set midtonesDensity(value: number);
  8019. /**
  8020. * Gets the midtones Saturation value.
  8021. * 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.
  8022. */
  8023. get midtonesSaturation(): number;
  8024. /**
  8025. * Sets the midtones Saturation value.
  8026. * 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.
  8027. */
  8028. set midtonesSaturation(value: number);
  8029. /**
  8030. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  8032. */
  8033. get midtonesExposure(): number;
  8034. /**
  8035. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  8037. */
  8038. set midtonesExposure(value: number);
  8039. private _shadowsHue;
  8040. private _shadowsDensity;
  8041. private _shadowsSaturation;
  8042. private _shadowsExposure;
  8043. /**
  8044. * Gets the shadows Hue value.
  8045. * 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).
  8046. */
  8047. get shadowsHue(): number;
  8048. /**
  8049. * Sets the shadows Hue value.
  8050. * 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).
  8051. */
  8052. set shadowsHue(value: number);
  8053. /**
  8054. * Gets the shadows Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. get shadowsDensity(): number;
  8059. /**
  8060. * Sets the shadows Density value.
  8061. * 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.
  8062. * Values less than zero provide a filter of opposite hue.
  8063. */
  8064. set shadowsDensity(value: number);
  8065. /**
  8066. * Gets the shadows Saturation value.
  8067. * 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.
  8068. */
  8069. get shadowsSaturation(): number;
  8070. /**
  8071. * Sets the shadows Saturation value.
  8072. * 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.
  8073. */
  8074. set shadowsSaturation(value: number);
  8075. /**
  8076. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  8078. */
  8079. get shadowsExposure(): number;
  8080. /**
  8081. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  8083. */
  8084. set shadowsExposure(value: number);
  8085. /**
  8086. * Returns the class name
  8087. * @returns The class name
  8088. */
  8089. getClassName(): string;
  8090. /**
  8091. * Binds the color curves to the shader.
  8092. * @param colorCurves The color curve to bind
  8093. * @param effect The effect to bind to
  8094. * @param positiveUniform The positive uniform shader parameter
  8095. * @param neutralUniform The neutral uniform shader parameter
  8096. * @param negativeUniform The negative uniform shader parameter
  8097. */
  8098. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8099. /**
  8100. * Prepare the list of uniforms associated with the ColorCurves effects.
  8101. * @param uniformsList The list of uniforms used in the effect
  8102. */
  8103. static PrepareUniforms(uniformsList: string[]): void;
  8104. /**
  8105. * Returns color grading data based on a hue, density, saturation and exposure value.
  8106. * @param filterHue The hue of the color filter.
  8107. * @param filterDensity The density of the color filter.
  8108. * @param saturation The saturation.
  8109. * @param exposure The exposure.
  8110. * @param result The result data container.
  8111. */
  8112. private getColorGradingDataToRef;
  8113. /**
  8114. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8115. * @param value The input slider value in range [-100,100].
  8116. * @returns Adjusted value.
  8117. */
  8118. private static applyColorGradingSliderNonlinear;
  8119. /**
  8120. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8121. * @param hue The hue (H) input.
  8122. * @param saturation The saturation (S) input.
  8123. * @param brightness The brightness (B) input.
  8124. * @result An RGBA color represented as Vector4.
  8125. */
  8126. private static fromHSBToRef;
  8127. /**
  8128. * Returns a value clamped between min and max
  8129. * @param value The value to clamp
  8130. * @param min The minimum of value
  8131. * @param max The maximum of value
  8132. * @returns The clamped value.
  8133. */
  8134. private static clamp;
  8135. /**
  8136. * Clones the current color curve instance.
  8137. * @return The cloned curves
  8138. */
  8139. clone(): ColorCurves;
  8140. /**
  8141. * Serializes the current color curve instance to a json representation.
  8142. * @return a JSON representation
  8143. */
  8144. serialize(): any;
  8145. /**
  8146. * Parses the color curve from a json representation.
  8147. * @param source the JSON source to parse
  8148. * @return The parsed curves
  8149. */
  8150. static Parse(source: any): ColorCurves;
  8151. }
  8152. }
  8153. declare module BABYLON {
  8154. /**
  8155. * Interface to follow in your material defines to integrate easily the
  8156. * Image proccessing functions.
  8157. * @hidden
  8158. */
  8159. export interface IImageProcessingConfigurationDefines {
  8160. IMAGEPROCESSING: boolean;
  8161. VIGNETTE: boolean;
  8162. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8163. VIGNETTEBLENDMODEOPAQUE: boolean;
  8164. TONEMAPPING: boolean;
  8165. TONEMAPPING_ACES: boolean;
  8166. CONTRAST: boolean;
  8167. EXPOSURE: boolean;
  8168. COLORCURVES: boolean;
  8169. COLORGRADING: boolean;
  8170. COLORGRADING3D: boolean;
  8171. SAMPLER3DGREENDEPTH: boolean;
  8172. SAMPLER3DBGRMAP: boolean;
  8173. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8174. }
  8175. /**
  8176. * @hidden
  8177. */
  8178. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8179. IMAGEPROCESSING: boolean;
  8180. VIGNETTE: boolean;
  8181. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8182. VIGNETTEBLENDMODEOPAQUE: boolean;
  8183. TONEMAPPING: boolean;
  8184. TONEMAPPING_ACES: boolean;
  8185. CONTRAST: boolean;
  8186. COLORCURVES: boolean;
  8187. COLORGRADING: boolean;
  8188. COLORGRADING3D: boolean;
  8189. SAMPLER3DGREENDEPTH: boolean;
  8190. SAMPLER3DBGRMAP: boolean;
  8191. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8192. EXPOSURE: boolean;
  8193. constructor();
  8194. }
  8195. /**
  8196. * This groups together the common properties used for image processing either in direct forward pass
  8197. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8198. * or not.
  8199. */
  8200. export class ImageProcessingConfiguration {
  8201. /**
  8202. * Default tone mapping applied in BabylonJS.
  8203. */
  8204. static readonly TONEMAPPING_STANDARD: number;
  8205. /**
  8206. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8207. * to other engines rendering to increase portability.
  8208. */
  8209. static readonly TONEMAPPING_ACES: number;
  8210. /**
  8211. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8212. */
  8213. colorCurves: Nullable<ColorCurves>;
  8214. private _colorCurvesEnabled;
  8215. /**
  8216. * Gets wether the color curves effect is enabled.
  8217. */
  8218. get colorCurvesEnabled(): boolean;
  8219. /**
  8220. * Sets wether the color curves effect is enabled.
  8221. */
  8222. set colorCurvesEnabled(value: boolean);
  8223. private _colorGradingTexture;
  8224. /**
  8225. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8226. */
  8227. get colorGradingTexture(): Nullable<BaseTexture>;
  8228. /**
  8229. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8230. */
  8231. set colorGradingTexture(value: Nullable<BaseTexture>);
  8232. private _colorGradingEnabled;
  8233. /**
  8234. * Gets wether the color grading effect is enabled.
  8235. */
  8236. get colorGradingEnabled(): boolean;
  8237. /**
  8238. * Sets wether the color grading effect is enabled.
  8239. */
  8240. set colorGradingEnabled(value: boolean);
  8241. private _colorGradingWithGreenDepth;
  8242. /**
  8243. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8244. */
  8245. get colorGradingWithGreenDepth(): boolean;
  8246. /**
  8247. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8248. */
  8249. set colorGradingWithGreenDepth(value: boolean);
  8250. private _colorGradingBGR;
  8251. /**
  8252. * Gets wether the color grading texture contains BGR values.
  8253. */
  8254. get colorGradingBGR(): boolean;
  8255. /**
  8256. * Sets wether the color grading texture contains BGR values.
  8257. */
  8258. set colorGradingBGR(value: boolean);
  8259. /** @hidden */
  8260. _exposure: number;
  8261. /**
  8262. * Gets the Exposure used in the effect.
  8263. */
  8264. get exposure(): number;
  8265. /**
  8266. * Sets the Exposure used in the effect.
  8267. */
  8268. set exposure(value: number);
  8269. private _toneMappingEnabled;
  8270. /**
  8271. * Gets wether the tone mapping effect is enabled.
  8272. */
  8273. get toneMappingEnabled(): boolean;
  8274. /**
  8275. * Sets wether the tone mapping effect is enabled.
  8276. */
  8277. set toneMappingEnabled(value: boolean);
  8278. private _toneMappingType;
  8279. /**
  8280. * Gets the type of tone mapping effect.
  8281. */
  8282. get toneMappingType(): number;
  8283. /**
  8284. * Sets the type of tone mapping effect used in BabylonJS.
  8285. */
  8286. set toneMappingType(value: number);
  8287. protected _contrast: number;
  8288. /**
  8289. * Gets the contrast used in the effect.
  8290. */
  8291. get contrast(): number;
  8292. /**
  8293. * Sets the contrast used in the effect.
  8294. */
  8295. set contrast(value: number);
  8296. /**
  8297. * Vignette stretch size.
  8298. */
  8299. vignetteStretch: number;
  8300. /**
  8301. * Vignette centre X Offset.
  8302. */
  8303. vignetteCentreX: number;
  8304. /**
  8305. * Vignette centre Y Offset.
  8306. */
  8307. vignetteCentreY: number;
  8308. /**
  8309. * Vignette weight or intensity of the vignette effect.
  8310. */
  8311. vignetteWeight: number;
  8312. /**
  8313. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8314. * if vignetteEnabled is set to true.
  8315. */
  8316. vignetteColor: Color4;
  8317. /**
  8318. * Camera field of view used by the Vignette effect.
  8319. */
  8320. vignetteCameraFov: number;
  8321. private _vignetteBlendMode;
  8322. /**
  8323. * Gets the vignette blend mode allowing different kind of effect.
  8324. */
  8325. get vignetteBlendMode(): number;
  8326. /**
  8327. * Sets the vignette blend mode allowing different kind of effect.
  8328. */
  8329. set vignetteBlendMode(value: number);
  8330. private _vignetteEnabled;
  8331. /**
  8332. * Gets wether the vignette effect is enabled.
  8333. */
  8334. get vignetteEnabled(): boolean;
  8335. /**
  8336. * Sets wether the vignette effect is enabled.
  8337. */
  8338. set vignetteEnabled(value: boolean);
  8339. private _applyByPostProcess;
  8340. /**
  8341. * Gets wether the image processing is applied through a post process or not.
  8342. */
  8343. get applyByPostProcess(): boolean;
  8344. /**
  8345. * Sets wether the image processing is applied through a post process or not.
  8346. */
  8347. set applyByPostProcess(value: boolean);
  8348. private _isEnabled;
  8349. /**
  8350. * Gets wether the image processing is enabled or not.
  8351. */
  8352. get isEnabled(): boolean;
  8353. /**
  8354. * Sets wether the image processing is enabled or not.
  8355. */
  8356. set isEnabled(value: boolean);
  8357. /**
  8358. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8359. */
  8360. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8361. /**
  8362. * Method called each time the image processing information changes requires to recompile the effect.
  8363. */
  8364. protected _updateParameters(): void;
  8365. /**
  8366. * Gets the current class name.
  8367. * @return "ImageProcessingConfiguration"
  8368. */
  8369. getClassName(): string;
  8370. /**
  8371. * Prepare the list of uniforms associated with the Image Processing effects.
  8372. * @param uniforms The list of uniforms used in the effect
  8373. * @param defines the list of defines currently in use
  8374. */
  8375. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8376. /**
  8377. * Prepare the list of samplers associated with the Image Processing effects.
  8378. * @param samplersList The list of uniforms used in the effect
  8379. * @param defines the list of defines currently in use
  8380. */
  8381. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8382. /**
  8383. * Prepare the list of defines associated to the shader.
  8384. * @param defines the list of defines to complete
  8385. * @param forPostProcess Define if we are currently in post process mode or not
  8386. */
  8387. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8388. /**
  8389. * Returns true if all the image processing information are ready.
  8390. * @returns True if ready, otherwise, false
  8391. */
  8392. isReady(): boolean;
  8393. /**
  8394. * Binds the image processing to the shader.
  8395. * @param effect The effect to bind to
  8396. * @param overrideAspectRatio Override the aspect ratio of the effect
  8397. */
  8398. bind(effect: Effect, overrideAspectRatio?: number): void;
  8399. /**
  8400. * Clones the current image processing instance.
  8401. * @return The cloned image processing
  8402. */
  8403. clone(): ImageProcessingConfiguration;
  8404. /**
  8405. * Serializes the current image processing instance to a json representation.
  8406. * @return a JSON representation
  8407. */
  8408. serialize(): any;
  8409. /**
  8410. * Parses the image processing from a json representation.
  8411. * @param source the JSON source to parse
  8412. * @return The parsed image processing
  8413. */
  8414. static Parse(source: any): ImageProcessingConfiguration;
  8415. private static _VIGNETTEMODE_MULTIPLY;
  8416. private static _VIGNETTEMODE_OPAQUE;
  8417. /**
  8418. * Used to apply the vignette as a mix with the pixel color.
  8419. */
  8420. static get VIGNETTEMODE_MULTIPLY(): number;
  8421. /**
  8422. * Used to apply the vignette as a replacement of the pixel color.
  8423. */
  8424. static get VIGNETTEMODE_OPAQUE(): number;
  8425. }
  8426. }
  8427. declare module BABYLON {
  8428. /** @hidden */
  8429. export var postprocessVertexShader: {
  8430. name: string;
  8431. shader: string;
  8432. };
  8433. }
  8434. declare module BABYLON {
  8435. interface ThinEngine {
  8436. /**
  8437. * Creates a new render target texture
  8438. * @param size defines the size of the texture
  8439. * @param options defines the options used to create the texture
  8440. * @returns a new render target texture stored in an InternalTexture
  8441. */
  8442. createRenderTargetTexture(size: number | {
  8443. width: number;
  8444. height: number;
  8445. layers?: number;
  8446. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8447. /**
  8448. * Creates a depth stencil texture.
  8449. * This is only available in WebGL 2 or with the depth texture extension available.
  8450. * @param size The size of face edge in the texture.
  8451. * @param options The options defining the texture.
  8452. * @returns The texture
  8453. */
  8454. createDepthStencilTexture(size: number | {
  8455. width: number;
  8456. height: number;
  8457. layers?: number;
  8458. }, options: DepthTextureCreationOptions): InternalTexture;
  8459. /** @hidden */
  8460. _createDepthStencilTexture(size: number | {
  8461. width: number;
  8462. height: number;
  8463. layers?: number;
  8464. }, options: DepthTextureCreationOptions): InternalTexture;
  8465. }
  8466. }
  8467. declare module BABYLON {
  8468. /** Defines supported spaces */
  8469. export enum Space {
  8470. /** Local (object) space */
  8471. LOCAL = 0,
  8472. /** World space */
  8473. WORLD = 1,
  8474. /** Bone space */
  8475. BONE = 2
  8476. }
  8477. /** Defines the 3 main axes */
  8478. export class Axis {
  8479. /** X axis */
  8480. static X: Vector3;
  8481. /** Y axis */
  8482. static Y: Vector3;
  8483. /** Z axis */
  8484. static Z: Vector3;
  8485. }
  8486. }
  8487. declare module BABYLON {
  8488. /**
  8489. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8490. * This is the base of the follow, arc rotate cameras and Free camera
  8491. * @see http://doc.babylonjs.com/features/cameras
  8492. */
  8493. export class TargetCamera extends Camera {
  8494. private static _RigCamTransformMatrix;
  8495. private static _TargetTransformMatrix;
  8496. private static _TargetFocalPoint;
  8497. /**
  8498. * Define the current direction the camera is moving to
  8499. */
  8500. cameraDirection: Vector3;
  8501. /**
  8502. * Define the current rotation the camera is rotating to
  8503. */
  8504. cameraRotation: Vector2;
  8505. /**
  8506. * When set, the up vector of the camera will be updated by the rotation of the camera
  8507. */
  8508. updateUpVectorFromRotation: boolean;
  8509. private _tmpQuaternion;
  8510. /**
  8511. * Define the current rotation of the camera
  8512. */
  8513. rotation: Vector3;
  8514. /**
  8515. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8516. */
  8517. rotationQuaternion: Quaternion;
  8518. /**
  8519. * Define the current speed of the camera
  8520. */
  8521. speed: number;
  8522. /**
  8523. * Add constraint to the camera to prevent it to move freely in all directions and
  8524. * around all axis.
  8525. */
  8526. noRotationConstraint: boolean;
  8527. /**
  8528. * Define the current target of the camera as an object or a position.
  8529. */
  8530. lockedTarget: any;
  8531. /** @hidden */
  8532. _currentTarget: Vector3;
  8533. /** @hidden */
  8534. _initialFocalDistance: number;
  8535. /** @hidden */
  8536. _viewMatrix: Matrix;
  8537. /** @hidden */
  8538. _camMatrix: Matrix;
  8539. /** @hidden */
  8540. _cameraTransformMatrix: Matrix;
  8541. /** @hidden */
  8542. _cameraRotationMatrix: Matrix;
  8543. /** @hidden */
  8544. _referencePoint: Vector3;
  8545. /** @hidden */
  8546. _transformedReferencePoint: Vector3;
  8547. protected _globalCurrentTarget: Vector3;
  8548. protected _globalCurrentUpVector: Vector3;
  8549. /** @hidden */
  8550. _reset: () => void;
  8551. private _defaultUp;
  8552. /**
  8553. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8554. * This is the base of the follow, arc rotate cameras and Free camera
  8555. * @see http://doc.babylonjs.com/features/cameras
  8556. * @param name Defines the name of the camera in the scene
  8557. * @param position Defines the start position of the camera in the scene
  8558. * @param scene Defines the scene the camera belongs to
  8559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8560. */
  8561. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8562. /**
  8563. * Gets the position in front of the camera at a given distance.
  8564. * @param distance The distance from the camera we want the position to be
  8565. * @returns the position
  8566. */
  8567. getFrontPosition(distance: number): Vector3;
  8568. /** @hidden */
  8569. _getLockedTargetPosition(): Nullable<Vector3>;
  8570. private _storedPosition;
  8571. private _storedRotation;
  8572. private _storedRotationQuaternion;
  8573. /**
  8574. * Store current camera state of the camera (fov, position, rotation, etc..)
  8575. * @returns the camera
  8576. */
  8577. storeState(): Camera;
  8578. /**
  8579. * Restored camera state. You must call storeState() first
  8580. * @returns whether it was successful or not
  8581. * @hidden
  8582. */
  8583. _restoreStateValues(): boolean;
  8584. /** @hidden */
  8585. _initCache(): void;
  8586. /** @hidden */
  8587. _updateCache(ignoreParentClass?: boolean): void;
  8588. /** @hidden */
  8589. _isSynchronizedViewMatrix(): boolean;
  8590. /** @hidden */
  8591. _computeLocalCameraSpeed(): number;
  8592. /**
  8593. * Defines the target the camera should look at.
  8594. * @param target Defines the new target as a Vector or a mesh
  8595. */
  8596. setTarget(target: Vector3): void;
  8597. /**
  8598. * Return the current target position of the camera. This value is expressed in local space.
  8599. * @returns the target position
  8600. */
  8601. getTarget(): Vector3;
  8602. /** @hidden */
  8603. _decideIfNeedsToMove(): boolean;
  8604. /** @hidden */
  8605. _updatePosition(): void;
  8606. /** @hidden */
  8607. _checkInputs(): void;
  8608. protected _updateCameraRotationMatrix(): void;
  8609. /**
  8610. * 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)
  8611. * @returns the current camera
  8612. */
  8613. private _rotateUpVectorWithCameraRotationMatrix;
  8614. private _cachedRotationZ;
  8615. private _cachedQuaternionRotationZ;
  8616. /** @hidden */
  8617. _getViewMatrix(): Matrix;
  8618. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8619. /**
  8620. * @hidden
  8621. */
  8622. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8623. /**
  8624. * @hidden
  8625. */
  8626. _updateRigCameras(): void;
  8627. private _getRigCamPositionAndTarget;
  8628. /**
  8629. * Gets the current object class name.
  8630. * @return the class name
  8631. */
  8632. getClassName(): string;
  8633. }
  8634. }
  8635. declare module BABYLON {
  8636. /**
  8637. * Gather the list of keyboard event types as constants.
  8638. */
  8639. export class KeyboardEventTypes {
  8640. /**
  8641. * The keydown event is fired when a key becomes active (pressed).
  8642. */
  8643. static readonly KEYDOWN: number;
  8644. /**
  8645. * The keyup event is fired when a key has been released.
  8646. */
  8647. static readonly KEYUP: number;
  8648. }
  8649. /**
  8650. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8651. */
  8652. export class KeyboardInfo {
  8653. /**
  8654. * Defines the type of event (KeyboardEventTypes)
  8655. */
  8656. type: number;
  8657. /**
  8658. * Defines the related dom event
  8659. */
  8660. event: KeyboardEvent;
  8661. /**
  8662. * Instantiates a new keyboard info.
  8663. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8664. * @param type Defines the type of event (KeyboardEventTypes)
  8665. * @param event Defines the related dom event
  8666. */
  8667. constructor(
  8668. /**
  8669. * Defines the type of event (KeyboardEventTypes)
  8670. */
  8671. type: number,
  8672. /**
  8673. * Defines the related dom event
  8674. */
  8675. event: KeyboardEvent);
  8676. }
  8677. /**
  8678. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8679. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8680. */
  8681. export class KeyboardInfoPre extends KeyboardInfo {
  8682. /**
  8683. * Defines the type of event (KeyboardEventTypes)
  8684. */
  8685. type: number;
  8686. /**
  8687. * Defines the related dom event
  8688. */
  8689. event: KeyboardEvent;
  8690. /**
  8691. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8692. */
  8693. skipOnPointerObservable: boolean;
  8694. /**
  8695. * Instantiates a new keyboard pre info.
  8696. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8697. * @param type Defines the type of event (KeyboardEventTypes)
  8698. * @param event Defines the related dom event
  8699. */
  8700. constructor(
  8701. /**
  8702. * Defines the type of event (KeyboardEventTypes)
  8703. */
  8704. type: number,
  8705. /**
  8706. * Defines the related dom event
  8707. */
  8708. event: KeyboardEvent);
  8709. }
  8710. }
  8711. declare module BABYLON {
  8712. /**
  8713. * Manage the keyboard inputs to control the movement of a free camera.
  8714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8715. */
  8716. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8717. /**
  8718. * Defines the camera the input is attached to.
  8719. */
  8720. camera: FreeCamera;
  8721. /**
  8722. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8723. */
  8724. keysUp: number[];
  8725. /**
  8726. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8727. */
  8728. keysDown: number[];
  8729. /**
  8730. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8731. */
  8732. keysLeft: number[];
  8733. /**
  8734. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8735. */
  8736. keysRight: number[];
  8737. private _keys;
  8738. private _onCanvasBlurObserver;
  8739. private _onKeyboardObserver;
  8740. private _engine;
  8741. private _scene;
  8742. /**
  8743. * Attach the input controls to a specific dom element to get the input from.
  8744. * @param element Defines the element the controls should be listened from
  8745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8746. */
  8747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8748. /**
  8749. * Detach the current controls from the specified dom element.
  8750. * @param element Defines the element to stop listening the inputs from
  8751. */
  8752. detachControl(element: Nullable<HTMLElement>): void;
  8753. /**
  8754. * Update the current camera state depending on the inputs that have been used this frame.
  8755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8756. */
  8757. checkInputs(): void;
  8758. /**
  8759. * Gets the class name of the current intput.
  8760. * @returns the class name
  8761. */
  8762. getClassName(): string;
  8763. /** @hidden */
  8764. _onLostFocus(): void;
  8765. /**
  8766. * Get the friendly name associated with the input class.
  8767. * @returns the input friendly name
  8768. */
  8769. getSimpleName(): string;
  8770. }
  8771. }
  8772. declare module BABYLON {
  8773. /**
  8774. * Interface describing all the common properties and methods a shadow light needs to implement.
  8775. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8776. * as well as binding the different shadow properties to the effects.
  8777. */
  8778. export interface IShadowLight extends Light {
  8779. /**
  8780. * The light id in the scene (used in scene.findLighById for instance)
  8781. */
  8782. id: string;
  8783. /**
  8784. * The position the shdow will be casted from.
  8785. */
  8786. position: Vector3;
  8787. /**
  8788. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8789. */
  8790. direction: Vector3;
  8791. /**
  8792. * The transformed position. Position of the light in world space taking parenting in account.
  8793. */
  8794. transformedPosition: Vector3;
  8795. /**
  8796. * The transformed direction. Direction of the light in world space taking parenting in account.
  8797. */
  8798. transformedDirection: Vector3;
  8799. /**
  8800. * The friendly name of the light in the scene.
  8801. */
  8802. name: string;
  8803. /**
  8804. * Defines the shadow projection clipping minimum z value.
  8805. */
  8806. shadowMinZ: number;
  8807. /**
  8808. * Defines the shadow projection clipping maximum z value.
  8809. */
  8810. shadowMaxZ: number;
  8811. /**
  8812. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8813. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8814. */
  8815. computeTransformedInformation(): boolean;
  8816. /**
  8817. * Gets the scene the light belongs to.
  8818. * @returns The scene
  8819. */
  8820. getScene(): Scene;
  8821. /**
  8822. * Callback defining a custom Projection Matrix Builder.
  8823. * This can be used to override the default projection matrix computation.
  8824. */
  8825. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8826. /**
  8827. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8828. * @param matrix The materix to updated with the projection information
  8829. * @param viewMatrix The transform matrix of the light
  8830. * @param renderList The list of mesh to render in the map
  8831. * @returns The current light
  8832. */
  8833. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8834. /**
  8835. * Gets the current depth scale used in ESM.
  8836. * @returns The scale
  8837. */
  8838. getDepthScale(): number;
  8839. /**
  8840. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8841. * @returns true if a cube texture needs to be use
  8842. */
  8843. needCube(): boolean;
  8844. /**
  8845. * Detects if the projection matrix requires to be recomputed this frame.
  8846. * @returns true if it requires to be recomputed otherwise, false.
  8847. */
  8848. needProjectionMatrixCompute(): boolean;
  8849. /**
  8850. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8851. */
  8852. forceProjectionMatrixCompute(): void;
  8853. /**
  8854. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8855. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8856. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8857. */
  8858. getShadowDirection(faceIndex?: number): Vector3;
  8859. /**
  8860. * Gets the minZ used for shadow according to both the scene and the light.
  8861. * @param activeCamera The camera we are returning the min for
  8862. * @returns the depth min z
  8863. */
  8864. getDepthMinZ(activeCamera: Camera): number;
  8865. /**
  8866. * Gets the maxZ used for shadow according to both the scene and the light.
  8867. * @param activeCamera The camera we are returning the max for
  8868. * @returns the depth max z
  8869. */
  8870. getDepthMaxZ(activeCamera: Camera): number;
  8871. }
  8872. /**
  8873. * Base implementation IShadowLight
  8874. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8875. */
  8876. export abstract class ShadowLight extends Light implements IShadowLight {
  8877. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8878. protected _position: Vector3;
  8879. protected _setPosition(value: Vector3): void;
  8880. /**
  8881. * Sets the position the shadow will be casted from. Also use as the light position for both
  8882. * point and spot lights.
  8883. */
  8884. get position(): Vector3;
  8885. /**
  8886. * Sets the position the shadow will be casted from. Also use as the light position for both
  8887. * point and spot lights.
  8888. */
  8889. set position(value: Vector3);
  8890. protected _direction: Vector3;
  8891. protected _setDirection(value: Vector3): void;
  8892. /**
  8893. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8894. * Also use as the light direction on spot and directional lights.
  8895. */
  8896. get direction(): Vector3;
  8897. /**
  8898. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8899. * Also use as the light direction on spot and directional lights.
  8900. */
  8901. set direction(value: Vector3);
  8902. protected _shadowMinZ: number;
  8903. /**
  8904. * Gets the shadow projection clipping minimum z value.
  8905. */
  8906. get shadowMinZ(): number;
  8907. /**
  8908. * Sets the shadow projection clipping minimum z value.
  8909. */
  8910. set shadowMinZ(value: number);
  8911. protected _shadowMaxZ: number;
  8912. /**
  8913. * Sets the shadow projection clipping maximum z value.
  8914. */
  8915. get shadowMaxZ(): number;
  8916. /**
  8917. * Gets the shadow projection clipping maximum z value.
  8918. */
  8919. set shadowMaxZ(value: number);
  8920. /**
  8921. * Callback defining a custom Projection Matrix Builder.
  8922. * This can be used to override the default projection matrix computation.
  8923. */
  8924. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8925. /**
  8926. * The transformed position. Position of the light in world space taking parenting in account.
  8927. */
  8928. transformedPosition: Vector3;
  8929. /**
  8930. * The transformed direction. Direction of the light in world space taking parenting in account.
  8931. */
  8932. transformedDirection: Vector3;
  8933. private _needProjectionMatrixCompute;
  8934. /**
  8935. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8936. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8937. */
  8938. computeTransformedInformation(): boolean;
  8939. /**
  8940. * Return the depth scale used for the shadow map.
  8941. * @returns the depth scale.
  8942. */
  8943. getDepthScale(): number;
  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. * Returns the ShadowLight absolute position in the World.
  8952. * @returns the position vector in world space
  8953. */
  8954. getAbsolutePosition(): Vector3;
  8955. /**
  8956. * Sets the ShadowLight direction toward the passed target.
  8957. * @param target The point to target in local space
  8958. * @returns the updated ShadowLight direction
  8959. */
  8960. setDirectionToTarget(target: Vector3): Vector3;
  8961. /**
  8962. * Returns the light rotation in euler definition.
  8963. * @returns the x y z rotation in local space.
  8964. */
  8965. getRotation(): Vector3;
  8966. /**
  8967. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8968. * @returns true if a cube texture needs to be use
  8969. */
  8970. needCube(): boolean;
  8971. /**
  8972. * Detects if the projection matrix requires to be recomputed this frame.
  8973. * @returns true if it requires to be recomputed otherwise, false.
  8974. */
  8975. needProjectionMatrixCompute(): boolean;
  8976. /**
  8977. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8978. */
  8979. forceProjectionMatrixCompute(): void;
  8980. /** @hidden */
  8981. _initCache(): void;
  8982. /** @hidden */
  8983. _isSynchronized(): boolean;
  8984. /**
  8985. * Computes the world matrix of the node
  8986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8987. * @returns the world matrix
  8988. */
  8989. computeWorldMatrix(force?: boolean): Matrix;
  8990. /**
  8991. * Gets the minZ used for shadow according to both the scene and the light.
  8992. * @param activeCamera The camera we are returning the min for
  8993. * @returns the depth min z
  8994. */
  8995. getDepthMinZ(activeCamera: Camera): number;
  8996. /**
  8997. * Gets the maxZ used for shadow according to both the scene and the light.
  8998. * @param activeCamera The camera we are returning the max for
  8999. * @returns the depth max z
  9000. */
  9001. getDepthMaxZ(activeCamera: Camera): number;
  9002. /**
  9003. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9004. * @param matrix The materix to updated with the projection information
  9005. * @param viewMatrix The transform matrix of the light
  9006. * @param renderList The list of mesh to render in the map
  9007. * @returns The current light
  9008. */
  9009. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9010. }
  9011. }
  9012. declare module BABYLON {
  9013. /**
  9014. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9015. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9016. */
  9017. export class EffectFallbacks implements IEffectFallbacks {
  9018. private _defines;
  9019. private _currentRank;
  9020. private _maxRank;
  9021. private _mesh;
  9022. /**
  9023. * Removes the fallback from the bound mesh.
  9024. */
  9025. unBindMesh(): void;
  9026. /**
  9027. * Adds a fallback on the specified property.
  9028. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9029. * @param define The name of the define in the shader
  9030. */
  9031. addFallback(rank: number, define: string): void;
  9032. /**
  9033. * Sets the mesh to use CPU skinning when needing to fallback.
  9034. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9035. * @param mesh The mesh to use the fallbacks.
  9036. */
  9037. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9038. /**
  9039. * Checks to see if more fallbacks are still availible.
  9040. */
  9041. get hasMoreFallbacks(): boolean;
  9042. /**
  9043. * Removes the defines that should be removed when falling back.
  9044. * @param currentDefines defines the current define statements for the shader.
  9045. * @param effect defines the current effect we try to compile
  9046. * @returns The resulting defines with defines of the current rank removed.
  9047. */
  9048. reduce(currentDefines: string, effect: Effect): string;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. /**
  9053. * "Static Class" containing the most commonly used helper while dealing with material for
  9054. * rendering purpose.
  9055. *
  9056. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9057. *
  9058. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9059. */
  9060. export class MaterialHelper {
  9061. /**
  9062. * Bind the current view position to an effect.
  9063. * @param effect The effect to be bound
  9064. * @param scene The scene the eyes position is used from
  9065. */
  9066. static BindEyePosition(effect: Effect, scene: Scene): void;
  9067. /**
  9068. * Helps preparing the defines values about the UVs in used in the effect.
  9069. * UVs are shared as much as we can accross channels in the shaders.
  9070. * @param texture The texture we are preparing the UVs for
  9071. * @param defines The defines to update
  9072. * @param key The channel key "diffuse", "specular"... used in the shader
  9073. */
  9074. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9075. /**
  9076. * Binds a texture matrix value to its corrsponding uniform
  9077. * @param texture The texture to bind the matrix for
  9078. * @param uniformBuffer The uniform buffer receivin the data
  9079. * @param key The channel key "diffuse", "specular"... used in the shader
  9080. */
  9081. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9082. /**
  9083. * Gets the current status of the fog (should it be enabled?)
  9084. * @param mesh defines the mesh to evaluate for fog support
  9085. * @param scene defines the hosting scene
  9086. * @returns true if fog must be enabled
  9087. */
  9088. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9089. /**
  9090. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9091. * @param mesh defines the current mesh
  9092. * @param scene defines the current scene
  9093. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9094. * @param pointsCloud defines if point cloud rendering has to be turned on
  9095. * @param fogEnabled defines if fog has to be turned on
  9096. * @param alphaTest defines if alpha testing has to be turned on
  9097. * @param defines defines the current list of defines
  9098. */
  9099. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9100. /**
  9101. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9102. * @param scene defines the current scene
  9103. * @param engine defines the current engine
  9104. * @param defines specifies the list of active defines
  9105. * @param useInstances defines if instances have to be turned on
  9106. * @param useClipPlane defines if clip plane have to be turned on
  9107. */
  9108. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9109. /**
  9110. * Prepares the defines for bones
  9111. * @param mesh The mesh containing the geometry data we will draw
  9112. * @param defines The defines to update
  9113. */
  9114. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9115. /**
  9116. * Prepares the defines for morph targets
  9117. * @param mesh The mesh containing the geometry data we will draw
  9118. * @param defines The defines to update
  9119. */
  9120. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9121. /**
  9122. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9123. * @param mesh The mesh containing the geometry data we will draw
  9124. * @param defines The defines to update
  9125. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9126. * @param useBones Precise whether bones should be used or not (override mesh info)
  9127. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9128. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9129. * @returns false if defines are considered not dirty and have not been checked
  9130. */
  9131. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9132. /**
  9133. * Prepares the defines related to multiview
  9134. * @param scene The scene we are intending to draw
  9135. * @param defines The defines to update
  9136. */
  9137. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9138. /**
  9139. * Prepares the defines related to the light information passed in parameter
  9140. * @param scene The scene we are intending to draw
  9141. * @param mesh The mesh the effect is compiling for
  9142. * @param light The light the effect is compiling for
  9143. * @param lightIndex The index of the light
  9144. * @param defines The defines to update
  9145. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9146. * @param state Defines the current state regarding what is needed (normals, etc...)
  9147. */
  9148. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9149. needNormals: boolean;
  9150. needRebuild: boolean;
  9151. shadowEnabled: boolean;
  9152. specularEnabled: boolean;
  9153. lightmapMode: boolean;
  9154. }): void;
  9155. /**
  9156. * Prepares the defines related to the light information passed in parameter
  9157. * @param scene The scene we are intending to draw
  9158. * @param mesh The mesh the effect is compiling for
  9159. * @param defines The defines to update
  9160. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9161. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9162. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9163. * @returns true if normals will be required for the rest of the effect
  9164. */
  9165. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9166. /**
  9167. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9168. * @param lightIndex defines the light index
  9169. * @param uniformsList The uniform list
  9170. * @param samplersList The sampler list
  9171. * @param projectedLightTexture defines if projected texture must be used
  9172. * @param uniformBuffersList defines an optional list of uniform buffers
  9173. */
  9174. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9175. /**
  9176. * Prepares the uniforms and samplers list to be used in the effect
  9177. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9178. * @param samplersList The sampler list
  9179. * @param defines The defines helping in the list generation
  9180. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9181. */
  9182. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9183. /**
  9184. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9185. * @param defines The defines to update while falling back
  9186. * @param fallbacks The authorized effect fallbacks
  9187. * @param maxSimultaneousLights The maximum number of lights allowed
  9188. * @param rank the current rank of the Effect
  9189. * @returns The newly affected rank
  9190. */
  9191. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9192. private static _TmpMorphInfluencers;
  9193. /**
  9194. * Prepares the list of attributes required for morph targets according to the effect defines.
  9195. * @param attribs The current list of supported attribs
  9196. * @param mesh The mesh to prepare the morph targets attributes for
  9197. * @param influencers The number of influencers
  9198. */
  9199. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9200. /**
  9201. * Prepares the list of attributes required for morph targets according to the effect defines.
  9202. * @param attribs The current list of supported attribs
  9203. * @param mesh The mesh to prepare the morph targets attributes for
  9204. * @param defines The current Defines of the effect
  9205. */
  9206. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9207. /**
  9208. * Prepares the list of attributes required for bones according to the effect defines.
  9209. * @param attribs The current list of supported attribs
  9210. * @param mesh The mesh to prepare the bones attributes for
  9211. * @param defines The current Defines of the effect
  9212. * @param fallbacks The current efffect fallback strategy
  9213. */
  9214. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9215. /**
  9216. * Check and prepare the list of attributes required for instances according to the effect defines.
  9217. * @param attribs The current list of supported attribs
  9218. * @param defines The current MaterialDefines of the effect
  9219. */
  9220. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9221. /**
  9222. * Add the list of attributes required for instances to the attribs array.
  9223. * @param attribs The current list of supported attribs
  9224. */
  9225. static PushAttributesForInstances(attribs: string[]): void;
  9226. /**
  9227. * Binds the light information to the effect.
  9228. * @param light The light containing the generator
  9229. * @param effect The effect we are binding the data to
  9230. * @param lightIndex The light index in the effect used to render
  9231. */
  9232. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9233. /**
  9234. * Binds the lights information from the scene to the effect for the given mesh.
  9235. * @param light Light to bind
  9236. * @param lightIndex Light index
  9237. * @param scene The scene where the light belongs to
  9238. * @param effect The effect we are binding the data to
  9239. * @param useSpecular Defines if specular is supported
  9240. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9241. */
  9242. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9243. /**
  9244. * Binds the lights information from the scene to the effect for the given mesh.
  9245. * @param scene The scene the lights belongs to
  9246. * @param mesh The mesh we are binding the information to render
  9247. * @param effect The effect we are binding the data to
  9248. * @param defines The generated defines for the effect
  9249. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9250. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9251. */
  9252. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9253. private static _tempFogColor;
  9254. /**
  9255. * Binds the fog information from the scene to the effect for the given mesh.
  9256. * @param scene The scene the lights belongs to
  9257. * @param mesh The mesh we are binding the information to render
  9258. * @param effect The effect we are binding the data to
  9259. * @param linearSpace Defines if the fog effect is applied in linear space
  9260. */
  9261. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9262. /**
  9263. * Binds the bones information from the mesh to the effect.
  9264. * @param mesh The mesh we are binding the information to render
  9265. * @param effect The effect we are binding the data to
  9266. */
  9267. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9268. /**
  9269. * Binds the morph targets information from the mesh to the effect.
  9270. * @param abstractMesh The mesh we are binding the information to render
  9271. * @param effect The effect we are binding the data to
  9272. */
  9273. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9274. /**
  9275. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9276. * @param defines The generated defines used in the effect
  9277. * @param effect The effect we are binding the data to
  9278. * @param scene The scene we are willing to render with logarithmic scale for
  9279. */
  9280. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9281. /**
  9282. * Binds the clip plane information from the scene to the effect.
  9283. * @param scene The scene the clip plane information are extracted from
  9284. * @param effect The effect we are binding the data to
  9285. */
  9286. static BindClipPlane(effect: Effect, scene: Scene): void;
  9287. }
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var packingFunctions: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var clipPlaneFragmentDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var clipPlaneFragment: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var shadowMapPixelShader: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var bonesDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var morphTargetsVertexGlobalDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var morphTargetsVertexDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var instancesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var helperFunctions: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var morphTargetsVertex: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var instancesVertex: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var bonesVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var clipPlaneVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var shadowMapVertexShader: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var depthBoxBlurPixelShader: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /**
  9403. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9404. */
  9405. export interface ICustomShaderOptions {
  9406. /**
  9407. * Gets or sets the custom shader name to use
  9408. */
  9409. shaderName: string;
  9410. /**
  9411. * The list of attribute names used in the shader
  9412. */
  9413. attributes?: string[];
  9414. /**
  9415. * The list of unifrom names used in the shader
  9416. */
  9417. uniforms?: string[];
  9418. /**
  9419. * The list of sampler names used in the shader
  9420. */
  9421. samplers?: string[];
  9422. /**
  9423. * The list of defines used in the shader
  9424. */
  9425. defines?: string[];
  9426. }
  9427. /**
  9428. * Interface to implement to create a shadow generator compatible with BJS.
  9429. */
  9430. export interface IShadowGenerator {
  9431. /**
  9432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9433. * @returns The render target texture if present otherwise, null
  9434. */
  9435. getShadowMap(): Nullable<RenderTargetTexture>;
  9436. /**
  9437. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9438. * @param subMesh The submesh we want to render in the shadow map
  9439. * @param useInstances Defines wether will draw in the map using instances
  9440. * @returns true if ready otherwise, false
  9441. */
  9442. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9443. /**
  9444. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9445. * @param defines Defines of the material we want to update
  9446. * @param lightIndex Index of the light in the enabled light list of the material
  9447. */
  9448. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9449. /**
  9450. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9451. * defined in the generator but impacting the effect).
  9452. * It implies the unifroms available on the materials are the standard BJS ones.
  9453. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9454. * @param effect The effect we are binfing the information for
  9455. */
  9456. bindShadowLight(lightIndex: string, effect: Effect): void;
  9457. /**
  9458. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9459. * (eq to shadow prjection matrix * light transform matrix)
  9460. * @returns The transform matrix used to create the shadow map
  9461. */
  9462. getTransformMatrix(): Matrix;
  9463. /**
  9464. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9465. * Cube and 2D textures for instance.
  9466. */
  9467. recreateShadowMap(): void;
  9468. /**
  9469. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9470. * @param onCompiled Callback triggered at the and of the effects compilation
  9471. * @param options Sets of optional options forcing the compilation with different modes
  9472. */
  9473. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9474. useInstances: boolean;
  9475. }>): void;
  9476. /**
  9477. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9478. * @param options Sets of optional options forcing the compilation with different modes
  9479. * @returns A promise that resolves when the compilation completes
  9480. */
  9481. forceCompilationAsync(options?: Partial<{
  9482. useInstances: boolean;
  9483. }>): Promise<void>;
  9484. /**
  9485. * Serializes the shadow generator setup to a json object.
  9486. * @returns The serialized JSON object
  9487. */
  9488. serialize(): any;
  9489. /**
  9490. * Disposes the Shadow map and related Textures and effects.
  9491. */
  9492. dispose(): void;
  9493. }
  9494. /**
  9495. * Default implementation IShadowGenerator.
  9496. * This is the main object responsible of generating shadows in the framework.
  9497. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9498. */
  9499. export class ShadowGenerator implements IShadowGenerator {
  9500. /**
  9501. * Name of the shadow generator class
  9502. */
  9503. static CLASSNAME: string;
  9504. /**
  9505. * Shadow generator mode None: no filtering applied.
  9506. */
  9507. static readonly FILTER_NONE: number;
  9508. /**
  9509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9511. */
  9512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9513. /**
  9514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9516. */
  9517. static readonly FILTER_POISSONSAMPLING: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9521. */
  9522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9523. /**
  9524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9525. * edge artifacts on steep falloff.
  9526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9527. */
  9528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9529. /**
  9530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9531. * edge artifacts on steep falloff.
  9532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9533. */
  9534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9535. /**
  9536. * Shadow generator mode PCF: Percentage Closer Filtering
  9537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9539. */
  9540. static readonly FILTER_PCF: number;
  9541. /**
  9542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9544. * Contact Hardening
  9545. */
  9546. static readonly FILTER_PCSS: number;
  9547. /**
  9548. * Reserved for PCF and PCSS
  9549. * Highest Quality.
  9550. *
  9551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9552. *
  9553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9554. */
  9555. static readonly QUALITY_HIGH: number;
  9556. /**
  9557. * Reserved for PCF and PCSS
  9558. * Good tradeoff for quality/perf cross devices
  9559. *
  9560. * Execute PCF on a 3*3 kernel.
  9561. *
  9562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9563. */
  9564. static readonly QUALITY_MEDIUM: number;
  9565. /**
  9566. * Reserved for PCF and PCSS
  9567. * The lowest quality but the fastest.
  9568. *
  9569. * Execute PCF on a 1*1 kernel.
  9570. *
  9571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9572. */
  9573. static readonly QUALITY_LOW: number;
  9574. /** Gets or sets the custom shader name to use */
  9575. customShaderOptions: ICustomShaderOptions;
  9576. /**
  9577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9578. */
  9579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9580. /**
  9581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9582. */
  9583. onAfterShadowMapRenderObservable: Observable<Effect>;
  9584. /**
  9585. * Observable triggered before a mesh is rendered in the shadow map.
  9586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9587. */
  9588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9589. /**
  9590. * Observable triggered after a mesh is rendered in the shadow map.
  9591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9592. */
  9593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9594. protected _bias: number;
  9595. /**
  9596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9597. */
  9598. get bias(): number;
  9599. /**
  9600. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9601. */
  9602. set bias(bias: number);
  9603. protected _normalBias: number;
  9604. /**
  9605. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9606. */
  9607. get normalBias(): number;
  9608. /**
  9609. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9610. */
  9611. set normalBias(normalBias: number);
  9612. protected _blurBoxOffset: number;
  9613. /**
  9614. * Gets the blur box offset: offset applied during the blur pass.
  9615. * Only useful if useKernelBlur = false
  9616. */
  9617. get blurBoxOffset(): number;
  9618. /**
  9619. * Sets the blur box offset: offset applied during the blur pass.
  9620. * Only useful if useKernelBlur = false
  9621. */
  9622. set blurBoxOffset(value: number);
  9623. protected _blurScale: number;
  9624. /**
  9625. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9626. * 2 means half of the size.
  9627. */
  9628. get blurScale(): number;
  9629. /**
  9630. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9631. * 2 means half of the size.
  9632. */
  9633. set blurScale(value: number);
  9634. protected _blurKernel: number;
  9635. /**
  9636. * Gets the blur kernel: kernel size of the blur pass.
  9637. * Only useful if useKernelBlur = true
  9638. */
  9639. get blurKernel(): number;
  9640. /**
  9641. * Sets the blur kernel: kernel size of the blur pass.
  9642. * Only useful if useKernelBlur = true
  9643. */
  9644. set blurKernel(value: number);
  9645. protected _useKernelBlur: boolean;
  9646. /**
  9647. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9649. */
  9650. get useKernelBlur(): boolean;
  9651. /**
  9652. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9653. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9654. */
  9655. set useKernelBlur(value: boolean);
  9656. protected _depthScale: number;
  9657. /**
  9658. * Gets the depth scale used in ESM mode.
  9659. */
  9660. get depthScale(): number;
  9661. /**
  9662. * Sets the depth scale used in ESM mode.
  9663. * This can override the scale stored on the light.
  9664. */
  9665. set depthScale(value: number);
  9666. protected _validateFilter(filter: number): number;
  9667. protected _filter: number;
  9668. /**
  9669. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9670. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9671. */
  9672. get filter(): number;
  9673. /**
  9674. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9675. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9676. */
  9677. set filter(value: number);
  9678. /**
  9679. * Gets if the current filter is set to Poisson Sampling.
  9680. */
  9681. get usePoissonSampling(): boolean;
  9682. /**
  9683. * Sets the current filter to Poisson Sampling.
  9684. */
  9685. set usePoissonSampling(value: boolean);
  9686. /**
  9687. * Gets if the current filter is set to ESM.
  9688. */
  9689. get useExponentialShadowMap(): boolean;
  9690. /**
  9691. * Sets the current filter is to ESM.
  9692. */
  9693. set useExponentialShadowMap(value: boolean);
  9694. /**
  9695. * Gets if the current filter is set to filtered ESM.
  9696. */
  9697. get useBlurExponentialShadowMap(): boolean;
  9698. /**
  9699. * Gets if the current filter is set to filtered ESM.
  9700. */
  9701. set useBlurExponentialShadowMap(value: boolean);
  9702. /**
  9703. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9704. * exponential to prevent steep falloff artifacts).
  9705. */
  9706. get useCloseExponentialShadowMap(): boolean;
  9707. /**
  9708. * Sets the current filter to "close ESM" (using the inverse of the
  9709. * exponential to prevent steep falloff artifacts).
  9710. */
  9711. set useCloseExponentialShadowMap(value: boolean);
  9712. /**
  9713. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9714. * exponential to prevent steep falloff artifacts).
  9715. */
  9716. get useBlurCloseExponentialShadowMap(): boolean;
  9717. /**
  9718. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9719. * exponential to prevent steep falloff artifacts).
  9720. */
  9721. set useBlurCloseExponentialShadowMap(value: boolean);
  9722. /**
  9723. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9724. */
  9725. get usePercentageCloserFiltering(): boolean;
  9726. /**
  9727. * Sets the current filter to "PCF" (percentage closer filtering).
  9728. */
  9729. set usePercentageCloserFiltering(value: boolean);
  9730. protected _filteringQuality: number;
  9731. /**
  9732. * Gets the PCF or PCSS Quality.
  9733. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9734. */
  9735. get filteringQuality(): number;
  9736. /**
  9737. * Sets the PCF or PCSS Quality.
  9738. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9739. */
  9740. set filteringQuality(filteringQuality: number);
  9741. /**
  9742. * Gets if the current filter is set to "PCSS" (contact hardening).
  9743. */
  9744. get useContactHardeningShadow(): boolean;
  9745. /**
  9746. * Sets the current filter to "PCSS" (contact hardening).
  9747. */
  9748. set useContactHardeningShadow(value: boolean);
  9749. protected _contactHardeningLightSizeUVRatio: number;
  9750. /**
  9751. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9752. * Using a ratio helps keeping shape stability independently of the map size.
  9753. *
  9754. * It does not account for the light projection as it was having too much
  9755. * instability during the light setup or during light position changes.
  9756. *
  9757. * Only valid if useContactHardeningShadow is true.
  9758. */
  9759. get contactHardeningLightSizeUVRatio(): number;
  9760. /**
  9761. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9762. * Using a ratio helps keeping shape stability independently of the map size.
  9763. *
  9764. * It does not account for the light projection as it was having too much
  9765. * instability during the light setup or during light position changes.
  9766. *
  9767. * Only valid if useContactHardeningShadow is true.
  9768. */
  9769. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9770. protected _darkness: number;
  9771. /** Gets or sets the actual darkness of a shadow */
  9772. get darkness(): number;
  9773. set darkness(value: number);
  9774. /**
  9775. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9776. * 0 means strongest and 1 would means no shadow.
  9777. * @returns the darkness.
  9778. */
  9779. getDarkness(): number;
  9780. /**
  9781. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9782. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9783. * @returns the shadow generator allowing fluent coding.
  9784. */
  9785. setDarkness(darkness: number): ShadowGenerator;
  9786. protected _transparencyShadow: boolean;
  9787. /** Gets or sets the ability to have transparent shadow */
  9788. get transparencyShadow(): boolean;
  9789. set transparencyShadow(value: boolean);
  9790. /**
  9791. * Sets the ability to have transparent shadow (boolean).
  9792. * @param transparent True if transparent else False
  9793. * @returns the shadow generator allowing fluent coding
  9794. */
  9795. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9796. protected _shadowMap: Nullable<RenderTargetTexture>;
  9797. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9798. /**
  9799. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9800. * @returns The render target texture if present otherwise, null
  9801. */
  9802. getShadowMap(): Nullable<RenderTargetTexture>;
  9803. /**
  9804. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9805. * @returns The render target texture if the shadow map is present otherwise, null
  9806. */
  9807. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9808. /**
  9809. * Gets the class name of that object
  9810. * @returns "ShadowGenerator"
  9811. */
  9812. getClassName(): string;
  9813. /**
  9814. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9815. * @param mesh Mesh to add
  9816. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9817. * @returns the Shadow Generator itself
  9818. */
  9819. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9820. /**
  9821. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9822. * @param mesh Mesh to remove
  9823. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9824. * @returns the Shadow Generator itself
  9825. */
  9826. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9827. /**
  9828. * Controls the extent to which the shadows fade out at the edge of the frustum
  9829. */
  9830. frustumEdgeFalloff: number;
  9831. protected _light: IShadowLight;
  9832. /**
  9833. * Returns the associated light object.
  9834. * @returns the light generating the shadow
  9835. */
  9836. getLight(): IShadowLight;
  9837. /**
  9838. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9839. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9840. * It might on the other hand introduce peter panning.
  9841. */
  9842. forceBackFacesOnly: boolean;
  9843. protected _scene: Scene;
  9844. protected _lightDirection: Vector3;
  9845. protected _effect: Effect;
  9846. protected _viewMatrix: Matrix;
  9847. protected _projectionMatrix: Matrix;
  9848. protected _transformMatrix: Matrix;
  9849. protected _cachedPosition: Vector3;
  9850. protected _cachedDirection: Vector3;
  9851. protected _cachedDefines: string;
  9852. protected _currentRenderID: number;
  9853. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9854. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9855. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9856. protected _blurPostProcesses: PostProcess[];
  9857. protected _mapSize: number;
  9858. protected _currentFaceIndex: number;
  9859. protected _currentFaceIndexCache: number;
  9860. protected _textureType: number;
  9861. protected _defaultTextureMatrix: Matrix;
  9862. protected _storedUniqueId: Nullable<number>;
  9863. /** @hidden */
  9864. static _SceneComponentInitialization: (scene: Scene) => void;
  9865. /**
  9866. * Creates a ShadowGenerator object.
  9867. * A ShadowGenerator is the required tool to use the shadows.
  9868. * Each light casting shadows needs to use its own ShadowGenerator.
  9869. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9870. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9871. * @param light The light object generating the shadows.
  9872. * @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.
  9873. */
  9874. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9875. protected _initializeGenerator(): void;
  9876. protected _createTargetRenderTexture(): void;
  9877. protected _initializeShadowMap(): void;
  9878. protected _initializeBlurRTTAndPostProcesses(): void;
  9879. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  9880. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  9881. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  9882. protected _applyFilterValues(): void;
  9883. /**
  9884. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9885. * @param onCompiled Callback triggered at the and of the effects compilation
  9886. * @param options Sets of optional options forcing the compilation with different modes
  9887. */
  9888. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9889. useInstances: boolean;
  9890. }>): void;
  9891. /**
  9892. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9893. * @param options Sets of optional options forcing the compilation with different modes
  9894. * @returns A promise that resolves when the compilation completes
  9895. */
  9896. forceCompilationAsync(options?: Partial<{
  9897. useInstances: boolean;
  9898. }>): Promise<void>;
  9899. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  9900. /**
  9901. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9902. * @param subMesh The submesh we want to render in the shadow map
  9903. * @param useInstances Defines wether will draw in the map using instances
  9904. * @returns true if ready otherwise, false
  9905. */
  9906. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9907. /**
  9908. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9909. * @param defines Defines of the material we want to update
  9910. * @param lightIndex Index of the light in the enabled light list of the material
  9911. */
  9912. prepareDefines(defines: any, lightIndex: number): void;
  9913. /**
  9914. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9915. * defined in the generator but impacting the effect).
  9916. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9917. * @param effect The effect we are binfing the information for
  9918. */
  9919. bindShadowLight(lightIndex: string, effect: Effect): void;
  9920. /**
  9921. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9922. * (eq to shadow prjection matrix * light transform matrix)
  9923. * @returns The transform matrix used to create the shadow map
  9924. */
  9925. getTransformMatrix(): Matrix;
  9926. /**
  9927. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9928. * Cube and 2D textures for instance.
  9929. */
  9930. recreateShadowMap(): void;
  9931. protected _disposeBlurPostProcesses(): void;
  9932. protected _disposeRTTandPostProcesses(): void;
  9933. /**
  9934. * Disposes the ShadowGenerator.
  9935. * Returns nothing.
  9936. */
  9937. dispose(): void;
  9938. /**
  9939. * Serializes the shadow generator setup to a json object.
  9940. * @returns The serialized JSON object
  9941. */
  9942. serialize(): any;
  9943. /**
  9944. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9945. * @param parsedShadowGenerator The JSON object to parse
  9946. * @param scene The scene to create the shadow map for
  9947. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  9948. * @returns The parsed shadow generator
  9949. */
  9950. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  9951. }
  9952. }
  9953. declare module BABYLON {
  9954. /**
  9955. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9956. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9957. * 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.
  9958. */
  9959. export abstract class Light extends Node {
  9960. /**
  9961. * Falloff Default: light is falling off following the material specification:
  9962. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9963. */
  9964. static readonly FALLOFF_DEFAULT: number;
  9965. /**
  9966. * Falloff Physical: light is falling off following the inverse squared distance law.
  9967. */
  9968. static readonly FALLOFF_PHYSICAL: number;
  9969. /**
  9970. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9971. * to enhance interoperability with other engines.
  9972. */
  9973. static readonly FALLOFF_GLTF: number;
  9974. /**
  9975. * Falloff Standard: light is falling off like in the standard material
  9976. * to enhance interoperability with other materials.
  9977. */
  9978. static readonly FALLOFF_STANDARD: number;
  9979. /**
  9980. * If every light affecting the material is in this lightmapMode,
  9981. * material.lightmapTexture adds or multiplies
  9982. * (depends on material.useLightmapAsShadowmap)
  9983. * after every other light calculations.
  9984. */
  9985. static readonly LIGHTMAP_DEFAULT: number;
  9986. /**
  9987. * material.lightmapTexture as only diffuse lighting from this light
  9988. * adds only specular lighting from this light
  9989. * adds dynamic shadows
  9990. */
  9991. static readonly LIGHTMAP_SPECULAR: number;
  9992. /**
  9993. * material.lightmapTexture as only lighting
  9994. * no light calculation from this light
  9995. * only adds dynamic shadows from this light
  9996. */
  9997. static readonly LIGHTMAP_SHADOWSONLY: number;
  9998. /**
  9999. * Each light type uses the default quantity according to its type:
  10000. * point/spot lights use luminous intensity
  10001. * directional lights use illuminance
  10002. */
  10003. static readonly INTENSITYMODE_AUTOMATIC: number;
  10004. /**
  10005. * lumen (lm)
  10006. */
  10007. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10008. /**
  10009. * candela (lm/sr)
  10010. */
  10011. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10012. /**
  10013. * lux (lm/m^2)
  10014. */
  10015. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10016. /**
  10017. * nit (cd/m^2)
  10018. */
  10019. static readonly INTENSITYMODE_LUMINANCE: number;
  10020. /**
  10021. * Light type const id of the point light.
  10022. */
  10023. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10024. /**
  10025. * Light type const id of the directional light.
  10026. */
  10027. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10028. /**
  10029. * Light type const id of the spot light.
  10030. */
  10031. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10032. /**
  10033. * Light type const id of the hemispheric light.
  10034. */
  10035. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10036. /**
  10037. * Diffuse gives the basic color to an object.
  10038. */
  10039. diffuse: Color3;
  10040. /**
  10041. * Specular produces a highlight color on an object.
  10042. * Note: This is note affecting PBR materials.
  10043. */
  10044. specular: Color3;
  10045. /**
  10046. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10047. * falling off base on range or angle.
  10048. * This can be set to any values in Light.FALLOFF_x.
  10049. *
  10050. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10051. * other types of materials.
  10052. */
  10053. falloffType: number;
  10054. /**
  10055. * Strength of the light.
  10056. * Note: By default it is define in the framework own unit.
  10057. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10058. */
  10059. intensity: number;
  10060. private _range;
  10061. protected _inverseSquaredRange: number;
  10062. /**
  10063. * Defines how far from the source the light is impacting in scene units.
  10064. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10065. */
  10066. get range(): number;
  10067. /**
  10068. * Defines how far from the source the light is impacting in scene units.
  10069. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10070. */
  10071. set range(value: number);
  10072. /**
  10073. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10074. * of light.
  10075. */
  10076. private _photometricScale;
  10077. private _intensityMode;
  10078. /**
  10079. * Gets the photometric scale used to interpret the intensity.
  10080. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10081. */
  10082. get intensityMode(): number;
  10083. /**
  10084. * Sets the photometric scale used to interpret the intensity.
  10085. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10086. */
  10087. set intensityMode(value: number);
  10088. private _radius;
  10089. /**
  10090. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10091. */
  10092. get radius(): number;
  10093. /**
  10094. * sets the light radius used by PBR Materials to simulate soft area lights.
  10095. */
  10096. set radius(value: number);
  10097. private _renderPriority;
  10098. /**
  10099. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10100. * exceeding the number allowed of the materials.
  10101. */
  10102. renderPriority: number;
  10103. private _shadowEnabled;
  10104. /**
  10105. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10106. * the current shadow generator.
  10107. */
  10108. get shadowEnabled(): boolean;
  10109. /**
  10110. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10111. * the current shadow generator.
  10112. */
  10113. set shadowEnabled(value: boolean);
  10114. private _includedOnlyMeshes;
  10115. /**
  10116. * Gets the only meshes impacted by this light.
  10117. */
  10118. get includedOnlyMeshes(): AbstractMesh[];
  10119. /**
  10120. * Sets the only meshes impacted by this light.
  10121. */
  10122. set includedOnlyMeshes(value: AbstractMesh[]);
  10123. private _excludedMeshes;
  10124. /**
  10125. * Gets the meshes not impacted by this light.
  10126. */
  10127. get excludedMeshes(): AbstractMesh[];
  10128. /**
  10129. * Sets the meshes not impacted by this light.
  10130. */
  10131. set excludedMeshes(value: AbstractMesh[]);
  10132. private _excludeWithLayerMask;
  10133. /**
  10134. * Gets the layer id use to find what meshes are not impacted by the light.
  10135. * Inactive if 0
  10136. */
  10137. get excludeWithLayerMask(): number;
  10138. /**
  10139. * Sets the layer id use to find what meshes are not impacted by the light.
  10140. * Inactive if 0
  10141. */
  10142. set excludeWithLayerMask(value: number);
  10143. private _includeOnlyWithLayerMask;
  10144. /**
  10145. * Gets the layer id use to find what meshes are impacted by the light.
  10146. * Inactive if 0
  10147. */
  10148. get includeOnlyWithLayerMask(): number;
  10149. /**
  10150. * Sets the layer id use to find what meshes are impacted by the light.
  10151. * Inactive if 0
  10152. */
  10153. set includeOnlyWithLayerMask(value: number);
  10154. private _lightmapMode;
  10155. /**
  10156. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10157. */
  10158. get lightmapMode(): number;
  10159. /**
  10160. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10161. */
  10162. set lightmapMode(value: number);
  10163. /**
  10164. * Shadow generator associted to the light.
  10165. * @hidden Internal use only.
  10166. */
  10167. _shadowGenerator: Nullable<IShadowGenerator>;
  10168. /**
  10169. * @hidden Internal use only.
  10170. */
  10171. _excludedMeshesIds: string[];
  10172. /**
  10173. * @hidden Internal use only.
  10174. */
  10175. _includedOnlyMeshesIds: string[];
  10176. /**
  10177. * The current light unifom buffer.
  10178. * @hidden Internal use only.
  10179. */
  10180. _uniformBuffer: UniformBuffer;
  10181. /** @hidden */
  10182. _renderId: number;
  10183. /**
  10184. * Creates a Light object in the scene.
  10185. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10186. * @param name The firendly name of the light
  10187. * @param scene The scene the light belongs too
  10188. */
  10189. constructor(name: string, scene: Scene);
  10190. protected abstract _buildUniformLayout(): void;
  10191. /**
  10192. * Sets the passed Effect "effect" with the Light information.
  10193. * @param effect The effect to update
  10194. * @param lightIndex The index of the light in the effect to update
  10195. * @returns The light
  10196. */
  10197. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10198. /**
  10199. * Sets the passed Effect "effect" with the Light textures.
  10200. * @param effect The effect to update
  10201. * @param lightIndex The index of the light in the effect to update
  10202. * @returns The light
  10203. */
  10204. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10205. /**
  10206. * Binds the lights information from the scene to the effect for the given mesh.
  10207. * @param lightIndex Light index
  10208. * @param scene The scene where the light belongs to
  10209. * @param effect The effect we are binding the data to
  10210. * @param useSpecular Defines if specular is supported
  10211. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10212. */
  10213. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10214. /**
  10215. * Sets the passed Effect "effect" with the Light information.
  10216. * @param effect The effect to update
  10217. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10218. * @returns The light
  10219. */
  10220. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10221. /**
  10222. * Returns the string "Light".
  10223. * @returns the class name
  10224. */
  10225. getClassName(): string;
  10226. /** @hidden */
  10227. readonly _isLight: boolean;
  10228. /**
  10229. * Converts the light information to a readable string for debug purpose.
  10230. * @param fullDetails Supports for multiple levels of logging within scene loading
  10231. * @returns the human readable light info
  10232. */
  10233. toString(fullDetails?: boolean): string;
  10234. /** @hidden */
  10235. protected _syncParentEnabledState(): void;
  10236. /**
  10237. * Set the enabled state of this node.
  10238. * @param value - the new enabled state
  10239. */
  10240. setEnabled(value: boolean): void;
  10241. /**
  10242. * Returns the Light associated shadow generator if any.
  10243. * @return the associated shadow generator.
  10244. */
  10245. getShadowGenerator(): Nullable<IShadowGenerator>;
  10246. /**
  10247. * Returns a Vector3, the absolute light position in the World.
  10248. * @returns the world space position of the light
  10249. */
  10250. getAbsolutePosition(): Vector3;
  10251. /**
  10252. * Specifies if the light will affect the passed mesh.
  10253. * @param mesh The mesh to test against the light
  10254. * @return true the mesh is affected otherwise, false.
  10255. */
  10256. canAffectMesh(mesh: AbstractMesh): boolean;
  10257. /**
  10258. * Sort function to order lights for rendering.
  10259. * @param a First Light object to compare to second.
  10260. * @param b Second Light object to compare first.
  10261. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10262. */
  10263. static CompareLightsPriority(a: Light, b: Light): number;
  10264. /**
  10265. * Releases resources associated with this node.
  10266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10268. */
  10269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10270. /**
  10271. * Returns the light type ID (integer).
  10272. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10273. */
  10274. getTypeID(): number;
  10275. /**
  10276. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10277. * @returns the scaled intensity in intensity mode unit
  10278. */
  10279. getScaledIntensity(): number;
  10280. /**
  10281. * Returns a new Light object, named "name", from the current one.
  10282. * @param name The name of the cloned light
  10283. * @returns the new created light
  10284. */
  10285. clone(name: string): Nullable<Light>;
  10286. /**
  10287. * Serializes the current light into a Serialization object.
  10288. * @returns the serialized object.
  10289. */
  10290. serialize(): any;
  10291. /**
  10292. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10293. * This new light is named "name" and added to the passed scene.
  10294. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10295. * @param name The friendly name of the light
  10296. * @param scene The scene the new light will belong to
  10297. * @returns the constructor function
  10298. */
  10299. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10300. /**
  10301. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10302. * @param parsedLight The JSON representation of the light
  10303. * @param scene The scene to create the parsed light in
  10304. * @returns the created light after parsing
  10305. */
  10306. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10307. private _hookArrayForExcluded;
  10308. private _hookArrayForIncludedOnly;
  10309. private _resyncMeshes;
  10310. /**
  10311. * Forces the meshes to update their light related information in their rendering used effects
  10312. * @hidden Internal Use Only
  10313. */
  10314. _markMeshesAsLightDirty(): void;
  10315. /**
  10316. * Recomputes the cached photometric scale if needed.
  10317. */
  10318. private _computePhotometricScale;
  10319. /**
  10320. * Returns the Photometric Scale according to the light type and intensity mode.
  10321. */
  10322. private _getPhotometricScale;
  10323. /**
  10324. * Reorder the light in the scene according to their defined priority.
  10325. * @hidden Internal Use Only
  10326. */
  10327. _reorderLightsInScene(): void;
  10328. /**
  10329. * Prepares the list of defines specific to the light type.
  10330. * @param defines the list of defines
  10331. * @param lightIndex defines the index of the light for the effect
  10332. */
  10333. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10334. }
  10335. }
  10336. declare module BABYLON {
  10337. /**
  10338. * Interface used to define Action
  10339. */
  10340. export interface IAction {
  10341. /**
  10342. * Trigger for the action
  10343. */
  10344. trigger: number;
  10345. /** Options of the trigger */
  10346. triggerOptions: any;
  10347. /**
  10348. * Gets the trigger parameters
  10349. * @returns the trigger parameters
  10350. */
  10351. getTriggerParameter(): any;
  10352. /**
  10353. * Internal only - executes current action event
  10354. * @hidden
  10355. */
  10356. _executeCurrent(evt?: ActionEvent): void;
  10357. /**
  10358. * Serialize placeholder for child classes
  10359. * @param parent of child
  10360. * @returns the serialized object
  10361. */
  10362. serialize(parent: any): any;
  10363. /**
  10364. * Internal only
  10365. * @hidden
  10366. */
  10367. _prepare(): void;
  10368. /**
  10369. * Internal only - manager for action
  10370. * @hidden
  10371. */
  10372. _actionManager: AbstractActionManager;
  10373. /**
  10374. * Adds action to chain of actions, may be a DoNothingAction
  10375. * @param action defines the next action to execute
  10376. * @returns The action passed in
  10377. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10378. */
  10379. then(action: IAction): IAction;
  10380. }
  10381. /**
  10382. * The action to be carried out following a trigger
  10383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10384. */
  10385. export class Action implements IAction {
  10386. /** the trigger, with or without parameters, for the action */
  10387. triggerOptions: any;
  10388. /**
  10389. * Trigger for the action
  10390. */
  10391. trigger: number;
  10392. /**
  10393. * Internal only - manager for action
  10394. * @hidden
  10395. */
  10396. _actionManager: ActionManager;
  10397. private _nextActiveAction;
  10398. private _child;
  10399. private _condition?;
  10400. private _triggerParameter;
  10401. /**
  10402. * An event triggered prior to action being executed.
  10403. */
  10404. onBeforeExecuteObservable: Observable<Action>;
  10405. /**
  10406. * Creates a new Action
  10407. * @param triggerOptions the trigger, with or without parameters, for the action
  10408. * @param condition an optional determinant of action
  10409. */
  10410. constructor(
  10411. /** the trigger, with or without parameters, for the action */
  10412. triggerOptions: any, condition?: Condition);
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. _prepare(): void;
  10418. /**
  10419. * Gets the trigger parameters
  10420. * @returns the trigger parameters
  10421. */
  10422. getTriggerParameter(): any;
  10423. /**
  10424. * Internal only - executes current action event
  10425. * @hidden
  10426. */
  10427. _executeCurrent(evt?: ActionEvent): void;
  10428. /**
  10429. * Execute placeholder for child classes
  10430. * @param evt optional action event
  10431. */
  10432. execute(evt?: ActionEvent): void;
  10433. /**
  10434. * Skips to next active action
  10435. */
  10436. skipToNextActiveAction(): void;
  10437. /**
  10438. * Adds action to chain of actions, may be a DoNothingAction
  10439. * @param action defines the next action to execute
  10440. * @returns The action passed in
  10441. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10442. */
  10443. then(action: Action): Action;
  10444. /**
  10445. * Internal only
  10446. * @hidden
  10447. */
  10448. _getProperty(propertyPath: string): string;
  10449. /**
  10450. * Internal only
  10451. * @hidden
  10452. */
  10453. _getEffectiveTarget(target: any, propertyPath: string): any;
  10454. /**
  10455. * Serialize placeholder for child classes
  10456. * @param parent of child
  10457. * @returns the serialized object
  10458. */
  10459. serialize(parent: any): any;
  10460. /**
  10461. * Internal only called by serialize
  10462. * @hidden
  10463. */
  10464. protected _serialize(serializedAction: any, parent?: any): any;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. static _SerializeValueAsString: (value: any) => string;
  10470. /**
  10471. * Internal only
  10472. * @hidden
  10473. */
  10474. static _GetTargetProperty: (target: Node | Scene) => {
  10475. name: string;
  10476. targetType: string;
  10477. value: string;
  10478. };
  10479. }
  10480. }
  10481. declare module BABYLON {
  10482. /**
  10483. * A Condition applied to an Action
  10484. */
  10485. export class Condition {
  10486. /**
  10487. * Internal only - manager for action
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. _evaluationId: number;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _currentResult: boolean;
  10501. /**
  10502. * Creates a new Condition
  10503. * @param actionManager the manager of the action the condition is applied to
  10504. */
  10505. constructor(actionManager: ActionManager);
  10506. /**
  10507. * Check if the current condition is valid
  10508. * @returns a boolean
  10509. */
  10510. isValid(): boolean;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. _getProperty(propertyPath: string): string;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. _getEffectiveTarget(target: any, propertyPath: string): any;
  10521. /**
  10522. * Serialize placeholder for child classes
  10523. * @returns the serialized object
  10524. */
  10525. serialize(): any;
  10526. /**
  10527. * Internal only
  10528. * @hidden
  10529. */
  10530. protected _serialize(serializedCondition: any): any;
  10531. }
  10532. /**
  10533. * Defines specific conditional operators as extensions of Condition
  10534. */
  10535. export class ValueCondition extends Condition {
  10536. /** path to specify the property of the target the conditional operator uses */
  10537. propertyPath: string;
  10538. /** the value compared by the conditional operator against the current value of the property */
  10539. value: any;
  10540. /** the conditional operator, default ValueCondition.IsEqual */
  10541. operator: number;
  10542. /**
  10543. * Internal only
  10544. * @hidden
  10545. */
  10546. private static _IsEqual;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private static _IsDifferent;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private static _IsGreater;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private static _IsLesser;
  10562. /**
  10563. * returns the number for IsEqual
  10564. */
  10565. static get IsEqual(): number;
  10566. /**
  10567. * Returns the number for IsDifferent
  10568. */
  10569. static get IsDifferent(): number;
  10570. /**
  10571. * Returns the number for IsGreater
  10572. */
  10573. static get IsGreater(): number;
  10574. /**
  10575. * Returns the number for IsLesser
  10576. */
  10577. static get IsLesser(): number;
  10578. /**
  10579. * Internal only The action manager for the condition
  10580. * @hidden
  10581. */
  10582. _actionManager: ActionManager;
  10583. /**
  10584. * Internal only
  10585. * @hidden
  10586. */
  10587. private _target;
  10588. /**
  10589. * Internal only
  10590. * @hidden
  10591. */
  10592. private _effectiveTarget;
  10593. /**
  10594. * Internal only
  10595. * @hidden
  10596. */
  10597. private _property;
  10598. /**
  10599. * Creates a new ValueCondition
  10600. * @param actionManager manager for the action the condition applies to
  10601. * @param target for the action
  10602. * @param propertyPath path to specify the property of the target the conditional operator uses
  10603. * @param value the value compared by the conditional operator against the current value of the property
  10604. * @param operator the conditional operator, default ValueCondition.IsEqual
  10605. */
  10606. constructor(actionManager: ActionManager, target: any,
  10607. /** path to specify the property of the target the conditional operator uses */
  10608. propertyPath: string,
  10609. /** the value compared by the conditional operator against the current value of the property */
  10610. value: any,
  10611. /** the conditional operator, default ValueCondition.IsEqual */
  10612. operator?: number);
  10613. /**
  10614. * Compares the given value with the property value for the specified conditional operator
  10615. * @returns the result of the comparison
  10616. */
  10617. isValid(): boolean;
  10618. /**
  10619. * Serialize the ValueCondition into a JSON compatible object
  10620. * @returns serialization object
  10621. */
  10622. serialize(): any;
  10623. /**
  10624. * Gets the name of the conditional operator for the ValueCondition
  10625. * @param operator the conditional operator
  10626. * @returns the name
  10627. */
  10628. static GetOperatorName(operator: number): string;
  10629. }
  10630. /**
  10631. * Defines a predicate condition as an extension of Condition
  10632. */
  10633. export class PredicateCondition extends Condition {
  10634. /** defines the predicate function used to validate the condition */
  10635. predicate: () => boolean;
  10636. /**
  10637. * Internal only - manager for action
  10638. * @hidden
  10639. */
  10640. _actionManager: ActionManager;
  10641. /**
  10642. * Creates a new PredicateCondition
  10643. * @param actionManager manager for the action the condition applies to
  10644. * @param predicate defines the predicate function used to validate the condition
  10645. */
  10646. constructor(actionManager: ActionManager,
  10647. /** defines the predicate function used to validate the condition */
  10648. predicate: () => boolean);
  10649. /**
  10650. * @returns the validity of the predicate condition
  10651. */
  10652. isValid(): boolean;
  10653. }
  10654. /**
  10655. * Defines a state condition as an extension of Condition
  10656. */
  10657. export class StateCondition extends Condition {
  10658. /** Value to compare with target state */
  10659. value: string;
  10660. /**
  10661. * Internal only - manager for action
  10662. * @hidden
  10663. */
  10664. _actionManager: ActionManager;
  10665. /**
  10666. * Internal only
  10667. * @hidden
  10668. */
  10669. private _target;
  10670. /**
  10671. * Creates a new StateCondition
  10672. * @param actionManager manager for the action the condition applies to
  10673. * @param target of the condition
  10674. * @param value to compare with target state
  10675. */
  10676. constructor(actionManager: ActionManager, target: any,
  10677. /** Value to compare with target state */
  10678. value: string);
  10679. /**
  10680. * Gets a boolean indicating if the current condition is met
  10681. * @returns the validity of the state
  10682. */
  10683. isValid(): boolean;
  10684. /**
  10685. * Serialize the StateCondition into a JSON compatible object
  10686. * @returns serialization object
  10687. */
  10688. serialize(): any;
  10689. }
  10690. }
  10691. declare module BABYLON {
  10692. /**
  10693. * This defines an action responsible to toggle a boolean once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SwitchBooleanAction extends Action {
  10697. /**
  10698. * The path to the boolean property in the target object
  10699. */
  10700. propertyPath: string;
  10701. private _target;
  10702. private _effectiveTarget;
  10703. private _property;
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param target defines the object containing the boolean
  10708. * @param propertyPath defines the path to the boolean property in the target object
  10709. * @param condition defines the trigger related conditions
  10710. */
  10711. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10712. /** @hidden */
  10713. _prepare(): void;
  10714. /**
  10715. * Execute the action toggle the boolean value.
  10716. */
  10717. execute(): void;
  10718. /**
  10719. * Serializes the actions and its related information.
  10720. * @param parent defines the object to serialize in
  10721. * @returns the serialized object
  10722. */
  10723. serialize(parent: any): any;
  10724. }
  10725. /**
  10726. * This defines an action responsible to set a the state field of the target
  10727. * to a desired value once triggered.
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10729. */
  10730. export class SetStateAction extends Action {
  10731. /**
  10732. * The value to store in the state field.
  10733. */
  10734. value: string;
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the object containing the state property
  10740. * @param value defines the value to store in the state field
  10741. * @param condition defines the trigger related conditions
  10742. */
  10743. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10744. /**
  10745. * Execute the action and store the value on the target state property.
  10746. */
  10747. execute(): void;
  10748. /**
  10749. * Serializes the actions and its related information.
  10750. * @param parent defines the object to serialize in
  10751. * @returns the serialized object
  10752. */
  10753. serialize(parent: any): any;
  10754. }
  10755. /**
  10756. * This defines an action responsible to set a property of the target
  10757. * to a desired value once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class SetValueAction extends Action {
  10761. /**
  10762. * The path of the property to set in the target.
  10763. */
  10764. propertyPath: string;
  10765. /**
  10766. * The value to set in the property
  10767. */
  10768. value: any;
  10769. private _target;
  10770. private _effectiveTarget;
  10771. private _property;
  10772. /**
  10773. * Instantiate the action
  10774. * @param triggerOptions defines the trigger options
  10775. * @param target defines the object containing the property
  10776. * @param propertyPath defines the path of the property to set in the target
  10777. * @param value defines the value to set in the property
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10781. /** @hidden */
  10782. _prepare(): void;
  10783. /**
  10784. * Execute the action and set the targetted property to the desired value.
  10785. */
  10786. execute(): void;
  10787. /**
  10788. * Serializes the actions and its related information.
  10789. * @param parent defines the object to serialize in
  10790. * @returns the serialized object
  10791. */
  10792. serialize(parent: any): any;
  10793. }
  10794. /**
  10795. * This defines an action responsible to increment the target value
  10796. * to a desired value once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class IncrementValueAction extends Action {
  10800. /**
  10801. * The path of the property to increment in the target.
  10802. */
  10803. propertyPath: string;
  10804. /**
  10805. * The value we should increment the property by.
  10806. */
  10807. value: any;
  10808. private _target;
  10809. private _effectiveTarget;
  10810. private _property;
  10811. /**
  10812. * Instantiate the action
  10813. * @param triggerOptions defines the trigger options
  10814. * @param target defines the object containing the property
  10815. * @param propertyPath defines the path of the property to increment in the target
  10816. * @param value defines the value value we should increment the property by
  10817. * @param condition defines the trigger related conditions
  10818. */
  10819. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10820. /** @hidden */
  10821. _prepare(): void;
  10822. /**
  10823. * Execute the action and increment the target of the value amount.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to start an animation once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class PlayAnimationAction extends Action {
  10838. /**
  10839. * Where the animation should start (animation frame)
  10840. */
  10841. from: number;
  10842. /**
  10843. * Where the animation should stop (animation frame)
  10844. */
  10845. to: number;
  10846. /**
  10847. * Define if the animation should loop or stop after the first play.
  10848. */
  10849. loop?: boolean;
  10850. private _target;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the target animation or animation name
  10855. * @param from defines from where the animation should start (animation frame)
  10856. * @param end defines where the animation should stop (animation frame)
  10857. * @param loop defines if the animation should loop or stop after the first play
  10858. * @param condition defines the trigger related conditions
  10859. */
  10860. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10861. /** @hidden */
  10862. _prepare(): void;
  10863. /**
  10864. * Execute the action and play the animation.
  10865. */
  10866. execute(): void;
  10867. /**
  10868. * Serializes the actions and its related information.
  10869. * @param parent defines the object to serialize in
  10870. * @returns the serialized object
  10871. */
  10872. serialize(parent: any): any;
  10873. }
  10874. /**
  10875. * This defines an action responsible to stop an animation once triggered.
  10876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10877. */
  10878. export class StopAnimationAction extends Action {
  10879. private _target;
  10880. /**
  10881. * Instantiate the action
  10882. * @param triggerOptions defines the trigger options
  10883. * @param target defines the target animation or animation name
  10884. * @param condition defines the trigger related conditions
  10885. */
  10886. constructor(triggerOptions: any, target: any, condition?: Condition);
  10887. /** @hidden */
  10888. _prepare(): void;
  10889. /**
  10890. * Execute the action and stop the animation.
  10891. */
  10892. execute(): void;
  10893. /**
  10894. * Serializes the actions and its related information.
  10895. * @param parent defines the object to serialize in
  10896. * @returns the serialized object
  10897. */
  10898. serialize(parent: any): any;
  10899. }
  10900. /**
  10901. * This defines an action responsible that does nothing once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class DoNothingAction extends Action {
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param condition defines the trigger related conditions
  10909. */
  10910. constructor(triggerOptions?: any, condition?: Condition);
  10911. /**
  10912. * Execute the action and do nothing.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to trigger several actions once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class CombineAction extends Action {
  10927. /**
  10928. * The list of aggregated animations to run.
  10929. */
  10930. children: Action[];
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param children defines the list of aggregated animations to run
  10935. * @param condition defines the trigger related conditions
  10936. */
  10937. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10938. /** @hidden */
  10939. _prepare(): void;
  10940. /**
  10941. * Execute the action and executes all the aggregated actions.
  10942. */
  10943. execute(evt: ActionEvent): void;
  10944. /**
  10945. * Serializes the actions and its related information.
  10946. * @param parent defines the object to serialize in
  10947. * @returns the serialized object
  10948. */
  10949. serialize(parent: any): any;
  10950. }
  10951. /**
  10952. * This defines an action responsible to run code (external event) once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class ExecuteCodeAction extends Action {
  10956. /**
  10957. * The callback function to run.
  10958. */
  10959. func: (evt: ActionEvent) => void;
  10960. /**
  10961. * Instantiate the action
  10962. * @param triggerOptions defines the trigger options
  10963. * @param func defines the callback function to run
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10967. /**
  10968. * Execute the action and run the attached code.
  10969. */
  10970. execute(evt: ActionEvent): void;
  10971. }
  10972. /**
  10973. * This defines an action responsible to set the parent property of the target once triggered.
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10975. */
  10976. export class SetParentAction extends Action {
  10977. private _parent;
  10978. private _target;
  10979. /**
  10980. * Instantiate the action
  10981. * @param triggerOptions defines the trigger options
  10982. * @param target defines the target containing the parent property
  10983. * @param parent defines from where the animation should start (animation frame)
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10987. /** @hidden */
  10988. _prepare(): void;
  10989. /**
  10990. * Execute the action and set the parent property.
  10991. */
  10992. execute(): void;
  10993. /**
  10994. * Serializes the actions and its related information.
  10995. * @param parent defines the object to serialize in
  10996. * @returns the serialized object
  10997. */
  10998. serialize(parent: any): any;
  10999. }
  11000. }
  11001. declare module BABYLON {
  11002. /**
  11003. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11004. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11006. */
  11007. export class ActionManager extends AbstractActionManager {
  11008. /**
  11009. * Nothing
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly NothingTrigger: number;
  11013. /**
  11014. * On pick
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnPickTrigger: number;
  11018. /**
  11019. * On left pick
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnLeftPickTrigger: number;
  11023. /**
  11024. * On right pick
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnRightPickTrigger: number;
  11028. /**
  11029. * On center pick
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnCenterPickTrigger: number;
  11033. /**
  11034. * On pick down
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnPickDownTrigger: number;
  11038. /**
  11039. * On double pick
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnDoublePickTrigger: number;
  11043. /**
  11044. * On pick up
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnPickUpTrigger: number;
  11048. /**
  11049. * On pick out.
  11050. * This trigger will only be raised if you also declared a OnPickDown
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnPickOutTrigger: number;
  11054. /**
  11055. * On long press
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnLongPressTrigger: number;
  11059. /**
  11060. * On pointer over
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPointerOverTrigger: number;
  11064. /**
  11065. * On pointer out
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnPointerOutTrigger: number;
  11069. /**
  11070. * On every frame
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnEveryFrameTrigger: number;
  11074. /**
  11075. * On intersection enter
  11076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11077. */
  11078. static readonly OnIntersectionEnterTrigger: number;
  11079. /**
  11080. * On intersection exit
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11082. */
  11083. static readonly OnIntersectionExitTrigger: number;
  11084. /**
  11085. * On key down
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11087. */
  11088. static readonly OnKeyDownTrigger: number;
  11089. /**
  11090. * On key up
  11091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11092. */
  11093. static readonly OnKeyUpTrigger: number;
  11094. private _scene;
  11095. /**
  11096. * Creates a new action manager
  11097. * @param scene defines the hosting scene
  11098. */
  11099. constructor(scene: Scene);
  11100. /**
  11101. * Releases all associated resources
  11102. */
  11103. dispose(): void;
  11104. /**
  11105. * Gets hosting scene
  11106. * @returns the hosting scene
  11107. */
  11108. getScene(): Scene;
  11109. /**
  11110. * Does this action manager handles actions of any of the given triggers
  11111. * @param triggers defines the triggers to be tested
  11112. * @return a boolean indicating whether one (or more) of the triggers is handled
  11113. */
  11114. hasSpecificTriggers(triggers: number[]): boolean;
  11115. /**
  11116. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11117. * speed.
  11118. * @param triggerA defines the trigger to be tested
  11119. * @param triggerB defines the trigger to be tested
  11120. * @return a boolean indicating whether one (or more) of the triggers is handled
  11121. */
  11122. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11123. /**
  11124. * Does this action manager handles actions of a given trigger
  11125. * @param trigger defines the trigger to be tested
  11126. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11127. * @return whether the trigger is handled
  11128. */
  11129. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11130. /**
  11131. * Does this action manager has pointer triggers
  11132. */
  11133. get hasPointerTriggers(): boolean;
  11134. /**
  11135. * Does this action manager has pick triggers
  11136. */
  11137. get hasPickTriggers(): boolean;
  11138. /**
  11139. * Registers an action to this action manager
  11140. * @param action defines the action to be registered
  11141. * @return the action amended (prepared) after registration
  11142. */
  11143. registerAction(action: IAction): Nullable<IAction>;
  11144. /**
  11145. * Unregisters an action to this action manager
  11146. * @param action defines the action to be unregistered
  11147. * @return a boolean indicating whether the action has been unregistered
  11148. */
  11149. unregisterAction(action: IAction): Boolean;
  11150. /**
  11151. * Process a specific trigger
  11152. * @param trigger defines the trigger to process
  11153. * @param evt defines the event details to be processed
  11154. */
  11155. processTrigger(trigger: number, evt?: IActionEvent): void;
  11156. /** @hidden */
  11157. _getEffectiveTarget(target: any, propertyPath: string): any;
  11158. /** @hidden */
  11159. _getProperty(propertyPath: string): string;
  11160. /**
  11161. * Serialize this manager to a JSON object
  11162. * @param name defines the property name to store this manager
  11163. * @returns a JSON representation of this manager
  11164. */
  11165. serialize(name: string): any;
  11166. /**
  11167. * Creates a new ActionManager from a JSON data
  11168. * @param parsedActions defines the JSON data to read from
  11169. * @param object defines the hosting mesh
  11170. * @param scene defines the hosting scene
  11171. */
  11172. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11173. /**
  11174. * Get a trigger name by index
  11175. * @param trigger defines the trigger index
  11176. * @returns a trigger name
  11177. */
  11178. static GetTriggerName(trigger: number): string;
  11179. }
  11180. }
  11181. declare module BABYLON {
  11182. /**
  11183. * Class representing a ray with position and direction
  11184. */
  11185. export class Ray {
  11186. /** origin point */
  11187. origin: Vector3;
  11188. /** direction */
  11189. direction: Vector3;
  11190. /** length of the ray */
  11191. length: number;
  11192. private static readonly TmpVector3;
  11193. private _tmpRay;
  11194. /**
  11195. * Creates a new ray
  11196. * @param origin origin point
  11197. * @param direction direction
  11198. * @param length length of the ray
  11199. */
  11200. constructor(
  11201. /** origin point */
  11202. origin: Vector3,
  11203. /** direction */
  11204. direction: Vector3,
  11205. /** length of the ray */
  11206. length?: number);
  11207. /**
  11208. * Checks if the ray intersects a box
  11209. * @param minimum bound of the box
  11210. * @param maximum bound of the box
  11211. * @param intersectionTreshold extra extend to be added to the box in all direction
  11212. * @returns if the box was hit
  11213. */
  11214. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11215. /**
  11216. * Checks if the ray intersects a box
  11217. * @param box the bounding box to check
  11218. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11219. * @returns if the box was hit
  11220. */
  11221. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11222. /**
  11223. * If the ray hits a sphere
  11224. * @param sphere the bounding sphere to check
  11225. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11226. * @returns true if it hits the sphere
  11227. */
  11228. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11229. /**
  11230. * If the ray hits a triange
  11231. * @param vertex0 triangle vertex
  11232. * @param vertex1 triangle vertex
  11233. * @param vertex2 triangle vertex
  11234. * @returns intersection information if hit
  11235. */
  11236. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11237. /**
  11238. * Checks if ray intersects a plane
  11239. * @param plane the plane to check
  11240. * @returns the distance away it was hit
  11241. */
  11242. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11243. /**
  11244. * Calculate the intercept of a ray on a given axis
  11245. * @param axis to check 'x' | 'y' | 'z'
  11246. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11247. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11248. */
  11249. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11250. /**
  11251. * Checks if ray intersects a mesh
  11252. * @param mesh the mesh to check
  11253. * @param fastCheck if only the bounding box should checked
  11254. * @returns picking info of the intersecton
  11255. */
  11256. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11257. /**
  11258. * Checks if ray intersects a mesh
  11259. * @param meshes the meshes to check
  11260. * @param fastCheck if only the bounding box should checked
  11261. * @param results array to store result in
  11262. * @returns Array of picking infos
  11263. */
  11264. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11265. private _comparePickingInfo;
  11266. private static smallnum;
  11267. private static rayl;
  11268. /**
  11269. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11270. * @param sega the first point of the segment to test the intersection against
  11271. * @param segb the second point of the segment to test the intersection against
  11272. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11273. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11274. */
  11275. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11276. /**
  11277. * Update the ray from viewport position
  11278. * @param x position
  11279. * @param y y position
  11280. * @param viewportWidth viewport width
  11281. * @param viewportHeight viewport height
  11282. * @param world world matrix
  11283. * @param view view matrix
  11284. * @param projection projection matrix
  11285. * @returns this ray updated
  11286. */
  11287. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11288. /**
  11289. * Creates a ray with origin and direction of 0,0,0
  11290. * @returns the new ray
  11291. */
  11292. static Zero(): Ray;
  11293. /**
  11294. * Creates a new ray from screen space and viewport
  11295. * @param x position
  11296. * @param y y position
  11297. * @param viewportWidth viewport width
  11298. * @param viewportHeight viewport height
  11299. * @param world world matrix
  11300. * @param view view matrix
  11301. * @param projection projection matrix
  11302. * @returns new ray
  11303. */
  11304. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11305. /**
  11306. * 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
  11307. * transformed to the given world matrix.
  11308. * @param origin The origin point
  11309. * @param end The end point
  11310. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11311. * @returns the new ray
  11312. */
  11313. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11314. /**
  11315. * Transforms a ray by a matrix
  11316. * @param ray ray to transform
  11317. * @param matrix matrix to apply
  11318. * @returns the resulting new ray
  11319. */
  11320. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11321. /**
  11322. * Transforms a ray by a matrix
  11323. * @param ray ray to transform
  11324. * @param matrix matrix to apply
  11325. * @param result ray to store result in
  11326. */
  11327. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11328. /**
  11329. * Unproject a ray from screen space to object space
  11330. * @param sourceX defines the screen space x coordinate to use
  11331. * @param sourceY defines the screen space y coordinate to use
  11332. * @param viewportWidth defines the current width of the viewport
  11333. * @param viewportHeight defines the current height of the viewport
  11334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11335. * @param view defines the view matrix to use
  11336. * @param projection defines the projection matrix to use
  11337. */
  11338. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11339. }
  11340. /**
  11341. * Type used to define predicate used to select faces when a mesh intersection is detected
  11342. */
  11343. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11344. interface Scene {
  11345. /** @hidden */
  11346. _tempPickingRay: Nullable<Ray>;
  11347. /** @hidden */
  11348. _cachedRayForTransform: Ray;
  11349. /** @hidden */
  11350. _pickWithRayInverseMatrix: Matrix;
  11351. /** @hidden */
  11352. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11353. /** @hidden */
  11354. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11355. }
  11356. }
  11357. declare module BABYLON {
  11358. /**
  11359. * Groups all the scene component constants in one place to ease maintenance.
  11360. * @hidden
  11361. */
  11362. export class SceneComponentConstants {
  11363. static readonly NAME_EFFECTLAYER: string;
  11364. static readonly NAME_LAYER: string;
  11365. static readonly NAME_LENSFLARESYSTEM: string;
  11366. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11367. static readonly NAME_PARTICLESYSTEM: string;
  11368. static readonly NAME_GAMEPAD: string;
  11369. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11370. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11371. static readonly NAME_DEPTHRENDERER: string;
  11372. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11373. static readonly NAME_SPRITE: string;
  11374. static readonly NAME_OUTLINERENDERER: string;
  11375. static readonly NAME_PROCEDURALTEXTURE: string;
  11376. static readonly NAME_SHADOWGENERATOR: string;
  11377. static readonly NAME_OCTREE: string;
  11378. static readonly NAME_PHYSICSENGINE: string;
  11379. static readonly NAME_AUDIO: string;
  11380. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11381. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11382. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11383. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11384. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11385. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11386. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11387. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11388. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11389. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11390. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11391. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11392. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11393. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11394. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11395. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11396. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11397. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11398. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11399. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11400. static readonly STEP_AFTERRENDER_AUDIO: number;
  11401. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11402. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11403. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11404. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11405. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11406. static readonly STEP_POINTERMOVE_SPRITE: number;
  11407. static readonly STEP_POINTERDOWN_SPRITE: number;
  11408. static readonly STEP_POINTERUP_SPRITE: number;
  11409. }
  11410. /**
  11411. * This represents a scene component.
  11412. *
  11413. * This is used to decouple the dependency the scene is having on the different workloads like
  11414. * layers, post processes...
  11415. */
  11416. export interface ISceneComponent {
  11417. /**
  11418. * The name of the component. Each component must have a unique name.
  11419. */
  11420. name: string;
  11421. /**
  11422. * The scene the component belongs to.
  11423. */
  11424. scene: Scene;
  11425. /**
  11426. * Register the component to one instance of a scene.
  11427. */
  11428. register(): void;
  11429. /**
  11430. * Rebuilds the elements related to this component in case of
  11431. * context lost for instance.
  11432. */
  11433. rebuild(): void;
  11434. /**
  11435. * Disposes the component and the associated ressources.
  11436. */
  11437. dispose(): void;
  11438. }
  11439. /**
  11440. * This represents a SERIALIZABLE scene component.
  11441. *
  11442. * This extends Scene Component to add Serialization methods on top.
  11443. */
  11444. export interface ISceneSerializableComponent extends ISceneComponent {
  11445. /**
  11446. * Adds all the elements from the container to the scene
  11447. * @param container the container holding the elements
  11448. */
  11449. addFromContainer(container: AbstractScene): void;
  11450. /**
  11451. * Removes all the elements in the container from the scene
  11452. * @param container contains the elements to remove
  11453. * @param dispose if the removed element should be disposed (default: false)
  11454. */
  11455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11456. /**
  11457. * Serializes the component data to the specified json object
  11458. * @param serializationObject The object to serialize to
  11459. */
  11460. serialize(serializationObject: any): void;
  11461. }
  11462. /**
  11463. * Strong typing of a Mesh related stage step action
  11464. */
  11465. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11466. /**
  11467. * Strong typing of a Evaluate Sub Mesh related stage step action
  11468. */
  11469. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11470. /**
  11471. * Strong typing of a Active Mesh related stage step action
  11472. */
  11473. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11474. /**
  11475. * Strong typing of a Camera related stage step action
  11476. */
  11477. export type CameraStageAction = (camera: Camera) => void;
  11478. /**
  11479. * Strong typing of a Camera Frame buffer related stage step action
  11480. */
  11481. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11482. /**
  11483. * Strong typing of a Render Target related stage step action
  11484. */
  11485. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11486. /**
  11487. * Strong typing of a RenderingGroup related stage step action
  11488. */
  11489. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11490. /**
  11491. * Strong typing of a Mesh Render related stage step action
  11492. */
  11493. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11494. /**
  11495. * Strong typing of a simple stage step action
  11496. */
  11497. export type SimpleStageAction = () => void;
  11498. /**
  11499. * Strong typing of a render target action.
  11500. */
  11501. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11502. /**
  11503. * Strong typing of a pointer move action.
  11504. */
  11505. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11506. /**
  11507. * Strong typing of a pointer up/down action.
  11508. */
  11509. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11510. /**
  11511. * Representation of a stage in the scene (Basically a list of ordered steps)
  11512. * @hidden
  11513. */
  11514. export class Stage<T extends Function> extends Array<{
  11515. index: number;
  11516. component: ISceneComponent;
  11517. action: T;
  11518. }> {
  11519. /**
  11520. * Hide ctor from the rest of the world.
  11521. * @param items The items to add.
  11522. */
  11523. private constructor();
  11524. /**
  11525. * Creates a new Stage.
  11526. * @returns A new instance of a Stage
  11527. */
  11528. static Create<T extends Function>(): Stage<T>;
  11529. /**
  11530. * Registers a step in an ordered way in the targeted stage.
  11531. * @param index Defines the position to register the step in
  11532. * @param component Defines the component attached to the step
  11533. * @param action Defines the action to launch during the step
  11534. */
  11535. registerStep(index: number, component: ISceneComponent, action: T): void;
  11536. /**
  11537. * Clears all the steps from the stage.
  11538. */
  11539. clear(): void;
  11540. }
  11541. }
  11542. declare module BABYLON {
  11543. interface Scene {
  11544. /** @hidden */
  11545. _pointerOverSprite: Nullable<Sprite>;
  11546. /** @hidden */
  11547. _pickedDownSprite: Nullable<Sprite>;
  11548. /** @hidden */
  11549. _tempSpritePickingRay: Nullable<Ray>;
  11550. /**
  11551. * All of the sprite managers added to this scene
  11552. * @see http://doc.babylonjs.com/babylon101/sprites
  11553. */
  11554. spriteManagers: Array<ISpriteManager>;
  11555. /**
  11556. * An event triggered when sprites rendering is about to start
  11557. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11558. */
  11559. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11560. /**
  11561. * An event triggered when sprites rendering is done
  11562. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11563. */
  11564. onAfterSpritesRenderingObservable: Observable<Scene>;
  11565. /** @hidden */
  11566. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11567. /** Launch a ray to try to pick a sprite in the scene
  11568. * @param x position on screen
  11569. * @param y position on screen
  11570. * @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
  11571. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11572. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11573. * @returns a PickingInfo
  11574. */
  11575. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11576. /** Use the given ray to pick a sprite in the scene
  11577. * @param ray The ray (in world space) to use to pick meshes
  11578. * @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
  11579. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11580. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11581. * @returns a PickingInfo
  11582. */
  11583. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11584. /** @hidden */
  11585. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11586. /** Launch a ray to try to pick sprites in the scene
  11587. * @param x position on screen
  11588. * @param y position on screen
  11589. * @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
  11590. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11591. * @returns a PickingInfo array
  11592. */
  11593. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11594. /** Use the given ray to pick sprites in the scene
  11595. * @param ray The ray (in world space) to use to pick meshes
  11596. * @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
  11597. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11598. * @returns a PickingInfo array
  11599. */
  11600. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11601. /**
  11602. * Force the sprite under the pointer
  11603. * @param sprite defines the sprite to use
  11604. */
  11605. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11606. /**
  11607. * Gets the sprite under the pointer
  11608. * @returns a Sprite or null if no sprite is under the pointer
  11609. */
  11610. getPointerOverSprite(): Nullable<Sprite>;
  11611. }
  11612. /**
  11613. * Defines the sprite scene component responsible to manage sprites
  11614. * in a given scene.
  11615. */
  11616. export class SpriteSceneComponent implements ISceneComponent {
  11617. /**
  11618. * The component name helpfull to identify the component in the list of scene components.
  11619. */
  11620. readonly name: string;
  11621. /**
  11622. * The scene the component belongs to.
  11623. */
  11624. scene: Scene;
  11625. /** @hidden */
  11626. private _spritePredicate;
  11627. /**
  11628. * Creates a new instance of the component for the given scene
  11629. * @param scene Defines the scene to register the component in
  11630. */
  11631. constructor(scene: Scene);
  11632. /**
  11633. * Registers the component in a given scene
  11634. */
  11635. register(): void;
  11636. /**
  11637. * Rebuilds the elements related to this component in case of
  11638. * context lost for instance.
  11639. */
  11640. rebuild(): void;
  11641. /**
  11642. * Disposes the component and the associated ressources.
  11643. */
  11644. dispose(): void;
  11645. private _pickSpriteButKeepRay;
  11646. private _pointerMove;
  11647. private _pointerDown;
  11648. private _pointerUp;
  11649. }
  11650. }
  11651. declare module BABYLON {
  11652. /** @hidden */
  11653. export var fogFragmentDeclaration: {
  11654. name: string;
  11655. shader: string;
  11656. };
  11657. }
  11658. declare module BABYLON {
  11659. /** @hidden */
  11660. export var fogFragment: {
  11661. name: string;
  11662. shader: string;
  11663. };
  11664. }
  11665. declare module BABYLON {
  11666. /** @hidden */
  11667. export var spritesPixelShader: {
  11668. name: string;
  11669. shader: string;
  11670. };
  11671. }
  11672. declare module BABYLON {
  11673. /** @hidden */
  11674. export var fogVertexDeclaration: {
  11675. name: string;
  11676. shader: string;
  11677. };
  11678. }
  11679. declare module BABYLON {
  11680. /** @hidden */
  11681. export var spritesVertexShader: {
  11682. name: string;
  11683. shader: string;
  11684. };
  11685. }
  11686. declare module BABYLON {
  11687. /**
  11688. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11689. */
  11690. export interface ISpriteManager extends IDisposable {
  11691. /**
  11692. * Restricts the camera to viewing objects with the same layerMask.
  11693. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11694. */
  11695. layerMask: number;
  11696. /**
  11697. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11698. */
  11699. isPickable: boolean;
  11700. /**
  11701. * Specifies the rendering group id for this mesh (0 by default)
  11702. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11703. */
  11704. renderingGroupId: number;
  11705. /**
  11706. * Defines the list of sprites managed by the manager.
  11707. */
  11708. sprites: Array<Sprite>;
  11709. /**
  11710. * Tests the intersection of a sprite with a specific ray.
  11711. * @param ray The ray we are sending to test the collision
  11712. * @param camera The camera space we are sending rays in
  11713. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11714. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11715. * @returns picking info or null.
  11716. */
  11717. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11718. /**
  11719. * Intersects the sprites with a ray
  11720. * @param ray defines the ray to intersect with
  11721. * @param camera defines the current active camera
  11722. * @param predicate defines a predicate used to select candidate sprites
  11723. * @returns null if no hit or a PickingInfo array
  11724. */
  11725. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11726. /**
  11727. * Renders the list of sprites on screen.
  11728. */
  11729. render(): void;
  11730. }
  11731. /**
  11732. * Class used to manage multiple sprites on the same spritesheet
  11733. * @see http://doc.babylonjs.com/babylon101/sprites
  11734. */
  11735. export class SpriteManager implements ISpriteManager {
  11736. /** defines the manager's name */
  11737. name: string;
  11738. /** Gets the list of sprites */
  11739. sprites: Sprite[];
  11740. /** Gets or sets the rendering group id (0 by default) */
  11741. renderingGroupId: number;
  11742. /** Gets or sets camera layer mask */
  11743. layerMask: number;
  11744. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11745. fogEnabled: boolean;
  11746. /** Gets or sets a boolean indicating if the sprites are pickable */
  11747. isPickable: boolean;
  11748. /** Defines the default width of a cell in the spritesheet */
  11749. cellWidth: number;
  11750. /** Defines the default height of a cell in the spritesheet */
  11751. cellHeight: number;
  11752. /** Associative array from JSON sprite data file */
  11753. private _cellData;
  11754. /** Array of sprite names from JSON sprite data file */
  11755. private _spriteMap;
  11756. /** True when packed cell data from JSON file is ready*/
  11757. private _packedAndReady;
  11758. /**
  11759. * An event triggered when the manager is disposed.
  11760. */
  11761. onDisposeObservable: Observable<SpriteManager>;
  11762. private _onDisposeObserver;
  11763. /**
  11764. * Callback called when the manager is disposed
  11765. */
  11766. set onDispose(callback: () => void);
  11767. private _capacity;
  11768. private _fromPacked;
  11769. private _spriteTexture;
  11770. private _epsilon;
  11771. private _scene;
  11772. private _vertexData;
  11773. private _buffer;
  11774. private _vertexBuffers;
  11775. private _indexBuffer;
  11776. private _effectBase;
  11777. private _effectFog;
  11778. /**
  11779. * Gets or sets the spritesheet texture
  11780. */
  11781. get texture(): Texture;
  11782. set texture(value: Texture);
  11783. /**
  11784. * Creates a new sprite manager
  11785. * @param name defines the manager's name
  11786. * @param imgUrl defines the sprite sheet url
  11787. * @param capacity defines the maximum allowed number of sprites
  11788. * @param cellSize defines the size of a sprite cell
  11789. * @param scene defines the hosting scene
  11790. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11791. * @param samplingMode defines the smapling mode to use with spritesheet
  11792. * @param fromPacked set to false; do not alter
  11793. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11794. */
  11795. constructor(
  11796. /** defines the manager's name */
  11797. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11798. private _makePacked;
  11799. private _appendSpriteVertex;
  11800. /**
  11801. * Intersects the sprites with a ray
  11802. * @param ray defines the ray to intersect with
  11803. * @param camera defines the current active camera
  11804. * @param predicate defines a predicate used to select candidate sprites
  11805. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11806. * @returns null if no hit or a PickingInfo
  11807. */
  11808. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11809. /**
  11810. * Intersects the sprites with a ray
  11811. * @param ray defines the ray to intersect with
  11812. * @param camera defines the current active camera
  11813. * @param predicate defines a predicate used to select candidate sprites
  11814. * @returns null if no hit or a PickingInfo array
  11815. */
  11816. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11817. /**
  11818. * Render all child sprites
  11819. */
  11820. render(): void;
  11821. /**
  11822. * Release associated resources
  11823. */
  11824. dispose(): void;
  11825. }
  11826. }
  11827. declare module BABYLON {
  11828. /**
  11829. * Class used to represent a sprite
  11830. * @see http://doc.babylonjs.com/babylon101/sprites
  11831. */
  11832. export class Sprite {
  11833. /** defines the name */
  11834. name: string;
  11835. /** Gets or sets the current world position */
  11836. position: Vector3;
  11837. /** Gets or sets the main color */
  11838. color: Color4;
  11839. /** Gets or sets the width */
  11840. width: number;
  11841. /** Gets or sets the height */
  11842. height: number;
  11843. /** Gets or sets rotation angle */
  11844. angle: number;
  11845. /** Gets or sets the cell index in the sprite sheet */
  11846. cellIndex: number;
  11847. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11848. cellRef: string;
  11849. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11850. invertU: number;
  11851. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11852. invertV: number;
  11853. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11854. disposeWhenFinishedAnimating: boolean;
  11855. /** Gets the list of attached animations */
  11856. animations: Animation[];
  11857. /** Gets or sets a boolean indicating if the sprite can be picked */
  11858. isPickable: boolean;
  11859. /**
  11860. * Gets or sets the associated action manager
  11861. */
  11862. actionManager: Nullable<ActionManager>;
  11863. private _animationStarted;
  11864. private _loopAnimation;
  11865. private _fromIndex;
  11866. private _toIndex;
  11867. private _delay;
  11868. private _direction;
  11869. private _manager;
  11870. private _time;
  11871. private _onAnimationEnd;
  11872. /**
  11873. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11874. */
  11875. isVisible: boolean;
  11876. /**
  11877. * Gets or sets the sprite size
  11878. */
  11879. get size(): number;
  11880. set size(value: number);
  11881. /**
  11882. * Creates a new Sprite
  11883. * @param name defines the name
  11884. * @param manager defines the manager
  11885. */
  11886. constructor(
  11887. /** defines the name */
  11888. name: string, manager: ISpriteManager);
  11889. /**
  11890. * Starts an animation
  11891. * @param from defines the initial key
  11892. * @param to defines the end key
  11893. * @param loop defines if the animation must loop
  11894. * @param delay defines the start delay (in ms)
  11895. * @param onAnimationEnd defines a callback to call when animation ends
  11896. */
  11897. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11898. /** Stops current animation (if any) */
  11899. stopAnimation(): void;
  11900. /** @hidden */
  11901. _animate(deltaTime: number): void;
  11902. /** Release associated resources */
  11903. dispose(): void;
  11904. }
  11905. }
  11906. declare module BABYLON {
  11907. /**
  11908. * Information about the result of picking within a scene
  11909. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11910. */
  11911. export class PickingInfo {
  11912. /** @hidden */
  11913. _pickingUnavailable: boolean;
  11914. /**
  11915. * If the pick collided with an object
  11916. */
  11917. hit: boolean;
  11918. /**
  11919. * Distance away where the pick collided
  11920. */
  11921. distance: number;
  11922. /**
  11923. * The location of pick collision
  11924. */
  11925. pickedPoint: Nullable<Vector3>;
  11926. /**
  11927. * The mesh corresponding the the pick collision
  11928. */
  11929. pickedMesh: Nullable<AbstractMesh>;
  11930. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11931. bu: number;
  11932. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11933. bv: number;
  11934. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11935. faceId: number;
  11936. /** Id of the the submesh that was picked */
  11937. subMeshId: number;
  11938. /** If a sprite was picked, this will be the sprite the pick collided with */
  11939. pickedSprite: Nullable<Sprite>;
  11940. /**
  11941. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11942. */
  11943. originMesh: Nullable<AbstractMesh>;
  11944. /**
  11945. * The ray that was used to perform the picking.
  11946. */
  11947. ray: Nullable<Ray>;
  11948. /**
  11949. * Gets the normal correspodning to the face the pick collided with
  11950. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11951. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11952. * @returns The normal correspodning to the face the pick collided with
  11953. */
  11954. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11955. /**
  11956. * Gets the texture coordinates of where the pick occured
  11957. * @returns the vector containing the coordnates of the texture
  11958. */
  11959. getTextureCoordinates(): Nullable<Vector2>;
  11960. }
  11961. }
  11962. declare module BABYLON {
  11963. /**
  11964. * Gather the list of pointer event types as constants.
  11965. */
  11966. export class PointerEventTypes {
  11967. /**
  11968. * 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.
  11969. */
  11970. static readonly POINTERDOWN: number;
  11971. /**
  11972. * The pointerup event is fired when a pointer is no longer active.
  11973. */
  11974. static readonly POINTERUP: number;
  11975. /**
  11976. * The pointermove event is fired when a pointer changes coordinates.
  11977. */
  11978. static readonly POINTERMOVE: number;
  11979. /**
  11980. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11981. */
  11982. static readonly POINTERWHEEL: number;
  11983. /**
  11984. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11985. */
  11986. static readonly POINTERPICK: number;
  11987. /**
  11988. * The pointertap event is fired when a the object has been touched and released without drag.
  11989. */
  11990. static readonly POINTERTAP: number;
  11991. /**
  11992. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11993. */
  11994. static readonly POINTERDOUBLETAP: number;
  11995. }
  11996. /**
  11997. * Base class of pointer info types.
  11998. */
  11999. export class PointerInfoBase {
  12000. /**
  12001. * Defines the type of event (PointerEventTypes)
  12002. */
  12003. type: number;
  12004. /**
  12005. * Defines the related dom event
  12006. */
  12007. event: PointerEvent | MouseWheelEvent;
  12008. /**
  12009. * Instantiates the base class of pointers info.
  12010. * @param type Defines the type of event (PointerEventTypes)
  12011. * @param event Defines the related dom event
  12012. */
  12013. constructor(
  12014. /**
  12015. * Defines the type of event (PointerEventTypes)
  12016. */
  12017. type: number,
  12018. /**
  12019. * Defines the related dom event
  12020. */
  12021. event: PointerEvent | MouseWheelEvent);
  12022. }
  12023. /**
  12024. * This class is used to store pointer related info for the onPrePointerObservable event.
  12025. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12026. */
  12027. export class PointerInfoPre extends PointerInfoBase {
  12028. /**
  12029. * Ray from a pointer if availible (eg. 6dof controller)
  12030. */
  12031. ray: Nullable<Ray>;
  12032. /**
  12033. * Defines the local position of the pointer on the canvas.
  12034. */
  12035. localPosition: Vector2;
  12036. /**
  12037. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12038. */
  12039. skipOnPointerObservable: boolean;
  12040. /**
  12041. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12042. * @param type Defines the type of event (PointerEventTypes)
  12043. * @param event Defines the related dom event
  12044. * @param localX Defines the local x coordinates of the pointer when the event occured
  12045. * @param localY Defines the local y coordinates of the pointer when the event occured
  12046. */
  12047. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12048. }
  12049. /**
  12050. * This type contains all the data related to a pointer event in Babylon.js.
  12051. * 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.
  12052. */
  12053. export class PointerInfo extends PointerInfoBase {
  12054. /**
  12055. * Defines the picking info associated to the info (if any)\
  12056. */
  12057. pickInfo: Nullable<PickingInfo>;
  12058. /**
  12059. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12060. * @param type Defines the type of event (PointerEventTypes)
  12061. * @param event Defines the related dom event
  12062. * @param pickInfo Defines the picking info associated to the info (if any)\
  12063. */
  12064. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12065. /**
  12066. * Defines the picking info associated to the info (if any)\
  12067. */
  12068. pickInfo: Nullable<PickingInfo>);
  12069. }
  12070. /**
  12071. * Data relating to a touch event on the screen.
  12072. */
  12073. export interface PointerTouch {
  12074. /**
  12075. * X coordinate of touch.
  12076. */
  12077. x: number;
  12078. /**
  12079. * Y coordinate of touch.
  12080. */
  12081. y: number;
  12082. /**
  12083. * Id of touch. Unique for each finger.
  12084. */
  12085. pointerId: number;
  12086. /**
  12087. * Event type passed from DOM.
  12088. */
  12089. type: any;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Manage the mouse inputs to control the movement of a free camera.
  12095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12096. */
  12097. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12098. /**
  12099. * Define if touch is enabled in the mouse input
  12100. */
  12101. touchEnabled: boolean;
  12102. /**
  12103. * Defines the camera the input is attached to.
  12104. */
  12105. camera: FreeCamera;
  12106. /**
  12107. * Defines the buttons associated with the input to handle camera move.
  12108. */
  12109. buttons: number[];
  12110. /**
  12111. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12112. */
  12113. angularSensibility: number;
  12114. private _pointerInput;
  12115. private _onMouseMove;
  12116. private _observer;
  12117. private previousPosition;
  12118. /**
  12119. * Observable for when a pointer move event occurs containing the move offset
  12120. */
  12121. onPointerMovedObservable: Observable<{
  12122. offsetX: number;
  12123. offsetY: number;
  12124. }>;
  12125. /**
  12126. * @hidden
  12127. * If the camera should be rotated automatically based on pointer movement
  12128. */
  12129. _allowCameraRotation: boolean;
  12130. /**
  12131. * Manage the mouse inputs to control the movement of a free camera.
  12132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12133. * @param touchEnabled Defines if touch is enabled or not
  12134. */
  12135. constructor(
  12136. /**
  12137. * Define if touch is enabled in the mouse input
  12138. */
  12139. touchEnabled?: boolean);
  12140. /**
  12141. * Attach the input controls to a specific dom element to get the input from.
  12142. * @param element Defines the element the controls should be listened from
  12143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12144. */
  12145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12146. /**
  12147. * Called on JS contextmenu event.
  12148. * Override this method to provide functionality.
  12149. */
  12150. protected onContextMenu(evt: PointerEvent): void;
  12151. /**
  12152. * Detach the current controls from the specified dom element.
  12153. * @param element Defines the element to stop listening the inputs from
  12154. */
  12155. detachControl(element: Nullable<HTMLElement>): void;
  12156. /**
  12157. * Gets the class name of the current intput.
  12158. * @returns the class name
  12159. */
  12160. getClassName(): string;
  12161. /**
  12162. * Get the friendly name associated with the input class.
  12163. * @returns the input friendly name
  12164. */
  12165. getSimpleName(): string;
  12166. }
  12167. }
  12168. declare module BABYLON {
  12169. /**
  12170. * Manage the touch inputs to control the movement of a free camera.
  12171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12172. */
  12173. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12174. /**
  12175. * Defines the camera the input is attached to.
  12176. */
  12177. camera: FreeCamera;
  12178. /**
  12179. * Defines the touch sensibility for rotation.
  12180. * The higher the faster.
  12181. */
  12182. touchAngularSensibility: number;
  12183. /**
  12184. * Defines the touch sensibility for move.
  12185. * The higher the faster.
  12186. */
  12187. touchMoveSensibility: number;
  12188. private _offsetX;
  12189. private _offsetY;
  12190. private _pointerPressed;
  12191. private _pointerInput;
  12192. private _observer;
  12193. private _onLostFocus;
  12194. /**
  12195. * Attach the input controls to a specific dom element to get the input from.
  12196. * @param element Defines the element the controls should be listened from
  12197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12198. */
  12199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12200. /**
  12201. * Detach the current controls from the specified dom element.
  12202. * @param element Defines the element to stop listening the inputs from
  12203. */
  12204. detachControl(element: Nullable<HTMLElement>): void;
  12205. /**
  12206. * Update the current camera state depending on the inputs that have been used this frame.
  12207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12208. */
  12209. checkInputs(): void;
  12210. /**
  12211. * Gets the class name of the current intput.
  12212. * @returns the class name
  12213. */
  12214. getClassName(): string;
  12215. /**
  12216. * Get the friendly name associated with the input class.
  12217. * @returns the input friendly name
  12218. */
  12219. getSimpleName(): string;
  12220. }
  12221. }
  12222. declare module BABYLON {
  12223. /**
  12224. * Default Inputs manager for the FreeCamera.
  12225. * It groups all the default supported inputs for ease of use.
  12226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12227. */
  12228. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12229. /**
  12230. * @hidden
  12231. */
  12232. _mouseInput: Nullable<FreeCameraMouseInput>;
  12233. /**
  12234. * Instantiates a new FreeCameraInputsManager.
  12235. * @param camera Defines the camera the inputs belong to
  12236. */
  12237. constructor(camera: FreeCamera);
  12238. /**
  12239. * Add keyboard input support to the input manager.
  12240. * @returns the current input manager
  12241. */
  12242. addKeyboard(): FreeCameraInputsManager;
  12243. /**
  12244. * Add mouse input support to the input manager.
  12245. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12246. * @returns the current input manager
  12247. */
  12248. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12249. /**
  12250. * Removes the mouse input support from the manager
  12251. * @returns the current input manager
  12252. */
  12253. removeMouse(): FreeCameraInputsManager;
  12254. /**
  12255. * Add touch input support to the input manager.
  12256. * @returns the current input manager
  12257. */
  12258. addTouch(): FreeCameraInputsManager;
  12259. /**
  12260. * Remove all attached input methods from a camera
  12261. */
  12262. clear(): void;
  12263. }
  12264. }
  12265. declare module BABYLON {
  12266. /**
  12267. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12268. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12270. */
  12271. export class FreeCamera extends TargetCamera {
  12272. /**
  12273. * Define the collision ellipsoid of the camera.
  12274. * This is helpful to simulate a camera body like the player body around the camera
  12275. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12276. */
  12277. ellipsoid: Vector3;
  12278. /**
  12279. * Define an offset for the position of the ellipsoid around the camera.
  12280. * This can be helpful to determine the center of the body near the gravity center of the body
  12281. * instead of its head.
  12282. */
  12283. ellipsoidOffset: Vector3;
  12284. /**
  12285. * Enable or disable collisions of the camera with the rest of the scene objects.
  12286. */
  12287. checkCollisions: boolean;
  12288. /**
  12289. * Enable or disable gravity on the camera.
  12290. */
  12291. applyGravity: boolean;
  12292. /**
  12293. * Define the input manager associated to the camera.
  12294. */
  12295. inputs: FreeCameraInputsManager;
  12296. /**
  12297. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12298. * Higher values reduce sensitivity.
  12299. */
  12300. get angularSensibility(): number;
  12301. /**
  12302. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12303. * Higher values reduce sensitivity.
  12304. */
  12305. set angularSensibility(value: number);
  12306. /**
  12307. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12308. */
  12309. get keysUp(): number[];
  12310. set keysUp(value: number[]);
  12311. /**
  12312. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12313. */
  12314. get keysDown(): number[];
  12315. set keysDown(value: number[]);
  12316. /**
  12317. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12318. */
  12319. get keysLeft(): number[];
  12320. set keysLeft(value: number[]);
  12321. /**
  12322. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12323. */
  12324. get keysRight(): number[];
  12325. set keysRight(value: number[]);
  12326. /**
  12327. * Event raised when the camera collide with a mesh in the scene.
  12328. */
  12329. onCollide: (collidedMesh: AbstractMesh) => void;
  12330. private _collider;
  12331. private _needMoveForGravity;
  12332. private _oldPosition;
  12333. private _diffPosition;
  12334. private _newPosition;
  12335. /** @hidden */
  12336. _localDirection: Vector3;
  12337. /** @hidden */
  12338. _transformedDirection: Vector3;
  12339. /**
  12340. * Instantiates a Free Camera.
  12341. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12342. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12344. * @param name Define the name of the camera in the scene
  12345. * @param position Define the start position of the camera in the scene
  12346. * @param scene Define the scene the camera belongs to
  12347. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12348. */
  12349. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12350. /**
  12351. * Attached controls to the current camera.
  12352. * @param element Defines the element the controls should be listened from
  12353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12354. */
  12355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12356. /**
  12357. * Detach the current controls from the camera.
  12358. * The camera will stop reacting to inputs.
  12359. * @param element Defines the element to stop listening the inputs from
  12360. */
  12361. detachControl(element: HTMLElement): void;
  12362. private _collisionMask;
  12363. /**
  12364. * Define a collision mask to limit the list of object the camera can collide with
  12365. */
  12366. get collisionMask(): number;
  12367. set collisionMask(mask: number);
  12368. /** @hidden */
  12369. _collideWithWorld(displacement: Vector3): void;
  12370. private _onCollisionPositionChange;
  12371. /** @hidden */
  12372. _checkInputs(): void;
  12373. /** @hidden */
  12374. _decideIfNeedsToMove(): boolean;
  12375. /** @hidden */
  12376. _updatePosition(): void;
  12377. /**
  12378. * Destroy the camera and release the current resources hold by it.
  12379. */
  12380. dispose(): void;
  12381. /**
  12382. * Gets the current object class name.
  12383. * @return the class name
  12384. */
  12385. getClassName(): string;
  12386. }
  12387. }
  12388. declare module BABYLON {
  12389. /**
  12390. * Represents a gamepad control stick position
  12391. */
  12392. export class StickValues {
  12393. /**
  12394. * The x component of the control stick
  12395. */
  12396. x: number;
  12397. /**
  12398. * The y component of the control stick
  12399. */
  12400. y: number;
  12401. /**
  12402. * Initializes the gamepad x and y control stick values
  12403. * @param x The x component of the gamepad control stick value
  12404. * @param y The y component of the gamepad control stick value
  12405. */
  12406. constructor(
  12407. /**
  12408. * The x component of the control stick
  12409. */
  12410. x: number,
  12411. /**
  12412. * The y component of the control stick
  12413. */
  12414. y: number);
  12415. }
  12416. /**
  12417. * An interface which manages callbacks for gamepad button changes
  12418. */
  12419. export interface GamepadButtonChanges {
  12420. /**
  12421. * Called when a gamepad has been changed
  12422. */
  12423. changed: boolean;
  12424. /**
  12425. * Called when a gamepad press event has been triggered
  12426. */
  12427. pressChanged: boolean;
  12428. /**
  12429. * Called when a touch event has been triggered
  12430. */
  12431. touchChanged: boolean;
  12432. /**
  12433. * Called when a value has changed
  12434. */
  12435. valueChanged: boolean;
  12436. }
  12437. /**
  12438. * Represents a gamepad
  12439. */
  12440. export class Gamepad {
  12441. /**
  12442. * The id of the gamepad
  12443. */
  12444. id: string;
  12445. /**
  12446. * The index of the gamepad
  12447. */
  12448. index: number;
  12449. /**
  12450. * The browser gamepad
  12451. */
  12452. browserGamepad: any;
  12453. /**
  12454. * Specifies what type of gamepad this represents
  12455. */
  12456. type: number;
  12457. private _leftStick;
  12458. private _rightStick;
  12459. /** @hidden */
  12460. _isConnected: boolean;
  12461. private _leftStickAxisX;
  12462. private _leftStickAxisY;
  12463. private _rightStickAxisX;
  12464. private _rightStickAxisY;
  12465. /**
  12466. * Triggered when the left control stick has been changed
  12467. */
  12468. private _onleftstickchanged;
  12469. /**
  12470. * Triggered when the right control stick has been changed
  12471. */
  12472. private _onrightstickchanged;
  12473. /**
  12474. * Represents a gamepad controller
  12475. */
  12476. static GAMEPAD: number;
  12477. /**
  12478. * Represents a generic controller
  12479. */
  12480. static GENERIC: number;
  12481. /**
  12482. * Represents an XBox controller
  12483. */
  12484. static XBOX: number;
  12485. /**
  12486. * Represents a pose-enabled controller
  12487. */
  12488. static POSE_ENABLED: number;
  12489. /**
  12490. * Represents an Dual Shock controller
  12491. */
  12492. static DUALSHOCK: number;
  12493. /**
  12494. * Specifies whether the left control stick should be Y-inverted
  12495. */
  12496. protected _invertLeftStickY: boolean;
  12497. /**
  12498. * Specifies if the gamepad has been connected
  12499. */
  12500. get isConnected(): boolean;
  12501. /**
  12502. * Initializes the gamepad
  12503. * @param id The id of the gamepad
  12504. * @param index The index of the gamepad
  12505. * @param browserGamepad The browser gamepad
  12506. * @param leftStickX The x component of the left joystick
  12507. * @param leftStickY The y component of the left joystick
  12508. * @param rightStickX The x component of the right joystick
  12509. * @param rightStickY The y component of the right joystick
  12510. */
  12511. constructor(
  12512. /**
  12513. * The id of the gamepad
  12514. */
  12515. id: string,
  12516. /**
  12517. * The index of the gamepad
  12518. */
  12519. index: number,
  12520. /**
  12521. * The browser gamepad
  12522. */
  12523. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12524. /**
  12525. * Callback triggered when the left joystick has changed
  12526. * @param callback
  12527. */
  12528. onleftstickchanged(callback: (values: StickValues) => void): void;
  12529. /**
  12530. * Callback triggered when the right joystick has changed
  12531. * @param callback
  12532. */
  12533. onrightstickchanged(callback: (values: StickValues) => void): void;
  12534. /**
  12535. * Gets the left joystick
  12536. */
  12537. get leftStick(): StickValues;
  12538. /**
  12539. * Sets the left joystick values
  12540. */
  12541. set leftStick(newValues: StickValues);
  12542. /**
  12543. * Gets the right joystick
  12544. */
  12545. get rightStick(): StickValues;
  12546. /**
  12547. * Sets the right joystick value
  12548. */
  12549. set rightStick(newValues: StickValues);
  12550. /**
  12551. * Updates the gamepad joystick positions
  12552. */
  12553. update(): void;
  12554. /**
  12555. * Disposes the gamepad
  12556. */
  12557. dispose(): void;
  12558. }
  12559. /**
  12560. * Represents a generic gamepad
  12561. */
  12562. export class GenericPad extends Gamepad {
  12563. private _buttons;
  12564. private _onbuttondown;
  12565. private _onbuttonup;
  12566. /**
  12567. * Observable triggered when a button has been pressed
  12568. */
  12569. onButtonDownObservable: Observable<number>;
  12570. /**
  12571. * Observable triggered when a button has been released
  12572. */
  12573. onButtonUpObservable: Observable<number>;
  12574. /**
  12575. * Callback triggered when a button has been pressed
  12576. * @param callback Called when a button has been pressed
  12577. */
  12578. onbuttondown(callback: (buttonPressed: number) => void): void;
  12579. /**
  12580. * Callback triggered when a button has been released
  12581. * @param callback Called when a button has been released
  12582. */
  12583. onbuttonup(callback: (buttonReleased: number) => void): void;
  12584. /**
  12585. * Initializes the generic gamepad
  12586. * @param id The id of the generic gamepad
  12587. * @param index The index of the generic gamepad
  12588. * @param browserGamepad The browser gamepad
  12589. */
  12590. constructor(id: string, index: number, browserGamepad: any);
  12591. private _setButtonValue;
  12592. /**
  12593. * Updates the generic gamepad
  12594. */
  12595. update(): void;
  12596. /**
  12597. * Disposes the generic gamepad
  12598. */
  12599. dispose(): void;
  12600. }
  12601. }
  12602. declare module BABYLON {
  12603. interface Engine {
  12604. /**
  12605. * Creates a raw texture
  12606. * @param data defines the data to store in the texture
  12607. * @param width defines the width of the texture
  12608. * @param height defines the height of the texture
  12609. * @param format defines the format of the data
  12610. * @param generateMipMaps defines if the engine should generate the mip levels
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12613. * @param compression defines the compression used (null by default)
  12614. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12615. * @returns the raw texture inside an InternalTexture
  12616. */
  12617. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12618. /**
  12619. * Update a raw texture
  12620. * @param texture defines the texture to update
  12621. * @param data defines the data to store in the texture
  12622. * @param format defines the format of the data
  12623. * @param invertY defines if data must be stored with Y axis inverted
  12624. */
  12625. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12626. /**
  12627. * Update a raw texture
  12628. * @param texture defines the texture to update
  12629. * @param data defines the data to store in the texture
  12630. * @param format defines the format of the data
  12631. * @param invertY defines if data must be stored with Y axis inverted
  12632. * @param compression defines the compression used (null by default)
  12633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12634. */
  12635. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12636. /**
  12637. * Creates a new raw cube texture
  12638. * @param data defines the array of data to use to create each face
  12639. * @param size defines the size of the textures
  12640. * @param format defines the format of the data
  12641. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12642. * @param generateMipMaps defines if the engine should generate the mip levels
  12643. * @param invertY defines if data must be stored with Y axis inverted
  12644. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12645. * @param compression defines the compression used (null by default)
  12646. * @returns the cube texture as an InternalTexture
  12647. */
  12648. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12649. /**
  12650. * Update a raw cube texture
  12651. * @param texture defines the texture to udpdate
  12652. * @param data defines the data to store
  12653. * @param format defines the data format
  12654. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12655. * @param invertY defines if data must be stored with Y axis inverted
  12656. */
  12657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12658. /**
  12659. * Update a raw cube texture
  12660. * @param texture defines the texture to udpdate
  12661. * @param data defines the data to store
  12662. * @param format defines the data format
  12663. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12664. * @param invertY defines if data must be stored with Y axis inverted
  12665. * @param compression defines the compression used (null by default)
  12666. */
  12667. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12668. /**
  12669. * Update a raw cube texture
  12670. * @param texture defines the texture to udpdate
  12671. * @param data defines the data to store
  12672. * @param format defines the data format
  12673. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12674. * @param invertY defines if data must be stored with Y axis inverted
  12675. * @param compression defines the compression used (null by default)
  12676. * @param level defines which level of the texture to update
  12677. */
  12678. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12679. /**
  12680. * Creates a new raw cube texture from a specified url
  12681. * @param url defines the url where the data is located
  12682. * @param scene defines the current scene
  12683. * @param size defines the size of the textures
  12684. * @param format defines the format of the data
  12685. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12686. * @param noMipmap defines if the engine should avoid generating the mip levels
  12687. * @param callback defines a callback used to extract texture data from loaded data
  12688. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12689. * @param onLoad defines a callback called when texture is loaded
  12690. * @param onError defines a callback called if there is an error
  12691. * @returns the cube texture as an InternalTexture
  12692. */
  12693. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12694. /**
  12695. * Creates a new raw cube texture from a specified url
  12696. * @param url defines the url where the data is located
  12697. * @param scene defines the current scene
  12698. * @param size defines the size of the textures
  12699. * @param format defines the format of the data
  12700. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12701. * @param noMipmap defines if the engine should avoid generating the mip levels
  12702. * @param callback defines a callback used to extract texture data from loaded data
  12703. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12704. * @param onLoad defines a callback called when texture is loaded
  12705. * @param onError defines a callback called if there is an error
  12706. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @returns the cube texture as an InternalTexture
  12709. */
  12710. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12711. /**
  12712. * Creates a new raw 3D texture
  12713. * @param data defines the data used to create the texture
  12714. * @param width defines the width of the texture
  12715. * @param height defines the height of the texture
  12716. * @param depth defines the depth of the texture
  12717. * @param format defines the format of the texture
  12718. * @param generateMipMaps defines if the engine must generate mip levels
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12721. * @param compression defines the compressed used (can be null)
  12722. * @param textureType defines the compressed used (can be null)
  12723. * @returns a new raw 3D texture (stored in an InternalTexture)
  12724. */
  12725. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12726. /**
  12727. * Update a raw 3D texture
  12728. * @param texture defines the texture to update
  12729. * @param data defines the data to store
  12730. * @param format defines the data format
  12731. * @param invertY defines if data must be stored with Y axis inverted
  12732. */
  12733. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12734. /**
  12735. * Update a raw 3D texture
  12736. * @param texture defines the texture to update
  12737. * @param data defines the data to store
  12738. * @param format defines the data format
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param compression defines the used compression (can be null)
  12741. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12742. */
  12743. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12744. /**
  12745. * Creates a new raw 2D array texture
  12746. * @param data defines the data used to create the texture
  12747. * @param width defines the width of the texture
  12748. * @param height defines the height of the texture
  12749. * @param depth defines the number of layers of the texture
  12750. * @param format defines the format of the texture
  12751. * @param generateMipMaps defines if the engine must generate mip levels
  12752. * @param invertY defines if data must be stored with Y axis inverted
  12753. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12754. * @param compression defines the compressed used (can be null)
  12755. * @param textureType defines the compressed used (can be null)
  12756. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12757. */
  12758. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12759. /**
  12760. * Update a raw 2D array texture
  12761. * @param texture defines the texture to update
  12762. * @param data defines the data to store
  12763. * @param format defines the data format
  12764. * @param invertY defines if data must be stored with Y axis inverted
  12765. */
  12766. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12767. /**
  12768. * Update a raw 2D array texture
  12769. * @param texture defines the texture to update
  12770. * @param data defines the data to store
  12771. * @param format defines the data format
  12772. * @param invertY defines if data must be stored with Y axis inverted
  12773. * @param compression defines the used compression (can be null)
  12774. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12775. */
  12776. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12777. }
  12778. }
  12779. declare module BABYLON {
  12780. /**
  12781. * Raw texture can help creating a texture directly from an array of data.
  12782. * This can be super useful if you either get the data from an uncompressed source or
  12783. * if you wish to create your texture pixel by pixel.
  12784. */
  12785. export class RawTexture extends Texture {
  12786. /**
  12787. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12788. */
  12789. format: number;
  12790. private _engine;
  12791. /**
  12792. * Instantiates a new RawTexture.
  12793. * Raw texture can help creating a texture directly from an array of data.
  12794. * This can be super useful if you either get the data from an uncompressed source or
  12795. * if you wish to create your texture pixel by pixel.
  12796. * @param data define the array of data to use to create the texture
  12797. * @param width define the width of the texture
  12798. * @param height define the height of the texture
  12799. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12800. * @param scene define the scene the texture belongs to
  12801. * @param generateMipMaps define whether mip maps should be generated or not
  12802. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12803. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12804. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12805. */
  12806. constructor(data: ArrayBufferView, width: number, height: number,
  12807. /**
  12808. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12809. */
  12810. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12811. /**
  12812. * Updates the texture underlying data.
  12813. * @param data Define the new data of the texture
  12814. */
  12815. update(data: ArrayBufferView): void;
  12816. /**
  12817. * Creates a luminance texture from some data.
  12818. * @param data Define the texture data
  12819. * @param width Define the width of the texture
  12820. * @param height Define the height of the texture
  12821. * @param scene Define the scene the texture belongs to
  12822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12825. * @returns the luminance texture
  12826. */
  12827. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12828. /**
  12829. * Creates a luminance alpha texture from some data.
  12830. * @param data Define the texture data
  12831. * @param width Define the width of the texture
  12832. * @param height Define the height of the texture
  12833. * @param scene Define the scene the texture belongs to
  12834. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12835. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12836. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12837. * @returns the luminance alpha texture
  12838. */
  12839. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12840. /**
  12841. * Creates an alpha texture from some data.
  12842. * @param data Define the texture data
  12843. * @param width Define the width of the texture
  12844. * @param height Define the height of the texture
  12845. * @param scene Define the scene the texture belongs to
  12846. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12847. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12848. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12849. * @returns the alpha texture
  12850. */
  12851. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12852. /**
  12853. * Creates a RGB texture from some data.
  12854. * @param data Define the texture data
  12855. * @param width Define the width of the texture
  12856. * @param height Define the height of the texture
  12857. * @param scene Define the scene the texture belongs to
  12858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12862. * @returns the RGB alpha texture
  12863. */
  12864. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12865. /**
  12866. * Creates a RGBA texture from some data.
  12867. * @param data Define the texture data
  12868. * @param width Define the width of the texture
  12869. * @param height Define the height of the texture
  12870. * @param scene Define the scene the texture belongs to
  12871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12874. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12875. * @returns the RGBA texture
  12876. */
  12877. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12878. /**
  12879. * Creates a R texture from some data.
  12880. * @param data Define the texture data
  12881. * @param width Define the width of the texture
  12882. * @param height Define the height of the texture
  12883. * @param scene Define the scene the texture belongs to
  12884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12887. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12888. * @returns the R texture
  12889. */
  12890. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12891. }
  12892. }
  12893. declare module BABYLON {
  12894. /**
  12895. * Interface for the size containing width and height
  12896. */
  12897. export interface ISize {
  12898. /**
  12899. * Width
  12900. */
  12901. width: number;
  12902. /**
  12903. * Heighht
  12904. */
  12905. height: number;
  12906. }
  12907. /**
  12908. * Size containing widht and height
  12909. */
  12910. export class Size implements ISize {
  12911. /**
  12912. * Width
  12913. */
  12914. width: number;
  12915. /**
  12916. * Height
  12917. */
  12918. height: number;
  12919. /**
  12920. * Creates a Size object from the given width and height (floats).
  12921. * @param width width of the new size
  12922. * @param height height of the new size
  12923. */
  12924. constructor(width: number, height: number);
  12925. /**
  12926. * Returns a string with the Size width and height
  12927. * @returns a string with the Size width and height
  12928. */
  12929. toString(): string;
  12930. /**
  12931. * "Size"
  12932. * @returns the string "Size"
  12933. */
  12934. getClassName(): string;
  12935. /**
  12936. * Returns the Size hash code.
  12937. * @returns a hash code for a unique width and height
  12938. */
  12939. getHashCode(): number;
  12940. /**
  12941. * Updates the current size from the given one.
  12942. * @param src the given size
  12943. */
  12944. copyFrom(src: Size): void;
  12945. /**
  12946. * Updates in place the current Size from the given floats.
  12947. * @param width width of the new size
  12948. * @param height height of the new size
  12949. * @returns the updated Size.
  12950. */
  12951. copyFromFloats(width: number, height: number): Size;
  12952. /**
  12953. * Updates in place the current Size from the given floats.
  12954. * @param width width to set
  12955. * @param height height to set
  12956. * @returns the updated Size.
  12957. */
  12958. set(width: number, height: number): Size;
  12959. /**
  12960. * Multiplies the width and height by numbers
  12961. * @param w factor to multiple the width by
  12962. * @param h factor to multiple the height by
  12963. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12964. */
  12965. multiplyByFloats(w: number, h: number): Size;
  12966. /**
  12967. * Clones the size
  12968. * @returns a new Size copied from the given one.
  12969. */
  12970. clone(): Size;
  12971. /**
  12972. * True if the current Size and the given one width and height are strictly equal.
  12973. * @param other the other size to compare against
  12974. * @returns True if the current Size and the given one width and height are strictly equal.
  12975. */
  12976. equals(other: Size): boolean;
  12977. /**
  12978. * The surface of the Size : width * height (float).
  12979. */
  12980. get surface(): number;
  12981. /**
  12982. * Create a new size of zero
  12983. * @returns a new Size set to (0.0, 0.0)
  12984. */
  12985. static Zero(): Size;
  12986. /**
  12987. * Sums the width and height of two sizes
  12988. * @param otherSize size to add to this size
  12989. * @returns a new Size set as the addition result of the current Size and the given one.
  12990. */
  12991. add(otherSize: Size): Size;
  12992. /**
  12993. * Subtracts the width and height of two
  12994. * @param otherSize size to subtract to this size
  12995. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12996. */
  12997. subtract(otherSize: Size): Size;
  12998. /**
  12999. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13000. * @param start starting size to lerp between
  13001. * @param end end size to lerp between
  13002. * @param amount amount to lerp between the start and end values
  13003. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13004. */
  13005. static Lerp(start: Size, end: Size, amount: number): Size;
  13006. }
  13007. }
  13008. declare module BABYLON {
  13009. /**
  13010. * Defines a runtime animation
  13011. */
  13012. export class RuntimeAnimation {
  13013. private _events;
  13014. /**
  13015. * The current frame of the runtime animation
  13016. */
  13017. private _currentFrame;
  13018. /**
  13019. * The animation used by the runtime animation
  13020. */
  13021. private _animation;
  13022. /**
  13023. * The target of the runtime animation
  13024. */
  13025. private _target;
  13026. /**
  13027. * The initiating animatable
  13028. */
  13029. private _host;
  13030. /**
  13031. * The original value of the runtime animation
  13032. */
  13033. private _originalValue;
  13034. /**
  13035. * The original blend value of the runtime animation
  13036. */
  13037. private _originalBlendValue;
  13038. /**
  13039. * The offsets cache of the runtime animation
  13040. */
  13041. private _offsetsCache;
  13042. /**
  13043. * The high limits cache of the runtime animation
  13044. */
  13045. private _highLimitsCache;
  13046. /**
  13047. * Specifies if the runtime animation has been stopped
  13048. */
  13049. private _stopped;
  13050. /**
  13051. * The blending factor of the runtime animation
  13052. */
  13053. private _blendingFactor;
  13054. /**
  13055. * The BabylonJS scene
  13056. */
  13057. private _scene;
  13058. /**
  13059. * The current value of the runtime animation
  13060. */
  13061. private _currentValue;
  13062. /** @hidden */
  13063. _animationState: _IAnimationState;
  13064. /**
  13065. * The active target of the runtime animation
  13066. */
  13067. private _activeTargets;
  13068. private _currentActiveTarget;
  13069. private _directTarget;
  13070. /**
  13071. * The target path of the runtime animation
  13072. */
  13073. private _targetPath;
  13074. /**
  13075. * The weight of the runtime animation
  13076. */
  13077. private _weight;
  13078. /**
  13079. * The ratio offset of the runtime animation
  13080. */
  13081. private _ratioOffset;
  13082. /**
  13083. * The previous delay of the runtime animation
  13084. */
  13085. private _previousDelay;
  13086. /**
  13087. * The previous ratio of the runtime animation
  13088. */
  13089. private _previousRatio;
  13090. private _enableBlending;
  13091. private _keys;
  13092. private _minFrame;
  13093. private _maxFrame;
  13094. private _minValue;
  13095. private _maxValue;
  13096. private _targetIsArray;
  13097. /**
  13098. * Gets the current frame of the runtime animation
  13099. */
  13100. get currentFrame(): number;
  13101. /**
  13102. * Gets the weight of the runtime animation
  13103. */
  13104. get weight(): number;
  13105. /**
  13106. * Gets the current value of the runtime animation
  13107. */
  13108. get currentValue(): any;
  13109. /**
  13110. * Gets the target path of the runtime animation
  13111. */
  13112. get targetPath(): string;
  13113. /**
  13114. * Gets the actual target of the runtime animation
  13115. */
  13116. get target(): any;
  13117. /** @hidden */
  13118. _onLoop: () => void;
  13119. /**
  13120. * Create a new RuntimeAnimation object
  13121. * @param target defines the target of the animation
  13122. * @param animation defines the source animation object
  13123. * @param scene defines the hosting scene
  13124. * @param host defines the initiating Animatable
  13125. */
  13126. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13127. private _preparePath;
  13128. /**
  13129. * Gets the animation from the runtime animation
  13130. */
  13131. get animation(): Animation;
  13132. /**
  13133. * Resets the runtime animation to the beginning
  13134. * @param restoreOriginal defines whether to restore the target property to the original value
  13135. */
  13136. reset(restoreOriginal?: boolean): void;
  13137. /**
  13138. * Specifies if the runtime animation is stopped
  13139. * @returns Boolean specifying if the runtime animation is stopped
  13140. */
  13141. isStopped(): boolean;
  13142. /**
  13143. * Disposes of the runtime animation
  13144. */
  13145. dispose(): void;
  13146. /**
  13147. * Apply the interpolated value to the target
  13148. * @param currentValue defines the value computed by the animation
  13149. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13150. */
  13151. setValue(currentValue: any, weight: number): void;
  13152. private _getOriginalValues;
  13153. private _setValue;
  13154. /**
  13155. * Gets the loop pmode of the runtime animation
  13156. * @returns Loop Mode
  13157. */
  13158. private _getCorrectLoopMode;
  13159. /**
  13160. * Move the current animation to a given frame
  13161. * @param frame defines the frame to move to
  13162. */
  13163. goToFrame(frame: number): void;
  13164. /**
  13165. * @hidden Internal use only
  13166. */
  13167. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13168. /**
  13169. * Execute the current animation
  13170. * @param delay defines the delay to add to the current frame
  13171. * @param from defines the lower bound of the animation range
  13172. * @param to defines the upper bound of the animation range
  13173. * @param loop defines if the current animation must loop
  13174. * @param speedRatio defines the current speed ratio
  13175. * @param weight defines the weight of the animation (default is -1 so no weight)
  13176. * @param onLoop optional callback called when animation loops
  13177. * @returns a boolean indicating if the animation is running
  13178. */
  13179. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13180. }
  13181. }
  13182. declare module BABYLON {
  13183. /**
  13184. * Class used to store an actual running animation
  13185. */
  13186. export class Animatable {
  13187. /** defines the target object */
  13188. target: any;
  13189. /** defines the starting frame number (default is 0) */
  13190. fromFrame: number;
  13191. /** defines the ending frame number (default is 100) */
  13192. toFrame: number;
  13193. /** defines if the animation must loop (default is false) */
  13194. loopAnimation: boolean;
  13195. /** defines a callback to call when animation ends if it is not looping */
  13196. onAnimationEnd?: (() => void) | null | undefined;
  13197. /** defines a callback to call when animation loops */
  13198. onAnimationLoop?: (() => void) | null | undefined;
  13199. private _localDelayOffset;
  13200. private _pausedDelay;
  13201. private _runtimeAnimations;
  13202. private _paused;
  13203. private _scene;
  13204. private _speedRatio;
  13205. private _weight;
  13206. private _syncRoot;
  13207. /**
  13208. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13209. * This will only apply for non looping animation (default is true)
  13210. */
  13211. disposeOnEnd: boolean;
  13212. /**
  13213. * Gets a boolean indicating if the animation has started
  13214. */
  13215. animationStarted: boolean;
  13216. /**
  13217. * Observer raised when the animation ends
  13218. */
  13219. onAnimationEndObservable: Observable<Animatable>;
  13220. /**
  13221. * Observer raised when the animation loops
  13222. */
  13223. onAnimationLoopObservable: Observable<Animatable>;
  13224. /**
  13225. * Gets the root Animatable used to synchronize and normalize animations
  13226. */
  13227. get syncRoot(): Nullable<Animatable>;
  13228. /**
  13229. * Gets the current frame of the first RuntimeAnimation
  13230. * Used to synchronize Animatables
  13231. */
  13232. get masterFrame(): number;
  13233. /**
  13234. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13235. */
  13236. get weight(): number;
  13237. set weight(value: number);
  13238. /**
  13239. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13240. */
  13241. get speedRatio(): number;
  13242. set speedRatio(value: number);
  13243. /**
  13244. * Creates a new Animatable
  13245. * @param scene defines the hosting scene
  13246. * @param target defines the target object
  13247. * @param fromFrame defines the starting frame number (default is 0)
  13248. * @param toFrame defines the ending frame number (default is 100)
  13249. * @param loopAnimation defines if the animation must loop (default is false)
  13250. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13251. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13252. * @param animations defines a group of animation to add to the new Animatable
  13253. * @param onAnimationLoop defines a callback to call when animation loops
  13254. */
  13255. constructor(scene: Scene,
  13256. /** defines the target object */
  13257. target: any,
  13258. /** defines the starting frame number (default is 0) */
  13259. fromFrame?: number,
  13260. /** defines the ending frame number (default is 100) */
  13261. toFrame?: number,
  13262. /** defines if the animation must loop (default is false) */
  13263. loopAnimation?: boolean, speedRatio?: number,
  13264. /** defines a callback to call when animation ends if it is not looping */
  13265. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13266. /** defines a callback to call when animation loops */
  13267. onAnimationLoop?: (() => void) | null | undefined);
  13268. /**
  13269. * Synchronize and normalize current Animatable with a source Animatable
  13270. * This is useful when using animation weights and when animations are not of the same length
  13271. * @param root defines the root Animatable to synchronize with
  13272. * @returns the current Animatable
  13273. */
  13274. syncWith(root: Animatable): Animatable;
  13275. /**
  13276. * Gets the list of runtime animations
  13277. * @returns an array of RuntimeAnimation
  13278. */
  13279. getAnimations(): RuntimeAnimation[];
  13280. /**
  13281. * Adds more animations to the current animatable
  13282. * @param target defines the target of the animations
  13283. * @param animations defines the new animations to add
  13284. */
  13285. appendAnimations(target: any, animations: Animation[]): void;
  13286. /**
  13287. * Gets the source animation for a specific property
  13288. * @param property defines the propertyu to look for
  13289. * @returns null or the source animation for the given property
  13290. */
  13291. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13292. /**
  13293. * Gets the runtime animation for a specific property
  13294. * @param property defines the propertyu to look for
  13295. * @returns null or the runtime animation for the given property
  13296. */
  13297. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13298. /**
  13299. * Resets the animatable to its original state
  13300. */
  13301. reset(): void;
  13302. /**
  13303. * Allows the animatable to blend with current running animations
  13304. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13305. * @param blendingSpeed defines the blending speed to use
  13306. */
  13307. enableBlending(blendingSpeed: number): void;
  13308. /**
  13309. * Disable animation blending
  13310. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13311. */
  13312. disableBlending(): void;
  13313. /**
  13314. * Jump directly to a given frame
  13315. * @param frame defines the frame to jump to
  13316. */
  13317. goToFrame(frame: number): void;
  13318. /**
  13319. * Pause the animation
  13320. */
  13321. pause(): void;
  13322. /**
  13323. * Restart the animation
  13324. */
  13325. restart(): void;
  13326. private _raiseOnAnimationEnd;
  13327. /**
  13328. * Stop and delete the current animation
  13329. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13330. * @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)
  13331. */
  13332. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13333. /**
  13334. * Wait asynchronously for the animation to end
  13335. * @returns a promise which will be fullfilled when the animation ends
  13336. */
  13337. waitAsync(): Promise<Animatable>;
  13338. /** @hidden */
  13339. _animate(delay: number): boolean;
  13340. }
  13341. interface Scene {
  13342. /** @hidden */
  13343. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13344. /** @hidden */
  13345. _processLateAnimationBindingsForMatrices(holder: {
  13346. totalWeight: number;
  13347. animations: RuntimeAnimation[];
  13348. originalValue: Matrix;
  13349. }): any;
  13350. /** @hidden */
  13351. _processLateAnimationBindingsForQuaternions(holder: {
  13352. totalWeight: number;
  13353. animations: RuntimeAnimation[];
  13354. originalValue: Quaternion;
  13355. }, refQuaternion: Quaternion): Quaternion;
  13356. /** @hidden */
  13357. _processLateAnimationBindings(): void;
  13358. /**
  13359. * Will start the animation sequence of a given target
  13360. * @param target defines the target
  13361. * @param from defines from which frame should animation start
  13362. * @param to defines until which frame should animation run.
  13363. * @param weight defines the weight to apply to the animation (1.0 by default)
  13364. * @param loop defines if the animation loops
  13365. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13366. * @param onAnimationEnd defines the function to be executed when the animation ends
  13367. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13368. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13369. * @param onAnimationLoop defines the callback to call when an animation loops
  13370. * @returns the animatable object created for this animation
  13371. */
  13372. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13373. /**
  13374. * Will start the animation sequence of a given target
  13375. * @param target defines the target
  13376. * @param from defines from which frame should animation start
  13377. * @param to defines until which frame should animation run.
  13378. * @param loop defines if the animation loops
  13379. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13380. * @param onAnimationEnd defines the function to be executed when the animation ends
  13381. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13382. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13383. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13384. * @param onAnimationLoop defines the callback to call when an animation loops
  13385. * @returns the animatable object created for this animation
  13386. */
  13387. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13388. /**
  13389. * Will start the animation sequence of a given target and its hierarchy
  13390. * @param target defines the target
  13391. * @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.
  13392. * @param from defines from which frame should animation start
  13393. * @param to defines until which frame should animation run.
  13394. * @param loop defines if the animation loops
  13395. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13396. * @param onAnimationEnd defines the function to be executed when the animation ends
  13397. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13398. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13399. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13400. * @param onAnimationLoop defines the callback to call when an animation loops
  13401. * @returns the list of created animatables
  13402. */
  13403. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13404. /**
  13405. * Begin a new animation on a given node
  13406. * @param target defines the target where the animation will take place
  13407. * @param animations defines the list of animations to start
  13408. * @param from defines the initial value
  13409. * @param to defines the final value
  13410. * @param loop defines if you want animation to loop (off by default)
  13411. * @param speedRatio defines the speed ratio to apply to all animations
  13412. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13413. * @param onAnimationLoop defines the callback to call when an animation loops
  13414. * @returns the list of created animatables
  13415. */
  13416. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13417. /**
  13418. * Begin a new animation on a given node and its hierarchy
  13419. * @param target defines the root node where the animation will take place
  13420. * @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.
  13421. * @param animations defines the list of animations to start
  13422. * @param from defines the initial value
  13423. * @param to defines the final value
  13424. * @param loop defines if you want animation to loop (off by default)
  13425. * @param speedRatio defines the speed ratio to apply to all animations
  13426. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13427. * @param onAnimationLoop defines the callback to call when an animation loops
  13428. * @returns the list of animatables created for all nodes
  13429. */
  13430. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13431. /**
  13432. * Gets the animatable associated with a specific target
  13433. * @param target defines the target of the animatable
  13434. * @returns the required animatable if found
  13435. */
  13436. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13437. /**
  13438. * Gets all animatables associated with a given target
  13439. * @param target defines the target to look animatables for
  13440. * @returns an array of Animatables
  13441. */
  13442. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13443. /**
  13444. * Stops and removes all animations that have been applied to the scene
  13445. */
  13446. stopAllAnimations(): void;
  13447. /**
  13448. * Gets the current delta time used by animation engine
  13449. */
  13450. deltaTime: number;
  13451. }
  13452. interface Bone {
  13453. /**
  13454. * Copy an animation range from another bone
  13455. * @param source defines the source bone
  13456. * @param rangeName defines the range name to copy
  13457. * @param frameOffset defines the frame offset
  13458. * @param rescaleAsRequired defines if rescaling must be applied if required
  13459. * @param skelDimensionsRatio defines the scaling ratio
  13460. * @returns true if operation was successful
  13461. */
  13462. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13463. }
  13464. }
  13465. declare module BABYLON {
  13466. /**
  13467. * Class used to override all child animations of a given target
  13468. */
  13469. export class AnimationPropertiesOverride {
  13470. /**
  13471. * Gets or sets a value indicating if animation blending must be used
  13472. */
  13473. enableBlending: boolean;
  13474. /**
  13475. * Gets or sets the blending speed to use when enableBlending is true
  13476. */
  13477. blendingSpeed: number;
  13478. /**
  13479. * Gets or sets the default loop mode to use
  13480. */
  13481. loopMode: number;
  13482. }
  13483. }
  13484. declare module BABYLON {
  13485. /**
  13486. * Class used to handle skinning animations
  13487. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13488. */
  13489. export class Skeleton implements IAnimatable {
  13490. /** defines the skeleton name */
  13491. name: string;
  13492. /** defines the skeleton Id */
  13493. id: string;
  13494. /**
  13495. * Defines the list of child bones
  13496. */
  13497. bones: Bone[];
  13498. /**
  13499. * Defines an estimate of the dimension of the skeleton at rest
  13500. */
  13501. dimensionsAtRest: Vector3;
  13502. /**
  13503. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13504. */
  13505. needInitialSkinMatrix: boolean;
  13506. /**
  13507. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13508. */
  13509. overrideMesh: Nullable<AbstractMesh>;
  13510. /**
  13511. * Gets the list of animations attached to this skeleton
  13512. */
  13513. animations: Array<Animation>;
  13514. private _scene;
  13515. private _isDirty;
  13516. private _transformMatrices;
  13517. private _transformMatrixTexture;
  13518. private _meshesWithPoseMatrix;
  13519. private _animatables;
  13520. private _identity;
  13521. private _synchronizedWithMesh;
  13522. private _ranges;
  13523. private _lastAbsoluteTransformsUpdateId;
  13524. private _canUseTextureForBones;
  13525. private _uniqueId;
  13526. /** @hidden */
  13527. _numBonesWithLinkedTransformNode: number;
  13528. /** @hidden */
  13529. _hasWaitingData: Nullable<boolean>;
  13530. /**
  13531. * Specifies if the skeleton should be serialized
  13532. */
  13533. doNotSerialize: boolean;
  13534. private _useTextureToStoreBoneMatrices;
  13535. /**
  13536. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13537. * Please note that this option is not available if the hardware does not support it
  13538. */
  13539. get useTextureToStoreBoneMatrices(): boolean;
  13540. set useTextureToStoreBoneMatrices(value: boolean);
  13541. private _animationPropertiesOverride;
  13542. /**
  13543. * Gets or sets the animation properties override
  13544. */
  13545. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13546. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13547. /**
  13548. * List of inspectable custom properties (used by the Inspector)
  13549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13550. */
  13551. inspectableCustomProperties: IInspectable[];
  13552. /**
  13553. * An observable triggered before computing the skeleton's matrices
  13554. */
  13555. onBeforeComputeObservable: Observable<Skeleton>;
  13556. /**
  13557. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13558. */
  13559. get isUsingTextureForMatrices(): boolean;
  13560. /**
  13561. * Gets the unique ID of this skeleton
  13562. */
  13563. get uniqueId(): number;
  13564. /**
  13565. * Creates a new skeleton
  13566. * @param name defines the skeleton name
  13567. * @param id defines the skeleton Id
  13568. * @param scene defines the hosting scene
  13569. */
  13570. constructor(
  13571. /** defines the skeleton name */
  13572. name: string,
  13573. /** defines the skeleton Id */
  13574. id: string, scene: Scene);
  13575. /**
  13576. * Gets the current object class name.
  13577. * @return the class name
  13578. */
  13579. getClassName(): string;
  13580. /**
  13581. * Returns an array containing the root bones
  13582. * @returns an array containing the root bones
  13583. */
  13584. getChildren(): Array<Bone>;
  13585. /**
  13586. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13587. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13588. * @returns a Float32Array containing matrices data
  13589. */
  13590. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13591. /**
  13592. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13593. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13594. * @returns a raw texture containing the data
  13595. */
  13596. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13597. /**
  13598. * Gets the current hosting scene
  13599. * @returns a scene object
  13600. */
  13601. getScene(): Scene;
  13602. /**
  13603. * Gets a string representing the current skeleton data
  13604. * @param fullDetails defines a boolean indicating if we want a verbose version
  13605. * @returns a string representing the current skeleton data
  13606. */
  13607. toString(fullDetails?: boolean): string;
  13608. /**
  13609. * Get bone's index searching by name
  13610. * @param name defines bone's name to search for
  13611. * @return the indice of the bone. Returns -1 if not found
  13612. */
  13613. getBoneIndexByName(name: string): number;
  13614. /**
  13615. * Creater a new animation range
  13616. * @param name defines the name of the range
  13617. * @param from defines the start key
  13618. * @param to defines the end key
  13619. */
  13620. createAnimationRange(name: string, from: number, to: number): void;
  13621. /**
  13622. * Delete a specific animation range
  13623. * @param name defines the name of the range
  13624. * @param deleteFrames defines if frames must be removed as well
  13625. */
  13626. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13627. /**
  13628. * Gets a specific animation range
  13629. * @param name defines the name of the range to look for
  13630. * @returns the requested animation range or null if not found
  13631. */
  13632. getAnimationRange(name: string): Nullable<AnimationRange>;
  13633. /**
  13634. * Gets the list of all animation ranges defined on this skeleton
  13635. * @returns an array
  13636. */
  13637. getAnimationRanges(): Nullable<AnimationRange>[];
  13638. /**
  13639. * Copy animation range from a source skeleton.
  13640. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13641. * @param source defines the source skeleton
  13642. * @param name defines the name of the range to copy
  13643. * @param rescaleAsRequired defines if rescaling must be applied if required
  13644. * @returns true if operation was successful
  13645. */
  13646. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13647. /**
  13648. * Forces the skeleton to go to rest pose
  13649. */
  13650. returnToRest(): void;
  13651. private _getHighestAnimationFrame;
  13652. /**
  13653. * Begin a specific animation range
  13654. * @param name defines the name of the range to start
  13655. * @param loop defines if looping must be turned on (false by default)
  13656. * @param speedRatio defines the speed ratio to apply (1 by default)
  13657. * @param onAnimationEnd defines a callback which will be called when animation will end
  13658. * @returns a new animatable
  13659. */
  13660. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13661. /** @hidden */
  13662. _markAsDirty(): void;
  13663. /** @hidden */
  13664. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13665. /** @hidden */
  13666. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13667. private _computeTransformMatrices;
  13668. /**
  13669. * Build all resources required to render a skeleton
  13670. */
  13671. prepare(): void;
  13672. /**
  13673. * Gets the list of animatables currently running for this skeleton
  13674. * @returns an array of animatables
  13675. */
  13676. getAnimatables(): IAnimatable[];
  13677. /**
  13678. * Clone the current skeleton
  13679. * @param name defines the name of the new skeleton
  13680. * @param id defines the id of the new skeleton
  13681. * @returns the new skeleton
  13682. */
  13683. clone(name: string, id?: string): Skeleton;
  13684. /**
  13685. * Enable animation blending for this skeleton
  13686. * @param blendingSpeed defines the blending speed to apply
  13687. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13688. */
  13689. enableBlending(blendingSpeed?: number): void;
  13690. /**
  13691. * Releases all resources associated with the current skeleton
  13692. */
  13693. dispose(): void;
  13694. /**
  13695. * Serialize the skeleton in a JSON object
  13696. * @returns a JSON object
  13697. */
  13698. serialize(): any;
  13699. /**
  13700. * Creates a new skeleton from serialized data
  13701. * @param parsedSkeleton defines the serialized data
  13702. * @param scene defines the hosting scene
  13703. * @returns a new skeleton
  13704. */
  13705. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13706. /**
  13707. * Compute all node absolute transforms
  13708. * @param forceUpdate defines if computation must be done even if cache is up to date
  13709. */
  13710. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13711. /**
  13712. * Gets the root pose matrix
  13713. * @returns a matrix
  13714. */
  13715. getPoseMatrix(): Nullable<Matrix>;
  13716. /**
  13717. * Sorts bones per internal index
  13718. */
  13719. sortBones(): void;
  13720. private _sortBones;
  13721. }
  13722. }
  13723. declare module BABYLON {
  13724. /**
  13725. * Class used to store bone information
  13726. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13727. */
  13728. export class Bone extends Node {
  13729. /**
  13730. * defines the bone name
  13731. */
  13732. name: string;
  13733. private static _tmpVecs;
  13734. private static _tmpQuat;
  13735. private static _tmpMats;
  13736. /**
  13737. * Gets the list of child bones
  13738. */
  13739. children: Bone[];
  13740. /** Gets the animations associated with this bone */
  13741. animations: Animation[];
  13742. /**
  13743. * Gets or sets bone length
  13744. */
  13745. length: number;
  13746. /**
  13747. * @hidden Internal only
  13748. * Set this value to map this bone to a different index in the transform matrices
  13749. * Set this value to -1 to exclude the bone from the transform matrices
  13750. */
  13751. _index: Nullable<number>;
  13752. private _skeleton;
  13753. private _localMatrix;
  13754. private _restPose;
  13755. private _baseMatrix;
  13756. private _absoluteTransform;
  13757. private _invertedAbsoluteTransform;
  13758. private _parent;
  13759. private _scalingDeterminant;
  13760. private _worldTransform;
  13761. private _localScaling;
  13762. private _localRotation;
  13763. private _localPosition;
  13764. private _needToDecompose;
  13765. private _needToCompose;
  13766. /** @hidden */
  13767. _linkedTransformNode: Nullable<TransformNode>;
  13768. /** @hidden */
  13769. _waitingTransformNodeId: Nullable<string>;
  13770. /** @hidden */
  13771. get _matrix(): Matrix;
  13772. /** @hidden */
  13773. set _matrix(value: Matrix);
  13774. /**
  13775. * Create a new bone
  13776. * @param name defines the bone name
  13777. * @param skeleton defines the parent skeleton
  13778. * @param parentBone defines the parent (can be null if the bone is the root)
  13779. * @param localMatrix defines the local matrix
  13780. * @param restPose defines the rest pose matrix
  13781. * @param baseMatrix defines the base matrix
  13782. * @param index defines index of the bone in the hiearchy
  13783. */
  13784. constructor(
  13785. /**
  13786. * defines the bone name
  13787. */
  13788. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13789. /**
  13790. * Gets the current object class name.
  13791. * @return the class name
  13792. */
  13793. getClassName(): string;
  13794. /**
  13795. * Gets the parent skeleton
  13796. * @returns a skeleton
  13797. */
  13798. getSkeleton(): Skeleton;
  13799. /**
  13800. * Gets parent bone
  13801. * @returns a bone or null if the bone is the root of the bone hierarchy
  13802. */
  13803. getParent(): Nullable<Bone>;
  13804. /**
  13805. * Returns an array containing the root bones
  13806. * @returns an array containing the root bones
  13807. */
  13808. getChildren(): Array<Bone>;
  13809. /**
  13810. * Gets the node index in matrix array generated for rendering
  13811. * @returns the node index
  13812. */
  13813. getIndex(): number;
  13814. /**
  13815. * Sets the parent bone
  13816. * @param parent defines the parent (can be null if the bone is the root)
  13817. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13818. */
  13819. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13820. /**
  13821. * Gets the local matrix
  13822. * @returns a matrix
  13823. */
  13824. getLocalMatrix(): Matrix;
  13825. /**
  13826. * Gets the base matrix (initial matrix which remains unchanged)
  13827. * @returns a matrix
  13828. */
  13829. getBaseMatrix(): Matrix;
  13830. /**
  13831. * Gets the rest pose matrix
  13832. * @returns a matrix
  13833. */
  13834. getRestPose(): Matrix;
  13835. /**
  13836. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13837. */
  13838. getWorldMatrix(): Matrix;
  13839. /**
  13840. * Sets the local matrix to rest pose matrix
  13841. */
  13842. returnToRest(): void;
  13843. /**
  13844. * Gets the inverse of the absolute transform matrix.
  13845. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13846. * @returns a matrix
  13847. */
  13848. getInvertedAbsoluteTransform(): Matrix;
  13849. /**
  13850. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13851. * @returns a matrix
  13852. */
  13853. getAbsoluteTransform(): Matrix;
  13854. /**
  13855. * Links with the given transform node.
  13856. * The local matrix of this bone is copied from the transform node every frame.
  13857. * @param transformNode defines the transform node to link to
  13858. */
  13859. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13860. /**
  13861. * Gets the node used to drive the bone's transformation
  13862. * @returns a transform node or null
  13863. */
  13864. getTransformNode(): Nullable<TransformNode>;
  13865. /** Gets or sets current position (in local space) */
  13866. get position(): Vector3;
  13867. set position(newPosition: Vector3);
  13868. /** Gets or sets current rotation (in local space) */
  13869. get rotation(): Vector3;
  13870. set rotation(newRotation: Vector3);
  13871. /** Gets or sets current rotation quaternion (in local space) */
  13872. get rotationQuaternion(): Quaternion;
  13873. set rotationQuaternion(newRotation: Quaternion);
  13874. /** Gets or sets current scaling (in local space) */
  13875. get scaling(): Vector3;
  13876. set scaling(newScaling: Vector3);
  13877. /**
  13878. * Gets the animation properties override
  13879. */
  13880. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13881. private _decompose;
  13882. private _compose;
  13883. /**
  13884. * Update the base and local matrices
  13885. * @param matrix defines the new base or local matrix
  13886. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13887. * @param updateLocalMatrix defines if the local matrix should be updated
  13888. */
  13889. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13890. /** @hidden */
  13891. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13892. /**
  13893. * Flag the bone as dirty (Forcing it to update everything)
  13894. */
  13895. markAsDirty(): void;
  13896. /** @hidden */
  13897. _markAsDirtyAndCompose(): void;
  13898. private _markAsDirtyAndDecompose;
  13899. /**
  13900. * Translate the bone in local or world space
  13901. * @param vec The amount to translate the bone
  13902. * @param space The space that the translation is in
  13903. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13904. */
  13905. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13906. /**
  13907. * Set the postion of the bone in local or world space
  13908. * @param position The position to set the bone
  13909. * @param space The space that the position is in
  13910. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13911. */
  13912. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13913. /**
  13914. * Set the absolute position of the bone (world space)
  13915. * @param position The position to set the bone
  13916. * @param mesh The mesh that this bone is attached to
  13917. */
  13918. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13919. /**
  13920. * Scale the bone on the x, y and z axes (in local space)
  13921. * @param x The amount to scale the bone on the x axis
  13922. * @param y The amount to scale the bone on the y axis
  13923. * @param z The amount to scale the bone on the z axis
  13924. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13925. */
  13926. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13927. /**
  13928. * Set the bone scaling in local space
  13929. * @param scale defines the scaling vector
  13930. */
  13931. setScale(scale: Vector3): void;
  13932. /**
  13933. * Gets the current scaling in local space
  13934. * @returns the current scaling vector
  13935. */
  13936. getScale(): Vector3;
  13937. /**
  13938. * Gets the current scaling in local space and stores it in a target vector
  13939. * @param result defines the target vector
  13940. */
  13941. getScaleToRef(result: Vector3): void;
  13942. /**
  13943. * Set the yaw, pitch, and roll of the bone in local or world space
  13944. * @param yaw The rotation of the bone on the y axis
  13945. * @param pitch The rotation of the bone on the x axis
  13946. * @param roll The rotation of the bone on the z axis
  13947. * @param space The space that the axes of rotation are in
  13948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13949. */
  13950. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13951. /**
  13952. * Add a rotation to the bone on an axis in local or world space
  13953. * @param axis The axis to rotate the bone on
  13954. * @param amount The amount to rotate the bone
  13955. * @param space The space that the axis is in
  13956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13957. */
  13958. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13959. /**
  13960. * Set the rotation of the bone to a particular axis angle in local or world space
  13961. * @param axis The axis to rotate the bone on
  13962. * @param angle The angle that the bone should be rotated to
  13963. * @param space The space that the axis is in
  13964. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13965. */
  13966. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13967. /**
  13968. * Set the euler rotation of the bone in local of world space
  13969. * @param rotation The euler rotation that the bone should be set to
  13970. * @param space The space that the rotation is in
  13971. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13972. */
  13973. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13974. /**
  13975. * Set the quaternion rotation of the bone in local of world space
  13976. * @param quat The quaternion rotation that the bone should be set to
  13977. * @param space The space that the rotation is in
  13978. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13979. */
  13980. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13981. /**
  13982. * Set the rotation matrix of the bone in local of world space
  13983. * @param rotMat The rotation matrix that the bone should be set to
  13984. * @param space The space that the rotation is in
  13985. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13986. */
  13987. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13988. private _rotateWithMatrix;
  13989. private _getNegativeRotationToRef;
  13990. /**
  13991. * Get the position of the bone in local or world space
  13992. * @param space The space that the returned position is in
  13993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13994. * @returns The position of the bone
  13995. */
  13996. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13997. /**
  13998. * Copy the position of the bone to a vector3 in local or world space
  13999. * @param space The space that the returned position is in
  14000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14001. * @param result The vector3 to copy the position to
  14002. */
  14003. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14004. /**
  14005. * Get the absolute position of the bone (world space)
  14006. * @param mesh The mesh that this bone is attached to
  14007. * @returns The absolute position of the bone
  14008. */
  14009. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14010. /**
  14011. * Copy the absolute position of the bone (world space) to the result param
  14012. * @param mesh The mesh that this bone is attached to
  14013. * @param result The vector3 to copy the absolute position to
  14014. */
  14015. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14016. /**
  14017. * Compute the absolute transforms of this bone and its children
  14018. */
  14019. computeAbsoluteTransforms(): void;
  14020. /**
  14021. * Get the world direction from an axis that is in the local space of the bone
  14022. * @param localAxis The local direction that is used to compute the world direction
  14023. * @param mesh The mesh that this bone is attached to
  14024. * @returns The world direction
  14025. */
  14026. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14027. /**
  14028. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14029. * @param localAxis The local direction that is used to compute the world direction
  14030. * @param mesh The mesh that this bone is attached to
  14031. * @param result The vector3 that the world direction will be copied to
  14032. */
  14033. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14034. /**
  14035. * Get the euler rotation of the bone in local or world space
  14036. * @param space The space that the rotation should be in
  14037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14038. * @returns The euler rotation
  14039. */
  14040. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14041. /**
  14042. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14043. * @param space The space that the rotation should be in
  14044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14045. * @param result The vector3 that the rotation should be copied to
  14046. */
  14047. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14048. /**
  14049. * Get the quaternion rotation of the bone in either local or world space
  14050. * @param space The space that the rotation should be in
  14051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14052. * @returns The quaternion rotation
  14053. */
  14054. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14055. /**
  14056. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14057. * @param space The space that the rotation should be in
  14058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14059. * @param result The quaternion that the rotation should be copied to
  14060. */
  14061. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14062. /**
  14063. * Get the rotation matrix of the bone in local or world space
  14064. * @param space The space that the rotation should be in
  14065. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14066. * @returns The rotation matrix
  14067. */
  14068. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14069. /**
  14070. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14071. * @param space The space that the rotation should be in
  14072. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14073. * @param result The quaternion that the rotation should be copied to
  14074. */
  14075. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14076. /**
  14077. * Get the world position of a point that is in the local space of the bone
  14078. * @param position The local position
  14079. * @param mesh The mesh that this bone is attached to
  14080. * @returns The world position
  14081. */
  14082. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14083. /**
  14084. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14085. * @param position The local position
  14086. * @param mesh The mesh that this bone is attached to
  14087. * @param result The vector3 that the world position should be copied to
  14088. */
  14089. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14090. /**
  14091. * Get the local position of a point that is in world space
  14092. * @param position The world position
  14093. * @param mesh The mesh that this bone is attached to
  14094. * @returns The local position
  14095. */
  14096. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14097. /**
  14098. * Get the local position of a point that is in world space and copy it to the result param
  14099. * @param position The world position
  14100. * @param mesh The mesh that this bone is attached to
  14101. * @param result The vector3 that the local position should be copied to
  14102. */
  14103. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14104. }
  14105. }
  14106. declare module BABYLON {
  14107. /**
  14108. * 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.
  14109. * @see https://doc.babylonjs.com/how_to/transformnode
  14110. */
  14111. export class TransformNode extends Node {
  14112. /**
  14113. * Object will not rotate to face the camera
  14114. */
  14115. static BILLBOARDMODE_NONE: number;
  14116. /**
  14117. * Object will rotate to face the camera but only on the x axis
  14118. */
  14119. static BILLBOARDMODE_X: number;
  14120. /**
  14121. * Object will rotate to face the camera but only on the y axis
  14122. */
  14123. static BILLBOARDMODE_Y: number;
  14124. /**
  14125. * Object will rotate to face the camera but only on the z axis
  14126. */
  14127. static BILLBOARDMODE_Z: number;
  14128. /**
  14129. * Object will rotate to face the camera
  14130. */
  14131. static BILLBOARDMODE_ALL: number;
  14132. /**
  14133. * Object will rotate to face the camera's position instead of orientation
  14134. */
  14135. static BILLBOARDMODE_USE_POSITION: number;
  14136. private _forward;
  14137. private _forwardInverted;
  14138. private _up;
  14139. private _right;
  14140. private _rightInverted;
  14141. private _position;
  14142. private _rotation;
  14143. private _rotationQuaternion;
  14144. protected _scaling: Vector3;
  14145. protected _isDirty: boolean;
  14146. private _transformToBoneReferal;
  14147. private _isAbsoluteSynced;
  14148. private _billboardMode;
  14149. /**
  14150. * Gets or sets the billboard mode. Default is 0.
  14151. *
  14152. * | Value | Type | Description |
  14153. * | --- | --- | --- |
  14154. * | 0 | BILLBOARDMODE_NONE | |
  14155. * | 1 | BILLBOARDMODE_X | |
  14156. * | 2 | BILLBOARDMODE_Y | |
  14157. * | 4 | BILLBOARDMODE_Z | |
  14158. * | 7 | BILLBOARDMODE_ALL | |
  14159. *
  14160. */
  14161. get billboardMode(): number;
  14162. set billboardMode(value: number);
  14163. private _preserveParentRotationForBillboard;
  14164. /**
  14165. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14166. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14167. */
  14168. get preserveParentRotationForBillboard(): boolean;
  14169. set preserveParentRotationForBillboard(value: boolean);
  14170. /**
  14171. * 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
  14172. */
  14173. scalingDeterminant: number;
  14174. private _infiniteDistance;
  14175. /**
  14176. * Gets or sets the distance of the object to max, often used by skybox
  14177. */
  14178. get infiniteDistance(): boolean;
  14179. set infiniteDistance(value: boolean);
  14180. /**
  14181. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14182. * By default the system will update normals to compensate
  14183. */
  14184. ignoreNonUniformScaling: boolean;
  14185. /**
  14186. * 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
  14187. */
  14188. reIntegrateRotationIntoRotationQuaternion: boolean;
  14189. /** @hidden */
  14190. _poseMatrix: Nullable<Matrix>;
  14191. /** @hidden */
  14192. _localMatrix: Matrix;
  14193. private _usePivotMatrix;
  14194. private _absolutePosition;
  14195. private _absoluteScaling;
  14196. private _absoluteRotationQuaternion;
  14197. private _pivotMatrix;
  14198. private _pivotMatrixInverse;
  14199. protected _postMultiplyPivotMatrix: boolean;
  14200. protected _isWorldMatrixFrozen: boolean;
  14201. /** @hidden */
  14202. _indexInSceneTransformNodesArray: number;
  14203. /**
  14204. * An event triggered after the world matrix is updated
  14205. */
  14206. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14207. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14208. /**
  14209. * Gets a string identifying the name of the class
  14210. * @returns "TransformNode" string
  14211. */
  14212. getClassName(): string;
  14213. /**
  14214. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14215. */
  14216. get position(): Vector3;
  14217. set position(newPosition: Vector3);
  14218. /**
  14219. * 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)).
  14220. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14221. */
  14222. get rotation(): Vector3;
  14223. set rotation(newRotation: Vector3);
  14224. /**
  14225. * 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)).
  14226. */
  14227. get scaling(): Vector3;
  14228. set scaling(newScaling: Vector3);
  14229. /**
  14230. * 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).
  14231. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14232. */
  14233. get rotationQuaternion(): Nullable<Quaternion>;
  14234. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14235. /**
  14236. * The forward direction of that transform in world space.
  14237. */
  14238. get forward(): Vector3;
  14239. /**
  14240. * The up direction of that transform in world space.
  14241. */
  14242. get up(): Vector3;
  14243. /**
  14244. * The right direction of that transform in world space.
  14245. */
  14246. get right(): Vector3;
  14247. /**
  14248. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14249. * @param matrix the matrix to copy the pose from
  14250. * @returns this TransformNode.
  14251. */
  14252. updatePoseMatrix(matrix: Matrix): TransformNode;
  14253. /**
  14254. * Returns the mesh Pose matrix.
  14255. * @returns the pose matrix
  14256. */
  14257. getPoseMatrix(): Matrix;
  14258. /** @hidden */
  14259. _isSynchronized(): boolean;
  14260. /** @hidden */
  14261. _initCache(): void;
  14262. /**
  14263. * Flag the transform node as dirty (Forcing it to update everything)
  14264. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14265. * @returns this transform node
  14266. */
  14267. markAsDirty(property: string): TransformNode;
  14268. /**
  14269. * Returns the current mesh absolute position.
  14270. * Returns a Vector3.
  14271. */
  14272. get absolutePosition(): Vector3;
  14273. /**
  14274. * Returns the current mesh absolute scaling.
  14275. * Returns a Vector3.
  14276. */
  14277. get absoluteScaling(): Vector3;
  14278. /**
  14279. * Returns the current mesh absolute rotation.
  14280. * Returns a Quaternion.
  14281. */
  14282. get absoluteRotationQuaternion(): Quaternion;
  14283. /**
  14284. * Sets a new matrix to apply before all other transformation
  14285. * @param matrix defines the transform matrix
  14286. * @returns the current TransformNode
  14287. */
  14288. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14289. /**
  14290. * Sets a new pivot matrix to the current node
  14291. * @param matrix defines the new pivot matrix to use
  14292. * @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
  14293. * @returns the current TransformNode
  14294. */
  14295. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14296. /**
  14297. * Returns the mesh pivot matrix.
  14298. * Default : Identity.
  14299. * @returns the matrix
  14300. */
  14301. getPivotMatrix(): Matrix;
  14302. /**
  14303. * Instantiate (when possible) or clone that node with its hierarchy
  14304. * @param newParent defines the new parent to use for the instance (or clone)
  14305. * @param options defines options to configure how copy is done
  14306. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14307. * @returns an instance (or a clone) of the current node with its hiearchy
  14308. */
  14309. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14310. doNotInstantiate: boolean;
  14311. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14312. /**
  14313. * Prevents the World matrix to be computed any longer
  14314. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14315. * @returns the TransformNode.
  14316. */
  14317. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14318. /**
  14319. * Allows back the World matrix computation.
  14320. * @returns the TransformNode.
  14321. */
  14322. unfreezeWorldMatrix(): this;
  14323. /**
  14324. * True if the World matrix has been frozen.
  14325. */
  14326. get isWorldMatrixFrozen(): boolean;
  14327. /**
  14328. * Retuns the mesh absolute position in the World.
  14329. * @returns a Vector3.
  14330. */
  14331. getAbsolutePosition(): Vector3;
  14332. /**
  14333. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14334. * @param absolutePosition the absolute position to set
  14335. * @returns the TransformNode.
  14336. */
  14337. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14338. /**
  14339. * Sets the mesh position in its local space.
  14340. * @param vector3 the position to set in localspace
  14341. * @returns the TransformNode.
  14342. */
  14343. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14344. /**
  14345. * Returns the mesh position in the local space from the current World matrix values.
  14346. * @returns a new Vector3.
  14347. */
  14348. getPositionExpressedInLocalSpace(): Vector3;
  14349. /**
  14350. * Translates the mesh along the passed Vector3 in its local space.
  14351. * @param vector3 the distance to translate in localspace
  14352. * @returns the TransformNode.
  14353. */
  14354. locallyTranslate(vector3: Vector3): TransformNode;
  14355. private static _lookAtVectorCache;
  14356. /**
  14357. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14358. * @param targetPoint the position (must be in same space as current mesh) to look at
  14359. * @param yawCor optional yaw (y-axis) correction in radians
  14360. * @param pitchCor optional pitch (x-axis) correction in radians
  14361. * @param rollCor optional roll (z-axis) correction in radians
  14362. * @param space the choosen space of the target
  14363. * @returns the TransformNode.
  14364. */
  14365. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14366. /**
  14367. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14368. * This Vector3 is expressed in the World space.
  14369. * @param localAxis axis to rotate
  14370. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14371. */
  14372. getDirection(localAxis: Vector3): Vector3;
  14373. /**
  14374. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14375. * localAxis is expressed in the mesh local space.
  14376. * result is computed in the Wordl space from the mesh World matrix.
  14377. * @param localAxis axis to rotate
  14378. * @param result the resulting transformnode
  14379. * @returns this TransformNode.
  14380. */
  14381. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14382. /**
  14383. * Sets this transform node rotation to the given local axis.
  14384. * @param localAxis the axis in local space
  14385. * @param yawCor optional yaw (y-axis) correction in radians
  14386. * @param pitchCor optional pitch (x-axis) correction in radians
  14387. * @param rollCor optional roll (z-axis) correction in radians
  14388. * @returns this TransformNode
  14389. */
  14390. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14391. /**
  14392. * Sets a new pivot point to the current node
  14393. * @param point defines the new pivot point to use
  14394. * @param space defines if the point is in world or local space (local by default)
  14395. * @returns the current TransformNode
  14396. */
  14397. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14398. /**
  14399. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14400. * @returns the pivot point
  14401. */
  14402. getPivotPoint(): Vector3;
  14403. /**
  14404. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14405. * @param result the vector3 to store the result
  14406. * @returns this TransformNode.
  14407. */
  14408. getPivotPointToRef(result: Vector3): TransformNode;
  14409. /**
  14410. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14411. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14412. */
  14413. getAbsolutePivotPoint(): Vector3;
  14414. /**
  14415. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14416. * @param result vector3 to store the result
  14417. * @returns this TransformNode.
  14418. */
  14419. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14420. /**
  14421. * Defines the passed node as the parent of the current node.
  14422. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14423. * @see https://doc.babylonjs.com/how_to/parenting
  14424. * @param node the node ot set as the parent
  14425. * @returns this TransformNode.
  14426. */
  14427. setParent(node: Nullable<Node>): TransformNode;
  14428. private _nonUniformScaling;
  14429. /**
  14430. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14431. */
  14432. get nonUniformScaling(): boolean;
  14433. /** @hidden */
  14434. _updateNonUniformScalingState(value: boolean): boolean;
  14435. /**
  14436. * Attach the current TransformNode to another TransformNode associated with a bone
  14437. * @param bone Bone affecting the TransformNode
  14438. * @param affectedTransformNode TransformNode associated with the bone
  14439. * @returns this object
  14440. */
  14441. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14442. /**
  14443. * Detach the transform node if its associated with a bone
  14444. * @returns this object
  14445. */
  14446. detachFromBone(): TransformNode;
  14447. private static _rotationAxisCache;
  14448. /**
  14449. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14450. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14451. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14452. * The passed axis is also normalized.
  14453. * @param axis the axis to rotate around
  14454. * @param amount the amount to rotate in radians
  14455. * @param space Space to rotate in (Default: local)
  14456. * @returns the TransformNode.
  14457. */
  14458. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14459. /**
  14460. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14461. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14462. * The passed axis is also normalized. .
  14463. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14464. * @param point the point to rotate around
  14465. * @param axis the axis to rotate around
  14466. * @param amount the amount to rotate in radians
  14467. * @returns the TransformNode
  14468. */
  14469. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14470. /**
  14471. * Translates the mesh along the axis vector for the passed distance in the given space.
  14472. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14473. * @param axis the axis to translate in
  14474. * @param distance the distance to translate
  14475. * @param space Space to rotate in (Default: local)
  14476. * @returns the TransformNode.
  14477. */
  14478. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14479. /**
  14480. * Adds a rotation step to the mesh current rotation.
  14481. * x, y, z are Euler angles expressed in radians.
  14482. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14483. * This means this rotation is made in the mesh local space only.
  14484. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14485. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14486. * ```javascript
  14487. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14488. * ```
  14489. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14490. * 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.
  14491. * @param x Rotation to add
  14492. * @param y Rotation to add
  14493. * @param z Rotation to add
  14494. * @returns the TransformNode.
  14495. */
  14496. addRotation(x: number, y: number, z: number): TransformNode;
  14497. /**
  14498. * @hidden
  14499. */
  14500. protected _getEffectiveParent(): Nullable<Node>;
  14501. /**
  14502. * Computes the world matrix of the node
  14503. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14504. * @returns the world matrix
  14505. */
  14506. computeWorldMatrix(force?: boolean): Matrix;
  14507. /**
  14508. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14509. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14510. */
  14511. resetLocalMatrix(independentOfChildren?: boolean): void;
  14512. protected _afterComputeWorldMatrix(): void;
  14513. /**
  14514. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14515. * @param func callback function to add
  14516. *
  14517. * @returns the TransformNode.
  14518. */
  14519. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14520. /**
  14521. * Removes a registered callback function.
  14522. * @param func callback function to remove
  14523. * @returns the TransformNode.
  14524. */
  14525. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14526. /**
  14527. * Gets the position of the current mesh in camera space
  14528. * @param camera defines the camera to use
  14529. * @returns a position
  14530. */
  14531. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14532. /**
  14533. * Returns the distance from the mesh to the active camera
  14534. * @param camera defines the camera to use
  14535. * @returns the distance
  14536. */
  14537. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14538. /**
  14539. * Clone the current transform node
  14540. * @param name Name of the new clone
  14541. * @param newParent New parent for the clone
  14542. * @param doNotCloneChildren Do not clone children hierarchy
  14543. * @returns the new transform node
  14544. */
  14545. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14546. /**
  14547. * Serializes the objects information.
  14548. * @param currentSerializationObject defines the object to serialize in
  14549. * @returns the serialized object
  14550. */
  14551. serialize(currentSerializationObject?: any): any;
  14552. /**
  14553. * Returns a new TransformNode object parsed from the source provided.
  14554. * @param parsedTransformNode is the source.
  14555. * @param scene the scne the object belongs to
  14556. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14557. * @returns a new TransformNode object parsed from the source provided.
  14558. */
  14559. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14560. /**
  14561. * Get all child-transformNodes of this node
  14562. * @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
  14563. * @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
  14564. * @returns an array of TransformNode
  14565. */
  14566. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14567. /**
  14568. * Releases resources associated with this transform node.
  14569. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14570. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14571. */
  14572. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14573. /**
  14574. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14575. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14576. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14577. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14578. * @returns the current mesh
  14579. */
  14580. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14581. private _syncAbsoluteScalingAndRotation;
  14582. }
  14583. }
  14584. declare module BABYLON {
  14585. /**
  14586. * Defines the types of pose enabled controllers that are supported
  14587. */
  14588. export enum PoseEnabledControllerType {
  14589. /**
  14590. * HTC Vive
  14591. */
  14592. VIVE = 0,
  14593. /**
  14594. * Oculus Rift
  14595. */
  14596. OCULUS = 1,
  14597. /**
  14598. * Windows mixed reality
  14599. */
  14600. WINDOWS = 2,
  14601. /**
  14602. * Samsung gear VR
  14603. */
  14604. GEAR_VR = 3,
  14605. /**
  14606. * Google Daydream
  14607. */
  14608. DAYDREAM = 4,
  14609. /**
  14610. * Generic
  14611. */
  14612. GENERIC = 5
  14613. }
  14614. /**
  14615. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14616. */
  14617. export interface MutableGamepadButton {
  14618. /**
  14619. * Value of the button/trigger
  14620. */
  14621. value: number;
  14622. /**
  14623. * If the button/trigger is currently touched
  14624. */
  14625. touched: boolean;
  14626. /**
  14627. * If the button/trigger is currently pressed
  14628. */
  14629. pressed: boolean;
  14630. }
  14631. /**
  14632. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14633. * @hidden
  14634. */
  14635. export interface ExtendedGamepadButton extends GamepadButton {
  14636. /**
  14637. * If the button/trigger is currently pressed
  14638. */
  14639. readonly pressed: boolean;
  14640. /**
  14641. * If the button/trigger is currently touched
  14642. */
  14643. readonly touched: boolean;
  14644. /**
  14645. * Value of the button/trigger
  14646. */
  14647. readonly value: number;
  14648. }
  14649. /** @hidden */
  14650. export interface _GamePadFactory {
  14651. /**
  14652. * Returns wether or not the current gamepad can be created for this type of controller.
  14653. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14654. * @returns true if it can be created, otherwise false
  14655. */
  14656. canCreate(gamepadInfo: any): boolean;
  14657. /**
  14658. * Creates a new instance of the Gamepad.
  14659. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14660. * @returns the new gamepad instance
  14661. */
  14662. create(gamepadInfo: any): Gamepad;
  14663. }
  14664. /**
  14665. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14666. */
  14667. export class PoseEnabledControllerHelper {
  14668. /** @hidden */
  14669. static _ControllerFactories: _GamePadFactory[];
  14670. /** @hidden */
  14671. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14672. /**
  14673. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14674. * @param vrGamepad the gamepad to initialized
  14675. * @returns a vr controller of the type the gamepad identified as
  14676. */
  14677. static InitiateController(vrGamepad: any): Gamepad;
  14678. }
  14679. /**
  14680. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14681. */
  14682. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14683. /**
  14684. * If the controller is used in a webXR session
  14685. */
  14686. isXR: boolean;
  14687. private _deviceRoomPosition;
  14688. private _deviceRoomRotationQuaternion;
  14689. /**
  14690. * The device position in babylon space
  14691. */
  14692. devicePosition: Vector3;
  14693. /**
  14694. * The device rotation in babylon space
  14695. */
  14696. deviceRotationQuaternion: Quaternion;
  14697. /**
  14698. * The scale factor of the device in babylon space
  14699. */
  14700. deviceScaleFactor: number;
  14701. /**
  14702. * (Likely devicePosition should be used instead) The device position in its room space
  14703. */
  14704. position: Vector3;
  14705. /**
  14706. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14707. */
  14708. rotationQuaternion: Quaternion;
  14709. /**
  14710. * The type of controller (Eg. Windows mixed reality)
  14711. */
  14712. controllerType: PoseEnabledControllerType;
  14713. protected _calculatedPosition: Vector3;
  14714. private _calculatedRotation;
  14715. /**
  14716. * The raw pose from the device
  14717. */
  14718. rawPose: DevicePose;
  14719. private _trackPosition;
  14720. private _maxRotationDistFromHeadset;
  14721. private _draggedRoomRotation;
  14722. /**
  14723. * @hidden
  14724. */
  14725. _disableTrackPosition(fixedPosition: Vector3): void;
  14726. /**
  14727. * Internal, the mesh attached to the controller
  14728. * @hidden
  14729. */
  14730. _mesh: Nullable<AbstractMesh>;
  14731. private _poseControlledCamera;
  14732. private _leftHandSystemQuaternion;
  14733. /**
  14734. * Internal, matrix used to convert room space to babylon space
  14735. * @hidden
  14736. */
  14737. _deviceToWorld: Matrix;
  14738. /**
  14739. * Node to be used when casting a ray from the controller
  14740. * @hidden
  14741. */
  14742. _pointingPoseNode: Nullable<TransformNode>;
  14743. /**
  14744. * Name of the child mesh that can be used to cast a ray from the controller
  14745. */
  14746. static readonly POINTING_POSE: string;
  14747. /**
  14748. * Creates a new PoseEnabledController from a gamepad
  14749. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14750. */
  14751. constructor(browserGamepad: any);
  14752. private _workingMatrix;
  14753. /**
  14754. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14755. */
  14756. update(): void;
  14757. /**
  14758. * Updates only the pose device and mesh without doing any button event checking
  14759. */
  14760. protected _updatePoseAndMesh(): void;
  14761. /**
  14762. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14763. * @param poseData raw pose fromthe device
  14764. */
  14765. updateFromDevice(poseData: DevicePose): void;
  14766. /**
  14767. * @hidden
  14768. */
  14769. _meshAttachedObservable: Observable<AbstractMesh>;
  14770. /**
  14771. * Attaches a mesh to the controller
  14772. * @param mesh the mesh to be attached
  14773. */
  14774. attachToMesh(mesh: AbstractMesh): void;
  14775. /**
  14776. * Attaches the controllers mesh to a camera
  14777. * @param camera the camera the mesh should be attached to
  14778. */
  14779. attachToPoseControlledCamera(camera: TargetCamera): void;
  14780. /**
  14781. * Disposes of the controller
  14782. */
  14783. dispose(): void;
  14784. /**
  14785. * The mesh that is attached to the controller
  14786. */
  14787. get mesh(): Nullable<AbstractMesh>;
  14788. /**
  14789. * Gets the ray of the controller in the direction the controller is pointing
  14790. * @param length the length the resulting ray should be
  14791. * @returns a ray in the direction the controller is pointing
  14792. */
  14793. getForwardRay(length?: number): Ray;
  14794. }
  14795. }
  14796. declare module BABYLON {
  14797. /**
  14798. * Defines the WebVRController object that represents controllers tracked in 3D space
  14799. */
  14800. export abstract class WebVRController extends PoseEnabledController {
  14801. /**
  14802. * Internal, the default controller model for the controller
  14803. */
  14804. protected _defaultModel: Nullable<AbstractMesh>;
  14805. /**
  14806. * Fired when the trigger state has changed
  14807. */
  14808. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14809. /**
  14810. * Fired when the main button state has changed
  14811. */
  14812. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14813. /**
  14814. * Fired when the secondary button state has changed
  14815. */
  14816. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14817. /**
  14818. * Fired when the pad state has changed
  14819. */
  14820. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14821. /**
  14822. * Fired when controllers stick values have changed
  14823. */
  14824. onPadValuesChangedObservable: Observable<StickValues>;
  14825. /**
  14826. * Array of button availible on the controller
  14827. */
  14828. protected _buttons: Array<MutableGamepadButton>;
  14829. private _onButtonStateChange;
  14830. /**
  14831. * Fired when a controller button's state has changed
  14832. * @param callback the callback containing the button that was modified
  14833. */
  14834. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14835. /**
  14836. * X and Y axis corresponding to the controllers joystick
  14837. */
  14838. pad: StickValues;
  14839. /**
  14840. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14841. */
  14842. hand: string;
  14843. /**
  14844. * The default controller model for the controller
  14845. */
  14846. get defaultModel(): Nullable<AbstractMesh>;
  14847. /**
  14848. * Creates a new WebVRController from a gamepad
  14849. * @param vrGamepad the gamepad that the WebVRController should be created from
  14850. */
  14851. constructor(vrGamepad: any);
  14852. /**
  14853. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14854. */
  14855. update(): void;
  14856. /**
  14857. * Function to be called when a button is modified
  14858. */
  14859. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14860. /**
  14861. * Loads a mesh and attaches it to the controller
  14862. * @param scene the scene the mesh should be added to
  14863. * @param meshLoaded callback for when the mesh has been loaded
  14864. */
  14865. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14866. private _setButtonValue;
  14867. private _changes;
  14868. private _checkChanges;
  14869. /**
  14870. * Disposes of th webVRCOntroller
  14871. */
  14872. dispose(): void;
  14873. }
  14874. }
  14875. declare module BABYLON {
  14876. /**
  14877. * The HemisphericLight simulates the ambient environment light,
  14878. * so the passed direction is the light reflection direction, not the incoming direction.
  14879. */
  14880. export class HemisphericLight extends Light {
  14881. /**
  14882. * The groundColor is the light in the opposite direction to the one specified during creation.
  14883. * 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.
  14884. */
  14885. groundColor: Color3;
  14886. /**
  14887. * The light reflection direction, not the incoming direction.
  14888. */
  14889. direction: Vector3;
  14890. /**
  14891. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14892. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14893. * The HemisphericLight can't cast shadows.
  14894. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14895. * @param name The friendly name of the light
  14896. * @param direction The direction of the light reflection
  14897. * @param scene The scene the light belongs to
  14898. */
  14899. constructor(name: string, direction: Vector3, scene: Scene);
  14900. protected _buildUniformLayout(): void;
  14901. /**
  14902. * Returns the string "HemisphericLight".
  14903. * @return The class name
  14904. */
  14905. getClassName(): string;
  14906. /**
  14907. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14908. * Returns the updated direction.
  14909. * @param target The target the direction should point to
  14910. * @return The computed direction
  14911. */
  14912. setDirectionToTarget(target: Vector3): Vector3;
  14913. /**
  14914. * Returns the shadow generator associated to the light.
  14915. * @returns Always null for hemispheric lights because it does not support shadows.
  14916. */
  14917. getShadowGenerator(): Nullable<IShadowGenerator>;
  14918. /**
  14919. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14920. * @param effect The effect to update
  14921. * @param lightIndex The index of the light in the effect to update
  14922. * @returns The hemispheric light
  14923. */
  14924. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14925. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14926. /**
  14927. * Computes the world matrix of the node
  14928. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14929. * @param useWasUpdatedFlag defines a reserved property
  14930. * @returns the world matrix
  14931. */
  14932. computeWorldMatrix(): Matrix;
  14933. /**
  14934. * Returns the integer 3.
  14935. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14936. */
  14937. getTypeID(): number;
  14938. /**
  14939. * Prepares the list of defines specific to the light type.
  14940. * @param defines the list of defines
  14941. * @param lightIndex defines the index of the light for the effect
  14942. */
  14943. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14944. }
  14945. }
  14946. declare module BABYLON {
  14947. /** @hidden */
  14948. export var vrMultiviewToSingleviewPixelShader: {
  14949. name: string;
  14950. shader: string;
  14951. };
  14952. }
  14953. declare module BABYLON {
  14954. /**
  14955. * Renders to multiple views with a single draw call
  14956. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14957. */
  14958. export class MultiviewRenderTarget extends RenderTargetTexture {
  14959. /**
  14960. * Creates a multiview render target
  14961. * @param scene scene used with the render target
  14962. * @param size the size of the render target (used for each view)
  14963. */
  14964. constructor(scene: Scene, size?: number | {
  14965. width: number;
  14966. height: number;
  14967. } | {
  14968. ratio: number;
  14969. });
  14970. /**
  14971. * @hidden
  14972. * @param faceIndex the face index, if its a cube texture
  14973. */
  14974. _bindFrameBuffer(faceIndex?: number): void;
  14975. /**
  14976. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14977. * @returns the view count
  14978. */
  14979. getViewCount(): number;
  14980. }
  14981. }
  14982. declare module BABYLON {
  14983. /**
  14984. * Represents a camera frustum
  14985. */
  14986. export class Frustum {
  14987. /**
  14988. * Gets the planes representing the frustum
  14989. * @param transform matrix to be applied to the returned planes
  14990. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14991. */
  14992. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14993. /**
  14994. * Gets the near frustum plane transformed by the transform matrix
  14995. * @param transform transformation matrix to be applied to the resulting frustum plane
  14996. * @param frustumPlane the resuling frustum plane
  14997. */
  14998. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14999. /**
  15000. * Gets the far frustum plane transformed by the transform matrix
  15001. * @param transform transformation matrix to be applied to the resulting frustum plane
  15002. * @param frustumPlane the resuling frustum plane
  15003. */
  15004. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15005. /**
  15006. * Gets the left frustum plane transformed by the transform matrix
  15007. * @param transform transformation matrix to be applied to the resulting frustum plane
  15008. * @param frustumPlane the resuling frustum plane
  15009. */
  15010. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15011. /**
  15012. * Gets the right frustum plane transformed by the transform matrix
  15013. * @param transform transformation matrix to be applied to the resulting frustum plane
  15014. * @param frustumPlane the resuling frustum plane
  15015. */
  15016. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15017. /**
  15018. * Gets the top frustum plane transformed by the transform matrix
  15019. * @param transform transformation matrix to be applied to the resulting frustum plane
  15020. * @param frustumPlane the resuling frustum plane
  15021. */
  15022. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15023. /**
  15024. * Gets the bottom frustum plane transformed by the transform matrix
  15025. * @param transform transformation matrix to be applied to the resulting frustum plane
  15026. * @param frustumPlane the resuling frustum plane
  15027. */
  15028. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15029. /**
  15030. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15031. * @param transform transformation matrix to be applied to the resulting frustum planes
  15032. * @param frustumPlanes the resuling frustum planes
  15033. */
  15034. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15035. }
  15036. }
  15037. declare module BABYLON {
  15038. interface Engine {
  15039. /**
  15040. * Creates a new multiview render target
  15041. * @param width defines the width of the texture
  15042. * @param height defines the height of the texture
  15043. * @returns the created multiview texture
  15044. */
  15045. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15046. /**
  15047. * Binds a multiview framebuffer to be drawn to
  15048. * @param multiviewTexture texture to bind
  15049. */
  15050. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15051. }
  15052. interface Camera {
  15053. /**
  15054. * @hidden
  15055. * 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)
  15056. */
  15057. _useMultiviewToSingleView: boolean;
  15058. /**
  15059. * @hidden
  15060. * 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)
  15061. */
  15062. _multiviewTexture: Nullable<RenderTargetTexture>;
  15063. /**
  15064. * @hidden
  15065. * ensures the multiview texture of the camera exists and has the specified width/height
  15066. * @param width height to set on the multiview texture
  15067. * @param height width to set on the multiview texture
  15068. */
  15069. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15070. }
  15071. interface Scene {
  15072. /** @hidden */
  15073. _transformMatrixR: Matrix;
  15074. /** @hidden */
  15075. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15076. /** @hidden */
  15077. _createMultiviewUbo(): void;
  15078. /** @hidden */
  15079. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15080. /** @hidden */
  15081. _renderMultiviewToSingleView(camera: Camera): void;
  15082. }
  15083. }
  15084. declare module BABYLON {
  15085. /**
  15086. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15087. * This will not be used for webXR as it supports displaying texture arrays directly
  15088. */
  15089. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15090. /**
  15091. * Initializes a VRMultiviewToSingleview
  15092. * @param name name of the post process
  15093. * @param camera camera to be applied to
  15094. * @param scaleFactor scaling factor to the size of the output texture
  15095. */
  15096. constructor(name: string, camera: Camera, scaleFactor: number);
  15097. }
  15098. }
  15099. declare module BABYLON {
  15100. /**
  15101. * Interface used to define additional presentation attributes
  15102. */
  15103. export interface IVRPresentationAttributes {
  15104. /**
  15105. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15106. */
  15107. highRefreshRate: boolean;
  15108. /**
  15109. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15110. */
  15111. foveationLevel: number;
  15112. }
  15113. interface Engine {
  15114. /** @hidden */
  15115. _vrDisplay: any;
  15116. /** @hidden */
  15117. _vrSupported: boolean;
  15118. /** @hidden */
  15119. _oldSize: Size;
  15120. /** @hidden */
  15121. _oldHardwareScaleFactor: number;
  15122. /** @hidden */
  15123. _vrExclusivePointerMode: boolean;
  15124. /** @hidden */
  15125. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15126. /** @hidden */
  15127. _onVRDisplayPointerRestricted: () => void;
  15128. /** @hidden */
  15129. _onVRDisplayPointerUnrestricted: () => void;
  15130. /** @hidden */
  15131. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15132. /** @hidden */
  15133. _onVrDisplayDisconnect: Nullable<() => void>;
  15134. /** @hidden */
  15135. _onVrDisplayPresentChange: Nullable<() => void>;
  15136. /**
  15137. * Observable signaled when VR display mode changes
  15138. */
  15139. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15140. /**
  15141. * Observable signaled when VR request present is complete
  15142. */
  15143. onVRRequestPresentComplete: Observable<boolean>;
  15144. /**
  15145. * Observable signaled when VR request present starts
  15146. */
  15147. onVRRequestPresentStart: Observable<Engine>;
  15148. /**
  15149. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15150. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15151. */
  15152. isInVRExclusivePointerMode: boolean;
  15153. /**
  15154. * Gets a boolean indicating if a webVR device was detected
  15155. * @returns true if a webVR device was detected
  15156. */
  15157. isVRDevicePresent(): boolean;
  15158. /**
  15159. * Gets the current webVR device
  15160. * @returns the current webVR device (or null)
  15161. */
  15162. getVRDevice(): any;
  15163. /**
  15164. * Initializes a webVR display and starts listening to display change events
  15165. * The onVRDisplayChangedObservable will be notified upon these changes
  15166. * @returns A promise containing a VRDisplay and if vr is supported
  15167. */
  15168. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15169. /** @hidden */
  15170. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15171. /**
  15172. * Gets or sets the presentation attributes used to configure VR rendering
  15173. */
  15174. vrPresentationAttributes?: IVRPresentationAttributes;
  15175. /**
  15176. * Call this function to switch to webVR mode
  15177. * Will do nothing if webVR is not supported or if there is no webVR device
  15178. * @param options the webvr options provided to the camera. mainly used for multiview
  15179. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15180. */
  15181. enableVR(options: WebVROptions): void;
  15182. /** @hidden */
  15183. _onVRFullScreenTriggered(): void;
  15184. }
  15185. }
  15186. declare module BABYLON {
  15187. /**
  15188. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15189. * IMPORTANT!! The data is right-hand data.
  15190. * @export
  15191. * @interface DevicePose
  15192. */
  15193. export interface DevicePose {
  15194. /**
  15195. * The position of the device, values in array are [x,y,z].
  15196. */
  15197. readonly position: Nullable<Float32Array>;
  15198. /**
  15199. * The linearVelocity of the device, values in array are [x,y,z].
  15200. */
  15201. readonly linearVelocity: Nullable<Float32Array>;
  15202. /**
  15203. * The linearAcceleration of the device, values in array are [x,y,z].
  15204. */
  15205. readonly linearAcceleration: Nullable<Float32Array>;
  15206. /**
  15207. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15208. */
  15209. readonly orientation: Nullable<Float32Array>;
  15210. /**
  15211. * The angularVelocity of the device, values in array are [x,y,z].
  15212. */
  15213. readonly angularVelocity: Nullable<Float32Array>;
  15214. /**
  15215. * The angularAcceleration of the device, values in array are [x,y,z].
  15216. */
  15217. readonly angularAcceleration: Nullable<Float32Array>;
  15218. }
  15219. /**
  15220. * Interface representing a pose controlled object in Babylon.
  15221. * A pose controlled object has both regular pose values as well as pose values
  15222. * from an external device such as a VR head mounted display
  15223. */
  15224. export interface PoseControlled {
  15225. /**
  15226. * The position of the object in babylon space.
  15227. */
  15228. position: Vector3;
  15229. /**
  15230. * The rotation quaternion of the object in babylon space.
  15231. */
  15232. rotationQuaternion: Quaternion;
  15233. /**
  15234. * The position of the device in babylon space.
  15235. */
  15236. devicePosition?: Vector3;
  15237. /**
  15238. * The rotation quaternion of the device in babylon space.
  15239. */
  15240. deviceRotationQuaternion: Quaternion;
  15241. /**
  15242. * The raw pose coming from the device.
  15243. */
  15244. rawPose: Nullable<DevicePose>;
  15245. /**
  15246. * The scale of the device to be used when translating from device space to babylon space.
  15247. */
  15248. deviceScaleFactor: number;
  15249. /**
  15250. * Updates the poseControlled values based on the input device pose.
  15251. * @param poseData the pose data to update the object with
  15252. */
  15253. updateFromDevice(poseData: DevicePose): void;
  15254. }
  15255. /**
  15256. * Set of options to customize the webVRCamera
  15257. */
  15258. export interface WebVROptions {
  15259. /**
  15260. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15261. */
  15262. trackPosition?: boolean;
  15263. /**
  15264. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15265. */
  15266. positionScale?: number;
  15267. /**
  15268. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15269. */
  15270. displayName?: string;
  15271. /**
  15272. * Should the native controller meshes be initialized. (default: true)
  15273. */
  15274. controllerMeshes?: boolean;
  15275. /**
  15276. * Creating a default HemiLight only on controllers. (default: true)
  15277. */
  15278. defaultLightingOnControllers?: boolean;
  15279. /**
  15280. * If you don't want to use the default VR button of the helper. (default: false)
  15281. */
  15282. useCustomVRButton?: boolean;
  15283. /**
  15284. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15285. */
  15286. customVRButton?: HTMLButtonElement;
  15287. /**
  15288. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15289. */
  15290. rayLength?: number;
  15291. /**
  15292. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15293. */
  15294. defaultHeight?: number;
  15295. /**
  15296. * If multiview should be used if availible (default: false)
  15297. */
  15298. useMultiview?: boolean;
  15299. }
  15300. /**
  15301. * This represents a WebVR camera.
  15302. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15303. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15304. */
  15305. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15306. private webVROptions;
  15307. /**
  15308. * @hidden
  15309. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15310. */
  15311. _vrDevice: any;
  15312. /**
  15313. * The rawPose of the vrDevice.
  15314. */
  15315. rawPose: Nullable<DevicePose>;
  15316. private _onVREnabled;
  15317. private _specsVersion;
  15318. private _attached;
  15319. private _frameData;
  15320. protected _descendants: Array<Node>;
  15321. private _deviceRoomPosition;
  15322. /** @hidden */
  15323. _deviceRoomRotationQuaternion: Quaternion;
  15324. private _standingMatrix;
  15325. /**
  15326. * Represents device position in babylon space.
  15327. */
  15328. devicePosition: Vector3;
  15329. /**
  15330. * Represents device rotation in babylon space.
  15331. */
  15332. deviceRotationQuaternion: Quaternion;
  15333. /**
  15334. * The scale of the device to be used when translating from device space to babylon space.
  15335. */
  15336. deviceScaleFactor: number;
  15337. private _deviceToWorld;
  15338. private _worldToDevice;
  15339. /**
  15340. * References to the webVR controllers for the vrDevice.
  15341. */
  15342. controllers: Array<WebVRController>;
  15343. /**
  15344. * Emits an event when a controller is attached.
  15345. */
  15346. onControllersAttachedObservable: Observable<WebVRController[]>;
  15347. /**
  15348. * Emits an event when a controller's mesh has been loaded;
  15349. */
  15350. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15351. /**
  15352. * Emits an event when the HMD's pose has been updated.
  15353. */
  15354. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15355. private _poseSet;
  15356. /**
  15357. * If the rig cameras be used as parent instead of this camera.
  15358. */
  15359. rigParenting: boolean;
  15360. private _lightOnControllers;
  15361. private _defaultHeight?;
  15362. /**
  15363. * Instantiates a WebVRFreeCamera.
  15364. * @param name The name of the WebVRFreeCamera
  15365. * @param position The starting anchor position for the camera
  15366. * @param scene The scene the camera belongs to
  15367. * @param webVROptions a set of customizable options for the webVRCamera
  15368. */
  15369. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15370. /**
  15371. * Gets the device distance from the ground in meters.
  15372. * @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.
  15373. */
  15374. deviceDistanceToRoomGround(): number;
  15375. /**
  15376. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15377. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15378. */
  15379. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15380. /**
  15381. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15382. * @returns A promise with a boolean set to if the standing matrix is supported.
  15383. */
  15384. useStandingMatrixAsync(): Promise<boolean>;
  15385. /**
  15386. * Disposes the camera
  15387. */
  15388. dispose(): void;
  15389. /**
  15390. * Gets a vrController by name.
  15391. * @param name The name of the controller to retreive
  15392. * @returns the controller matching the name specified or null if not found
  15393. */
  15394. getControllerByName(name: string): Nullable<WebVRController>;
  15395. private _leftController;
  15396. /**
  15397. * The controller corresponding to the users left hand.
  15398. */
  15399. get leftController(): Nullable<WebVRController>;
  15400. private _rightController;
  15401. /**
  15402. * The controller corresponding to the users right hand.
  15403. */
  15404. get rightController(): Nullable<WebVRController>;
  15405. /**
  15406. * Casts a ray forward from the vrCamera's gaze.
  15407. * @param length Length of the ray (default: 100)
  15408. * @returns the ray corresponding to the gaze
  15409. */
  15410. getForwardRay(length?: number): Ray;
  15411. /**
  15412. * @hidden
  15413. * Updates the camera based on device's frame data
  15414. */
  15415. _checkInputs(): void;
  15416. /**
  15417. * Updates the poseControlled values based on the input device pose.
  15418. * @param poseData Pose coming from the device
  15419. */
  15420. updateFromDevice(poseData: DevicePose): void;
  15421. private _htmlElementAttached;
  15422. private _detachIfAttached;
  15423. /**
  15424. * WebVR's attach control will start broadcasting frames to the device.
  15425. * Note that in certain browsers (chrome for example) this function must be called
  15426. * within a user-interaction callback. Example:
  15427. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15428. *
  15429. * @param element html element to attach the vrDevice to
  15430. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15431. */
  15432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15433. /**
  15434. * Detaches the camera from the html element and disables VR
  15435. *
  15436. * @param element html element to detach from
  15437. */
  15438. detachControl(element: HTMLElement): void;
  15439. /**
  15440. * @returns the name of this class
  15441. */
  15442. getClassName(): string;
  15443. /**
  15444. * Calls resetPose on the vrDisplay
  15445. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15446. */
  15447. resetToCurrentRotation(): void;
  15448. /**
  15449. * @hidden
  15450. * Updates the rig cameras (left and right eye)
  15451. */
  15452. _updateRigCameras(): void;
  15453. private _workingVector;
  15454. private _oneVector;
  15455. private _workingMatrix;
  15456. private updateCacheCalled;
  15457. private _correctPositionIfNotTrackPosition;
  15458. /**
  15459. * @hidden
  15460. * Updates the cached values of the camera
  15461. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15462. */
  15463. _updateCache(ignoreParentClass?: boolean): void;
  15464. /**
  15465. * @hidden
  15466. * Get current device position in babylon world
  15467. */
  15468. _computeDevicePosition(): void;
  15469. /**
  15470. * Updates the current device position and rotation in the babylon world
  15471. */
  15472. update(): void;
  15473. /**
  15474. * @hidden
  15475. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15476. * @returns an identity matrix
  15477. */
  15478. _getViewMatrix(): Matrix;
  15479. private _tmpMatrix;
  15480. /**
  15481. * This function is called by the two RIG cameras.
  15482. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15483. * @hidden
  15484. */
  15485. _getWebVRViewMatrix(): Matrix;
  15486. /** @hidden */
  15487. _getWebVRProjectionMatrix(): Matrix;
  15488. private _onGamepadConnectedObserver;
  15489. private _onGamepadDisconnectedObserver;
  15490. private _updateCacheWhenTrackingDisabledObserver;
  15491. /**
  15492. * Initializes the controllers and their meshes
  15493. */
  15494. initControllers(): void;
  15495. }
  15496. }
  15497. declare module BABYLON {
  15498. /**
  15499. * Size options for a post process
  15500. */
  15501. export type PostProcessOptions = {
  15502. width: number;
  15503. height: number;
  15504. };
  15505. /**
  15506. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15507. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15508. */
  15509. export class PostProcess {
  15510. /** Name of the PostProcess. */
  15511. name: string;
  15512. /**
  15513. * Gets or sets the unique id of the post process
  15514. */
  15515. uniqueId: number;
  15516. /**
  15517. * Width of the texture to apply the post process on
  15518. */
  15519. width: number;
  15520. /**
  15521. * Height of the texture to apply the post process on
  15522. */
  15523. height: number;
  15524. /**
  15525. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15526. * @hidden
  15527. */
  15528. _outputTexture: Nullable<InternalTexture>;
  15529. /**
  15530. * Sampling mode used by the shader
  15531. * See https://doc.babylonjs.com/classes/3.1/texture
  15532. */
  15533. renderTargetSamplingMode: number;
  15534. /**
  15535. * Clear color to use when screen clearing
  15536. */
  15537. clearColor: Color4;
  15538. /**
  15539. * If the buffer needs to be cleared before applying the post process. (default: true)
  15540. * Should be set to false if shader will overwrite all previous pixels.
  15541. */
  15542. autoClear: boolean;
  15543. /**
  15544. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15545. */
  15546. alphaMode: number;
  15547. /**
  15548. * Sets the setAlphaBlendConstants of the babylon engine
  15549. */
  15550. alphaConstants: Color4;
  15551. /**
  15552. * Animations to be used for the post processing
  15553. */
  15554. animations: Animation[];
  15555. /**
  15556. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15557. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15558. */
  15559. enablePixelPerfectMode: boolean;
  15560. /**
  15561. * Force the postprocess to be applied without taking in account viewport
  15562. */
  15563. forceFullscreenViewport: boolean;
  15564. /**
  15565. * List of inspectable custom properties (used by the Inspector)
  15566. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15567. */
  15568. inspectableCustomProperties: IInspectable[];
  15569. /**
  15570. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15571. *
  15572. * | Value | Type | Description |
  15573. * | ----- | ----------------------------------- | ----------- |
  15574. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15575. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15576. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15577. *
  15578. */
  15579. scaleMode: number;
  15580. /**
  15581. * Force textures to be a power of two (default: false)
  15582. */
  15583. alwaysForcePOT: boolean;
  15584. private _samples;
  15585. /**
  15586. * Number of sample textures (default: 1)
  15587. */
  15588. get samples(): number;
  15589. set samples(n: number);
  15590. /**
  15591. * Modify the scale of the post process to be the same as the viewport (default: false)
  15592. */
  15593. adaptScaleToCurrentViewport: boolean;
  15594. private _camera;
  15595. private _scene;
  15596. private _engine;
  15597. private _options;
  15598. private _reusable;
  15599. private _textureType;
  15600. private _textureFormat;
  15601. /**
  15602. * Smart array of input and output textures for the post process.
  15603. * @hidden
  15604. */
  15605. _textures: SmartArray<InternalTexture>;
  15606. /**
  15607. * The index in _textures that corresponds to the output texture.
  15608. * @hidden
  15609. */
  15610. _currentRenderTextureInd: number;
  15611. private _effect;
  15612. private _samplers;
  15613. private _fragmentUrl;
  15614. private _vertexUrl;
  15615. private _parameters;
  15616. private _scaleRatio;
  15617. protected _indexParameters: any;
  15618. private _shareOutputWithPostProcess;
  15619. private _texelSize;
  15620. private _forcedOutputTexture;
  15621. /**
  15622. * Returns the fragment url or shader name used in the post process.
  15623. * @returns the fragment url or name in the shader store.
  15624. */
  15625. getEffectName(): string;
  15626. /**
  15627. * An event triggered when the postprocess is activated.
  15628. */
  15629. onActivateObservable: Observable<Camera>;
  15630. private _onActivateObserver;
  15631. /**
  15632. * A function that is added to the onActivateObservable
  15633. */
  15634. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15635. /**
  15636. * An event triggered when the postprocess changes its size.
  15637. */
  15638. onSizeChangedObservable: Observable<PostProcess>;
  15639. private _onSizeChangedObserver;
  15640. /**
  15641. * A function that is added to the onSizeChangedObservable
  15642. */
  15643. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15644. /**
  15645. * An event triggered when the postprocess applies its effect.
  15646. */
  15647. onApplyObservable: Observable<Effect>;
  15648. private _onApplyObserver;
  15649. /**
  15650. * A function that is added to the onApplyObservable
  15651. */
  15652. set onApply(callback: (effect: Effect) => void);
  15653. /**
  15654. * An event triggered before rendering the postprocess
  15655. */
  15656. onBeforeRenderObservable: Observable<Effect>;
  15657. private _onBeforeRenderObserver;
  15658. /**
  15659. * A function that is added to the onBeforeRenderObservable
  15660. */
  15661. set onBeforeRender(callback: (effect: Effect) => void);
  15662. /**
  15663. * An event triggered after rendering the postprocess
  15664. */
  15665. onAfterRenderObservable: Observable<Effect>;
  15666. private _onAfterRenderObserver;
  15667. /**
  15668. * A function that is added to the onAfterRenderObservable
  15669. */
  15670. set onAfterRender(callback: (efect: Effect) => void);
  15671. /**
  15672. * 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
  15673. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15674. */
  15675. get inputTexture(): InternalTexture;
  15676. set inputTexture(value: InternalTexture);
  15677. /**
  15678. * Gets the camera which post process is applied to.
  15679. * @returns The camera the post process is applied to.
  15680. */
  15681. getCamera(): Camera;
  15682. /**
  15683. * Gets the texel size of the postprocess.
  15684. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15685. */
  15686. get texelSize(): Vector2;
  15687. /**
  15688. * Creates a new instance PostProcess
  15689. * @param name The name of the PostProcess.
  15690. * @param fragmentUrl The url of the fragment shader to be used.
  15691. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15692. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15693. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15694. * @param camera The camera to apply the render pass to.
  15695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15696. * @param engine The engine which the post process will be applied. (default: current engine)
  15697. * @param reusable If the post process can be reused on the same frame. (default: false)
  15698. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15699. * @param textureType Type of textures used when performing the post process. (default: 0)
  15700. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15701. * @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
  15702. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15703. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  15704. */
  15705. constructor(
  15706. /** Name of the PostProcess. */
  15707. 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);
  15708. /**
  15709. * Gets a string idenfifying the name of the class
  15710. * @returns "PostProcess" string
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Gets the engine which this post process belongs to.
  15715. * @returns The engine the post process was enabled with.
  15716. */
  15717. getEngine(): Engine;
  15718. /**
  15719. * The effect that is created when initializing the post process.
  15720. * @returns The created effect corresponding the the postprocess.
  15721. */
  15722. getEffect(): Effect;
  15723. /**
  15724. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15725. * @param postProcess The post process to share the output with.
  15726. * @returns This post process.
  15727. */
  15728. shareOutputWith(postProcess: PostProcess): PostProcess;
  15729. /**
  15730. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15731. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15732. */
  15733. useOwnOutput(): void;
  15734. /**
  15735. * Updates the effect with the current post process compile time values and recompiles the shader.
  15736. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15737. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15738. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15739. * @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
  15740. * @param onCompiled Called when the shader has been compiled.
  15741. * @param onError Called if there is an error when compiling a shader.
  15742. */
  15743. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15744. /**
  15745. * The post process is reusable if it can be used multiple times within one frame.
  15746. * @returns If the post process is reusable
  15747. */
  15748. isReusable(): boolean;
  15749. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15750. markTextureDirty(): void;
  15751. /**
  15752. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15753. * 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.
  15754. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15755. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15756. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15757. * @returns The target texture that was bound to be written to.
  15758. */
  15759. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15760. /**
  15761. * If the post process is supported.
  15762. */
  15763. get isSupported(): boolean;
  15764. /**
  15765. * The aspect ratio of the output texture.
  15766. */
  15767. get aspectRatio(): number;
  15768. /**
  15769. * Get a value indicating if the post-process is ready to be used
  15770. * @returns true if the post-process is ready (shader is compiled)
  15771. */
  15772. isReady(): boolean;
  15773. /**
  15774. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15775. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15776. */
  15777. apply(): Nullable<Effect>;
  15778. private _disposeTextures;
  15779. /**
  15780. * Disposes the post process.
  15781. * @param camera The camera to dispose the post process on.
  15782. */
  15783. dispose(camera?: Camera): void;
  15784. }
  15785. }
  15786. declare module BABYLON {
  15787. /** @hidden */
  15788. export var kernelBlurVaryingDeclaration: {
  15789. name: string;
  15790. shader: string;
  15791. };
  15792. }
  15793. declare module BABYLON {
  15794. /** @hidden */
  15795. export var kernelBlurFragment: {
  15796. name: string;
  15797. shader: string;
  15798. };
  15799. }
  15800. declare module BABYLON {
  15801. /** @hidden */
  15802. export var kernelBlurFragment2: {
  15803. name: string;
  15804. shader: string;
  15805. };
  15806. }
  15807. declare module BABYLON {
  15808. /** @hidden */
  15809. export var kernelBlurPixelShader: {
  15810. name: string;
  15811. shader: string;
  15812. };
  15813. }
  15814. declare module BABYLON {
  15815. /** @hidden */
  15816. export var kernelBlurVertex: {
  15817. name: string;
  15818. shader: string;
  15819. };
  15820. }
  15821. declare module BABYLON {
  15822. /** @hidden */
  15823. export var kernelBlurVertexShader: {
  15824. name: string;
  15825. shader: string;
  15826. };
  15827. }
  15828. declare module BABYLON {
  15829. /**
  15830. * The Blur Post Process which blurs an image based on a kernel and direction.
  15831. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15832. */
  15833. export class BlurPostProcess extends PostProcess {
  15834. /** The direction in which to blur the image. */
  15835. direction: Vector2;
  15836. private blockCompilation;
  15837. protected _kernel: number;
  15838. protected _idealKernel: number;
  15839. protected _packedFloat: boolean;
  15840. private _staticDefines;
  15841. /**
  15842. * Sets the length in pixels of the blur sample region
  15843. */
  15844. set kernel(v: number);
  15845. /**
  15846. * Gets the length in pixels of the blur sample region
  15847. */
  15848. get kernel(): number;
  15849. /**
  15850. * Sets wether or not the blur needs to unpack/repack floats
  15851. */
  15852. set packedFloat(v: boolean);
  15853. /**
  15854. * Gets wether or not the blur is unpacking/repacking floats
  15855. */
  15856. get packedFloat(): boolean;
  15857. /**
  15858. * Creates a new instance BlurPostProcess
  15859. * @param name The name of the effect.
  15860. * @param direction The direction in which to blur the image.
  15861. * @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.
  15862. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15863. * @param camera The camera to apply the render pass to.
  15864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15865. * @param engine The engine which the post process will be applied. (default: current engine)
  15866. * @param reusable If the post process can be reused on the same frame. (default: false)
  15867. * @param textureType Type of textures used when performing the post process. (default: 0)
  15868. * @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)
  15869. */
  15870. constructor(name: string,
  15871. /** The direction in which to blur the image. */
  15872. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15873. /**
  15874. * Updates the effect with the current post process compile time values and recompiles the shader.
  15875. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15876. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15877. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15878. * @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
  15879. * @param onCompiled Called when the shader has been compiled.
  15880. * @param onError Called if there is an error when compiling a shader.
  15881. */
  15882. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15883. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15884. /**
  15885. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15886. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15887. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15888. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15889. * The gaps between physical kernels are compensated for in the weighting of the samples
  15890. * @param idealKernel Ideal blur kernel.
  15891. * @return Nearest best kernel.
  15892. */
  15893. protected _nearestBestKernel(idealKernel: number): number;
  15894. /**
  15895. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15896. * @param x The point on the Gaussian distribution to sample.
  15897. * @return the value of the Gaussian function at x.
  15898. */
  15899. protected _gaussianWeight(x: number): number;
  15900. /**
  15901. * Generates a string that can be used as a floating point number in GLSL.
  15902. * @param x Value to print.
  15903. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15904. * @return GLSL float string.
  15905. */
  15906. protected _glslFloat(x: number, decimalFigures?: number): string;
  15907. }
  15908. }
  15909. declare module BABYLON {
  15910. /**
  15911. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15912. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15913. * You can then easily use it as a reflectionTexture on a flat surface.
  15914. * In case the surface is not a plane, please consider relying on reflection probes.
  15915. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15916. */
  15917. export class MirrorTexture extends RenderTargetTexture {
  15918. private scene;
  15919. /**
  15920. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15921. * 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.
  15922. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15923. */
  15924. mirrorPlane: Plane;
  15925. /**
  15926. * Define the blur ratio used to blur the reflection if needed.
  15927. */
  15928. set blurRatio(value: number);
  15929. get blurRatio(): number;
  15930. /**
  15931. * Define the adaptive blur kernel used to blur the reflection if needed.
  15932. * This will autocompute the closest best match for the `blurKernel`
  15933. */
  15934. set adaptiveBlurKernel(value: number);
  15935. /**
  15936. * Define the blur kernel used to blur the reflection if needed.
  15937. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15938. */
  15939. set blurKernel(value: number);
  15940. /**
  15941. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15942. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15943. */
  15944. set blurKernelX(value: number);
  15945. get blurKernelX(): number;
  15946. /**
  15947. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15948. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15949. */
  15950. set blurKernelY(value: number);
  15951. get blurKernelY(): number;
  15952. private _autoComputeBlurKernel;
  15953. protected _onRatioRescale(): void;
  15954. private _updateGammaSpace;
  15955. private _imageProcessingConfigChangeObserver;
  15956. private _transformMatrix;
  15957. private _mirrorMatrix;
  15958. private _savedViewMatrix;
  15959. private _blurX;
  15960. private _blurY;
  15961. private _adaptiveBlurKernel;
  15962. private _blurKernelX;
  15963. private _blurKernelY;
  15964. private _blurRatio;
  15965. /**
  15966. * Instantiates a Mirror Texture.
  15967. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15968. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15969. * You can then easily use it as a reflectionTexture on a flat surface.
  15970. * In case the surface is not a plane, please consider relying on reflection probes.
  15971. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15972. * @param name
  15973. * @param size
  15974. * @param scene
  15975. * @param generateMipMaps
  15976. * @param type
  15977. * @param samplingMode
  15978. * @param generateDepthBuffer
  15979. */
  15980. constructor(name: string, size: number | {
  15981. width: number;
  15982. height: number;
  15983. } | {
  15984. ratio: number;
  15985. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15986. private _preparePostProcesses;
  15987. /**
  15988. * Clone the mirror texture.
  15989. * @returns the cloned texture
  15990. */
  15991. clone(): MirrorTexture;
  15992. /**
  15993. * Serialize the texture to a JSON representation you could use in Parse later on
  15994. * @returns the serialized JSON representation
  15995. */
  15996. serialize(): any;
  15997. /**
  15998. * Dispose the texture and release its associated resources.
  15999. */
  16000. dispose(): void;
  16001. }
  16002. }
  16003. declare module BABYLON {
  16004. /**
  16005. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16006. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16007. */
  16008. export class Texture extends BaseTexture {
  16009. /**
  16010. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16011. */
  16012. static SerializeBuffers: boolean;
  16013. /** @hidden */
  16014. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  16015. /** @hidden */
  16016. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  16017. /** @hidden */
  16018. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  16019. /** nearest is mag = nearest and min = nearest and mip = linear */
  16020. static readonly NEAREST_SAMPLINGMODE: number;
  16021. /** nearest is mag = nearest and min = nearest and mip = linear */
  16022. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16024. static readonly BILINEAR_SAMPLINGMODE: number;
  16025. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16026. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16027. /** Trilinear is mag = linear and min = linear and mip = linear */
  16028. static readonly TRILINEAR_SAMPLINGMODE: number;
  16029. /** Trilinear is mag = linear and min = linear and mip = linear */
  16030. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16031. /** mag = nearest and min = nearest and mip = nearest */
  16032. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16033. /** mag = nearest and min = linear and mip = nearest */
  16034. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16035. /** mag = nearest and min = linear and mip = linear */
  16036. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16037. /** mag = nearest and min = linear and mip = none */
  16038. static readonly NEAREST_LINEAR: number;
  16039. /** mag = nearest and min = nearest and mip = none */
  16040. static readonly NEAREST_NEAREST: number;
  16041. /** mag = linear and min = nearest and mip = nearest */
  16042. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16043. /** mag = linear and min = nearest and mip = linear */
  16044. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16045. /** mag = linear and min = linear and mip = none */
  16046. static readonly LINEAR_LINEAR: number;
  16047. /** mag = linear and min = nearest and mip = none */
  16048. static readonly LINEAR_NEAREST: number;
  16049. /** Explicit coordinates mode */
  16050. static readonly EXPLICIT_MODE: number;
  16051. /** Spherical coordinates mode */
  16052. static readonly SPHERICAL_MODE: number;
  16053. /** Planar coordinates mode */
  16054. static readonly PLANAR_MODE: number;
  16055. /** Cubic coordinates mode */
  16056. static readonly CUBIC_MODE: number;
  16057. /** Projection coordinates mode */
  16058. static readonly PROJECTION_MODE: number;
  16059. /** Inverse Cubic coordinates mode */
  16060. static readonly SKYBOX_MODE: number;
  16061. /** Inverse Cubic coordinates mode */
  16062. static readonly INVCUBIC_MODE: number;
  16063. /** Equirectangular coordinates mode */
  16064. static readonly EQUIRECTANGULAR_MODE: number;
  16065. /** Equirectangular Fixed coordinates mode */
  16066. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16067. /** Equirectangular Fixed Mirrored coordinates mode */
  16068. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16069. /** Texture is not repeating outside of 0..1 UVs */
  16070. static readonly CLAMP_ADDRESSMODE: number;
  16071. /** Texture is repeating outside of 0..1 UVs */
  16072. static readonly WRAP_ADDRESSMODE: number;
  16073. /** Texture is repeating and mirrored */
  16074. static readonly MIRROR_ADDRESSMODE: number;
  16075. /**
  16076. * 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
  16077. */
  16078. static UseSerializedUrlIfAny: boolean;
  16079. /**
  16080. * Define the url of the texture.
  16081. */
  16082. url: Nullable<string>;
  16083. /**
  16084. * Define an offset on the texture to offset the u coordinates of the UVs
  16085. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16086. */
  16087. uOffset: number;
  16088. /**
  16089. * Define an offset on the texture to offset the v coordinates of the UVs
  16090. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16091. */
  16092. vOffset: number;
  16093. /**
  16094. * Define an offset on the texture to scale the u coordinates of the UVs
  16095. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16096. */
  16097. uScale: number;
  16098. /**
  16099. * Define an offset on the texture to scale the v coordinates of the UVs
  16100. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16101. */
  16102. vScale: number;
  16103. /**
  16104. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16105. * @see http://doc.babylonjs.com/how_to/more_materials
  16106. */
  16107. uAng: number;
  16108. /**
  16109. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16110. * @see http://doc.babylonjs.com/how_to/more_materials
  16111. */
  16112. vAng: number;
  16113. /**
  16114. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16115. * @see http://doc.babylonjs.com/how_to/more_materials
  16116. */
  16117. wAng: number;
  16118. /**
  16119. * Defines the center of rotation (U)
  16120. */
  16121. uRotationCenter: number;
  16122. /**
  16123. * Defines the center of rotation (V)
  16124. */
  16125. vRotationCenter: number;
  16126. /**
  16127. * Defines the center of rotation (W)
  16128. */
  16129. wRotationCenter: number;
  16130. /**
  16131. * Are mip maps generated for this texture or not.
  16132. */
  16133. get noMipmap(): boolean;
  16134. /**
  16135. * List of inspectable custom properties (used by the Inspector)
  16136. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16137. */
  16138. inspectableCustomProperties: Nullable<IInspectable[]>;
  16139. private _noMipmap;
  16140. /** @hidden */
  16141. _invertY: boolean;
  16142. private _rowGenerationMatrix;
  16143. private _cachedTextureMatrix;
  16144. private _projectionModeMatrix;
  16145. private _t0;
  16146. private _t1;
  16147. private _t2;
  16148. private _cachedUOffset;
  16149. private _cachedVOffset;
  16150. private _cachedUScale;
  16151. private _cachedVScale;
  16152. private _cachedUAng;
  16153. private _cachedVAng;
  16154. private _cachedWAng;
  16155. private _cachedProjectionMatrixId;
  16156. private _cachedCoordinatesMode;
  16157. /** @hidden */
  16158. protected _initialSamplingMode: number;
  16159. /** @hidden */
  16160. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16161. private _deleteBuffer;
  16162. protected _format: Nullable<number>;
  16163. private _delayedOnLoad;
  16164. private _delayedOnError;
  16165. private _mimeType?;
  16166. /**
  16167. * Observable triggered once the texture has been loaded.
  16168. */
  16169. onLoadObservable: Observable<Texture>;
  16170. protected _isBlocking: boolean;
  16171. /**
  16172. * Is the texture preventing material to render while loading.
  16173. * If false, a default texture will be used instead of the loading one during the preparation step.
  16174. */
  16175. set isBlocking(value: boolean);
  16176. get isBlocking(): boolean;
  16177. /**
  16178. * Get the current sampling mode associated with the texture.
  16179. */
  16180. get samplingMode(): number;
  16181. /**
  16182. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16183. */
  16184. get invertY(): boolean;
  16185. /**
  16186. * Instantiates a new texture.
  16187. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16188. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16189. * @param url defines the url of the picture to load as a texture
  16190. * @param scene defines the scene or engine the texture will belong to
  16191. * @param noMipmap defines if the texture will require mip maps or not
  16192. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16193. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16194. * @param onLoad defines a callback triggered when the texture has been loaded
  16195. * @param onError defines a callback triggered when an error occurred during the loading session
  16196. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16197. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16198. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16199. * @param mimeType defines an optional mime type information
  16200. */
  16201. 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);
  16202. /**
  16203. * Update the url (and optional buffer) of this texture if url was null during construction.
  16204. * @param url the url of the texture
  16205. * @param buffer the buffer of the texture (defaults to null)
  16206. * @param onLoad callback called when the texture is loaded (defaults to null)
  16207. */
  16208. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16209. /**
  16210. * Finish the loading sequence of a texture flagged as delayed load.
  16211. * @hidden
  16212. */
  16213. delayLoad(): void;
  16214. private _prepareRowForTextureGeneration;
  16215. /**
  16216. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16217. * @returns the transform matrix of the texture.
  16218. */
  16219. getTextureMatrix(uBase?: number): Matrix;
  16220. /**
  16221. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16222. * @returns The reflection texture transform
  16223. */
  16224. getReflectionTextureMatrix(): Matrix;
  16225. /**
  16226. * Clones the texture.
  16227. * @returns the cloned texture
  16228. */
  16229. clone(): Texture;
  16230. /**
  16231. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16232. * @returns The JSON representation of the texture
  16233. */
  16234. serialize(): any;
  16235. /**
  16236. * Get the current class name of the texture useful for serialization or dynamic coding.
  16237. * @returns "Texture"
  16238. */
  16239. getClassName(): string;
  16240. /**
  16241. * Dispose the texture and release its associated resources.
  16242. */
  16243. dispose(): void;
  16244. /**
  16245. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16246. * @param parsedTexture Define the JSON representation of the texture
  16247. * @param scene Define the scene the parsed texture should be instantiated in
  16248. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16249. * @returns The parsed texture if successful
  16250. */
  16251. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16252. /**
  16253. * Creates a texture from its base 64 representation.
  16254. * @param data Define the base64 payload without the data: prefix
  16255. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16256. * @param scene Define the scene the texture should belong to
  16257. * @param noMipmap Forces the texture to not create mip map information if true
  16258. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16259. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16260. * @param onLoad define a callback triggered when the texture has been loaded
  16261. * @param onError define a callback triggered when an error occurred during the loading session
  16262. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16263. * @returns the created texture
  16264. */
  16265. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16266. /**
  16267. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16268. * @param data Define the base64 payload without the data: prefix
  16269. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16270. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16271. * @param scene Define the scene the texture should belong to
  16272. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16273. * @param noMipmap Forces the texture to not create mip map information if true
  16274. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16275. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16276. * @param onLoad define a callback triggered when the texture has been loaded
  16277. * @param onError define a callback triggered when an error occurred during the loading session
  16278. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16279. * @returns the created texture
  16280. */
  16281. 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;
  16282. }
  16283. }
  16284. declare module BABYLON {
  16285. /**
  16286. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16287. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16288. */
  16289. export class PostProcessManager {
  16290. private _scene;
  16291. private _indexBuffer;
  16292. private _vertexBuffers;
  16293. /**
  16294. * Creates a new instance PostProcess
  16295. * @param scene The scene that the post process is associated with.
  16296. */
  16297. constructor(scene: Scene);
  16298. private _prepareBuffers;
  16299. private _buildIndexBuffer;
  16300. /**
  16301. * Rebuilds the vertex buffers of the manager.
  16302. * @hidden
  16303. */
  16304. _rebuild(): void;
  16305. /**
  16306. * Prepares a frame to be run through a post process.
  16307. * @param sourceTexture The input texture to the post procesess. (default: null)
  16308. * @param postProcesses An array of post processes to be run. (default: null)
  16309. * @returns True if the post processes were able to be run.
  16310. * @hidden
  16311. */
  16312. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16313. /**
  16314. * Manually render a set of post processes to a texture.
  16315. * @param postProcesses An array of post processes to be run.
  16316. * @param targetTexture The target texture to render to.
  16317. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16318. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16319. * @param lodLevel defines which lod of the texture to render to
  16320. */
  16321. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16322. /**
  16323. * Finalize the result of the output of the postprocesses.
  16324. * @param doNotPresent If true the result will not be displayed to the screen.
  16325. * @param targetTexture The target texture to render to.
  16326. * @param faceIndex The index of the face to bind the target texture to.
  16327. * @param postProcesses The array of post processes to render.
  16328. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16329. * @hidden
  16330. */
  16331. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16332. /**
  16333. * Disposes of the post process manager.
  16334. */
  16335. dispose(): void;
  16336. }
  16337. }
  16338. declare module BABYLON {
  16339. /** Interface used by value gradients (color, factor, ...) */
  16340. export interface IValueGradient {
  16341. /**
  16342. * Gets or sets the gradient value (between 0 and 1)
  16343. */
  16344. gradient: number;
  16345. }
  16346. /** Class used to store color4 gradient */
  16347. export class ColorGradient implements IValueGradient {
  16348. /**
  16349. * Gets or sets the gradient value (between 0 and 1)
  16350. */
  16351. gradient: number;
  16352. /**
  16353. * Gets or sets first associated color
  16354. */
  16355. color1: Color4;
  16356. /**
  16357. * Gets or sets second associated color
  16358. */
  16359. color2?: Color4;
  16360. /**
  16361. * Will get a color picked randomly between color1 and color2.
  16362. * If color2 is undefined then color1 will be used
  16363. * @param result defines the target Color4 to store the result in
  16364. */
  16365. getColorToRef(result: Color4): void;
  16366. }
  16367. /** Class used to store color 3 gradient */
  16368. export class Color3Gradient implements IValueGradient {
  16369. /**
  16370. * Gets or sets the gradient value (between 0 and 1)
  16371. */
  16372. gradient: number;
  16373. /**
  16374. * Gets or sets the associated color
  16375. */
  16376. color: Color3;
  16377. }
  16378. /** Class used to store factor gradient */
  16379. export class FactorGradient implements IValueGradient {
  16380. /**
  16381. * Gets or sets the gradient value (between 0 and 1)
  16382. */
  16383. gradient: number;
  16384. /**
  16385. * Gets or sets first associated factor
  16386. */
  16387. factor1: number;
  16388. /**
  16389. * Gets or sets second associated factor
  16390. */
  16391. factor2?: number;
  16392. /**
  16393. * Will get a number picked randomly between factor1 and factor2.
  16394. * If factor2 is undefined then factor1 will be used
  16395. * @returns the picked number
  16396. */
  16397. getFactor(): number;
  16398. }
  16399. /**
  16400. * Helper used to simplify some generic gradient tasks
  16401. */
  16402. export class GradientHelper {
  16403. /**
  16404. * Gets the current gradient from an array of IValueGradient
  16405. * @param ratio defines the current ratio to get
  16406. * @param gradients defines the array of IValueGradient
  16407. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16408. */
  16409. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16410. }
  16411. }
  16412. declare module BABYLON {
  16413. interface ThinEngine {
  16414. /**
  16415. * Creates a dynamic texture
  16416. * @param width defines the width of the texture
  16417. * @param height defines the height of the texture
  16418. * @param generateMipMaps defines if the engine should generate the mip levels
  16419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16420. * @returns the dynamic texture inside an InternalTexture
  16421. */
  16422. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16423. /**
  16424. * Update the content of a dynamic texture
  16425. * @param texture defines the texture to update
  16426. * @param canvas defines the canvas containing the source
  16427. * @param invertY defines if data must be stored with Y axis inverted
  16428. * @param premulAlpha defines if alpha is stored as premultiplied
  16429. * @param format defines the format of the data
  16430. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16431. */
  16432. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16433. }
  16434. }
  16435. declare module BABYLON {
  16436. /**
  16437. * Helper class used to generate a canvas to manipulate images
  16438. */
  16439. export class CanvasGenerator {
  16440. /**
  16441. * Create a new canvas (or offscreen canvas depending on the context)
  16442. * @param width defines the expected width
  16443. * @param height defines the expected height
  16444. * @return a new canvas or offscreen canvas
  16445. */
  16446. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16447. }
  16448. }
  16449. declare module BABYLON {
  16450. /**
  16451. * A class extending Texture allowing drawing on a texture
  16452. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16453. */
  16454. export class DynamicTexture extends Texture {
  16455. private _generateMipMaps;
  16456. private _canvas;
  16457. private _context;
  16458. private _engine;
  16459. /**
  16460. * Creates a DynamicTexture
  16461. * @param name defines the name of the texture
  16462. * @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
  16463. * @param scene defines the scene where you want the texture
  16464. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16465. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16466. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16467. */
  16468. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16469. /**
  16470. * Get the current class name of the texture useful for serialization or dynamic coding.
  16471. * @returns "DynamicTexture"
  16472. */
  16473. getClassName(): string;
  16474. /**
  16475. * Gets the current state of canRescale
  16476. */
  16477. get canRescale(): boolean;
  16478. private _recreate;
  16479. /**
  16480. * Scales the texture
  16481. * @param ratio the scale factor to apply to both width and height
  16482. */
  16483. scale(ratio: number): void;
  16484. /**
  16485. * Resizes the texture
  16486. * @param width the new width
  16487. * @param height the new height
  16488. */
  16489. scaleTo(width: number, height: number): void;
  16490. /**
  16491. * Gets the context of the canvas used by the texture
  16492. * @returns the canvas context of the dynamic texture
  16493. */
  16494. getContext(): CanvasRenderingContext2D;
  16495. /**
  16496. * Clears the texture
  16497. */
  16498. clear(): void;
  16499. /**
  16500. * Updates the texture
  16501. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16502. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16503. */
  16504. update(invertY?: boolean, premulAlpha?: boolean): void;
  16505. /**
  16506. * Draws text onto the texture
  16507. * @param text defines the text to be drawn
  16508. * @param x defines the placement of the text from the left
  16509. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16510. * @param font defines the font to be used with font-style, font-size, font-name
  16511. * @param color defines the color used for the text
  16512. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16513. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16514. * @param update defines whether texture is immediately update (default is true)
  16515. */
  16516. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16517. /**
  16518. * Clones the texture
  16519. * @returns the clone of the texture.
  16520. */
  16521. clone(): DynamicTexture;
  16522. /**
  16523. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16524. * @returns a serialized dynamic texture object
  16525. */
  16526. serialize(): any;
  16527. /** @hidden */
  16528. _rebuild(): void;
  16529. }
  16530. }
  16531. declare module BABYLON {
  16532. interface AbstractScene {
  16533. /**
  16534. * The list of procedural textures added to the scene
  16535. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16536. */
  16537. proceduralTextures: Array<ProceduralTexture>;
  16538. }
  16539. /**
  16540. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16541. * in a given scene.
  16542. */
  16543. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16544. /**
  16545. * The component name helpfull to identify the component in the list of scene components.
  16546. */
  16547. readonly name: string;
  16548. /**
  16549. * The scene the component belongs to.
  16550. */
  16551. scene: Scene;
  16552. /**
  16553. * Creates a new instance of the component for the given scene
  16554. * @param scene Defines the scene to register the component in
  16555. */
  16556. constructor(scene: Scene);
  16557. /**
  16558. * Registers the component in a given scene
  16559. */
  16560. register(): void;
  16561. /**
  16562. * Rebuilds the elements related to this component in case of
  16563. * context lost for instance.
  16564. */
  16565. rebuild(): void;
  16566. /**
  16567. * Disposes the component and the associated ressources.
  16568. */
  16569. dispose(): void;
  16570. private _beforeClear;
  16571. }
  16572. }
  16573. declare module BABYLON {
  16574. interface ThinEngine {
  16575. /**
  16576. * Creates a new render target cube texture
  16577. * @param size defines the size of the texture
  16578. * @param options defines the options used to create the texture
  16579. * @returns a new render target cube texture stored in an InternalTexture
  16580. */
  16581. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16582. }
  16583. }
  16584. declare module BABYLON {
  16585. /** @hidden */
  16586. export var proceduralVertexShader: {
  16587. name: string;
  16588. shader: string;
  16589. };
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * 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.
  16594. * This is the base class of any Procedural texture and contains most of the shareable code.
  16595. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16596. */
  16597. export class ProceduralTexture extends Texture {
  16598. isCube: boolean;
  16599. /**
  16600. * Define if the texture is enabled or not (disabled texture will not render)
  16601. */
  16602. isEnabled: boolean;
  16603. /**
  16604. * Define if the texture must be cleared before rendering (default is true)
  16605. */
  16606. autoClear: boolean;
  16607. /**
  16608. * Callback called when the texture is generated
  16609. */
  16610. onGenerated: () => void;
  16611. /**
  16612. * Event raised when the texture is generated
  16613. */
  16614. onGeneratedObservable: Observable<ProceduralTexture>;
  16615. /** @hidden */
  16616. _generateMipMaps: boolean;
  16617. /** @hidden **/
  16618. _effect: Effect;
  16619. /** @hidden */
  16620. _textures: {
  16621. [key: string]: Texture;
  16622. };
  16623. private _size;
  16624. private _currentRefreshId;
  16625. private _frameId;
  16626. private _refreshRate;
  16627. private _vertexBuffers;
  16628. private _indexBuffer;
  16629. private _uniforms;
  16630. private _samplers;
  16631. private _fragment;
  16632. private _floats;
  16633. private _ints;
  16634. private _floatsArrays;
  16635. private _colors3;
  16636. private _colors4;
  16637. private _vectors2;
  16638. private _vectors3;
  16639. private _matrices;
  16640. private _fallbackTexture;
  16641. private _fallbackTextureUsed;
  16642. private _engine;
  16643. private _cachedDefines;
  16644. private _contentUpdateId;
  16645. private _contentData;
  16646. /**
  16647. * Instantiates a new procedural texture.
  16648. * 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.
  16649. * This is the base class of any Procedural texture and contains most of the shareable code.
  16650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16651. * @param name Define the name of the texture
  16652. * @param size Define the size of the texture to create
  16653. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16654. * @param scene Define the scene the texture belongs to
  16655. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16656. * @param generateMipMaps Define if the texture should creates mip maps or not
  16657. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16658. */
  16659. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16660. /**
  16661. * The effect that is created when initializing the post process.
  16662. * @returns The created effect corresponding the the postprocess.
  16663. */
  16664. getEffect(): Effect;
  16665. /**
  16666. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16667. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16668. */
  16669. getContent(): Nullable<ArrayBufferView>;
  16670. private _createIndexBuffer;
  16671. /** @hidden */
  16672. _rebuild(): void;
  16673. /**
  16674. * Resets the texture in order to recreate its associated resources.
  16675. * This can be called in case of context loss
  16676. */
  16677. reset(): void;
  16678. protected _getDefines(): string;
  16679. /**
  16680. * Is the texture ready to be used ? (rendered at least once)
  16681. * @returns true if ready, otherwise, false.
  16682. */
  16683. isReady(): boolean;
  16684. /**
  16685. * Resets the refresh counter of the texture and start bak from scratch.
  16686. * Could be useful to regenerate the texture if it is setup to render only once.
  16687. */
  16688. resetRefreshCounter(): void;
  16689. /**
  16690. * Set the fragment shader to use in order to render the texture.
  16691. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16692. */
  16693. setFragment(fragment: any): void;
  16694. /**
  16695. * Define the refresh rate of the texture or the rendering frequency.
  16696. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16697. */
  16698. get refreshRate(): number;
  16699. set refreshRate(value: number);
  16700. /** @hidden */
  16701. _shouldRender(): boolean;
  16702. /**
  16703. * Get the size the texture is rendering at.
  16704. * @returns the size (texture is always squared)
  16705. */
  16706. getRenderSize(): number;
  16707. /**
  16708. * Resize the texture to new value.
  16709. * @param size Define the new size the texture should have
  16710. * @param generateMipMaps Define whether the new texture should create mip maps
  16711. */
  16712. resize(size: number, generateMipMaps: boolean): void;
  16713. private _checkUniform;
  16714. /**
  16715. * Set a texture in the shader program used to render.
  16716. * @param name Define the name of the uniform samplers as defined in the shader
  16717. * @param texture Define the texture to bind to this sampler
  16718. * @return the texture itself allowing "fluent" like uniform updates
  16719. */
  16720. setTexture(name: string, texture: Texture): ProceduralTexture;
  16721. /**
  16722. * Set a float in the shader.
  16723. * @param name Define the name of the uniform as defined in the shader
  16724. * @param value Define the value to give to the uniform
  16725. * @return the texture itself allowing "fluent" like uniform updates
  16726. */
  16727. setFloat(name: string, value: number): ProceduralTexture;
  16728. /**
  16729. * Set a int in the shader.
  16730. * @param name Define the name of the uniform as defined in the shader
  16731. * @param value Define the value to give to the uniform
  16732. * @return the texture itself allowing "fluent" like uniform updates
  16733. */
  16734. setInt(name: string, value: number): ProceduralTexture;
  16735. /**
  16736. * Set an array of floats in the shader.
  16737. * @param name Define the name of the uniform as defined in the shader
  16738. * @param value Define the value to give to the uniform
  16739. * @return the texture itself allowing "fluent" like uniform updates
  16740. */
  16741. setFloats(name: string, value: number[]): ProceduralTexture;
  16742. /**
  16743. * Set a vec3 in the shader from a Color3.
  16744. * @param name Define the name of the uniform as defined in the shader
  16745. * @param value Define the value to give to the uniform
  16746. * @return the texture itself allowing "fluent" like uniform updates
  16747. */
  16748. setColor3(name: string, value: Color3): ProceduralTexture;
  16749. /**
  16750. * Set a vec4 in the shader from a Color4.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the texture itself allowing "fluent" like uniform updates
  16754. */
  16755. setColor4(name: string, value: Color4): ProceduralTexture;
  16756. /**
  16757. * Set a vec2 in the shader from a Vector2.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the texture itself allowing "fluent" like uniform updates
  16761. */
  16762. setVector2(name: string, value: Vector2): ProceduralTexture;
  16763. /**
  16764. * Set a vec3 in the shader from a Vector3.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the texture itself allowing "fluent" like uniform updates
  16768. */
  16769. setVector3(name: string, value: Vector3): ProceduralTexture;
  16770. /**
  16771. * Set a mat4 in the shader from a MAtrix.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the texture itself allowing "fluent" like uniform updates
  16775. */
  16776. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16777. /**
  16778. * Render the texture to its associated render target.
  16779. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16780. */
  16781. render(useCameraPostProcess?: boolean): void;
  16782. /**
  16783. * Clone the texture.
  16784. * @returns the cloned texture
  16785. */
  16786. clone(): ProceduralTexture;
  16787. /**
  16788. * Dispose the texture and release its asoociated resources.
  16789. */
  16790. dispose(): void;
  16791. }
  16792. }
  16793. declare module BABYLON {
  16794. /**
  16795. * This represents the base class for particle system in Babylon.
  16796. * 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.
  16797. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16798. * @example https://doc.babylonjs.com/babylon101/particles
  16799. */
  16800. export class BaseParticleSystem {
  16801. /**
  16802. * Source color is added to the destination color without alpha affecting the result
  16803. */
  16804. static BLENDMODE_ONEONE: number;
  16805. /**
  16806. * Blend current color and particle color using particle’s alpha
  16807. */
  16808. static BLENDMODE_STANDARD: number;
  16809. /**
  16810. * Add current color and particle color multiplied by particle’s alpha
  16811. */
  16812. static BLENDMODE_ADD: number;
  16813. /**
  16814. * Multiply current color with particle color
  16815. */
  16816. static BLENDMODE_MULTIPLY: number;
  16817. /**
  16818. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16819. */
  16820. static BLENDMODE_MULTIPLYADD: number;
  16821. /**
  16822. * List of animations used by the particle system.
  16823. */
  16824. animations: Animation[];
  16825. /**
  16826. * The id of the Particle system.
  16827. */
  16828. id: string;
  16829. /**
  16830. * The friendly name of the Particle system.
  16831. */
  16832. name: string;
  16833. /**
  16834. * The rendering group used by the Particle system to chose when to render.
  16835. */
  16836. renderingGroupId: number;
  16837. /**
  16838. * The emitter represents the Mesh or position we are attaching the particle system to.
  16839. */
  16840. emitter: Nullable<AbstractMesh | Vector3>;
  16841. /**
  16842. * The maximum number of particles to emit per frame
  16843. */
  16844. emitRate: number;
  16845. /**
  16846. * If you want to launch only a few particles at once, that can be done, as well.
  16847. */
  16848. manualEmitCount: number;
  16849. /**
  16850. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16851. */
  16852. updateSpeed: number;
  16853. /**
  16854. * The amount of time the particle system is running (depends of the overall update speed).
  16855. */
  16856. targetStopDuration: number;
  16857. /**
  16858. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16859. */
  16860. disposeOnStop: boolean;
  16861. /**
  16862. * Minimum power of emitting particles.
  16863. */
  16864. minEmitPower: number;
  16865. /**
  16866. * Maximum power of emitting particles.
  16867. */
  16868. maxEmitPower: number;
  16869. /**
  16870. * Minimum life time of emitting particles.
  16871. */
  16872. minLifeTime: number;
  16873. /**
  16874. * Maximum life time of emitting particles.
  16875. */
  16876. maxLifeTime: number;
  16877. /**
  16878. * Minimum Size of emitting particles.
  16879. */
  16880. minSize: number;
  16881. /**
  16882. * Maximum Size of emitting particles.
  16883. */
  16884. maxSize: number;
  16885. /**
  16886. * Minimum scale of emitting particles on X axis.
  16887. */
  16888. minScaleX: number;
  16889. /**
  16890. * Maximum scale of emitting particles on X axis.
  16891. */
  16892. maxScaleX: number;
  16893. /**
  16894. * Minimum scale of emitting particles on Y axis.
  16895. */
  16896. minScaleY: number;
  16897. /**
  16898. * Maximum scale of emitting particles on Y axis.
  16899. */
  16900. maxScaleY: number;
  16901. /**
  16902. * Gets or sets the minimal initial rotation in radians.
  16903. */
  16904. minInitialRotation: number;
  16905. /**
  16906. * Gets or sets the maximal initial rotation in radians.
  16907. */
  16908. maxInitialRotation: number;
  16909. /**
  16910. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16911. */
  16912. minAngularSpeed: number;
  16913. /**
  16914. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16915. */
  16916. maxAngularSpeed: number;
  16917. /**
  16918. * The texture used to render each particle. (this can be a spritesheet)
  16919. */
  16920. particleTexture: Nullable<Texture>;
  16921. /**
  16922. * The layer mask we are rendering the particles through.
  16923. */
  16924. layerMask: number;
  16925. /**
  16926. * This can help using your own shader to render the particle system.
  16927. * The according effect will be created
  16928. */
  16929. customShader: any;
  16930. /**
  16931. * By default particle system starts as soon as they are created. This prevents the
  16932. * automatic start to happen and let you decide when to start emitting particles.
  16933. */
  16934. preventAutoStart: boolean;
  16935. private _noiseTexture;
  16936. /**
  16937. * Gets or sets a texture used to add random noise to particle positions
  16938. */
  16939. get noiseTexture(): Nullable<ProceduralTexture>;
  16940. set noiseTexture(value: Nullable<ProceduralTexture>);
  16941. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16942. noiseStrength: Vector3;
  16943. /**
  16944. * Callback triggered when the particle animation is ending.
  16945. */
  16946. onAnimationEnd: Nullable<() => void>;
  16947. /**
  16948. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16949. */
  16950. blendMode: number;
  16951. /**
  16952. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16953. * to override the particles.
  16954. */
  16955. forceDepthWrite: boolean;
  16956. /** 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 */
  16957. preWarmCycles: number;
  16958. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16959. preWarmStepOffset: number;
  16960. /**
  16961. * 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)
  16962. */
  16963. spriteCellChangeSpeed: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16966. */
  16967. startSpriteCellID: number;
  16968. /**
  16969. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16970. */
  16971. endSpriteCellID: number;
  16972. /**
  16973. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16974. */
  16975. spriteCellWidth: number;
  16976. /**
  16977. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16978. */
  16979. spriteCellHeight: number;
  16980. /**
  16981. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16982. */
  16983. spriteRandomStartCell: boolean;
  16984. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16985. translationPivot: Vector2;
  16986. /** @hidden */
  16987. protected _isAnimationSheetEnabled: boolean;
  16988. /**
  16989. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16990. */
  16991. beginAnimationOnStart: boolean;
  16992. /**
  16993. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16994. */
  16995. beginAnimationFrom: number;
  16996. /**
  16997. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16998. */
  16999. beginAnimationTo: number;
  17000. /**
  17001. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17002. */
  17003. beginAnimationLoop: boolean;
  17004. /**
  17005. * Gets or sets a world offset applied to all particles
  17006. */
  17007. worldOffset: Vector3;
  17008. /**
  17009. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17010. */
  17011. get isAnimationSheetEnabled(): boolean;
  17012. set isAnimationSheetEnabled(value: boolean);
  17013. /**
  17014. * Get hosting scene
  17015. * @returns the scene
  17016. */
  17017. getScene(): Scene;
  17018. /**
  17019. * You can use gravity if you want to give an orientation to your particles.
  17020. */
  17021. gravity: Vector3;
  17022. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17023. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17024. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17025. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17026. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17027. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17028. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17029. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17030. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17031. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17032. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17033. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17034. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17035. /**
  17036. * Defines the delay in milliseconds before starting the system (0 by default)
  17037. */
  17038. startDelay: number;
  17039. /**
  17040. * Gets the current list of drag gradients.
  17041. * You must use addDragGradient and removeDragGradient to udpate this list
  17042. * @returns the list of drag gradients
  17043. */
  17044. getDragGradients(): Nullable<Array<FactorGradient>>;
  17045. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17046. limitVelocityDamping: number;
  17047. /**
  17048. * Gets the current list of limit velocity gradients.
  17049. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17050. * @returns the list of limit velocity gradients
  17051. */
  17052. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17053. /**
  17054. * Gets the current list of color gradients.
  17055. * You must use addColorGradient and removeColorGradient to udpate this list
  17056. * @returns the list of color gradients
  17057. */
  17058. getColorGradients(): Nullable<Array<ColorGradient>>;
  17059. /**
  17060. * Gets the current list of size gradients.
  17061. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17062. * @returns the list of size gradients
  17063. */
  17064. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17065. /**
  17066. * Gets the current list of color remap gradients.
  17067. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17068. * @returns the list of color remap gradients
  17069. */
  17070. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17071. /**
  17072. * Gets the current list of alpha remap gradients.
  17073. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17074. * @returns the list of alpha remap gradients
  17075. */
  17076. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17077. /**
  17078. * Gets the current list of life time gradients.
  17079. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17080. * @returns the list of life time gradients
  17081. */
  17082. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17083. /**
  17084. * Gets the current list of angular speed gradients.
  17085. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17086. * @returns the list of angular speed gradients
  17087. */
  17088. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17089. /**
  17090. * Gets the current list of velocity gradients.
  17091. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17092. * @returns the list of velocity gradients
  17093. */
  17094. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17095. /**
  17096. * Gets the current list of start size gradients.
  17097. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17098. * @returns the list of start size gradients
  17099. */
  17100. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17101. /**
  17102. * Gets the current list of emit rate gradients.
  17103. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17104. * @returns the list of emit rate gradients
  17105. */
  17106. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17107. /**
  17108. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17109. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17110. */
  17111. get direction1(): Vector3;
  17112. set direction1(value: Vector3);
  17113. /**
  17114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17115. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17116. */
  17117. get direction2(): Vector3;
  17118. set direction2(value: Vector3);
  17119. /**
  17120. * 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.
  17121. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17122. */
  17123. get minEmitBox(): Vector3;
  17124. set minEmitBox(value: Vector3);
  17125. /**
  17126. * 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.
  17127. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17128. */
  17129. get maxEmitBox(): Vector3;
  17130. set maxEmitBox(value: Vector3);
  17131. /**
  17132. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17133. */
  17134. color1: Color4;
  17135. /**
  17136. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17137. */
  17138. color2: Color4;
  17139. /**
  17140. * Color the particle will have at the end of its lifetime
  17141. */
  17142. colorDead: Color4;
  17143. /**
  17144. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17145. */
  17146. textureMask: Color4;
  17147. /**
  17148. * The particle emitter type defines the emitter used by the particle system.
  17149. * It can be for example box, sphere, or cone...
  17150. */
  17151. particleEmitterType: IParticleEmitterType;
  17152. /** @hidden */
  17153. _isSubEmitter: boolean;
  17154. /**
  17155. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17156. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17157. */
  17158. billboardMode: number;
  17159. protected _isBillboardBased: boolean;
  17160. /**
  17161. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17162. */
  17163. get isBillboardBased(): boolean;
  17164. set isBillboardBased(value: boolean);
  17165. /**
  17166. * The scene the particle system belongs to.
  17167. */
  17168. protected _scene: Scene;
  17169. /**
  17170. * Local cache of defines for image processing.
  17171. */
  17172. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17173. /**
  17174. * Default configuration related to image processing available in the standard Material.
  17175. */
  17176. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17177. /**
  17178. * Gets the image processing configuration used either in this material.
  17179. */
  17180. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17181. /**
  17182. * Sets the Default image processing configuration used either in the this material.
  17183. *
  17184. * If sets to null, the scene one is in use.
  17185. */
  17186. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17187. /**
  17188. * Attaches a new image processing configuration to the Standard Material.
  17189. * @param configuration
  17190. */
  17191. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17192. /** @hidden */
  17193. protected _reset(): void;
  17194. /** @hidden */
  17195. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17196. /**
  17197. * Instantiates a particle system.
  17198. * 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.
  17199. * @param name The name of the particle system
  17200. */
  17201. constructor(name: string);
  17202. /**
  17203. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17204. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17205. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17206. * @returns the emitter
  17207. */
  17208. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17209. /**
  17210. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17211. * @param radius The radius of the hemisphere to emit from
  17212. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17213. * @returns the emitter
  17214. */
  17215. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17216. /**
  17217. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17218. * @param radius The radius of the sphere to emit from
  17219. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17220. * @returns the emitter
  17221. */
  17222. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17223. /**
  17224. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17225. * @param radius The radius of the sphere to emit from
  17226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17228. * @returns the emitter
  17229. */
  17230. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17231. /**
  17232. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17233. * @param radius The radius of the emission cylinder
  17234. * @param height The height of the emission cylinder
  17235. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17236. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17237. * @returns the emitter
  17238. */
  17239. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17240. /**
  17241. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17242. * @param radius The radius of the cylinder to emit from
  17243. * @param height The height of the emission cylinder
  17244. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17245. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17246. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17247. * @returns the emitter
  17248. */
  17249. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17250. /**
  17251. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17252. * @param radius The radius of the cone to emit from
  17253. * @param angle The base angle of the cone
  17254. * @returns the emitter
  17255. */
  17256. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17257. /**
  17258. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17259. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17260. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17261. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17262. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17263. * @returns the emitter
  17264. */
  17265. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17266. }
  17267. }
  17268. declare module BABYLON {
  17269. /**
  17270. * Type of sub emitter
  17271. */
  17272. export enum SubEmitterType {
  17273. /**
  17274. * Attached to the particle over it's lifetime
  17275. */
  17276. ATTACHED = 0,
  17277. /**
  17278. * Created when the particle dies
  17279. */
  17280. END = 1
  17281. }
  17282. /**
  17283. * Sub emitter class used to emit particles from an existing particle
  17284. */
  17285. export class SubEmitter {
  17286. /**
  17287. * the particle system to be used by the sub emitter
  17288. */
  17289. particleSystem: ParticleSystem;
  17290. /**
  17291. * Type of the submitter (Default: END)
  17292. */
  17293. type: SubEmitterType;
  17294. /**
  17295. * 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)
  17296. * Note: This only is supported when using an emitter of type Mesh
  17297. */
  17298. inheritDirection: boolean;
  17299. /**
  17300. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17301. */
  17302. inheritedVelocityAmount: number;
  17303. /**
  17304. * Creates a sub emitter
  17305. * @param particleSystem the particle system to be used by the sub emitter
  17306. */
  17307. constructor(
  17308. /**
  17309. * the particle system to be used by the sub emitter
  17310. */
  17311. particleSystem: ParticleSystem);
  17312. /**
  17313. * Clones the sub emitter
  17314. * @returns the cloned sub emitter
  17315. */
  17316. clone(): SubEmitter;
  17317. /**
  17318. * Serialize current object to a JSON object
  17319. * @returns the serialized object
  17320. */
  17321. serialize(): any;
  17322. /** @hidden */
  17323. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17324. /**
  17325. * Creates a new SubEmitter from a serialized JSON version
  17326. * @param serializationObject defines the JSON object to read from
  17327. * @param scene defines the hosting scene
  17328. * @param rootUrl defines the rootUrl for data loading
  17329. * @returns a new SubEmitter
  17330. */
  17331. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17332. /** Release associated resources */
  17333. dispose(): void;
  17334. }
  17335. }
  17336. declare module BABYLON {
  17337. /** @hidden */
  17338. export var imageProcessingDeclaration: {
  17339. name: string;
  17340. shader: string;
  17341. };
  17342. }
  17343. declare module BABYLON {
  17344. /** @hidden */
  17345. export var imageProcessingFunctions: {
  17346. name: string;
  17347. shader: string;
  17348. };
  17349. }
  17350. declare module BABYLON {
  17351. /** @hidden */
  17352. export var particlesPixelShader: {
  17353. name: string;
  17354. shader: string;
  17355. };
  17356. }
  17357. declare module BABYLON {
  17358. /** @hidden */
  17359. export var particlesVertexShader: {
  17360. name: string;
  17361. shader: string;
  17362. };
  17363. }
  17364. declare module BABYLON {
  17365. /**
  17366. * This represents a particle system in Babylon.
  17367. * 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.
  17368. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17369. * @example https://doc.babylonjs.com/babylon101/particles
  17370. */
  17371. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17372. /**
  17373. * Billboard mode will only apply to Y axis
  17374. */
  17375. static readonly BILLBOARDMODE_Y: number;
  17376. /**
  17377. * Billboard mode will apply to all axes
  17378. */
  17379. static readonly BILLBOARDMODE_ALL: number;
  17380. /**
  17381. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17382. */
  17383. static readonly BILLBOARDMODE_STRETCHED: number;
  17384. /**
  17385. * This function can be defined to provide custom update for active particles.
  17386. * This function will be called instead of regular update (age, position, color, etc.).
  17387. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17388. */
  17389. updateFunction: (particles: Particle[]) => void;
  17390. private _emitterWorldMatrix;
  17391. /**
  17392. * This function can be defined to specify initial direction for every new particle.
  17393. * It by default use the emitterType defined function
  17394. */
  17395. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17396. /**
  17397. * This function can be defined to specify initial position for every new particle.
  17398. * It by default use the emitterType defined function
  17399. */
  17400. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17401. /**
  17402. * @hidden
  17403. */
  17404. _inheritedVelocityOffset: Vector3;
  17405. /**
  17406. * An event triggered when the system is disposed
  17407. */
  17408. onDisposeObservable: Observable<ParticleSystem>;
  17409. private _onDisposeObserver;
  17410. /**
  17411. * Sets a callback that will be triggered when the system is disposed
  17412. */
  17413. set onDispose(callback: () => void);
  17414. private _particles;
  17415. private _epsilon;
  17416. private _capacity;
  17417. private _stockParticles;
  17418. private _newPartsExcess;
  17419. private _vertexData;
  17420. private _vertexBuffer;
  17421. private _vertexBuffers;
  17422. private _spriteBuffer;
  17423. private _indexBuffer;
  17424. private _effect;
  17425. private _customEffect;
  17426. private _cachedDefines;
  17427. private _scaledColorStep;
  17428. private _colorDiff;
  17429. private _scaledDirection;
  17430. private _scaledGravity;
  17431. private _currentRenderId;
  17432. private _alive;
  17433. private _useInstancing;
  17434. private _started;
  17435. private _stopped;
  17436. private _actualFrame;
  17437. private _scaledUpdateSpeed;
  17438. private _vertexBufferSize;
  17439. /** @hidden */
  17440. _currentEmitRateGradient: Nullable<FactorGradient>;
  17441. /** @hidden */
  17442. _currentEmitRate1: number;
  17443. /** @hidden */
  17444. _currentEmitRate2: number;
  17445. /** @hidden */
  17446. _currentStartSizeGradient: Nullable<FactorGradient>;
  17447. /** @hidden */
  17448. _currentStartSize1: number;
  17449. /** @hidden */
  17450. _currentStartSize2: number;
  17451. private readonly _rawTextureWidth;
  17452. private _rampGradientsTexture;
  17453. private _useRampGradients;
  17454. /** Gets or sets a boolean indicating that ramp gradients must be used
  17455. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17456. */
  17457. get useRampGradients(): boolean;
  17458. set useRampGradients(value: boolean);
  17459. /**
  17460. * 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.
  17461. * 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: [])
  17462. */
  17463. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17464. private _subEmitters;
  17465. /**
  17466. * @hidden
  17467. * If the particle systems emitter should be disposed when the particle system is disposed
  17468. */
  17469. _disposeEmitterOnDispose: boolean;
  17470. /**
  17471. * The current active Sub-systems, this property is used by the root particle system only.
  17472. */
  17473. activeSubSystems: Array<ParticleSystem>;
  17474. private _rootParticleSystem;
  17475. /**
  17476. * Gets the current list of active particles
  17477. */
  17478. get particles(): Particle[];
  17479. /**
  17480. * Returns the string "ParticleSystem"
  17481. * @returns a string containing the class name
  17482. */
  17483. getClassName(): string;
  17484. /**
  17485. * Instantiates a particle system.
  17486. * 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.
  17487. * @param name The name of the particle system
  17488. * @param capacity The max number of particles alive at the same time
  17489. * @param scene The scene the particle system belongs to
  17490. * @param customEffect a custom effect used to change the way particles are rendered by default
  17491. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17492. * @param epsilon Offset used to render the particles
  17493. */
  17494. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17495. private _addFactorGradient;
  17496. private _removeFactorGradient;
  17497. /**
  17498. * Adds a new life time gradient
  17499. * @param gradient defines the gradient to use (between 0 and 1)
  17500. * @param factor defines the life time factor to affect to the specified gradient
  17501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17502. * @returns the current particle system
  17503. */
  17504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17505. /**
  17506. * Remove a specific life time gradient
  17507. * @param gradient defines the gradient to remove
  17508. * @returns the current particle system
  17509. */
  17510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17511. /**
  17512. * Adds a new size gradient
  17513. * @param gradient defines the gradient to use (between 0 and 1)
  17514. * @param factor defines the size factor to affect to the specified gradient
  17515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17516. * @returns the current particle system
  17517. */
  17518. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17519. /**
  17520. * Remove a specific size gradient
  17521. * @param gradient defines the gradient to remove
  17522. * @returns the current particle system
  17523. */
  17524. removeSizeGradient(gradient: number): IParticleSystem;
  17525. /**
  17526. * Adds a new color remap gradient
  17527. * @param gradient defines the gradient to use (between 0 and 1)
  17528. * @param min defines the color remap minimal range
  17529. * @param max defines the color remap maximal range
  17530. * @returns the current particle system
  17531. */
  17532. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17533. /**
  17534. * Remove a specific color remap gradient
  17535. * @param gradient defines the gradient to remove
  17536. * @returns the current particle system
  17537. */
  17538. removeColorRemapGradient(gradient: number): IParticleSystem;
  17539. /**
  17540. * Adds a new alpha remap gradient
  17541. * @param gradient defines the gradient to use (between 0 and 1)
  17542. * @param min defines the alpha remap minimal range
  17543. * @param max defines the alpha remap maximal range
  17544. * @returns the current particle system
  17545. */
  17546. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17547. /**
  17548. * Remove a specific alpha remap gradient
  17549. * @param gradient defines the gradient to remove
  17550. * @returns the current particle system
  17551. */
  17552. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17553. /**
  17554. * Adds a new angular speed gradient
  17555. * @param gradient defines the gradient to use (between 0 and 1)
  17556. * @param factor defines the angular speed to affect to the specified gradient
  17557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17558. * @returns the current particle system
  17559. */
  17560. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17561. /**
  17562. * Remove a specific angular speed gradient
  17563. * @param gradient defines the gradient to remove
  17564. * @returns the current particle system
  17565. */
  17566. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17567. /**
  17568. * Adds a new velocity gradient
  17569. * @param gradient defines the gradient to use (between 0 and 1)
  17570. * @param factor defines the velocity to affect to the specified gradient
  17571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17572. * @returns the current particle system
  17573. */
  17574. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17575. /**
  17576. * Remove a specific velocity gradient
  17577. * @param gradient defines the gradient to remove
  17578. * @returns the current particle system
  17579. */
  17580. removeVelocityGradient(gradient: number): IParticleSystem;
  17581. /**
  17582. * Adds a new limit velocity gradient
  17583. * @param gradient defines the gradient to use (between 0 and 1)
  17584. * @param factor defines the limit velocity value to affect to the specified gradient
  17585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17586. * @returns the current particle system
  17587. */
  17588. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17589. /**
  17590. * Remove a specific limit velocity gradient
  17591. * @param gradient defines the gradient to remove
  17592. * @returns the current particle system
  17593. */
  17594. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17595. /**
  17596. * Adds a new drag gradient
  17597. * @param gradient defines the gradient to use (between 0 and 1)
  17598. * @param factor defines the drag value to affect to the specified gradient
  17599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17600. * @returns the current particle system
  17601. */
  17602. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17603. /**
  17604. * Remove a specific drag gradient
  17605. * @param gradient defines the gradient to remove
  17606. * @returns the current particle system
  17607. */
  17608. removeDragGradient(gradient: number): IParticleSystem;
  17609. /**
  17610. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param factor defines the emit rate value to affect to the specified gradient
  17613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17614. * @returns the current particle system
  17615. */
  17616. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17617. /**
  17618. * Remove a specific emit rate gradient
  17619. * @param gradient defines the gradient to remove
  17620. * @returns the current particle system
  17621. */
  17622. removeEmitRateGradient(gradient: number): IParticleSystem;
  17623. /**
  17624. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17625. * @param gradient defines the gradient to use (between 0 and 1)
  17626. * @param factor defines the start size value to affect to the specified gradient
  17627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17628. * @returns the current particle system
  17629. */
  17630. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17631. /**
  17632. * Remove a specific start size gradient
  17633. * @param gradient defines the gradient to remove
  17634. * @returns the current particle system
  17635. */
  17636. removeStartSizeGradient(gradient: number): IParticleSystem;
  17637. private _createRampGradientTexture;
  17638. /**
  17639. * Gets the current list of ramp gradients.
  17640. * You must use addRampGradient and removeRampGradient to udpate this list
  17641. * @returns the list of ramp gradients
  17642. */
  17643. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17644. /**
  17645. * Adds a new ramp gradient used to remap particle colors
  17646. * @param gradient defines the gradient to use (between 0 and 1)
  17647. * @param color defines the color to affect to the specified gradient
  17648. * @returns the current particle system
  17649. */
  17650. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17651. /**
  17652. * Remove a specific ramp gradient
  17653. * @param gradient defines the gradient to remove
  17654. * @returns the current particle system
  17655. */
  17656. removeRampGradient(gradient: number): ParticleSystem;
  17657. /**
  17658. * Adds a new color gradient
  17659. * @param gradient defines the gradient to use (between 0 and 1)
  17660. * @param color1 defines the color to affect to the specified gradient
  17661. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17662. * @returns this particle system
  17663. */
  17664. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17665. /**
  17666. * Remove a specific color gradient
  17667. * @param gradient defines the gradient to remove
  17668. * @returns this particle system
  17669. */
  17670. removeColorGradient(gradient: number): IParticleSystem;
  17671. private _fetchR;
  17672. protected _reset(): void;
  17673. private _resetEffect;
  17674. private _createVertexBuffers;
  17675. private _createIndexBuffer;
  17676. /**
  17677. * Gets the maximum number of particles active at the same time.
  17678. * @returns The max number of active particles.
  17679. */
  17680. getCapacity(): number;
  17681. /**
  17682. * Gets whether there are still active particles in the system.
  17683. * @returns True if it is alive, otherwise false.
  17684. */
  17685. isAlive(): boolean;
  17686. /**
  17687. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17688. * @returns True if it has been started, otherwise false.
  17689. */
  17690. isStarted(): boolean;
  17691. private _prepareSubEmitterInternalArray;
  17692. /**
  17693. * Starts the particle system and begins to emit
  17694. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17695. */
  17696. start(delay?: number): void;
  17697. /**
  17698. * Stops the particle system.
  17699. * @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.
  17700. */
  17701. stop(stopSubEmitters?: boolean): void;
  17702. /**
  17703. * Remove all active particles
  17704. */
  17705. reset(): void;
  17706. /**
  17707. * @hidden (for internal use only)
  17708. */
  17709. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17710. /**
  17711. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17712. * Its lifetime will start back at 0.
  17713. */
  17714. recycleParticle: (particle: Particle) => void;
  17715. private _stopSubEmitters;
  17716. private _createParticle;
  17717. private _removeFromRoot;
  17718. private _emitFromParticle;
  17719. private _update;
  17720. /** @hidden */
  17721. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17722. /** @hidden */
  17723. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17724. /** @hidden */
  17725. private _getEffect;
  17726. /**
  17727. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17728. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17729. */
  17730. animate(preWarmOnly?: boolean): void;
  17731. private _appendParticleVertices;
  17732. /**
  17733. * Rebuilds the particle system.
  17734. */
  17735. rebuild(): void;
  17736. /**
  17737. * Is this system ready to be used/rendered
  17738. * @return true if the system is ready
  17739. */
  17740. isReady(): boolean;
  17741. private _render;
  17742. /**
  17743. * Renders the particle system in its current state.
  17744. * @returns the current number of particles
  17745. */
  17746. render(): number;
  17747. /**
  17748. * Disposes the particle system and free the associated resources
  17749. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17750. */
  17751. dispose(disposeTexture?: boolean): void;
  17752. /**
  17753. * Clones the particle system.
  17754. * @param name The name of the cloned object
  17755. * @param newEmitter The new emitter to use
  17756. * @returns the cloned particle system
  17757. */
  17758. clone(name: string, newEmitter: any): ParticleSystem;
  17759. /**
  17760. * Serializes the particle system to a JSON object.
  17761. * @returns the JSON object
  17762. */
  17763. serialize(): any;
  17764. /** @hidden */
  17765. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17766. /** @hidden */
  17767. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17768. /**
  17769. * Parses a JSON object to create a particle system.
  17770. * @param parsedParticleSystem The JSON object to parse
  17771. * @param scene The scene to create the particle system in
  17772. * @param rootUrl The root url to use to load external dependencies like texture
  17773. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17774. * @returns the Parsed particle system
  17775. */
  17776. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17777. }
  17778. }
  17779. declare module BABYLON {
  17780. /**
  17781. * A particle represents one of the element emitted by a particle system.
  17782. * This is mainly define by its coordinates, direction, velocity and age.
  17783. */
  17784. export class Particle {
  17785. /**
  17786. * The particle system the particle belongs to.
  17787. */
  17788. particleSystem: ParticleSystem;
  17789. private static _Count;
  17790. /**
  17791. * Unique ID of the particle
  17792. */
  17793. id: number;
  17794. /**
  17795. * The world position of the particle in the scene.
  17796. */
  17797. position: Vector3;
  17798. /**
  17799. * The world direction of the particle in the scene.
  17800. */
  17801. direction: Vector3;
  17802. /**
  17803. * The color of the particle.
  17804. */
  17805. color: Color4;
  17806. /**
  17807. * The color change of the particle per step.
  17808. */
  17809. colorStep: Color4;
  17810. /**
  17811. * Defines how long will the life of the particle be.
  17812. */
  17813. lifeTime: number;
  17814. /**
  17815. * The current age of the particle.
  17816. */
  17817. age: number;
  17818. /**
  17819. * The current size of the particle.
  17820. */
  17821. size: number;
  17822. /**
  17823. * The current scale of the particle.
  17824. */
  17825. scale: Vector2;
  17826. /**
  17827. * The current angle of the particle.
  17828. */
  17829. angle: number;
  17830. /**
  17831. * Defines how fast is the angle changing.
  17832. */
  17833. angularSpeed: number;
  17834. /**
  17835. * Defines the cell index used by the particle to be rendered from a sprite.
  17836. */
  17837. cellIndex: number;
  17838. /**
  17839. * The information required to support color remapping
  17840. */
  17841. remapData: Vector4;
  17842. /** @hidden */
  17843. _randomCellOffset?: number;
  17844. /** @hidden */
  17845. _initialDirection: Nullable<Vector3>;
  17846. /** @hidden */
  17847. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17848. /** @hidden */
  17849. _initialStartSpriteCellID: number;
  17850. /** @hidden */
  17851. _initialEndSpriteCellID: number;
  17852. /** @hidden */
  17853. _currentColorGradient: Nullable<ColorGradient>;
  17854. /** @hidden */
  17855. _currentColor1: Color4;
  17856. /** @hidden */
  17857. _currentColor2: Color4;
  17858. /** @hidden */
  17859. _currentSizeGradient: Nullable<FactorGradient>;
  17860. /** @hidden */
  17861. _currentSize1: number;
  17862. /** @hidden */
  17863. _currentSize2: number;
  17864. /** @hidden */
  17865. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17866. /** @hidden */
  17867. _currentAngularSpeed1: number;
  17868. /** @hidden */
  17869. _currentAngularSpeed2: number;
  17870. /** @hidden */
  17871. _currentVelocityGradient: Nullable<FactorGradient>;
  17872. /** @hidden */
  17873. _currentVelocity1: number;
  17874. /** @hidden */
  17875. _currentVelocity2: number;
  17876. /** @hidden */
  17877. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17878. /** @hidden */
  17879. _currentLimitVelocity1: number;
  17880. /** @hidden */
  17881. _currentLimitVelocity2: number;
  17882. /** @hidden */
  17883. _currentDragGradient: Nullable<FactorGradient>;
  17884. /** @hidden */
  17885. _currentDrag1: number;
  17886. /** @hidden */
  17887. _currentDrag2: number;
  17888. /** @hidden */
  17889. _randomNoiseCoordinates1: Vector3;
  17890. /** @hidden */
  17891. _randomNoiseCoordinates2: Vector3;
  17892. /**
  17893. * Creates a new instance Particle
  17894. * @param particleSystem the particle system the particle belongs to
  17895. */
  17896. constructor(
  17897. /**
  17898. * The particle system the particle belongs to.
  17899. */
  17900. particleSystem: ParticleSystem);
  17901. private updateCellInfoFromSystem;
  17902. /**
  17903. * Defines how the sprite cell index is updated for the particle
  17904. */
  17905. updateCellIndex(): void;
  17906. /** @hidden */
  17907. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17908. /** @hidden */
  17909. _inheritParticleInfoToSubEmitters(): void;
  17910. /** @hidden */
  17911. _reset(): void;
  17912. /**
  17913. * Copy the properties of particle to another one.
  17914. * @param other the particle to copy the information to.
  17915. */
  17916. copyTo(other: Particle): void;
  17917. }
  17918. }
  17919. declare module BABYLON {
  17920. /**
  17921. * Particle emitter represents a volume emitting particles.
  17922. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17923. */
  17924. export interface IParticleEmitterType {
  17925. /**
  17926. * Called by the particle System when the direction is computed for the created particle.
  17927. * @param worldMatrix is the world matrix of the particle system
  17928. * @param directionToUpdate is the direction vector to update with the result
  17929. * @param particle is the particle we are computed the direction for
  17930. */
  17931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17932. /**
  17933. * Called by the particle System when the position is computed for the created particle.
  17934. * @param worldMatrix is the world matrix of the particle system
  17935. * @param positionToUpdate is the position vector to update with the result
  17936. * @param particle is the particle we are computed the position for
  17937. */
  17938. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17939. /**
  17940. * Clones the current emitter and returns a copy of it
  17941. * @returns the new emitter
  17942. */
  17943. clone(): IParticleEmitterType;
  17944. /**
  17945. * Called by the GPUParticleSystem to setup the update shader
  17946. * @param effect defines the update shader
  17947. */
  17948. applyToShader(effect: Effect): void;
  17949. /**
  17950. * Returns a string to use to update the GPU particles update shader
  17951. * @returns the effect defines string
  17952. */
  17953. getEffectDefines(): string;
  17954. /**
  17955. * Returns a string representing the class name
  17956. * @returns a string containing the class name
  17957. */
  17958. getClassName(): string;
  17959. /**
  17960. * Serializes the particle system to a JSON object.
  17961. * @returns the JSON object
  17962. */
  17963. serialize(): any;
  17964. /**
  17965. * Parse properties from a JSON object
  17966. * @param serializationObject defines the JSON object
  17967. */
  17968. parse(serializationObject: any): void;
  17969. }
  17970. }
  17971. declare module BABYLON {
  17972. /**
  17973. * Particle emitter emitting particles from the inside of a box.
  17974. * It emits the particles randomly between 2 given directions.
  17975. */
  17976. export class BoxParticleEmitter implements IParticleEmitterType {
  17977. /**
  17978. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17979. */
  17980. direction1: Vector3;
  17981. /**
  17982. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17983. */
  17984. direction2: Vector3;
  17985. /**
  17986. * 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.
  17987. */
  17988. minEmitBox: Vector3;
  17989. /**
  17990. * 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.
  17991. */
  17992. maxEmitBox: Vector3;
  17993. /**
  17994. * Creates a new instance BoxParticleEmitter
  17995. */
  17996. constructor();
  17997. /**
  17998. * Called by the particle System when the direction is computed for the created particle.
  17999. * @param worldMatrix is the world matrix of the particle system
  18000. * @param directionToUpdate is the direction vector to update with the result
  18001. * @param particle is the particle we are computed the direction for
  18002. */
  18003. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18004. /**
  18005. * Called by the particle System when the position is computed for the created particle.
  18006. * @param worldMatrix is the world matrix of the particle system
  18007. * @param positionToUpdate is the position vector to update with the result
  18008. * @param particle is the particle we are computed the position for
  18009. */
  18010. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18011. /**
  18012. * Clones the current emitter and returns a copy of it
  18013. * @returns the new emitter
  18014. */
  18015. clone(): BoxParticleEmitter;
  18016. /**
  18017. * Called by the GPUParticleSystem to setup the update shader
  18018. * @param effect defines the update shader
  18019. */
  18020. applyToShader(effect: Effect): void;
  18021. /**
  18022. * Returns a string to use to update the GPU particles update shader
  18023. * @returns a string containng the defines string
  18024. */
  18025. getEffectDefines(): string;
  18026. /**
  18027. * Returns the string "BoxParticleEmitter"
  18028. * @returns a string containing the class name
  18029. */
  18030. getClassName(): string;
  18031. /**
  18032. * Serializes the particle system to a JSON object.
  18033. * @returns the JSON object
  18034. */
  18035. serialize(): any;
  18036. /**
  18037. * Parse properties from a JSON object
  18038. * @param serializationObject defines the JSON object
  18039. */
  18040. parse(serializationObject: any): void;
  18041. }
  18042. }
  18043. declare module BABYLON {
  18044. /**
  18045. * Particle emitter emitting particles from the inside of a cone.
  18046. * It emits the particles alongside the cone volume from the base to the particle.
  18047. * The emission direction might be randomized.
  18048. */
  18049. export class ConeParticleEmitter implements IParticleEmitterType {
  18050. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18051. directionRandomizer: number;
  18052. private _radius;
  18053. private _angle;
  18054. private _height;
  18055. /**
  18056. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18057. */
  18058. radiusRange: number;
  18059. /**
  18060. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18061. */
  18062. heightRange: number;
  18063. /**
  18064. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18065. */
  18066. emitFromSpawnPointOnly: boolean;
  18067. /**
  18068. * Gets or sets the radius of the emission cone
  18069. */
  18070. get radius(): number;
  18071. set radius(value: number);
  18072. /**
  18073. * Gets or sets the angle of the emission cone
  18074. */
  18075. get angle(): number;
  18076. set angle(value: number);
  18077. private _buildHeight;
  18078. /**
  18079. * Creates a new instance ConeParticleEmitter
  18080. * @param radius the radius of the emission cone (1 by default)
  18081. * @param angle the cone base angle (PI by default)
  18082. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18083. */
  18084. constructor(radius?: number, angle?: number,
  18085. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18086. directionRandomizer?: number);
  18087. /**
  18088. * Called by the particle System when the direction is computed for the created particle.
  18089. * @param worldMatrix is the world matrix of the particle system
  18090. * @param directionToUpdate is the direction vector to update with the result
  18091. * @param particle is the particle we are computed the direction for
  18092. */
  18093. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18094. /**
  18095. * Called by the particle System when the position is computed for the created particle.
  18096. * @param worldMatrix is the world matrix of the particle system
  18097. * @param positionToUpdate is the position vector to update with the result
  18098. * @param particle is the particle we are computed the position for
  18099. */
  18100. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18101. /**
  18102. * Clones the current emitter and returns a copy of it
  18103. * @returns the new emitter
  18104. */
  18105. clone(): ConeParticleEmitter;
  18106. /**
  18107. * Called by the GPUParticleSystem to setup the update shader
  18108. * @param effect defines the update shader
  18109. */
  18110. applyToShader(effect: Effect): void;
  18111. /**
  18112. * Returns a string to use to update the GPU particles update shader
  18113. * @returns a string containng the defines string
  18114. */
  18115. getEffectDefines(): string;
  18116. /**
  18117. * Returns the string "ConeParticleEmitter"
  18118. * @returns a string containing the class name
  18119. */
  18120. getClassName(): string;
  18121. /**
  18122. * Serializes the particle system to a JSON object.
  18123. * @returns the JSON object
  18124. */
  18125. serialize(): any;
  18126. /**
  18127. * Parse properties from a JSON object
  18128. * @param serializationObject defines the JSON object
  18129. */
  18130. parse(serializationObject: any): void;
  18131. }
  18132. }
  18133. declare module BABYLON {
  18134. /**
  18135. * Particle emitter emitting particles from the inside of a cylinder.
  18136. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18137. */
  18138. export class CylinderParticleEmitter implements IParticleEmitterType {
  18139. /**
  18140. * The radius of the emission cylinder.
  18141. */
  18142. radius: number;
  18143. /**
  18144. * The height of the emission cylinder.
  18145. */
  18146. height: number;
  18147. /**
  18148. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18149. */
  18150. radiusRange: number;
  18151. /**
  18152. * How much to randomize the particle direction [0-1].
  18153. */
  18154. directionRandomizer: number;
  18155. /**
  18156. * Creates a new instance CylinderParticleEmitter
  18157. * @param radius the radius of the emission cylinder (1 by default)
  18158. * @param height the height of the emission cylinder (1 by default)
  18159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18160. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18161. */
  18162. constructor(
  18163. /**
  18164. * The radius of the emission cylinder.
  18165. */
  18166. radius?: number,
  18167. /**
  18168. * The height of the emission cylinder.
  18169. */
  18170. height?: number,
  18171. /**
  18172. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18173. */
  18174. radiusRange?: number,
  18175. /**
  18176. * How much to randomize the particle direction [0-1].
  18177. */
  18178. directionRandomizer?: number);
  18179. /**
  18180. * Called by the particle System when the direction is computed for the created particle.
  18181. * @param worldMatrix is the world matrix of the particle system
  18182. * @param directionToUpdate is the direction vector to update with the result
  18183. * @param particle is the particle we are computed the direction for
  18184. */
  18185. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18186. /**
  18187. * Called by the particle System when the position is computed for the created particle.
  18188. * @param worldMatrix is the world matrix of the particle system
  18189. * @param positionToUpdate is the position vector to update with the result
  18190. * @param particle is the particle we are computed the position for
  18191. */
  18192. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18193. /**
  18194. * Clones the current emitter and returns a copy of it
  18195. * @returns the new emitter
  18196. */
  18197. clone(): CylinderParticleEmitter;
  18198. /**
  18199. * Called by the GPUParticleSystem to setup the update shader
  18200. * @param effect defines the update shader
  18201. */
  18202. applyToShader(effect: Effect): void;
  18203. /**
  18204. * Returns a string to use to update the GPU particles update shader
  18205. * @returns a string containng the defines string
  18206. */
  18207. getEffectDefines(): string;
  18208. /**
  18209. * Returns the string "CylinderParticleEmitter"
  18210. * @returns a string containing the class name
  18211. */
  18212. getClassName(): string;
  18213. /**
  18214. * Serializes the particle system to a JSON object.
  18215. * @returns the JSON object
  18216. */
  18217. serialize(): any;
  18218. /**
  18219. * Parse properties from a JSON object
  18220. * @param serializationObject defines the JSON object
  18221. */
  18222. parse(serializationObject: any): void;
  18223. }
  18224. /**
  18225. * Particle emitter emitting particles from the inside of a cylinder.
  18226. * It emits the particles randomly between two vectors.
  18227. */
  18228. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18229. /**
  18230. * The min limit of the emission direction.
  18231. */
  18232. direction1: Vector3;
  18233. /**
  18234. * The max limit of the emission direction.
  18235. */
  18236. direction2: Vector3;
  18237. /**
  18238. * Creates a new instance CylinderDirectedParticleEmitter
  18239. * @param radius the radius of the emission cylinder (1 by default)
  18240. * @param height the height of the emission cylinder (1 by default)
  18241. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18242. * @param direction1 the min limit of the emission direction (up vector by default)
  18243. * @param direction2 the max limit of the emission direction (up vector by default)
  18244. */
  18245. constructor(radius?: number, height?: number, radiusRange?: number,
  18246. /**
  18247. * The min limit of the emission direction.
  18248. */
  18249. direction1?: Vector3,
  18250. /**
  18251. * The max limit of the emission direction.
  18252. */
  18253. direction2?: Vector3);
  18254. /**
  18255. * Called by the particle System when the direction is computed for the created particle.
  18256. * @param worldMatrix is the world matrix of the particle system
  18257. * @param directionToUpdate is the direction vector to update with the result
  18258. * @param particle is the particle we are computed the direction for
  18259. */
  18260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18261. /**
  18262. * Clones the current emitter and returns a copy of it
  18263. * @returns the new emitter
  18264. */
  18265. clone(): CylinderDirectedParticleEmitter;
  18266. /**
  18267. * Called by the GPUParticleSystem to setup the update shader
  18268. * @param effect defines the update shader
  18269. */
  18270. applyToShader(effect: Effect): void;
  18271. /**
  18272. * Returns a string to use to update the GPU particles update shader
  18273. * @returns a string containng the defines string
  18274. */
  18275. getEffectDefines(): string;
  18276. /**
  18277. * Returns the string "CylinderDirectedParticleEmitter"
  18278. * @returns a string containing the class name
  18279. */
  18280. getClassName(): string;
  18281. /**
  18282. * Serializes the particle system to a JSON object.
  18283. * @returns the JSON object
  18284. */
  18285. serialize(): any;
  18286. /**
  18287. * Parse properties from a JSON object
  18288. * @param serializationObject defines the JSON object
  18289. */
  18290. parse(serializationObject: any): void;
  18291. }
  18292. }
  18293. declare module BABYLON {
  18294. /**
  18295. * Particle emitter emitting particles from the inside of a hemisphere.
  18296. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18297. */
  18298. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18299. /**
  18300. * The radius of the emission hemisphere.
  18301. */
  18302. radius: number;
  18303. /**
  18304. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18305. */
  18306. radiusRange: number;
  18307. /**
  18308. * How much to randomize the particle direction [0-1].
  18309. */
  18310. directionRandomizer: number;
  18311. /**
  18312. * Creates a new instance HemisphericParticleEmitter
  18313. * @param radius the radius of the emission hemisphere (1 by default)
  18314. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18315. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18316. */
  18317. constructor(
  18318. /**
  18319. * The radius of the emission hemisphere.
  18320. */
  18321. radius?: number,
  18322. /**
  18323. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18324. */
  18325. radiusRange?: number,
  18326. /**
  18327. * How much to randomize the particle direction [0-1].
  18328. */
  18329. directionRandomizer?: number);
  18330. /**
  18331. * Called by the particle System when the direction is computed for the created particle.
  18332. * @param worldMatrix is the world matrix of the particle system
  18333. * @param directionToUpdate is the direction vector to update with the result
  18334. * @param particle is the particle we are computed the direction for
  18335. */
  18336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18337. /**
  18338. * Called by the particle System when the position is computed for the created particle.
  18339. * @param worldMatrix is the world matrix of the particle system
  18340. * @param positionToUpdate is the position vector to update with the result
  18341. * @param particle is the particle we are computed the position for
  18342. */
  18343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18344. /**
  18345. * Clones the current emitter and returns a copy of it
  18346. * @returns the new emitter
  18347. */
  18348. clone(): HemisphericParticleEmitter;
  18349. /**
  18350. * Called by the GPUParticleSystem to setup the update shader
  18351. * @param effect defines the update shader
  18352. */
  18353. applyToShader(effect: Effect): void;
  18354. /**
  18355. * Returns a string to use to update the GPU particles update shader
  18356. * @returns a string containng the defines string
  18357. */
  18358. getEffectDefines(): string;
  18359. /**
  18360. * Returns the string "HemisphericParticleEmitter"
  18361. * @returns a string containing the class name
  18362. */
  18363. getClassName(): string;
  18364. /**
  18365. * Serializes the particle system to a JSON object.
  18366. * @returns the JSON object
  18367. */
  18368. serialize(): any;
  18369. /**
  18370. * Parse properties from a JSON object
  18371. * @param serializationObject defines the JSON object
  18372. */
  18373. parse(serializationObject: any): void;
  18374. }
  18375. }
  18376. declare module BABYLON {
  18377. /**
  18378. * Particle emitter emitting particles from a point.
  18379. * It emits the particles randomly between 2 given directions.
  18380. */
  18381. export class PointParticleEmitter implements IParticleEmitterType {
  18382. /**
  18383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18384. */
  18385. direction1: Vector3;
  18386. /**
  18387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18388. */
  18389. direction2: Vector3;
  18390. /**
  18391. * Creates a new instance PointParticleEmitter
  18392. */
  18393. constructor();
  18394. /**
  18395. * Called by the particle System when the direction is computed for the created particle.
  18396. * @param worldMatrix is the world matrix of the particle system
  18397. * @param directionToUpdate is the direction vector to update with the result
  18398. * @param particle is the particle we are computed the direction for
  18399. */
  18400. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18401. /**
  18402. * Called by the particle System when the position is computed for the created particle.
  18403. * @param worldMatrix is the world matrix of the particle system
  18404. * @param positionToUpdate is the position vector to update with the result
  18405. * @param particle is the particle we are computed the position for
  18406. */
  18407. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18408. /**
  18409. * Clones the current emitter and returns a copy of it
  18410. * @returns the new emitter
  18411. */
  18412. clone(): PointParticleEmitter;
  18413. /**
  18414. * Called by the GPUParticleSystem to setup the update shader
  18415. * @param effect defines the update shader
  18416. */
  18417. applyToShader(effect: Effect): void;
  18418. /**
  18419. * Returns a string to use to update the GPU particles update shader
  18420. * @returns a string containng the defines string
  18421. */
  18422. getEffectDefines(): string;
  18423. /**
  18424. * Returns the string "PointParticleEmitter"
  18425. * @returns a string containing the class name
  18426. */
  18427. getClassName(): string;
  18428. /**
  18429. * Serializes the particle system to a JSON object.
  18430. * @returns the JSON object
  18431. */
  18432. serialize(): any;
  18433. /**
  18434. * Parse properties from a JSON object
  18435. * @param serializationObject defines the JSON object
  18436. */
  18437. parse(serializationObject: any): void;
  18438. }
  18439. }
  18440. declare module BABYLON {
  18441. /**
  18442. * Particle emitter emitting particles from the inside of a sphere.
  18443. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18444. */
  18445. export class SphereParticleEmitter implements IParticleEmitterType {
  18446. /**
  18447. * The radius of the emission sphere.
  18448. */
  18449. radius: number;
  18450. /**
  18451. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18452. */
  18453. radiusRange: number;
  18454. /**
  18455. * How much to randomize the particle direction [0-1].
  18456. */
  18457. directionRandomizer: number;
  18458. /**
  18459. * Creates a new instance SphereParticleEmitter
  18460. * @param radius the radius of the emission sphere (1 by default)
  18461. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18462. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18463. */
  18464. constructor(
  18465. /**
  18466. * The radius of the emission sphere.
  18467. */
  18468. radius?: number,
  18469. /**
  18470. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18471. */
  18472. radiusRange?: number,
  18473. /**
  18474. * How much to randomize the particle direction [0-1].
  18475. */
  18476. directionRandomizer?: number);
  18477. /**
  18478. * Called by the particle System when the direction is computed for the created particle.
  18479. * @param worldMatrix is the world matrix of the particle system
  18480. * @param directionToUpdate is the direction vector to update with the result
  18481. * @param particle is the particle we are computed the direction for
  18482. */
  18483. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18484. /**
  18485. * Called by the particle System when the position is computed for the created particle.
  18486. * @param worldMatrix is the world matrix of the particle system
  18487. * @param positionToUpdate is the position vector to update with the result
  18488. * @param particle is the particle we are computed the position for
  18489. */
  18490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18491. /**
  18492. * Clones the current emitter and returns a copy of it
  18493. * @returns the new emitter
  18494. */
  18495. clone(): SphereParticleEmitter;
  18496. /**
  18497. * Called by the GPUParticleSystem to setup the update shader
  18498. * @param effect defines the update shader
  18499. */
  18500. applyToShader(effect: Effect): void;
  18501. /**
  18502. * Returns a string to use to update the GPU particles update shader
  18503. * @returns a string containng the defines string
  18504. */
  18505. getEffectDefines(): string;
  18506. /**
  18507. * Returns the string "SphereParticleEmitter"
  18508. * @returns a string containing the class name
  18509. */
  18510. getClassName(): string;
  18511. /**
  18512. * Serializes the particle system to a JSON object.
  18513. * @returns the JSON object
  18514. */
  18515. serialize(): any;
  18516. /**
  18517. * Parse properties from a JSON object
  18518. * @param serializationObject defines the JSON object
  18519. */
  18520. parse(serializationObject: any): void;
  18521. }
  18522. /**
  18523. * Particle emitter emitting particles from the inside of a sphere.
  18524. * It emits the particles randomly between two vectors.
  18525. */
  18526. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18527. /**
  18528. * The min limit of the emission direction.
  18529. */
  18530. direction1: Vector3;
  18531. /**
  18532. * The max limit of the emission direction.
  18533. */
  18534. direction2: Vector3;
  18535. /**
  18536. * Creates a new instance SphereDirectedParticleEmitter
  18537. * @param radius the radius of the emission sphere (1 by default)
  18538. * @param direction1 the min limit of the emission direction (up vector by default)
  18539. * @param direction2 the max limit of the emission direction (up vector by default)
  18540. */
  18541. constructor(radius?: number,
  18542. /**
  18543. * The min limit of the emission direction.
  18544. */
  18545. direction1?: Vector3,
  18546. /**
  18547. * The max limit of the emission direction.
  18548. */
  18549. direction2?: Vector3);
  18550. /**
  18551. * Called by the particle System when the direction is computed for the created particle.
  18552. * @param worldMatrix is the world matrix of the particle system
  18553. * @param directionToUpdate is the direction vector to update with the result
  18554. * @param particle is the particle we are computed the direction for
  18555. */
  18556. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18557. /**
  18558. * Clones the current emitter and returns a copy of it
  18559. * @returns the new emitter
  18560. */
  18561. clone(): SphereDirectedParticleEmitter;
  18562. /**
  18563. * Called by the GPUParticleSystem to setup the update shader
  18564. * @param effect defines the update shader
  18565. */
  18566. applyToShader(effect: Effect): void;
  18567. /**
  18568. * Returns a string to use to update the GPU particles update shader
  18569. * @returns a string containng the defines string
  18570. */
  18571. getEffectDefines(): string;
  18572. /**
  18573. * Returns the string "SphereDirectedParticleEmitter"
  18574. * @returns a string containing the class name
  18575. */
  18576. getClassName(): string;
  18577. /**
  18578. * Serializes the particle system to a JSON object.
  18579. * @returns the JSON object
  18580. */
  18581. serialize(): any;
  18582. /**
  18583. * Parse properties from a JSON object
  18584. * @param serializationObject defines the JSON object
  18585. */
  18586. parse(serializationObject: any): void;
  18587. }
  18588. }
  18589. declare module BABYLON {
  18590. /**
  18591. * Particle emitter emitting particles from a custom list of positions.
  18592. */
  18593. export class CustomParticleEmitter implements IParticleEmitterType {
  18594. /**
  18595. * Gets or sets the position generator that will create the inital position of each particle.
  18596. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18597. */
  18598. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  18599. /**
  18600. * Gets or sets the destination generator that will create the final destination of each particle.
  18601. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  18602. */
  18603. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  18604. /**
  18605. * Creates a new instance CustomParticleEmitter
  18606. */
  18607. constructor();
  18608. /**
  18609. * Called by the particle System when the direction is computed for the created particle.
  18610. * @param worldMatrix is the world matrix of the particle system
  18611. * @param directionToUpdate is the direction vector to update with the result
  18612. * @param particle is the particle we are computed the direction for
  18613. */
  18614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18615. /**
  18616. * Called by the particle System when the position is computed for the created particle.
  18617. * @param worldMatrix is the world matrix of the particle system
  18618. * @param positionToUpdate is the position vector to update with the result
  18619. * @param particle is the particle we are computed the position for
  18620. */
  18621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18622. /**
  18623. * Clones the current emitter and returns a copy of it
  18624. * @returns the new emitter
  18625. */
  18626. clone(): CustomParticleEmitter;
  18627. /**
  18628. * Called by the GPUParticleSystem to setup the update shader
  18629. * @param effect defines the update shader
  18630. */
  18631. applyToShader(effect: Effect): void;
  18632. /**
  18633. * Returns a string to use to update the GPU particles update shader
  18634. * @returns a string containng the defines string
  18635. */
  18636. getEffectDefines(): string;
  18637. /**
  18638. * Returns the string "PointParticleEmitter"
  18639. * @returns a string containing the class name
  18640. */
  18641. getClassName(): string;
  18642. /**
  18643. * Serializes the particle system to a JSON object.
  18644. * @returns the JSON object
  18645. */
  18646. serialize(): any;
  18647. /**
  18648. * Parse properties from a JSON object
  18649. * @param serializationObject defines the JSON object
  18650. */
  18651. parse(serializationObject: any): void;
  18652. }
  18653. }
  18654. declare module BABYLON {
  18655. /**
  18656. * Interface representing a particle system in Babylon.js.
  18657. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18658. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18659. */
  18660. export interface IParticleSystem {
  18661. /**
  18662. * List of animations used by the particle system.
  18663. */
  18664. animations: Animation[];
  18665. /**
  18666. * The id of the Particle system.
  18667. */
  18668. id: string;
  18669. /**
  18670. * The name of the Particle system.
  18671. */
  18672. name: string;
  18673. /**
  18674. * The emitter represents the Mesh or position we are attaching the particle system to.
  18675. */
  18676. emitter: Nullable<AbstractMesh | Vector3>;
  18677. /**
  18678. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18679. */
  18680. isBillboardBased: boolean;
  18681. /**
  18682. * The rendering group used by the Particle system to chose when to render.
  18683. */
  18684. renderingGroupId: number;
  18685. /**
  18686. * The layer mask we are rendering the particles through.
  18687. */
  18688. layerMask: number;
  18689. /**
  18690. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18691. */
  18692. updateSpeed: number;
  18693. /**
  18694. * The amount of time the particle system is running (depends of the overall update speed).
  18695. */
  18696. targetStopDuration: number;
  18697. /**
  18698. * The texture used to render each particle. (this can be a spritesheet)
  18699. */
  18700. particleTexture: Nullable<Texture>;
  18701. /**
  18702. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18703. */
  18704. blendMode: number;
  18705. /**
  18706. * Minimum life time of emitting particles.
  18707. */
  18708. minLifeTime: number;
  18709. /**
  18710. * Maximum life time of emitting particles.
  18711. */
  18712. maxLifeTime: number;
  18713. /**
  18714. * Minimum Size of emitting particles.
  18715. */
  18716. minSize: number;
  18717. /**
  18718. * Maximum Size of emitting particles.
  18719. */
  18720. maxSize: number;
  18721. /**
  18722. * Minimum scale of emitting particles on X axis.
  18723. */
  18724. minScaleX: number;
  18725. /**
  18726. * Maximum scale of emitting particles on X axis.
  18727. */
  18728. maxScaleX: number;
  18729. /**
  18730. * Minimum scale of emitting particles on Y axis.
  18731. */
  18732. minScaleY: number;
  18733. /**
  18734. * Maximum scale of emitting particles on Y axis.
  18735. */
  18736. maxScaleY: number;
  18737. /**
  18738. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18739. */
  18740. color1: Color4;
  18741. /**
  18742. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18743. */
  18744. color2: Color4;
  18745. /**
  18746. * Color the particle will have at the end of its lifetime.
  18747. */
  18748. colorDead: Color4;
  18749. /**
  18750. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18751. */
  18752. emitRate: number;
  18753. /**
  18754. * You can use gravity if you want to give an orientation to your particles.
  18755. */
  18756. gravity: Vector3;
  18757. /**
  18758. * Minimum power of emitting particles.
  18759. */
  18760. minEmitPower: number;
  18761. /**
  18762. * Maximum power of emitting particles.
  18763. */
  18764. maxEmitPower: number;
  18765. /**
  18766. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18767. */
  18768. minAngularSpeed: number;
  18769. /**
  18770. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18771. */
  18772. maxAngularSpeed: number;
  18773. /**
  18774. * Gets or sets the minimal initial rotation in radians.
  18775. */
  18776. minInitialRotation: number;
  18777. /**
  18778. * Gets or sets the maximal initial rotation in radians.
  18779. */
  18780. maxInitialRotation: number;
  18781. /**
  18782. * The particle emitter type defines the emitter used by the particle system.
  18783. * It can be for example box, sphere, or cone...
  18784. */
  18785. particleEmitterType: Nullable<IParticleEmitterType>;
  18786. /**
  18787. * Defines the delay in milliseconds before starting the system (0 by default)
  18788. */
  18789. startDelay: number;
  18790. /**
  18791. * 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
  18792. */
  18793. preWarmCycles: number;
  18794. /**
  18795. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18796. */
  18797. preWarmStepOffset: number;
  18798. /**
  18799. * 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)
  18800. */
  18801. spriteCellChangeSpeed: number;
  18802. /**
  18803. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18804. */
  18805. startSpriteCellID: number;
  18806. /**
  18807. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18808. */
  18809. endSpriteCellID: number;
  18810. /**
  18811. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18812. */
  18813. spriteCellWidth: number;
  18814. /**
  18815. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18816. */
  18817. spriteCellHeight: number;
  18818. /**
  18819. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18820. */
  18821. spriteRandomStartCell: boolean;
  18822. /**
  18823. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18824. */
  18825. isAnimationSheetEnabled: boolean;
  18826. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18827. translationPivot: Vector2;
  18828. /**
  18829. * Gets or sets a texture used to add random noise to particle positions
  18830. */
  18831. noiseTexture: Nullable<BaseTexture>;
  18832. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18833. noiseStrength: Vector3;
  18834. /**
  18835. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18836. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18837. */
  18838. billboardMode: number;
  18839. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18840. limitVelocityDamping: number;
  18841. /**
  18842. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18843. */
  18844. beginAnimationOnStart: boolean;
  18845. /**
  18846. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18847. */
  18848. beginAnimationFrom: number;
  18849. /**
  18850. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18851. */
  18852. beginAnimationTo: number;
  18853. /**
  18854. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18855. */
  18856. beginAnimationLoop: boolean;
  18857. /**
  18858. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18859. */
  18860. disposeOnStop: boolean;
  18861. /**
  18862. * Gets the maximum number of particles active at the same time.
  18863. * @returns The max number of active particles.
  18864. */
  18865. getCapacity(): number;
  18866. /**
  18867. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18868. * @returns True if it has been started, otherwise false.
  18869. */
  18870. isStarted(): boolean;
  18871. /**
  18872. * Animates the particle system for this frame.
  18873. */
  18874. animate(): void;
  18875. /**
  18876. * Renders the particle system in its current state.
  18877. * @returns the current number of particles
  18878. */
  18879. render(): number;
  18880. /**
  18881. * Dispose the particle system and frees its associated resources.
  18882. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18883. */
  18884. dispose(disposeTexture?: boolean): void;
  18885. /**
  18886. * Clones the particle system.
  18887. * @param name The name of the cloned object
  18888. * @param newEmitter The new emitter to use
  18889. * @returns the cloned particle system
  18890. */
  18891. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18892. /**
  18893. * Serializes the particle system to a JSON object.
  18894. * @returns the JSON object
  18895. */
  18896. serialize(): any;
  18897. /**
  18898. * Rebuild the particle system
  18899. */
  18900. rebuild(): void;
  18901. /**
  18902. * Starts the particle system and begins to emit
  18903. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18904. */
  18905. start(delay?: number): void;
  18906. /**
  18907. * Stops the particle system.
  18908. */
  18909. stop(): void;
  18910. /**
  18911. * Remove all active particles
  18912. */
  18913. reset(): void;
  18914. /**
  18915. * Is this system ready to be used/rendered
  18916. * @return true if the system is ready
  18917. */
  18918. isReady(): boolean;
  18919. /**
  18920. * Adds a new color gradient
  18921. * @param gradient defines the gradient to use (between 0 and 1)
  18922. * @param color1 defines the color to affect to the specified gradient
  18923. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18924. * @returns the current particle system
  18925. */
  18926. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18927. /**
  18928. * Remove a specific color gradient
  18929. * @param gradient defines the gradient to remove
  18930. * @returns the current particle system
  18931. */
  18932. removeColorGradient(gradient: number): IParticleSystem;
  18933. /**
  18934. * Adds a new size gradient
  18935. * @param gradient defines the gradient to use (between 0 and 1)
  18936. * @param factor defines the size factor to affect to the specified gradient
  18937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18938. * @returns the current particle system
  18939. */
  18940. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18941. /**
  18942. * Remove a specific size gradient
  18943. * @param gradient defines the gradient to remove
  18944. * @returns the current particle system
  18945. */
  18946. removeSizeGradient(gradient: number): IParticleSystem;
  18947. /**
  18948. * Gets the current list of color gradients.
  18949. * You must use addColorGradient and removeColorGradient to udpate this list
  18950. * @returns the list of color gradients
  18951. */
  18952. getColorGradients(): Nullable<Array<ColorGradient>>;
  18953. /**
  18954. * Gets the current list of size gradients.
  18955. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18956. * @returns the list of size gradients
  18957. */
  18958. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18959. /**
  18960. * Gets the current list of angular speed gradients.
  18961. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18962. * @returns the list of angular speed gradients
  18963. */
  18964. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18965. /**
  18966. * Adds a new angular speed gradient
  18967. * @param gradient defines the gradient to use (between 0 and 1)
  18968. * @param factor defines the angular speed to affect to the specified gradient
  18969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18970. * @returns the current particle system
  18971. */
  18972. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18973. /**
  18974. * Remove a specific angular speed gradient
  18975. * @param gradient defines the gradient to remove
  18976. * @returns the current particle system
  18977. */
  18978. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18979. /**
  18980. * Gets the current list of velocity gradients.
  18981. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18982. * @returns the list of velocity gradients
  18983. */
  18984. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18985. /**
  18986. * Adds a new velocity gradient
  18987. * @param gradient defines the gradient to use (between 0 and 1)
  18988. * @param factor defines the velocity to affect to the specified gradient
  18989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18990. * @returns the current particle system
  18991. */
  18992. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18993. /**
  18994. * Remove a specific velocity gradient
  18995. * @param gradient defines the gradient to remove
  18996. * @returns the current particle system
  18997. */
  18998. removeVelocityGradient(gradient: number): IParticleSystem;
  18999. /**
  19000. * Gets the current list of limit velocity gradients.
  19001. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19002. * @returns the list of limit velocity gradients
  19003. */
  19004. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Adds a new limit velocity gradient
  19007. * @param gradient defines the gradient to use (between 0 and 1)
  19008. * @param factor defines the limit velocity to affect to the specified gradient
  19009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19010. * @returns the current particle system
  19011. */
  19012. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19013. /**
  19014. * Remove a specific limit velocity gradient
  19015. * @param gradient defines the gradient to remove
  19016. * @returns the current particle system
  19017. */
  19018. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19019. /**
  19020. * Adds a new drag gradient
  19021. * @param gradient defines the gradient to use (between 0 and 1)
  19022. * @param factor defines the drag to affect to the specified gradient
  19023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19024. * @returns the current particle system
  19025. */
  19026. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19027. /**
  19028. * Remove a specific drag gradient
  19029. * @param gradient defines the gradient to remove
  19030. * @returns the current particle system
  19031. */
  19032. removeDragGradient(gradient: number): IParticleSystem;
  19033. /**
  19034. * Gets the current list of drag gradients.
  19035. * You must use addDragGradient and removeDragGradient to udpate this list
  19036. * @returns the list of drag gradients
  19037. */
  19038. getDragGradients(): Nullable<Array<FactorGradient>>;
  19039. /**
  19040. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19041. * @param gradient defines the gradient to use (between 0 and 1)
  19042. * @param factor defines the emit rate to affect to the specified gradient
  19043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19044. * @returns the current particle system
  19045. */
  19046. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19047. /**
  19048. * Remove a specific emit rate gradient
  19049. * @param gradient defines the gradient to remove
  19050. * @returns the current particle system
  19051. */
  19052. removeEmitRateGradient(gradient: number): IParticleSystem;
  19053. /**
  19054. * Gets the current list of emit rate gradients.
  19055. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19056. * @returns the list of emit rate gradients
  19057. */
  19058. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19059. /**
  19060. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19061. * @param gradient defines the gradient to use (between 0 and 1)
  19062. * @param factor defines the start size to affect to the specified gradient
  19063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19064. * @returns the current particle system
  19065. */
  19066. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19067. /**
  19068. * Remove a specific start size gradient
  19069. * @param gradient defines the gradient to remove
  19070. * @returns the current particle system
  19071. */
  19072. removeStartSizeGradient(gradient: number): IParticleSystem;
  19073. /**
  19074. * Gets the current list of start size gradients.
  19075. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19076. * @returns the list of start size gradients
  19077. */
  19078. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19079. /**
  19080. * Adds a new life time gradient
  19081. * @param gradient defines the gradient to use (between 0 and 1)
  19082. * @param factor defines the life time factor to affect to the specified gradient
  19083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19084. * @returns the current particle system
  19085. */
  19086. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19087. /**
  19088. * Remove a specific life time gradient
  19089. * @param gradient defines the gradient to remove
  19090. * @returns the current particle system
  19091. */
  19092. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19093. /**
  19094. * Gets the current list of life time gradients.
  19095. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19096. * @returns the list of life time gradients
  19097. */
  19098. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19099. /**
  19100. * Gets the current list of color gradients.
  19101. * You must use addColorGradient and removeColorGradient to udpate this list
  19102. * @returns the list of color gradients
  19103. */
  19104. getColorGradients(): Nullable<Array<ColorGradient>>;
  19105. /**
  19106. * Adds a new ramp gradient used to remap particle colors
  19107. * @param gradient defines the gradient to use (between 0 and 1)
  19108. * @param color defines the color to affect to the specified gradient
  19109. * @returns the current particle system
  19110. */
  19111. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19112. /**
  19113. * Gets the current list of ramp gradients.
  19114. * You must use addRampGradient and removeRampGradient to udpate this list
  19115. * @returns the list of ramp gradients
  19116. */
  19117. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19118. /** Gets or sets a boolean indicating that ramp gradients must be used
  19119. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19120. */
  19121. useRampGradients: boolean;
  19122. /**
  19123. * Adds a new color remap gradient
  19124. * @param gradient defines the gradient to use (between 0 and 1)
  19125. * @param min defines the color remap minimal range
  19126. * @param max defines the color remap maximal range
  19127. * @returns the current particle system
  19128. */
  19129. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19130. /**
  19131. * Gets the current list of color remap gradients.
  19132. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19133. * @returns the list of color remap gradients
  19134. */
  19135. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19136. /**
  19137. * Adds a new alpha remap gradient
  19138. * @param gradient defines the gradient to use (between 0 and 1)
  19139. * @param min defines the alpha remap minimal range
  19140. * @param max defines the alpha remap maximal range
  19141. * @returns the current particle system
  19142. */
  19143. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19144. /**
  19145. * Gets the current list of alpha remap gradients.
  19146. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19147. * @returns the list of alpha remap gradients
  19148. */
  19149. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19150. /**
  19151. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19152. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19153. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19154. * @returns the emitter
  19155. */
  19156. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19157. /**
  19158. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19159. * @param radius The radius of the hemisphere to emit from
  19160. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19161. * @returns the emitter
  19162. */
  19163. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19164. /**
  19165. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19166. * @param radius The radius of the sphere to emit from
  19167. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19168. * @returns the emitter
  19169. */
  19170. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19171. /**
  19172. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19173. * @param radius The radius of the sphere to emit from
  19174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19176. * @returns the emitter
  19177. */
  19178. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19179. /**
  19180. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19181. * @param radius The radius of the emission cylinder
  19182. * @param height The height of the emission cylinder
  19183. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19184. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19185. * @returns the emitter
  19186. */
  19187. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19188. /**
  19189. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19190. * @param radius The radius of the cylinder to emit from
  19191. * @param height The height of the emission cylinder
  19192. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19193. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19194. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19195. * @returns the emitter
  19196. */
  19197. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19198. /**
  19199. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19200. * @param radius The radius of the cone to emit from
  19201. * @param angle The base angle of the cone
  19202. * @returns the emitter
  19203. */
  19204. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19205. /**
  19206. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19209. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19210. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19211. * @returns the emitter
  19212. */
  19213. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19214. /**
  19215. * Get hosting scene
  19216. * @returns the scene
  19217. */
  19218. getScene(): Scene;
  19219. }
  19220. }
  19221. declare module BABYLON {
  19222. /**
  19223. * Creates an instance based on a source mesh.
  19224. */
  19225. export class InstancedMesh extends AbstractMesh {
  19226. private _sourceMesh;
  19227. private _currentLOD;
  19228. /** @hidden */
  19229. _indexInSourceMeshInstanceArray: number;
  19230. constructor(name: string, source: Mesh);
  19231. /**
  19232. * Returns the string "InstancedMesh".
  19233. */
  19234. getClassName(): string;
  19235. /** Gets the list of lights affecting that mesh */
  19236. get lightSources(): Light[];
  19237. _resyncLightSources(): void;
  19238. _resyncLightSource(light: Light): void;
  19239. _removeLightSource(light: Light, dispose: boolean): void;
  19240. /**
  19241. * If the source mesh receives shadows
  19242. */
  19243. get receiveShadows(): boolean;
  19244. /**
  19245. * The material of the source mesh
  19246. */
  19247. get material(): Nullable<Material>;
  19248. /**
  19249. * Visibility of the source mesh
  19250. */
  19251. get visibility(): number;
  19252. /**
  19253. * Skeleton of the source mesh
  19254. */
  19255. get skeleton(): Nullable<Skeleton>;
  19256. /**
  19257. * Rendering ground id of the source mesh
  19258. */
  19259. get renderingGroupId(): number;
  19260. set renderingGroupId(value: number);
  19261. /**
  19262. * Returns the total number of vertices (integer).
  19263. */
  19264. getTotalVertices(): number;
  19265. /**
  19266. * Returns a positive integer : the total number of indices in this mesh geometry.
  19267. * @returns the numner of indices or zero if the mesh has no geometry.
  19268. */
  19269. getTotalIndices(): number;
  19270. /**
  19271. * The source mesh of the instance
  19272. */
  19273. get sourceMesh(): Mesh;
  19274. /**
  19275. * Is this node ready to be used/rendered
  19276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19277. * @return {boolean} is it ready
  19278. */
  19279. isReady(completeCheck?: boolean): boolean;
  19280. /**
  19281. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19282. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19283. * @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.
  19284. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19285. */
  19286. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19287. /**
  19288. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19289. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19290. * The `data` are either a numeric array either a Float32Array.
  19291. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19292. * 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).
  19293. * Note that a new underlying VertexBuffer object is created each call.
  19294. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19295. *
  19296. * Possible `kind` values :
  19297. * - VertexBuffer.PositionKind
  19298. * - VertexBuffer.UVKind
  19299. * - VertexBuffer.UV2Kind
  19300. * - VertexBuffer.UV3Kind
  19301. * - VertexBuffer.UV4Kind
  19302. * - VertexBuffer.UV5Kind
  19303. * - VertexBuffer.UV6Kind
  19304. * - VertexBuffer.ColorKind
  19305. * - VertexBuffer.MatricesIndicesKind
  19306. * - VertexBuffer.MatricesIndicesExtraKind
  19307. * - VertexBuffer.MatricesWeightsKind
  19308. * - VertexBuffer.MatricesWeightsExtraKind
  19309. *
  19310. * Returns the Mesh.
  19311. */
  19312. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19313. /**
  19314. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19315. * If the mesh has no geometry, it is simply returned as it is.
  19316. * The `data` are either a numeric array either a Float32Array.
  19317. * No new underlying VertexBuffer object is created.
  19318. * 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.
  19319. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19320. *
  19321. * Possible `kind` values :
  19322. * - VertexBuffer.PositionKind
  19323. * - VertexBuffer.UVKind
  19324. * - VertexBuffer.UV2Kind
  19325. * - VertexBuffer.UV3Kind
  19326. * - VertexBuffer.UV4Kind
  19327. * - VertexBuffer.UV5Kind
  19328. * - VertexBuffer.UV6Kind
  19329. * - VertexBuffer.ColorKind
  19330. * - VertexBuffer.MatricesIndicesKind
  19331. * - VertexBuffer.MatricesIndicesExtraKind
  19332. * - VertexBuffer.MatricesWeightsKind
  19333. * - VertexBuffer.MatricesWeightsExtraKind
  19334. *
  19335. * Returns the Mesh.
  19336. */
  19337. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19338. /**
  19339. * Sets the mesh indices.
  19340. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19341. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19342. * This method creates a new index buffer each call.
  19343. * Returns the Mesh.
  19344. */
  19345. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19346. /**
  19347. * Boolean : True if the mesh owns the requested kind of data.
  19348. */
  19349. isVerticesDataPresent(kind: string): boolean;
  19350. /**
  19351. * Returns an array of indices (IndicesArray).
  19352. */
  19353. getIndices(): Nullable<IndicesArray>;
  19354. get _positions(): Nullable<Vector3[]>;
  19355. /**
  19356. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19357. * This means the mesh underlying bounding box and sphere are recomputed.
  19358. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19359. * @returns the current mesh
  19360. */
  19361. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19362. /** @hidden */
  19363. _preActivate(): InstancedMesh;
  19364. /** @hidden */
  19365. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19366. /** @hidden */
  19367. _postActivate(): void;
  19368. getWorldMatrix(): Matrix;
  19369. get isAnInstance(): boolean;
  19370. /**
  19371. * Returns the current associated LOD AbstractMesh.
  19372. */
  19373. getLOD(camera: Camera): AbstractMesh;
  19374. /** @hidden */
  19375. _syncSubMeshes(): InstancedMesh;
  19376. /** @hidden */
  19377. _generatePointsArray(): boolean;
  19378. /**
  19379. * Creates a new InstancedMesh from the current mesh.
  19380. * - name (string) : the cloned mesh name
  19381. * - newParent (optional Node) : the optional Node to parent the clone to.
  19382. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19383. *
  19384. * Returns the clone.
  19385. */
  19386. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19387. /**
  19388. * Disposes the InstancedMesh.
  19389. * Returns nothing.
  19390. */
  19391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19392. }
  19393. interface Mesh {
  19394. /**
  19395. * Register a custom buffer that will be instanced
  19396. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19397. * @param kind defines the buffer kind
  19398. * @param stride defines the stride in floats
  19399. */
  19400. registerInstancedBuffer(kind: string, stride: number): void;
  19401. /** @hidden */
  19402. _userInstancedBuffersStorage: {
  19403. data: {
  19404. [key: string]: Float32Array;
  19405. };
  19406. sizes: {
  19407. [key: string]: number;
  19408. };
  19409. vertexBuffers: {
  19410. [key: string]: Nullable<VertexBuffer>;
  19411. };
  19412. strides: {
  19413. [key: string]: number;
  19414. };
  19415. };
  19416. }
  19417. interface AbstractMesh {
  19418. /**
  19419. * Object used to store instanced buffers defined by user
  19420. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19421. */
  19422. instancedBuffers: {
  19423. [key: string]: any;
  19424. };
  19425. }
  19426. }
  19427. declare module BABYLON {
  19428. /**
  19429. * Defines the options associated with the creation of a shader material.
  19430. */
  19431. export interface IShaderMaterialOptions {
  19432. /**
  19433. * Does the material work in alpha blend mode
  19434. */
  19435. needAlphaBlending: boolean;
  19436. /**
  19437. * Does the material work in alpha test mode
  19438. */
  19439. needAlphaTesting: boolean;
  19440. /**
  19441. * The list of attribute names used in the shader
  19442. */
  19443. attributes: string[];
  19444. /**
  19445. * The list of unifrom names used in the shader
  19446. */
  19447. uniforms: string[];
  19448. /**
  19449. * The list of UBO names used in the shader
  19450. */
  19451. uniformBuffers: string[];
  19452. /**
  19453. * The list of sampler names used in the shader
  19454. */
  19455. samplers: string[];
  19456. /**
  19457. * The list of defines used in the shader
  19458. */
  19459. defines: string[];
  19460. }
  19461. /**
  19462. * 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.
  19463. *
  19464. * This returned material effects how the mesh will look based on the code in the shaders.
  19465. *
  19466. * @see http://doc.babylonjs.com/how_to/shader_material
  19467. */
  19468. export class ShaderMaterial extends Material {
  19469. private _shaderPath;
  19470. private _options;
  19471. private _textures;
  19472. private _textureArrays;
  19473. private _floats;
  19474. private _ints;
  19475. private _floatsArrays;
  19476. private _colors3;
  19477. private _colors3Arrays;
  19478. private _colors4;
  19479. private _colors4Arrays;
  19480. private _vectors2;
  19481. private _vectors3;
  19482. private _vectors4;
  19483. private _matrices;
  19484. private _matrixArrays;
  19485. private _matrices3x3;
  19486. private _matrices2x2;
  19487. private _vectors2Arrays;
  19488. private _vectors3Arrays;
  19489. private _vectors4Arrays;
  19490. private _cachedWorldViewMatrix;
  19491. private _cachedWorldViewProjectionMatrix;
  19492. private _renderId;
  19493. private _multiview;
  19494. /**
  19495. * Instantiate a new shader material.
  19496. * 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.
  19497. * This returned material effects how the mesh will look based on the code in the shaders.
  19498. * @see http://doc.babylonjs.com/how_to/shader_material
  19499. * @param name Define the name of the material in the scene
  19500. * @param scene Define the scene the material belongs to
  19501. * @param shaderPath Defines the route to the shader code in one of three ways:
  19502. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19503. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19504. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19505. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19506. * @param options Define the options used to create the shader
  19507. */
  19508. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19509. /**
  19510. * Gets the shader path used to define the shader code
  19511. * It can be modified to trigger a new compilation
  19512. */
  19513. get shaderPath(): any;
  19514. /**
  19515. * Sets the shader path used to define the shader code
  19516. * It can be modified to trigger a new compilation
  19517. */
  19518. set shaderPath(shaderPath: any);
  19519. /**
  19520. * Gets the options used to compile the shader.
  19521. * They can be modified to trigger a new compilation
  19522. */
  19523. get options(): IShaderMaterialOptions;
  19524. /**
  19525. * Gets the current class name of the material e.g. "ShaderMaterial"
  19526. * Mainly use in serialization.
  19527. * @returns the class name
  19528. */
  19529. getClassName(): string;
  19530. /**
  19531. * Specifies if the material will require alpha blending
  19532. * @returns a boolean specifying if alpha blending is needed
  19533. */
  19534. needAlphaBlending(): boolean;
  19535. /**
  19536. * Specifies if this material should be rendered in alpha test mode
  19537. * @returns a boolean specifying if an alpha test is needed.
  19538. */
  19539. needAlphaTesting(): boolean;
  19540. private _checkUniform;
  19541. /**
  19542. * Set a texture in the shader.
  19543. * @param name Define the name of the uniform samplers as defined in the shader
  19544. * @param texture Define the texture to bind to this sampler
  19545. * @return the material itself allowing "fluent" like uniform updates
  19546. */
  19547. setTexture(name: string, texture: Texture): ShaderMaterial;
  19548. /**
  19549. * Set a texture array in the shader.
  19550. * @param name Define the name of the uniform sampler array as defined in the shader
  19551. * @param textures Define the list of textures to bind to this sampler
  19552. * @return the material itself allowing "fluent" like uniform updates
  19553. */
  19554. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19555. /**
  19556. * Set a float in the shader.
  19557. * @param name Define the name of the uniform as defined in the shader
  19558. * @param value Define the value to give to the uniform
  19559. * @return the material itself allowing "fluent" like uniform updates
  19560. */
  19561. setFloat(name: string, value: number): ShaderMaterial;
  19562. /**
  19563. * Set a int in the shader.
  19564. * @param name Define the name of the uniform as defined in the shader
  19565. * @param value Define the value to give to the uniform
  19566. * @return the material itself allowing "fluent" like uniform updates
  19567. */
  19568. setInt(name: string, value: number): ShaderMaterial;
  19569. /**
  19570. * Set an array of floats in the shader.
  19571. * @param name Define the name of the uniform as defined in the shader
  19572. * @param value Define the value to give to the uniform
  19573. * @return the material itself allowing "fluent" like uniform updates
  19574. */
  19575. setFloats(name: string, value: number[]): ShaderMaterial;
  19576. /**
  19577. * Set a vec3 in the shader from a Color3.
  19578. * @param name Define the name of the uniform as defined in the shader
  19579. * @param value Define the value to give to the uniform
  19580. * @return the material itself allowing "fluent" like uniform updates
  19581. */
  19582. setColor3(name: string, value: Color3): ShaderMaterial;
  19583. /**
  19584. * Set a vec3 array in the shader from a Color3 array.
  19585. * @param name Define the name of the uniform as defined in the shader
  19586. * @param value Define the value to give to the uniform
  19587. * @return the material itself allowing "fluent" like uniform updates
  19588. */
  19589. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19590. /**
  19591. * Set a vec4 in the shader from a Color4.
  19592. * @param name Define the name of the uniform as defined in the shader
  19593. * @param value Define the value to give to the uniform
  19594. * @return the material itself allowing "fluent" like uniform updates
  19595. */
  19596. setColor4(name: string, value: Color4): ShaderMaterial;
  19597. /**
  19598. * Set a vec4 array in the shader from a Color4 array.
  19599. * @param name Define the name of the uniform as defined in the shader
  19600. * @param value Define the value to give to the uniform
  19601. * @return the material itself allowing "fluent" like uniform updates
  19602. */
  19603. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19604. /**
  19605. * Set a vec2 in the shader from a Vector2.
  19606. * @param name Define the name of the uniform as defined in the shader
  19607. * @param value Define the value to give to the uniform
  19608. * @return the material itself allowing "fluent" like uniform updates
  19609. */
  19610. setVector2(name: string, value: Vector2): ShaderMaterial;
  19611. /**
  19612. * Set a vec3 in the shader from a Vector3.
  19613. * @param name Define the name of the uniform as defined in the shader
  19614. * @param value Define the value to give to the uniform
  19615. * @return the material itself allowing "fluent" like uniform updates
  19616. */
  19617. setVector3(name: string, value: Vector3): ShaderMaterial;
  19618. /**
  19619. * Set a vec4 in the shader from a Vector4.
  19620. * @param name Define the name of the uniform as defined in the shader
  19621. * @param value Define the value to give to the uniform
  19622. * @return the material itself allowing "fluent" like uniform updates
  19623. */
  19624. setVector4(name: string, value: Vector4): ShaderMaterial;
  19625. /**
  19626. * Set a mat4 in the shader from a Matrix.
  19627. * @param name Define the name of the uniform as defined in the shader
  19628. * @param value Define the value to give to the uniform
  19629. * @return the material itself allowing "fluent" like uniform updates
  19630. */
  19631. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19632. /**
  19633. * Set a float32Array in the shader from a matrix array.
  19634. * @param name Define the name of the uniform as defined in the shader
  19635. * @param value Define the value to give to the uniform
  19636. * @return the material itself allowing "fluent" like uniform updates
  19637. */
  19638. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19639. /**
  19640. * Set a mat3 in the shader from a Float32Array.
  19641. * @param name Define the name of the uniform as defined in the shader
  19642. * @param value Define the value to give to the uniform
  19643. * @return the material itself allowing "fluent" like uniform updates
  19644. */
  19645. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19646. /**
  19647. * Set a mat2 in the shader from a Float32Array.
  19648. * @param name Define the name of the uniform as defined in the shader
  19649. * @param value Define the value to give to the uniform
  19650. * @return the material itself allowing "fluent" like uniform updates
  19651. */
  19652. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19653. /**
  19654. * Set a vec2 array in the shader from a number array.
  19655. * @param name Define the name of the uniform as defined in the shader
  19656. * @param value Define the value to give to the uniform
  19657. * @return the material itself allowing "fluent" like uniform updates
  19658. */
  19659. setArray2(name: string, value: number[]): ShaderMaterial;
  19660. /**
  19661. * Set a vec3 array in the shader from a number array.
  19662. * @param name Define the name of the uniform as defined in the shader
  19663. * @param value Define the value to give to the uniform
  19664. * @return the material itself allowing "fluent" like uniform updates
  19665. */
  19666. setArray3(name: string, value: number[]): ShaderMaterial;
  19667. /**
  19668. * Set a vec4 array in the shader from a number array.
  19669. * @param name Define the name of the uniform as defined in the shader
  19670. * @param value Define the value to give to the uniform
  19671. * @return the material itself allowing "fluent" like uniform updates
  19672. */
  19673. setArray4(name: string, value: number[]): ShaderMaterial;
  19674. private _checkCache;
  19675. /**
  19676. * Specifies that the submesh is ready to be used
  19677. * @param mesh defines the mesh to check
  19678. * @param subMesh defines which submesh to check
  19679. * @param useInstances specifies that instances should be used
  19680. * @returns a boolean indicating that the submesh is ready or not
  19681. */
  19682. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19683. /**
  19684. * Checks if the material is ready to render the requested mesh
  19685. * @param mesh Define the mesh to render
  19686. * @param useInstances Define whether or not the material is used with instances
  19687. * @returns true if ready, otherwise false
  19688. */
  19689. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19690. /**
  19691. * Binds the world matrix to the material
  19692. * @param world defines the world transformation matrix
  19693. */
  19694. bindOnlyWorldMatrix(world: Matrix): void;
  19695. /**
  19696. * Binds the material to the mesh
  19697. * @param world defines the world transformation matrix
  19698. * @param mesh defines the mesh to bind the material to
  19699. */
  19700. bind(world: Matrix, mesh?: Mesh): void;
  19701. /**
  19702. * Gets the active textures from the material
  19703. * @returns an array of textures
  19704. */
  19705. getActiveTextures(): BaseTexture[];
  19706. /**
  19707. * Specifies if the material uses a texture
  19708. * @param texture defines the texture to check against the material
  19709. * @returns a boolean specifying if the material uses the texture
  19710. */
  19711. hasTexture(texture: BaseTexture): boolean;
  19712. /**
  19713. * Makes a duplicate of the material, and gives it a new name
  19714. * @param name defines the new name for the duplicated material
  19715. * @returns the cloned material
  19716. */
  19717. clone(name: string): ShaderMaterial;
  19718. /**
  19719. * Disposes the material
  19720. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19721. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19722. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19723. */
  19724. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19725. /**
  19726. * Serializes this material in a JSON representation
  19727. * @returns the serialized material object
  19728. */
  19729. serialize(): any;
  19730. /**
  19731. * Creates a shader material from parsed shader material data
  19732. * @param source defines the JSON represnetation of the material
  19733. * @param scene defines the hosting scene
  19734. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19735. * @returns a new material
  19736. */
  19737. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19738. }
  19739. }
  19740. declare module BABYLON {
  19741. /** @hidden */
  19742. export var colorPixelShader: {
  19743. name: string;
  19744. shader: string;
  19745. };
  19746. }
  19747. declare module BABYLON {
  19748. /** @hidden */
  19749. export var colorVertexShader: {
  19750. name: string;
  19751. shader: string;
  19752. };
  19753. }
  19754. declare module BABYLON {
  19755. /**
  19756. * Line mesh
  19757. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19758. */
  19759. export class LinesMesh extends Mesh {
  19760. /**
  19761. * If vertex color should be applied to the mesh
  19762. */
  19763. readonly useVertexColor?: boolean | undefined;
  19764. /**
  19765. * If vertex alpha should be applied to the mesh
  19766. */
  19767. readonly useVertexAlpha?: boolean | undefined;
  19768. /**
  19769. * Color of the line (Default: White)
  19770. */
  19771. color: Color3;
  19772. /**
  19773. * Alpha of the line (Default: 1)
  19774. */
  19775. alpha: number;
  19776. /**
  19777. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19778. * This margin is expressed in world space coordinates, so its value may vary.
  19779. * Default value is 0.1
  19780. */
  19781. intersectionThreshold: number;
  19782. private _colorShader;
  19783. private color4;
  19784. /**
  19785. * Creates a new LinesMesh
  19786. * @param name defines the name
  19787. * @param scene defines the hosting scene
  19788. * @param parent defines the parent mesh if any
  19789. * @param source defines the optional source LinesMesh used to clone data from
  19790. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19791. * When false, achieved by calling a clone(), also passing False.
  19792. * This will make creation of children, recursive.
  19793. * @param useVertexColor defines if this LinesMesh supports vertex color
  19794. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19795. */
  19796. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19797. /**
  19798. * If vertex color should be applied to the mesh
  19799. */
  19800. useVertexColor?: boolean | undefined,
  19801. /**
  19802. * If vertex alpha should be applied to the mesh
  19803. */
  19804. useVertexAlpha?: boolean | undefined);
  19805. private _addClipPlaneDefine;
  19806. private _removeClipPlaneDefine;
  19807. isReady(): boolean;
  19808. /**
  19809. * Returns the string "LineMesh"
  19810. */
  19811. getClassName(): string;
  19812. /**
  19813. * @hidden
  19814. */
  19815. get material(): Material;
  19816. /**
  19817. * @hidden
  19818. */
  19819. set material(value: Material);
  19820. /**
  19821. * @hidden
  19822. */
  19823. get checkCollisions(): boolean;
  19824. /** @hidden */
  19825. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19826. /** @hidden */
  19827. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19828. /**
  19829. * Disposes of the line mesh
  19830. * @param doNotRecurse If children should be disposed
  19831. */
  19832. dispose(doNotRecurse?: boolean): void;
  19833. /**
  19834. * Returns a new LineMesh object cloned from the current one.
  19835. */
  19836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  19837. /**
  19838. * Creates a new InstancedLinesMesh object from the mesh model.
  19839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19840. * @param name defines the name of the new instance
  19841. * @returns a new InstancedLinesMesh
  19842. */
  19843. createInstance(name: string): InstancedLinesMesh;
  19844. }
  19845. /**
  19846. * Creates an instance based on a source LinesMesh
  19847. */
  19848. export class InstancedLinesMesh extends InstancedMesh {
  19849. /**
  19850. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19851. * This margin is expressed in world space coordinates, so its value may vary.
  19852. * Initilized with the intersectionThreshold value of the source LinesMesh
  19853. */
  19854. intersectionThreshold: number;
  19855. constructor(name: string, source: LinesMesh);
  19856. /**
  19857. * Returns the string "InstancedLinesMesh".
  19858. */
  19859. getClassName(): string;
  19860. }
  19861. }
  19862. declare module BABYLON {
  19863. /** @hidden */
  19864. export var linePixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module BABYLON {
  19870. /** @hidden */
  19871. export var lineVertexShader: {
  19872. name: string;
  19873. shader: string;
  19874. };
  19875. }
  19876. declare module BABYLON {
  19877. interface AbstractMesh {
  19878. /**
  19879. * Gets the edgesRenderer associated with the mesh
  19880. */
  19881. edgesRenderer: Nullable<EdgesRenderer>;
  19882. }
  19883. interface LinesMesh {
  19884. /**
  19885. * Enables the edge rendering mode on the mesh.
  19886. * This mode makes the mesh edges visible
  19887. * @param epsilon defines the maximal distance between two angles to detect a face
  19888. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19889. * @returns the currentAbstractMesh
  19890. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19891. */
  19892. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19893. }
  19894. interface InstancedLinesMesh {
  19895. /**
  19896. * Enables the edge rendering mode on the mesh.
  19897. * This mode makes the mesh edges visible
  19898. * @param epsilon defines the maximal distance between two angles to detect a face
  19899. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19900. * @returns the current InstancedLinesMesh
  19901. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19902. */
  19903. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19904. }
  19905. /**
  19906. * Defines the minimum contract an Edges renderer should follow.
  19907. */
  19908. export interface IEdgesRenderer extends IDisposable {
  19909. /**
  19910. * Gets or sets a boolean indicating if the edgesRenderer is active
  19911. */
  19912. isEnabled: boolean;
  19913. /**
  19914. * Renders the edges of the attached mesh,
  19915. */
  19916. render(): void;
  19917. /**
  19918. * Checks wether or not the edges renderer is ready to render.
  19919. * @return true if ready, otherwise false.
  19920. */
  19921. isReady(): boolean;
  19922. }
  19923. /**
  19924. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19925. */
  19926. export class EdgesRenderer implements IEdgesRenderer {
  19927. /**
  19928. * Define the size of the edges with an orthographic camera
  19929. */
  19930. edgesWidthScalerForOrthographic: number;
  19931. /**
  19932. * Define the size of the edges with a perspective camera
  19933. */
  19934. edgesWidthScalerForPerspective: number;
  19935. protected _source: AbstractMesh;
  19936. protected _linesPositions: number[];
  19937. protected _linesNormals: number[];
  19938. protected _linesIndices: number[];
  19939. protected _epsilon: number;
  19940. protected _indicesCount: number;
  19941. protected _lineShader: ShaderMaterial;
  19942. protected _ib: DataBuffer;
  19943. protected _buffers: {
  19944. [key: string]: Nullable<VertexBuffer>;
  19945. };
  19946. protected _checkVerticesInsteadOfIndices: boolean;
  19947. private _meshRebuildObserver;
  19948. private _meshDisposeObserver;
  19949. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19950. isEnabled: boolean;
  19951. /**
  19952. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19953. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19954. * @param source Mesh used to create edges
  19955. * @param epsilon sum of angles in adjacency to check for edge
  19956. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19957. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19958. */
  19959. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19960. protected _prepareRessources(): void;
  19961. /** @hidden */
  19962. _rebuild(): void;
  19963. /**
  19964. * Releases the required resources for the edges renderer
  19965. */
  19966. dispose(): void;
  19967. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19968. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19969. /**
  19970. * Checks if the pair of p0 and p1 is en edge
  19971. * @param faceIndex
  19972. * @param edge
  19973. * @param faceNormals
  19974. * @param p0
  19975. * @param p1
  19976. * @private
  19977. */
  19978. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19979. /**
  19980. * push line into the position, normal and index buffer
  19981. * @protected
  19982. */
  19983. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19984. /**
  19985. * Generates lines edges from adjacencjes
  19986. * @private
  19987. */
  19988. _generateEdgesLines(): void;
  19989. /**
  19990. * Checks wether or not the edges renderer is ready to render.
  19991. * @return true if ready, otherwise false.
  19992. */
  19993. isReady(): boolean;
  19994. /**
  19995. * Renders the edges of the attached mesh,
  19996. */
  19997. render(): void;
  19998. }
  19999. /**
  20000. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20001. */
  20002. export class LineEdgesRenderer extends EdgesRenderer {
  20003. /**
  20004. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20005. * @param source LineMesh used to generate edges
  20006. * @param epsilon not important (specified angle for edge detection)
  20007. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20008. */
  20009. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20010. /**
  20011. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20012. */
  20013. _generateEdgesLines(): void;
  20014. }
  20015. }
  20016. declare module BABYLON {
  20017. /**
  20018. * This represents the object necessary to create a rendering group.
  20019. * This is exclusively used and created by the rendering manager.
  20020. * To modify the behavior, you use the available helpers in your scene or meshes.
  20021. * @hidden
  20022. */
  20023. export class RenderingGroup {
  20024. index: number;
  20025. private static _zeroVector;
  20026. private _scene;
  20027. private _opaqueSubMeshes;
  20028. private _transparentSubMeshes;
  20029. private _alphaTestSubMeshes;
  20030. private _depthOnlySubMeshes;
  20031. private _particleSystems;
  20032. private _spriteManagers;
  20033. private _opaqueSortCompareFn;
  20034. private _alphaTestSortCompareFn;
  20035. private _transparentSortCompareFn;
  20036. private _renderOpaque;
  20037. private _renderAlphaTest;
  20038. private _renderTransparent;
  20039. /** @hidden */
  20040. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20041. onBeforeTransparentRendering: () => void;
  20042. /**
  20043. * Set the opaque sort comparison function.
  20044. * If null the sub meshes will be render in the order they were created
  20045. */
  20046. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20047. /**
  20048. * Set the alpha test sort comparison function.
  20049. * If null the sub meshes will be render in the order they were created
  20050. */
  20051. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20052. /**
  20053. * Set the transparent sort comparison function.
  20054. * If null the sub meshes will be render in the order they were created
  20055. */
  20056. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20057. /**
  20058. * Creates a new rendering group.
  20059. * @param index The rendering group index
  20060. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20061. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20062. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20063. */
  20064. 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>);
  20065. /**
  20066. * Render all the sub meshes contained in the group.
  20067. * @param customRenderFunction Used to override the default render behaviour of the group.
  20068. * @returns true if rendered some submeshes.
  20069. */
  20070. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20071. /**
  20072. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20073. * @param subMeshes The submeshes to render
  20074. */
  20075. private renderOpaqueSorted;
  20076. /**
  20077. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20078. * @param subMeshes The submeshes to render
  20079. */
  20080. private renderAlphaTestSorted;
  20081. /**
  20082. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20083. * @param subMeshes The submeshes to render
  20084. */
  20085. private renderTransparentSorted;
  20086. /**
  20087. * Renders the submeshes in a specified order.
  20088. * @param subMeshes The submeshes to sort before render
  20089. * @param sortCompareFn The comparison function use to sort
  20090. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20091. * @param transparent Specifies to activate blending if true
  20092. */
  20093. private static renderSorted;
  20094. /**
  20095. * Renders the submeshes in the order they were dispatched (no sort applied).
  20096. * @param subMeshes The submeshes to render
  20097. */
  20098. private static renderUnsorted;
  20099. /**
  20100. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20101. * are rendered back to front if in the same alpha index.
  20102. *
  20103. * @param a The first submesh
  20104. * @param b The second submesh
  20105. * @returns The result of the comparison
  20106. */
  20107. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20108. /**
  20109. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20110. * are rendered back to front.
  20111. *
  20112. * @param a The first submesh
  20113. * @param b The second submesh
  20114. * @returns The result of the comparison
  20115. */
  20116. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20117. /**
  20118. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20119. * are rendered front to back (prevent overdraw).
  20120. *
  20121. * @param a The first submesh
  20122. * @param b The second submesh
  20123. * @returns The result of the comparison
  20124. */
  20125. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20126. /**
  20127. * Resets the different lists of submeshes to prepare a new frame.
  20128. */
  20129. prepare(): void;
  20130. dispose(): void;
  20131. /**
  20132. * Inserts the submesh in its correct queue depending on its material.
  20133. * @param subMesh The submesh to dispatch
  20134. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20135. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20136. */
  20137. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20138. dispatchSprites(spriteManager: ISpriteManager): void;
  20139. dispatchParticles(particleSystem: IParticleSystem): void;
  20140. private _renderParticles;
  20141. private _renderSprites;
  20142. }
  20143. }
  20144. declare module BABYLON {
  20145. /**
  20146. * Interface describing the different options available in the rendering manager
  20147. * regarding Auto Clear between groups.
  20148. */
  20149. export interface IRenderingManagerAutoClearSetup {
  20150. /**
  20151. * Defines whether or not autoclear is enable.
  20152. */
  20153. autoClear: boolean;
  20154. /**
  20155. * Defines whether or not to autoclear the depth buffer.
  20156. */
  20157. depth: boolean;
  20158. /**
  20159. * Defines whether or not to autoclear the stencil buffer.
  20160. */
  20161. stencil: boolean;
  20162. }
  20163. /**
  20164. * This class is used by the onRenderingGroupObservable
  20165. */
  20166. export class RenderingGroupInfo {
  20167. /**
  20168. * The Scene that being rendered
  20169. */
  20170. scene: Scene;
  20171. /**
  20172. * The camera currently used for the rendering pass
  20173. */
  20174. camera: Nullable<Camera>;
  20175. /**
  20176. * The ID of the renderingGroup being processed
  20177. */
  20178. renderingGroupId: number;
  20179. }
  20180. /**
  20181. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20182. * It is enable to manage the different groups as well as the different necessary sort functions.
  20183. * This should not be used directly aside of the few static configurations
  20184. */
  20185. export class RenderingManager {
  20186. /**
  20187. * The max id used for rendering groups (not included)
  20188. */
  20189. static MAX_RENDERINGGROUPS: number;
  20190. /**
  20191. * The min id used for rendering groups (included)
  20192. */
  20193. static MIN_RENDERINGGROUPS: number;
  20194. /**
  20195. * Used to globally prevent autoclearing scenes.
  20196. */
  20197. static AUTOCLEAR: boolean;
  20198. /**
  20199. * @hidden
  20200. */
  20201. _useSceneAutoClearSetup: boolean;
  20202. private _scene;
  20203. private _renderingGroups;
  20204. private _depthStencilBufferAlreadyCleaned;
  20205. private _autoClearDepthStencil;
  20206. private _customOpaqueSortCompareFn;
  20207. private _customAlphaTestSortCompareFn;
  20208. private _customTransparentSortCompareFn;
  20209. private _renderingGroupInfo;
  20210. /**
  20211. * Instantiates a new rendering group for a particular scene
  20212. * @param scene Defines the scene the groups belongs to
  20213. */
  20214. constructor(scene: Scene);
  20215. private _clearDepthStencilBuffer;
  20216. /**
  20217. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20218. * @hidden
  20219. */
  20220. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20221. /**
  20222. * Resets the different information of the group to prepare a new frame
  20223. * @hidden
  20224. */
  20225. reset(): void;
  20226. /**
  20227. * Dispose and release the group and its associated resources.
  20228. * @hidden
  20229. */
  20230. dispose(): void;
  20231. /**
  20232. * Clear the info related to rendering groups preventing retention points during dispose.
  20233. */
  20234. freeRenderingGroups(): void;
  20235. private _prepareRenderingGroup;
  20236. /**
  20237. * Add a sprite manager to the rendering manager in order to render it this frame.
  20238. * @param spriteManager Define the sprite manager to render
  20239. */
  20240. dispatchSprites(spriteManager: ISpriteManager): void;
  20241. /**
  20242. * Add a particle system to the rendering manager in order to render it this frame.
  20243. * @param particleSystem Define the particle system to render
  20244. */
  20245. dispatchParticles(particleSystem: IParticleSystem): void;
  20246. /**
  20247. * Add a submesh to the manager in order to render it this frame
  20248. * @param subMesh The submesh to dispatch
  20249. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20250. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20251. */
  20252. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20253. /**
  20254. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20255. * This allowed control for front to back rendering or reversly depending of the special needs.
  20256. *
  20257. * @param renderingGroupId The rendering group id corresponding to its index
  20258. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20259. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20260. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20261. */
  20262. 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;
  20263. /**
  20264. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20265. *
  20266. * @param renderingGroupId The rendering group id corresponding to its index
  20267. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20268. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20269. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20270. */
  20271. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20272. /**
  20273. * Gets the current auto clear configuration for one rendering group of the rendering
  20274. * manager.
  20275. * @param index the rendering group index to get the information for
  20276. * @returns The auto clear setup for the requested rendering group
  20277. */
  20278. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20279. }
  20280. }
  20281. declare module BABYLON {
  20282. /**
  20283. * This Helps creating a texture that will be created from a camera in your scene.
  20284. * It is basically a dynamic texture that could be used to create special effects for instance.
  20285. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20286. */
  20287. export class RenderTargetTexture extends Texture {
  20288. isCube: boolean;
  20289. /**
  20290. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20291. */
  20292. static readonly REFRESHRATE_RENDER_ONCE: number;
  20293. /**
  20294. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20295. */
  20296. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20297. /**
  20298. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20299. * the central point of your effect and can save a lot of performances.
  20300. */
  20301. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20302. /**
  20303. * Use this predicate to dynamically define the list of mesh you want to render.
  20304. * If set, the renderList property will be overwritten.
  20305. */
  20306. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20307. private _renderList;
  20308. /**
  20309. * Use this list to define the list of mesh you want to render.
  20310. */
  20311. get renderList(): Nullable<Array<AbstractMesh>>;
  20312. set renderList(value: Nullable<Array<AbstractMesh>>);
  20313. /**
  20314. * Use this function to overload the renderList array at rendering time.
  20315. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20316. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20317. * the cube (if the RTT is a cube, else layerOrFace=0).
  20318. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20319. */
  20320. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20321. private _hookArray;
  20322. /**
  20323. * Define if particles should be rendered in your texture.
  20324. */
  20325. renderParticles: boolean;
  20326. /**
  20327. * Define if sprites should be rendered in your texture.
  20328. */
  20329. renderSprites: boolean;
  20330. /**
  20331. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20332. */
  20333. coordinatesMode: number;
  20334. /**
  20335. * Define the camera used to render the texture.
  20336. */
  20337. activeCamera: Nullable<Camera>;
  20338. /**
  20339. * Override the render function of the texture with your own one.
  20340. */
  20341. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20342. /**
  20343. * Define if camera post processes should be use while rendering the texture.
  20344. */
  20345. useCameraPostProcesses: boolean;
  20346. /**
  20347. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20348. */
  20349. ignoreCameraViewport: boolean;
  20350. private _postProcessManager;
  20351. private _postProcesses;
  20352. private _resizeObserver;
  20353. /**
  20354. * An event triggered when the texture is unbind.
  20355. */
  20356. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20357. /**
  20358. * An event triggered when the texture is unbind.
  20359. */
  20360. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20361. private _onAfterUnbindObserver;
  20362. /**
  20363. * Set a after unbind callback in the texture.
  20364. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20365. */
  20366. set onAfterUnbind(callback: () => void);
  20367. /**
  20368. * An event triggered before rendering the texture
  20369. */
  20370. onBeforeRenderObservable: Observable<number>;
  20371. private _onBeforeRenderObserver;
  20372. /**
  20373. * Set a before render callback in the texture.
  20374. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20375. */
  20376. set onBeforeRender(callback: (faceIndex: number) => void);
  20377. /**
  20378. * An event triggered after rendering the texture
  20379. */
  20380. onAfterRenderObservable: Observable<number>;
  20381. private _onAfterRenderObserver;
  20382. /**
  20383. * Set a after render callback in the texture.
  20384. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20385. */
  20386. set onAfterRender(callback: (faceIndex: number) => void);
  20387. /**
  20388. * An event triggered after the texture clear
  20389. */
  20390. onClearObservable: Observable<Engine>;
  20391. private _onClearObserver;
  20392. /**
  20393. * Set a clear callback in the texture.
  20394. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20395. */
  20396. set onClear(callback: (Engine: Engine) => void);
  20397. /**
  20398. * An event triggered when the texture is resized.
  20399. */
  20400. onResizeObservable: Observable<RenderTargetTexture>;
  20401. /**
  20402. * Define the clear color of the Render Target if it should be different from the scene.
  20403. */
  20404. clearColor: Color4;
  20405. protected _size: number | {
  20406. width: number;
  20407. height: number;
  20408. layers?: number;
  20409. };
  20410. protected _initialSizeParameter: number | {
  20411. width: number;
  20412. height: number;
  20413. } | {
  20414. ratio: number;
  20415. };
  20416. protected _sizeRatio: Nullable<number>;
  20417. /** @hidden */
  20418. _generateMipMaps: boolean;
  20419. protected _renderingManager: RenderingManager;
  20420. /** @hidden */
  20421. _waitingRenderList: string[];
  20422. protected _doNotChangeAspectRatio: boolean;
  20423. protected _currentRefreshId: number;
  20424. protected _refreshRate: number;
  20425. protected _textureMatrix: Matrix;
  20426. protected _samples: number;
  20427. protected _renderTargetOptions: RenderTargetCreationOptions;
  20428. /**
  20429. * Gets render target creation options that were used.
  20430. */
  20431. get renderTargetOptions(): RenderTargetCreationOptions;
  20432. protected _engine: Engine;
  20433. protected _onRatioRescale(): void;
  20434. /**
  20435. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20436. * It must define where the camera used to render the texture is set
  20437. */
  20438. boundingBoxPosition: Vector3;
  20439. private _boundingBoxSize;
  20440. /**
  20441. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20442. * When defined, the cubemap will switch to local mode
  20443. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20444. * @example https://www.babylonjs-playground.com/#RNASML
  20445. */
  20446. set boundingBoxSize(value: Vector3);
  20447. get boundingBoxSize(): Vector3;
  20448. /**
  20449. * In case the RTT has been created with a depth texture, get the associated
  20450. * depth texture.
  20451. * Otherwise, return null.
  20452. */
  20453. get depthStencilTexture(): Nullable<InternalTexture>;
  20454. /**
  20455. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20456. * or used a shadow, depth texture...
  20457. * @param name The friendly name of the texture
  20458. * @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)
  20459. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20460. * @param generateMipMaps True if mip maps need to be generated after render.
  20461. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20462. * @param type The type of the buffer in the RTT (int, half float, float...)
  20463. * @param isCube True if a cube texture needs to be created
  20464. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20465. * @param generateDepthBuffer True to generate a depth buffer
  20466. * @param generateStencilBuffer True to generate a stencil buffer
  20467. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20468. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20469. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20470. */
  20471. constructor(name: string, size: number | {
  20472. width: number;
  20473. height: number;
  20474. layers?: number;
  20475. } | {
  20476. ratio: number;
  20477. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20478. /**
  20479. * Creates a depth stencil texture.
  20480. * This is only available in WebGL 2 or with the depth texture extension available.
  20481. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20482. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20483. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20484. */
  20485. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20486. private _processSizeParameter;
  20487. /**
  20488. * Define the number of samples to use in case of MSAA.
  20489. * It defaults to one meaning no MSAA has been enabled.
  20490. */
  20491. get samples(): number;
  20492. set samples(value: number);
  20493. /**
  20494. * Resets the refresh counter of the texture and start bak from scratch.
  20495. * Could be useful to regenerate the texture if it is setup to render only once.
  20496. */
  20497. resetRefreshCounter(): void;
  20498. /**
  20499. * Define the refresh rate of the texture or the rendering frequency.
  20500. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20501. */
  20502. get refreshRate(): number;
  20503. set refreshRate(value: number);
  20504. /**
  20505. * Adds a post process to the render target rendering passes.
  20506. * @param postProcess define the post process to add
  20507. */
  20508. addPostProcess(postProcess: PostProcess): void;
  20509. /**
  20510. * Clear all the post processes attached to the render target
  20511. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20512. */
  20513. clearPostProcesses(dispose?: boolean): void;
  20514. /**
  20515. * Remove one of the post process from the list of attached post processes to the texture
  20516. * @param postProcess define the post process to remove from the list
  20517. */
  20518. removePostProcess(postProcess: PostProcess): void;
  20519. /** @hidden */
  20520. _shouldRender(): boolean;
  20521. /**
  20522. * Gets the actual render size of the texture.
  20523. * @returns the width of the render size
  20524. */
  20525. getRenderSize(): number;
  20526. /**
  20527. * Gets the actual render width of the texture.
  20528. * @returns the width of the render size
  20529. */
  20530. getRenderWidth(): number;
  20531. /**
  20532. * Gets the actual render height of the texture.
  20533. * @returns the height of the render size
  20534. */
  20535. getRenderHeight(): number;
  20536. /**
  20537. * Gets the actual number of layers of the texture.
  20538. * @returns the number of layers
  20539. */
  20540. getRenderLayers(): number;
  20541. /**
  20542. * Get if the texture can be rescaled or not.
  20543. */
  20544. get canRescale(): boolean;
  20545. /**
  20546. * Resize the texture using a ratio.
  20547. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20548. */
  20549. scale(ratio: number): void;
  20550. /**
  20551. * Get the texture reflection matrix used to rotate/transform the reflection.
  20552. * @returns the reflection matrix
  20553. */
  20554. getReflectionTextureMatrix(): Matrix;
  20555. /**
  20556. * Resize the texture to a new desired size.
  20557. * Be carrefull as it will recreate all the data in the new texture.
  20558. * @param size Define the new size. It can be:
  20559. * - a number for squared texture,
  20560. * - an object containing { width: number, height: number }
  20561. * - or an object containing a ratio { ratio: number }
  20562. */
  20563. resize(size: number | {
  20564. width: number;
  20565. height: number;
  20566. } | {
  20567. ratio: number;
  20568. }): void;
  20569. private _defaultRenderListPrepared;
  20570. /**
  20571. * Renders all the objects from the render list into the texture.
  20572. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20573. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20574. */
  20575. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20576. private _bestReflectionRenderTargetDimension;
  20577. private _prepareRenderingManager;
  20578. /**
  20579. * @hidden
  20580. * @param faceIndex face index to bind to if this is a cubetexture
  20581. * @param layer defines the index of the texture to bind in the array
  20582. */
  20583. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20584. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20585. private renderToTarget;
  20586. /**
  20587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20588. * This allowed control for front to back rendering or reversly depending of the special needs.
  20589. *
  20590. * @param renderingGroupId The rendering group id corresponding to its index
  20591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20594. */
  20595. 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;
  20596. /**
  20597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20598. *
  20599. * @param renderingGroupId The rendering group id corresponding to its index
  20600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20601. */
  20602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20603. /**
  20604. * Clones the texture.
  20605. * @returns the cloned texture
  20606. */
  20607. clone(): RenderTargetTexture;
  20608. /**
  20609. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20610. * @returns The JSON representation of the texture
  20611. */
  20612. serialize(): any;
  20613. /**
  20614. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20615. */
  20616. disposeFramebufferObjects(): void;
  20617. /**
  20618. * Dispose the texture and release its associated resources.
  20619. */
  20620. dispose(): void;
  20621. /** @hidden */
  20622. _rebuild(): void;
  20623. /**
  20624. * Clear the info related to rendering groups preventing retention point in material dispose.
  20625. */
  20626. freeRenderingGroups(): void;
  20627. /**
  20628. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20629. * @returns the view count
  20630. */
  20631. getViewCount(): number;
  20632. }
  20633. }
  20634. declare module BABYLON {
  20635. /**
  20636. * Options for compiling materials.
  20637. */
  20638. export interface IMaterialCompilationOptions {
  20639. /**
  20640. * Defines whether clip planes are enabled.
  20641. */
  20642. clipPlane: boolean;
  20643. /**
  20644. * Defines whether instances are enabled.
  20645. */
  20646. useInstances: boolean;
  20647. }
  20648. /**
  20649. * Base class for the main features of a material in Babylon.js
  20650. */
  20651. export class Material implements IAnimatable {
  20652. /**
  20653. * Returns the triangle fill mode
  20654. */
  20655. static readonly TriangleFillMode: number;
  20656. /**
  20657. * Returns the wireframe mode
  20658. */
  20659. static readonly WireFrameFillMode: number;
  20660. /**
  20661. * Returns the point fill mode
  20662. */
  20663. static readonly PointFillMode: number;
  20664. /**
  20665. * Returns the point list draw mode
  20666. */
  20667. static readonly PointListDrawMode: number;
  20668. /**
  20669. * Returns the line list draw mode
  20670. */
  20671. static readonly LineListDrawMode: number;
  20672. /**
  20673. * Returns the line loop draw mode
  20674. */
  20675. static readonly LineLoopDrawMode: number;
  20676. /**
  20677. * Returns the line strip draw mode
  20678. */
  20679. static readonly LineStripDrawMode: number;
  20680. /**
  20681. * Returns the triangle strip draw mode
  20682. */
  20683. static readonly TriangleStripDrawMode: number;
  20684. /**
  20685. * Returns the triangle fan draw mode
  20686. */
  20687. static readonly TriangleFanDrawMode: number;
  20688. /**
  20689. * Stores the clock-wise side orientation
  20690. */
  20691. static readonly ClockWiseSideOrientation: number;
  20692. /**
  20693. * Stores the counter clock-wise side orientation
  20694. */
  20695. static readonly CounterClockWiseSideOrientation: number;
  20696. /**
  20697. * The dirty texture flag value
  20698. */
  20699. static readonly TextureDirtyFlag: number;
  20700. /**
  20701. * The dirty light flag value
  20702. */
  20703. static readonly LightDirtyFlag: number;
  20704. /**
  20705. * The dirty fresnel flag value
  20706. */
  20707. static readonly FresnelDirtyFlag: number;
  20708. /**
  20709. * The dirty attribute flag value
  20710. */
  20711. static readonly AttributesDirtyFlag: number;
  20712. /**
  20713. * The dirty misc flag value
  20714. */
  20715. static readonly MiscDirtyFlag: number;
  20716. /**
  20717. * The all dirty flag value
  20718. */
  20719. static readonly AllDirtyFlag: number;
  20720. /**
  20721. * The ID of the material
  20722. */
  20723. id: string;
  20724. /**
  20725. * Gets or sets the unique id of the material
  20726. */
  20727. uniqueId: number;
  20728. /**
  20729. * The name of the material
  20730. */
  20731. name: string;
  20732. /**
  20733. * Gets or sets user defined metadata
  20734. */
  20735. metadata: any;
  20736. /**
  20737. * For internal use only. Please do not use.
  20738. */
  20739. reservedDataStore: any;
  20740. /**
  20741. * Specifies if the ready state should be checked on each call
  20742. */
  20743. checkReadyOnEveryCall: boolean;
  20744. /**
  20745. * Specifies if the ready state should be checked once
  20746. */
  20747. checkReadyOnlyOnce: boolean;
  20748. /**
  20749. * The state of the material
  20750. */
  20751. state: string;
  20752. /**
  20753. * The alpha value of the material
  20754. */
  20755. protected _alpha: number;
  20756. /**
  20757. * List of inspectable custom properties (used by the Inspector)
  20758. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20759. */
  20760. inspectableCustomProperties: IInspectable[];
  20761. /**
  20762. * Sets the alpha value of the material
  20763. */
  20764. set alpha(value: number);
  20765. /**
  20766. * Gets the alpha value of the material
  20767. */
  20768. get alpha(): number;
  20769. /**
  20770. * Specifies if back face culling is enabled
  20771. */
  20772. protected _backFaceCulling: boolean;
  20773. /**
  20774. * Sets the back-face culling state
  20775. */
  20776. set backFaceCulling(value: boolean);
  20777. /**
  20778. * Gets the back-face culling state
  20779. */
  20780. get backFaceCulling(): boolean;
  20781. /**
  20782. * Stores the value for side orientation
  20783. */
  20784. sideOrientation: number;
  20785. /**
  20786. * Callback triggered when the material is compiled
  20787. */
  20788. onCompiled: Nullable<(effect: Effect) => void>;
  20789. /**
  20790. * Callback triggered when an error occurs
  20791. */
  20792. onError: Nullable<(effect: Effect, errors: string) => void>;
  20793. /**
  20794. * Callback triggered to get the render target textures
  20795. */
  20796. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20797. /**
  20798. * Gets a boolean indicating that current material needs to register RTT
  20799. */
  20800. get hasRenderTargetTextures(): boolean;
  20801. /**
  20802. * Specifies if the material should be serialized
  20803. */
  20804. doNotSerialize: boolean;
  20805. /**
  20806. * @hidden
  20807. */
  20808. _storeEffectOnSubMeshes: boolean;
  20809. /**
  20810. * Stores the animations for the material
  20811. */
  20812. animations: Nullable<Array<Animation>>;
  20813. /**
  20814. * An event triggered when the material is disposed
  20815. */
  20816. onDisposeObservable: Observable<Material>;
  20817. /**
  20818. * An observer which watches for dispose events
  20819. */
  20820. private _onDisposeObserver;
  20821. private _onUnBindObservable;
  20822. /**
  20823. * Called during a dispose event
  20824. */
  20825. set onDispose(callback: () => void);
  20826. private _onBindObservable;
  20827. /**
  20828. * An event triggered when the material is bound
  20829. */
  20830. get onBindObservable(): Observable<AbstractMesh>;
  20831. /**
  20832. * An observer which watches for bind events
  20833. */
  20834. private _onBindObserver;
  20835. /**
  20836. * Called during a bind event
  20837. */
  20838. set onBind(callback: (Mesh: AbstractMesh) => void);
  20839. /**
  20840. * An event triggered when the material is unbound
  20841. */
  20842. get onUnBindObservable(): Observable<Material>;
  20843. /**
  20844. * Stores the value of the alpha mode
  20845. */
  20846. private _alphaMode;
  20847. /**
  20848. * Sets the value of the alpha mode.
  20849. *
  20850. * | Value | Type | Description |
  20851. * | --- | --- | --- |
  20852. * | 0 | ALPHA_DISABLE | |
  20853. * | 1 | ALPHA_ADD | |
  20854. * | 2 | ALPHA_COMBINE | |
  20855. * | 3 | ALPHA_SUBTRACT | |
  20856. * | 4 | ALPHA_MULTIPLY | |
  20857. * | 5 | ALPHA_MAXIMIZED | |
  20858. * | 6 | ALPHA_ONEONE | |
  20859. * | 7 | ALPHA_PREMULTIPLIED | |
  20860. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20861. * | 9 | ALPHA_INTERPOLATE | |
  20862. * | 10 | ALPHA_SCREENMODE | |
  20863. *
  20864. */
  20865. set alphaMode(value: number);
  20866. /**
  20867. * Gets the value of the alpha mode
  20868. */
  20869. get alphaMode(): number;
  20870. /**
  20871. * Stores the state of the need depth pre-pass value
  20872. */
  20873. private _needDepthPrePass;
  20874. /**
  20875. * Sets the need depth pre-pass value
  20876. */
  20877. set needDepthPrePass(value: boolean);
  20878. /**
  20879. * Gets the depth pre-pass value
  20880. */
  20881. get needDepthPrePass(): boolean;
  20882. /**
  20883. * Specifies if depth writing should be disabled
  20884. */
  20885. disableDepthWrite: boolean;
  20886. /**
  20887. * Specifies if depth writing should be forced
  20888. */
  20889. forceDepthWrite: boolean;
  20890. /**
  20891. * Specifies the depth function that should be used. 0 means the default engine function
  20892. */
  20893. depthFunction: number;
  20894. /**
  20895. * Specifies if there should be a separate pass for culling
  20896. */
  20897. separateCullingPass: boolean;
  20898. /**
  20899. * Stores the state specifing if fog should be enabled
  20900. */
  20901. private _fogEnabled;
  20902. /**
  20903. * Sets the state for enabling fog
  20904. */
  20905. set fogEnabled(value: boolean);
  20906. /**
  20907. * Gets the value of the fog enabled state
  20908. */
  20909. get fogEnabled(): boolean;
  20910. /**
  20911. * Stores the size of points
  20912. */
  20913. pointSize: number;
  20914. /**
  20915. * Stores the z offset value
  20916. */
  20917. zOffset: number;
  20918. /**
  20919. * Gets a value specifying if wireframe mode is enabled
  20920. */
  20921. get wireframe(): boolean;
  20922. /**
  20923. * Sets the state of wireframe mode
  20924. */
  20925. set wireframe(value: boolean);
  20926. /**
  20927. * Gets the value specifying if point clouds are enabled
  20928. */
  20929. get pointsCloud(): boolean;
  20930. /**
  20931. * Sets the state of point cloud mode
  20932. */
  20933. set pointsCloud(value: boolean);
  20934. /**
  20935. * Gets the material fill mode
  20936. */
  20937. get fillMode(): number;
  20938. /**
  20939. * Sets the material fill mode
  20940. */
  20941. set fillMode(value: number);
  20942. /**
  20943. * @hidden
  20944. * Stores the effects for the material
  20945. */
  20946. _effect: Nullable<Effect>;
  20947. /**
  20948. * Specifies if uniform buffers should be used
  20949. */
  20950. private _useUBO;
  20951. /**
  20952. * Stores a reference to the scene
  20953. */
  20954. private _scene;
  20955. /**
  20956. * Stores the fill mode state
  20957. */
  20958. private _fillMode;
  20959. /**
  20960. * Specifies if the depth write state should be cached
  20961. */
  20962. private _cachedDepthWriteState;
  20963. /**
  20964. * Specifies if the depth function state should be cached
  20965. */
  20966. private _cachedDepthFunctionState;
  20967. /**
  20968. * Stores the uniform buffer
  20969. */
  20970. protected _uniformBuffer: UniformBuffer;
  20971. /** @hidden */
  20972. _indexInSceneMaterialArray: number;
  20973. /** @hidden */
  20974. meshMap: Nullable<{
  20975. [id: string]: AbstractMesh | undefined;
  20976. }>;
  20977. /**
  20978. * Creates a material instance
  20979. * @param name defines the name of the material
  20980. * @param scene defines the scene to reference
  20981. * @param doNotAdd specifies if the material should be added to the scene
  20982. */
  20983. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20984. /**
  20985. * Returns a string representation of the current material
  20986. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20987. * @returns a string with material information
  20988. */
  20989. toString(fullDetails?: boolean): string;
  20990. /**
  20991. * Gets the class name of the material
  20992. * @returns a string with the class name of the material
  20993. */
  20994. getClassName(): string;
  20995. /**
  20996. * Specifies if updates for the material been locked
  20997. */
  20998. get isFrozen(): boolean;
  20999. /**
  21000. * Locks updates for the material
  21001. */
  21002. freeze(): void;
  21003. /**
  21004. * Unlocks updates for the material
  21005. */
  21006. unfreeze(): void;
  21007. /**
  21008. * Specifies if the material is ready to be used
  21009. * @param mesh defines the mesh to check
  21010. * @param useInstances specifies if instances should be used
  21011. * @returns a boolean indicating if the material is ready to be used
  21012. */
  21013. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21014. /**
  21015. * Specifies that the submesh is ready to be used
  21016. * @param mesh defines the mesh to check
  21017. * @param subMesh defines which submesh to check
  21018. * @param useInstances specifies that instances should be used
  21019. * @returns a boolean indicating that the submesh is ready or not
  21020. */
  21021. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21022. /**
  21023. * Returns the material effect
  21024. * @returns the effect associated with the material
  21025. */
  21026. getEffect(): Nullable<Effect>;
  21027. /**
  21028. * Returns the current scene
  21029. * @returns a Scene
  21030. */
  21031. getScene(): Scene;
  21032. /**
  21033. * Specifies if the material will require alpha blending
  21034. * @returns a boolean specifying if alpha blending is needed
  21035. */
  21036. needAlphaBlending(): boolean;
  21037. /**
  21038. * Specifies if the mesh will require alpha blending
  21039. * @param mesh defines the mesh to check
  21040. * @returns a boolean specifying if alpha blending is needed for the mesh
  21041. */
  21042. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21043. /**
  21044. * Specifies if this material should be rendered in alpha test mode
  21045. * @returns a boolean specifying if an alpha test is needed.
  21046. */
  21047. needAlphaTesting(): boolean;
  21048. /**
  21049. * Gets the texture used for the alpha test
  21050. * @returns the texture to use for alpha testing
  21051. */
  21052. getAlphaTestTexture(): Nullable<BaseTexture>;
  21053. /**
  21054. * Marks the material to indicate that it needs to be re-calculated
  21055. */
  21056. markDirty(): void;
  21057. /** @hidden */
  21058. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21059. /**
  21060. * Binds the material to the mesh
  21061. * @param world defines the world transformation matrix
  21062. * @param mesh defines the mesh to bind the material to
  21063. */
  21064. bind(world: Matrix, mesh?: Mesh): void;
  21065. /**
  21066. * Binds the submesh to the material
  21067. * @param world defines the world transformation matrix
  21068. * @param mesh defines the mesh containing the submesh
  21069. * @param subMesh defines the submesh to bind the material to
  21070. */
  21071. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21072. /**
  21073. * Binds the world matrix to the material
  21074. * @param world defines the world transformation matrix
  21075. */
  21076. bindOnlyWorldMatrix(world: Matrix): void;
  21077. /**
  21078. * Binds the scene's uniform buffer to the effect.
  21079. * @param effect defines the effect to bind to the scene uniform buffer
  21080. * @param sceneUbo defines the uniform buffer storing scene data
  21081. */
  21082. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21083. /**
  21084. * Binds the view matrix to the effect
  21085. * @param effect defines the effect to bind the view matrix to
  21086. */
  21087. bindView(effect: Effect): void;
  21088. /**
  21089. * Binds the view projection matrix to the effect
  21090. * @param effect defines the effect to bind the view projection matrix to
  21091. */
  21092. bindViewProjection(effect: Effect): void;
  21093. /**
  21094. * Specifies if material alpha testing should be turned on for the mesh
  21095. * @param mesh defines the mesh to check
  21096. */
  21097. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21098. /**
  21099. * Processes to execute after binding the material to a mesh
  21100. * @param mesh defines the rendered mesh
  21101. */
  21102. protected _afterBind(mesh?: Mesh): void;
  21103. /**
  21104. * Unbinds the material from the mesh
  21105. */
  21106. unbind(): void;
  21107. /**
  21108. * Gets the active textures from the material
  21109. * @returns an array of textures
  21110. */
  21111. getActiveTextures(): BaseTexture[];
  21112. /**
  21113. * Specifies if the material uses a texture
  21114. * @param texture defines the texture to check against the material
  21115. * @returns a boolean specifying if the material uses the texture
  21116. */
  21117. hasTexture(texture: BaseTexture): boolean;
  21118. /**
  21119. * Makes a duplicate of the material, and gives it a new name
  21120. * @param name defines the new name for the duplicated material
  21121. * @returns the cloned material
  21122. */
  21123. clone(name: string): Nullable<Material>;
  21124. /**
  21125. * Gets the meshes bound to the material
  21126. * @returns an array of meshes bound to the material
  21127. */
  21128. getBindedMeshes(): AbstractMesh[];
  21129. /**
  21130. * Force shader compilation
  21131. * @param mesh defines the mesh associated with this material
  21132. * @param onCompiled defines a function to execute once the material is compiled
  21133. * @param options defines the options to configure the compilation
  21134. * @param onError defines a function to execute if the material fails compiling
  21135. */
  21136. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21137. /**
  21138. * Force shader compilation
  21139. * @param mesh defines the mesh that will use this material
  21140. * @param options defines additional options for compiling the shaders
  21141. * @returns a promise that resolves when the compilation completes
  21142. */
  21143. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21144. private static readonly _AllDirtyCallBack;
  21145. private static readonly _ImageProcessingDirtyCallBack;
  21146. private static readonly _TextureDirtyCallBack;
  21147. private static readonly _FresnelDirtyCallBack;
  21148. private static readonly _MiscDirtyCallBack;
  21149. private static readonly _LightsDirtyCallBack;
  21150. private static readonly _AttributeDirtyCallBack;
  21151. private static _FresnelAndMiscDirtyCallBack;
  21152. private static _TextureAndMiscDirtyCallBack;
  21153. private static readonly _DirtyCallbackArray;
  21154. private static readonly _RunDirtyCallBacks;
  21155. /**
  21156. * Marks a define in the material to indicate that it needs to be re-computed
  21157. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21158. */
  21159. markAsDirty(flag: number): void;
  21160. /**
  21161. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21162. * @param func defines a function which checks material defines against the submeshes
  21163. */
  21164. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21165. /**
  21166. * Indicates that we need to re-calculated for all submeshes
  21167. */
  21168. protected _markAllSubMeshesAsAllDirty(): void;
  21169. /**
  21170. * Indicates that image processing needs to be re-calculated for all submeshes
  21171. */
  21172. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21173. /**
  21174. * Indicates that textures need to be re-calculated for all submeshes
  21175. */
  21176. protected _markAllSubMeshesAsTexturesDirty(): void;
  21177. /**
  21178. * Indicates that fresnel needs to be re-calculated for all submeshes
  21179. */
  21180. protected _markAllSubMeshesAsFresnelDirty(): void;
  21181. /**
  21182. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21183. */
  21184. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21185. /**
  21186. * Indicates that lights need to be re-calculated for all submeshes
  21187. */
  21188. protected _markAllSubMeshesAsLightsDirty(): void;
  21189. /**
  21190. * Indicates that attributes need to be re-calculated for all submeshes
  21191. */
  21192. protected _markAllSubMeshesAsAttributesDirty(): void;
  21193. /**
  21194. * Indicates that misc needs to be re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsMiscDirty(): void;
  21197. /**
  21198. * Indicates that textures and misc need to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21201. /**
  21202. * Disposes the material
  21203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21206. */
  21207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21208. /** @hidden */
  21209. private releaseVertexArrayObject;
  21210. /**
  21211. * Serializes this material
  21212. * @returns the serialized material object
  21213. */
  21214. serialize(): any;
  21215. /**
  21216. * Creates a material from parsed material data
  21217. * @param parsedMaterial defines parsed material data
  21218. * @param scene defines the hosting scene
  21219. * @param rootUrl defines the root URL to use to load textures
  21220. * @returns a new material
  21221. */
  21222. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21223. }
  21224. }
  21225. declare module BABYLON {
  21226. /**
  21227. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21228. * separate meshes. This can be use to improve performances.
  21229. * @see http://doc.babylonjs.com/how_to/multi_materials
  21230. */
  21231. export class MultiMaterial extends Material {
  21232. private _subMaterials;
  21233. /**
  21234. * Gets or Sets the list of Materials used within the multi material.
  21235. * They need to be ordered according to the submeshes order in the associated mesh
  21236. */
  21237. get subMaterials(): Nullable<Material>[];
  21238. set subMaterials(value: Nullable<Material>[]);
  21239. /**
  21240. * Function used to align with Node.getChildren()
  21241. * @returns the list of Materials used within the multi material
  21242. */
  21243. getChildren(): Nullable<Material>[];
  21244. /**
  21245. * Instantiates a new Multi Material
  21246. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21247. * separate meshes. This can be use to improve performances.
  21248. * @see http://doc.babylonjs.com/how_to/multi_materials
  21249. * @param name Define the name in the scene
  21250. * @param scene Define the scene the material belongs to
  21251. */
  21252. constructor(name: string, scene: Scene);
  21253. private _hookArray;
  21254. /**
  21255. * Get one of the submaterial by its index in the submaterials array
  21256. * @param index The index to look the sub material at
  21257. * @returns The Material if the index has been defined
  21258. */
  21259. getSubMaterial(index: number): Nullable<Material>;
  21260. /**
  21261. * Get the list of active textures for the whole sub materials list.
  21262. * @returns All the textures that will be used during the rendering
  21263. */
  21264. getActiveTextures(): BaseTexture[];
  21265. /**
  21266. * Gets the current class name of the material e.g. "MultiMaterial"
  21267. * Mainly use in serialization.
  21268. * @returns the class name
  21269. */
  21270. getClassName(): string;
  21271. /**
  21272. * Checks if the material is ready to render the requested sub mesh
  21273. * @param mesh Define the mesh the submesh belongs to
  21274. * @param subMesh Define the sub mesh to look readyness for
  21275. * @param useInstances Define whether or not the material is used with instances
  21276. * @returns true if ready, otherwise false
  21277. */
  21278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21279. /**
  21280. * Clones the current material and its related sub materials
  21281. * @param name Define the name of the newly cloned material
  21282. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21283. * @returns the cloned material
  21284. */
  21285. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21286. /**
  21287. * Serializes the materials into a JSON representation.
  21288. * @returns the JSON representation
  21289. */
  21290. serialize(): any;
  21291. /**
  21292. * Dispose the material and release its associated resources
  21293. * @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)
  21294. * @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)
  21295. * @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)
  21296. */
  21297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21298. /**
  21299. * Creates a MultiMaterial from parsed MultiMaterial data.
  21300. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21301. * @param scene defines the hosting scene
  21302. * @returns a new MultiMaterial
  21303. */
  21304. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21305. }
  21306. }
  21307. declare module BABYLON {
  21308. /**
  21309. * Base class for submeshes
  21310. */
  21311. export class BaseSubMesh {
  21312. /** @hidden */
  21313. _materialDefines: Nullable<MaterialDefines>;
  21314. /** @hidden */
  21315. _materialEffect: Nullable<Effect>;
  21316. /**
  21317. * Gets material defines used by the effect associated to the sub mesh
  21318. */
  21319. get materialDefines(): Nullable<MaterialDefines>;
  21320. /**
  21321. * Sets material defines used by the effect associated to the sub mesh
  21322. */
  21323. set materialDefines(defines: Nullable<MaterialDefines>);
  21324. /**
  21325. * Gets associated effect
  21326. */
  21327. get effect(): Nullable<Effect>;
  21328. /**
  21329. * Sets associated effect (effect used to render this submesh)
  21330. * @param effect defines the effect to associate with
  21331. * @param defines defines the set of defines used to compile this effect
  21332. */
  21333. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21334. }
  21335. /**
  21336. * Defines a subdivision inside a mesh
  21337. */
  21338. export class SubMesh extends BaseSubMesh implements ICullable {
  21339. /** the material index to use */
  21340. materialIndex: number;
  21341. /** vertex index start */
  21342. verticesStart: number;
  21343. /** vertices count */
  21344. verticesCount: number;
  21345. /** index start */
  21346. indexStart: number;
  21347. /** indices count */
  21348. indexCount: number;
  21349. /** @hidden */
  21350. _linesIndexCount: number;
  21351. private _mesh;
  21352. private _renderingMesh;
  21353. private _boundingInfo;
  21354. private _linesIndexBuffer;
  21355. /** @hidden */
  21356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21357. /** @hidden */
  21358. _trianglePlanes: Plane[];
  21359. /** @hidden */
  21360. _lastColliderTransformMatrix: Nullable<Matrix>;
  21361. /** @hidden */
  21362. _renderId: number;
  21363. /** @hidden */
  21364. _alphaIndex: number;
  21365. /** @hidden */
  21366. _distanceToCamera: number;
  21367. /** @hidden */
  21368. _id: number;
  21369. private _currentMaterial;
  21370. /**
  21371. * Add a new submesh to a mesh
  21372. * @param materialIndex defines the material index to use
  21373. * @param verticesStart defines vertex index start
  21374. * @param verticesCount defines vertices count
  21375. * @param indexStart defines index start
  21376. * @param indexCount defines indices count
  21377. * @param mesh defines the parent mesh
  21378. * @param renderingMesh defines an optional rendering mesh
  21379. * @param createBoundingBox defines if bounding box should be created for this submesh
  21380. * @returns the new submesh
  21381. */
  21382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21383. /**
  21384. * Creates a new submesh
  21385. * @param materialIndex defines the material index to use
  21386. * @param verticesStart defines vertex index start
  21387. * @param verticesCount defines vertices count
  21388. * @param indexStart defines index start
  21389. * @param indexCount defines indices count
  21390. * @param mesh defines the parent mesh
  21391. * @param renderingMesh defines an optional rendering mesh
  21392. * @param createBoundingBox defines if bounding box should be created for this submesh
  21393. */
  21394. constructor(
  21395. /** the material index to use */
  21396. materialIndex: number,
  21397. /** vertex index start */
  21398. verticesStart: number,
  21399. /** vertices count */
  21400. verticesCount: number,
  21401. /** index start */
  21402. indexStart: number,
  21403. /** indices count */
  21404. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21405. /**
  21406. * Returns true if this submesh covers the entire parent mesh
  21407. * @ignorenaming
  21408. */
  21409. get IsGlobal(): boolean;
  21410. /**
  21411. * Returns the submesh BoudingInfo object
  21412. * @returns current bounding info (or mesh's one if the submesh is global)
  21413. */
  21414. getBoundingInfo(): BoundingInfo;
  21415. /**
  21416. * Sets the submesh BoundingInfo
  21417. * @param boundingInfo defines the new bounding info to use
  21418. * @returns the SubMesh
  21419. */
  21420. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21421. /**
  21422. * Returns the mesh of the current submesh
  21423. * @return the parent mesh
  21424. */
  21425. getMesh(): AbstractMesh;
  21426. /**
  21427. * Returns the rendering mesh of the submesh
  21428. * @returns the rendering mesh (could be different from parent mesh)
  21429. */
  21430. getRenderingMesh(): Mesh;
  21431. /**
  21432. * Returns the submesh material
  21433. * @returns null or the current material
  21434. */
  21435. getMaterial(): Nullable<Material>;
  21436. /**
  21437. * Sets a new updated BoundingInfo object to the submesh
  21438. * @param data defines an optional position array to use to determine the bounding info
  21439. * @returns the SubMesh
  21440. */
  21441. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21442. /** @hidden */
  21443. _checkCollision(collider: Collider): boolean;
  21444. /**
  21445. * Updates the submesh BoundingInfo
  21446. * @param world defines the world matrix to use to update the bounding info
  21447. * @returns the submesh
  21448. */
  21449. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21450. /**
  21451. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21452. * @param frustumPlanes defines the frustum planes
  21453. * @returns true if the submesh is intersecting with the frustum
  21454. */
  21455. isInFrustum(frustumPlanes: Plane[]): boolean;
  21456. /**
  21457. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21458. * @param frustumPlanes defines the frustum planes
  21459. * @returns true if the submesh is inside the frustum
  21460. */
  21461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21462. /**
  21463. * Renders the submesh
  21464. * @param enableAlphaMode defines if alpha needs to be used
  21465. * @returns the submesh
  21466. */
  21467. render(enableAlphaMode: boolean): SubMesh;
  21468. /**
  21469. * @hidden
  21470. */
  21471. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21472. /**
  21473. * Checks if the submesh intersects with a ray
  21474. * @param ray defines the ray to test
  21475. * @returns true is the passed ray intersects the submesh bounding box
  21476. */
  21477. canIntersects(ray: Ray): boolean;
  21478. /**
  21479. * Intersects current submesh with a ray
  21480. * @param ray defines the ray to test
  21481. * @param positions defines mesh's positions array
  21482. * @param indices defines mesh's indices array
  21483. * @param fastCheck defines if only bounding info should be used
  21484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21485. * @returns intersection info or null if no intersection
  21486. */
  21487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21488. /** @hidden */
  21489. private _intersectLines;
  21490. /** @hidden */
  21491. private _intersectUnIndexedLines;
  21492. /** @hidden */
  21493. private _intersectTriangles;
  21494. /** @hidden */
  21495. private _intersectUnIndexedTriangles;
  21496. /** @hidden */
  21497. _rebuild(): void;
  21498. /**
  21499. * Creates a new submesh from the passed mesh
  21500. * @param newMesh defines the new hosting mesh
  21501. * @param newRenderingMesh defines an optional rendering mesh
  21502. * @returns the new submesh
  21503. */
  21504. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21505. /**
  21506. * Release associated resources
  21507. */
  21508. dispose(): void;
  21509. /**
  21510. * Gets the class name
  21511. * @returns the string "SubMesh".
  21512. */
  21513. getClassName(): string;
  21514. /**
  21515. * Creates a new submesh from indices data
  21516. * @param materialIndex the index of the main mesh material
  21517. * @param startIndex the index where to start the copy in the mesh indices array
  21518. * @param indexCount the number of indices to copy then from the startIndex
  21519. * @param mesh the main mesh to create the submesh from
  21520. * @param renderingMesh the optional rendering mesh
  21521. * @returns a new submesh
  21522. */
  21523. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21524. }
  21525. }
  21526. declare module BABYLON {
  21527. /**
  21528. * Class used to represent data loading progression
  21529. */
  21530. export class SceneLoaderFlags {
  21531. private static _ForceFullSceneLoadingForIncremental;
  21532. private static _ShowLoadingScreen;
  21533. private static _CleanBoneMatrixWeights;
  21534. private static _loggingLevel;
  21535. /**
  21536. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21537. */
  21538. static get ForceFullSceneLoadingForIncremental(): boolean;
  21539. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21540. /**
  21541. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21542. */
  21543. static get ShowLoadingScreen(): boolean;
  21544. static set ShowLoadingScreen(value: boolean);
  21545. /**
  21546. * Defines the current logging level (while loading the scene)
  21547. * @ignorenaming
  21548. */
  21549. static get loggingLevel(): number;
  21550. static set loggingLevel(value: number);
  21551. /**
  21552. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21553. */
  21554. static get CleanBoneMatrixWeights(): boolean;
  21555. static set CleanBoneMatrixWeights(value: boolean);
  21556. }
  21557. }
  21558. declare module BABYLON {
  21559. /**
  21560. * Class used to store geometry data (vertex buffers + index buffer)
  21561. */
  21562. export class Geometry implements IGetSetVerticesData {
  21563. /**
  21564. * Gets or sets the ID of the geometry
  21565. */
  21566. id: string;
  21567. /**
  21568. * Gets or sets the unique ID of the geometry
  21569. */
  21570. uniqueId: number;
  21571. /**
  21572. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21573. */
  21574. delayLoadState: number;
  21575. /**
  21576. * Gets the file containing the data to load when running in delay load state
  21577. */
  21578. delayLoadingFile: Nullable<string>;
  21579. /**
  21580. * Callback called when the geometry is updated
  21581. */
  21582. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21583. private _scene;
  21584. private _engine;
  21585. private _meshes;
  21586. private _totalVertices;
  21587. /** @hidden */
  21588. _indices: IndicesArray;
  21589. /** @hidden */
  21590. _vertexBuffers: {
  21591. [key: string]: VertexBuffer;
  21592. };
  21593. private _isDisposed;
  21594. private _extend;
  21595. private _boundingBias;
  21596. /** @hidden */
  21597. _delayInfo: Array<string>;
  21598. private _indexBuffer;
  21599. private _indexBufferIsUpdatable;
  21600. /** @hidden */
  21601. _boundingInfo: Nullable<BoundingInfo>;
  21602. /** @hidden */
  21603. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21604. /** @hidden */
  21605. _softwareSkinningFrameId: number;
  21606. private _vertexArrayObjects;
  21607. private _updatable;
  21608. /** @hidden */
  21609. _positions: Nullable<Vector3[]>;
  21610. /**
  21611. * 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
  21612. */
  21613. get boundingBias(): Vector2;
  21614. /**
  21615. * 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
  21616. */
  21617. set boundingBias(value: Vector2);
  21618. /**
  21619. * Static function used to attach a new empty geometry to a mesh
  21620. * @param mesh defines the mesh to attach the geometry to
  21621. * @returns the new Geometry
  21622. */
  21623. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21624. /**
  21625. * Creates a new geometry
  21626. * @param id defines the unique ID
  21627. * @param scene defines the hosting scene
  21628. * @param vertexData defines the VertexData used to get geometry data
  21629. * @param updatable defines if geometry must be updatable (false by default)
  21630. * @param mesh defines the mesh that will be associated with the geometry
  21631. */
  21632. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21633. /**
  21634. * Gets the current extend of the geometry
  21635. */
  21636. get extend(): {
  21637. minimum: Vector3;
  21638. maximum: Vector3;
  21639. };
  21640. /**
  21641. * Gets the hosting scene
  21642. * @returns the hosting Scene
  21643. */
  21644. getScene(): Scene;
  21645. /**
  21646. * Gets the hosting engine
  21647. * @returns the hosting Engine
  21648. */
  21649. getEngine(): Engine;
  21650. /**
  21651. * Defines if the geometry is ready to use
  21652. * @returns true if the geometry is ready to be used
  21653. */
  21654. isReady(): boolean;
  21655. /**
  21656. * Gets a value indicating that the geometry should not be serialized
  21657. */
  21658. get doNotSerialize(): boolean;
  21659. /** @hidden */
  21660. _rebuild(): void;
  21661. /**
  21662. * Affects all geometry data in one call
  21663. * @param vertexData defines the geometry data
  21664. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21665. */
  21666. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21667. /**
  21668. * Set specific vertex data
  21669. * @param kind defines the data kind (Position, normal, etc...)
  21670. * @param data defines the vertex data to use
  21671. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21672. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21673. */
  21674. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21675. /**
  21676. * Removes a specific vertex data
  21677. * @param kind defines the data kind (Position, normal, etc...)
  21678. */
  21679. removeVerticesData(kind: string): void;
  21680. /**
  21681. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21682. * @param buffer defines the vertex buffer to use
  21683. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21684. */
  21685. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21686. /**
  21687. * Update a specific vertex buffer
  21688. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21689. * It will do nothing if the buffer is not updatable
  21690. * @param kind defines the data kind (Position, normal, etc...)
  21691. * @param data defines the data to use
  21692. * @param offset defines the offset in the target buffer where to store the data
  21693. * @param useBytes set to true if the offset is in bytes
  21694. */
  21695. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21696. /**
  21697. * Update a specific vertex buffer
  21698. * This function will create a new buffer if the current one is not updatable
  21699. * @param kind defines the data kind (Position, normal, etc...)
  21700. * @param data defines the data to use
  21701. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21702. */
  21703. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21704. private _updateBoundingInfo;
  21705. /** @hidden */
  21706. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21707. /**
  21708. * Gets total number of vertices
  21709. * @returns the total number of vertices
  21710. */
  21711. getTotalVertices(): number;
  21712. /**
  21713. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21717. * @returns a float array containing vertex data
  21718. */
  21719. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21720. /**
  21721. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21722. * @param kind defines the data kind (Position, normal, etc...)
  21723. * @returns true if the vertex buffer with the specified kind is updatable
  21724. */
  21725. isVertexBufferUpdatable(kind: string): boolean;
  21726. /**
  21727. * Gets a specific vertex buffer
  21728. * @param kind defines the data kind (Position, normal, etc...)
  21729. * @returns a VertexBuffer
  21730. */
  21731. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21732. /**
  21733. * Returns all vertex buffers
  21734. * @return an object holding all vertex buffers indexed by kind
  21735. */
  21736. getVertexBuffers(): Nullable<{
  21737. [key: string]: VertexBuffer;
  21738. }>;
  21739. /**
  21740. * Gets a boolean indicating if specific vertex buffer is present
  21741. * @param kind defines the data kind (Position, normal, etc...)
  21742. * @returns true if data is present
  21743. */
  21744. isVerticesDataPresent(kind: string): boolean;
  21745. /**
  21746. * Gets a list of all attached data kinds (Position, normal, etc...)
  21747. * @returns a list of string containing all kinds
  21748. */
  21749. getVerticesDataKinds(): string[];
  21750. /**
  21751. * Update index buffer
  21752. * @param indices defines the indices to store in the index buffer
  21753. * @param offset defines the offset in the target buffer where to store the data
  21754. * @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)
  21755. */
  21756. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21757. /**
  21758. * Creates a new index buffer
  21759. * @param indices defines the indices to store in the index buffer
  21760. * @param totalVertices defines the total number of vertices (could be null)
  21761. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21762. */
  21763. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21764. /**
  21765. * Return the total number of indices
  21766. * @returns the total number of indices
  21767. */
  21768. getTotalIndices(): number;
  21769. /**
  21770. * Gets the index buffer array
  21771. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21772. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21773. * @returns the index buffer array
  21774. */
  21775. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21776. /**
  21777. * Gets the index buffer
  21778. * @return the index buffer
  21779. */
  21780. getIndexBuffer(): Nullable<DataBuffer>;
  21781. /** @hidden */
  21782. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21783. /**
  21784. * Release the associated resources for a specific mesh
  21785. * @param mesh defines the source mesh
  21786. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21787. */
  21788. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21789. /**
  21790. * Apply current geometry to a given mesh
  21791. * @param mesh defines the mesh to apply geometry to
  21792. */
  21793. applyToMesh(mesh: Mesh): void;
  21794. private _updateExtend;
  21795. private _applyToMesh;
  21796. private notifyUpdate;
  21797. /**
  21798. * Load the geometry if it was flagged as delay loaded
  21799. * @param scene defines the hosting scene
  21800. * @param onLoaded defines a callback called when the geometry is loaded
  21801. */
  21802. load(scene: Scene, onLoaded?: () => void): void;
  21803. private _queueLoad;
  21804. /**
  21805. * Invert the geometry to move from a right handed system to a left handed one.
  21806. */
  21807. toLeftHanded(): void;
  21808. /** @hidden */
  21809. _resetPointsArrayCache(): void;
  21810. /** @hidden */
  21811. _generatePointsArray(): boolean;
  21812. /**
  21813. * Gets a value indicating if the geometry is disposed
  21814. * @returns true if the geometry was disposed
  21815. */
  21816. isDisposed(): boolean;
  21817. private _disposeVertexArrayObjects;
  21818. /**
  21819. * Free all associated resources
  21820. */
  21821. dispose(): void;
  21822. /**
  21823. * Clone the current geometry into a new geometry
  21824. * @param id defines the unique ID of the new geometry
  21825. * @returns a new geometry object
  21826. */
  21827. copy(id: string): Geometry;
  21828. /**
  21829. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21830. * @return a JSON representation of the current geometry data (without the vertices data)
  21831. */
  21832. serialize(): any;
  21833. private toNumberArray;
  21834. /**
  21835. * Serialize all vertices data into a JSON oject
  21836. * @returns a JSON representation of the current geometry data
  21837. */
  21838. serializeVerticeData(): any;
  21839. /**
  21840. * Extracts a clone of a mesh geometry
  21841. * @param mesh defines the source mesh
  21842. * @param id defines the unique ID of the new geometry object
  21843. * @returns the new geometry object
  21844. */
  21845. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21846. /**
  21847. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21848. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21849. * Be aware Math.random() could cause collisions, but:
  21850. * "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"
  21851. * @returns a string containing a new GUID
  21852. */
  21853. static RandomId(): string;
  21854. /** @hidden */
  21855. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21856. private static _CleanMatricesWeights;
  21857. /**
  21858. * Create a new geometry from persisted data (Using .babylon file format)
  21859. * @param parsedVertexData defines the persisted data
  21860. * @param scene defines the hosting scene
  21861. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21862. * @returns the new geometry object
  21863. */
  21864. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21865. }
  21866. }
  21867. declare module BABYLON {
  21868. /**
  21869. * Define an interface for all classes that will get and set the data on vertices
  21870. */
  21871. export interface IGetSetVerticesData {
  21872. /**
  21873. * Gets a boolean indicating if specific vertex data is present
  21874. * @param kind defines the vertex data kind to use
  21875. * @returns true is data kind is present
  21876. */
  21877. isVerticesDataPresent(kind: string): boolean;
  21878. /**
  21879. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21880. * @param kind defines the data kind (Position, normal, etc...)
  21881. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21882. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21883. * @returns a float array containing vertex data
  21884. */
  21885. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21886. /**
  21887. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21888. * @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.
  21889. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21890. * @returns the indices array or an empty array if the mesh has no geometry
  21891. */
  21892. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21893. /**
  21894. * Set specific vertex data
  21895. * @param kind defines the data kind (Position, normal, etc...)
  21896. * @param data defines the vertex data to use
  21897. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21898. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21899. */
  21900. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21901. /**
  21902. * Update a specific associated vertex buffer
  21903. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21904. * - VertexBuffer.PositionKind
  21905. * - VertexBuffer.UVKind
  21906. * - VertexBuffer.UV2Kind
  21907. * - VertexBuffer.UV3Kind
  21908. * - VertexBuffer.UV4Kind
  21909. * - VertexBuffer.UV5Kind
  21910. * - VertexBuffer.UV6Kind
  21911. * - VertexBuffer.ColorKind
  21912. * - VertexBuffer.MatricesIndicesKind
  21913. * - VertexBuffer.MatricesIndicesExtraKind
  21914. * - VertexBuffer.MatricesWeightsKind
  21915. * - VertexBuffer.MatricesWeightsExtraKind
  21916. * @param data defines the data source
  21917. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21918. * @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)
  21919. */
  21920. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21921. /**
  21922. * Creates a new index buffer
  21923. * @param indices defines the indices to store in the index buffer
  21924. * @param totalVertices defines the total number of vertices (could be null)
  21925. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21926. */
  21927. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21928. }
  21929. /**
  21930. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21931. */
  21932. export class VertexData {
  21933. /**
  21934. * Mesh side orientation : usually the external or front surface
  21935. */
  21936. static readonly FRONTSIDE: number;
  21937. /**
  21938. * Mesh side orientation : usually the internal or back surface
  21939. */
  21940. static readonly BACKSIDE: number;
  21941. /**
  21942. * Mesh side orientation : both internal and external or front and back surfaces
  21943. */
  21944. static readonly DOUBLESIDE: number;
  21945. /**
  21946. * Mesh side orientation : by default, `FRONTSIDE`
  21947. */
  21948. static readonly DEFAULTSIDE: number;
  21949. /**
  21950. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21951. */
  21952. positions: Nullable<FloatArray>;
  21953. /**
  21954. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21955. */
  21956. normals: Nullable<FloatArray>;
  21957. /**
  21958. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21959. */
  21960. tangents: Nullable<FloatArray>;
  21961. /**
  21962. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21963. */
  21964. uvs: Nullable<FloatArray>;
  21965. /**
  21966. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21967. */
  21968. uvs2: Nullable<FloatArray>;
  21969. /**
  21970. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21971. */
  21972. uvs3: Nullable<FloatArray>;
  21973. /**
  21974. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21975. */
  21976. uvs4: Nullable<FloatArray>;
  21977. /**
  21978. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21979. */
  21980. uvs5: Nullable<FloatArray>;
  21981. /**
  21982. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21983. */
  21984. uvs6: Nullable<FloatArray>;
  21985. /**
  21986. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21987. */
  21988. colors: Nullable<FloatArray>;
  21989. /**
  21990. * 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).
  21991. */
  21992. matricesIndices: Nullable<FloatArray>;
  21993. /**
  21994. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21995. */
  21996. matricesWeights: Nullable<FloatArray>;
  21997. /**
  21998. * An array extending the number of possible indices
  21999. */
  22000. matricesIndicesExtra: Nullable<FloatArray>;
  22001. /**
  22002. * An array extending the number of possible weights when the number of indices is extended
  22003. */
  22004. matricesWeightsExtra: Nullable<FloatArray>;
  22005. /**
  22006. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22007. */
  22008. indices: Nullable<IndicesArray>;
  22009. /**
  22010. * Uses the passed data array to set the set the values for the specified kind of data
  22011. * @param data a linear array of floating numbers
  22012. * @param kind the type of data that is being set, eg positions, colors etc
  22013. */
  22014. set(data: FloatArray, kind: string): void;
  22015. /**
  22016. * Associates the vertexData to the passed Mesh.
  22017. * Sets it as updatable or not (default `false`)
  22018. * @param mesh the mesh the vertexData is applied to
  22019. * @param updatable when used and having the value true allows new data to update the vertexData
  22020. * @returns the VertexData
  22021. */
  22022. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22023. /**
  22024. * Associates the vertexData to the passed Geometry.
  22025. * Sets it as updatable or not (default `false`)
  22026. * @param geometry the geometry the vertexData is applied to
  22027. * @param updatable when used and having the value true allows new data to update the vertexData
  22028. * @returns VertexData
  22029. */
  22030. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22031. /**
  22032. * Updates the associated mesh
  22033. * @param mesh the mesh to be updated
  22034. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22035. * @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
  22036. * @returns VertexData
  22037. */
  22038. updateMesh(mesh: Mesh): VertexData;
  22039. /**
  22040. * Updates the associated geometry
  22041. * @param geometry the geometry to be updated
  22042. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22043. * @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
  22044. * @returns VertexData.
  22045. */
  22046. updateGeometry(geometry: Geometry): VertexData;
  22047. private _applyTo;
  22048. private _update;
  22049. /**
  22050. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22051. * @param matrix the transforming matrix
  22052. * @returns the VertexData
  22053. */
  22054. transform(matrix: Matrix): VertexData;
  22055. /**
  22056. * Merges the passed VertexData into the current one
  22057. * @param other the VertexData to be merged into the current one
  22058. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22059. * @returns the modified VertexData
  22060. */
  22061. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22062. private _mergeElement;
  22063. private _validate;
  22064. /**
  22065. * Serializes the VertexData
  22066. * @returns a serialized object
  22067. */
  22068. serialize(): any;
  22069. /**
  22070. * Extracts the vertexData from a mesh
  22071. * @param mesh the mesh from which to extract the VertexData
  22072. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22073. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22074. * @returns the object VertexData associated to the passed mesh
  22075. */
  22076. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22077. /**
  22078. * Extracts the vertexData from the geometry
  22079. * @param geometry the geometry from which to extract the VertexData
  22080. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22081. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22082. * @returns the object VertexData associated to the passed mesh
  22083. */
  22084. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22085. private static _ExtractFrom;
  22086. /**
  22087. * Creates the VertexData for a Ribbon
  22088. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22089. * * pathArray array of paths, each of which an array of successive Vector3
  22090. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22091. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22092. * * 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
  22093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22094. * * 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)
  22095. * * 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)
  22096. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22097. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22098. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22099. * @returns the VertexData of the ribbon
  22100. */
  22101. static CreateRibbon(options: {
  22102. pathArray: Vector3[][];
  22103. closeArray?: boolean;
  22104. closePath?: boolean;
  22105. offset?: number;
  22106. sideOrientation?: number;
  22107. frontUVs?: Vector4;
  22108. backUVs?: Vector4;
  22109. invertUV?: boolean;
  22110. uvs?: Vector2[];
  22111. colors?: Color4[];
  22112. }): VertexData;
  22113. /**
  22114. * Creates the VertexData for a box
  22115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22116. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22117. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22118. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22119. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22123. * * 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)
  22124. * * 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)
  22125. * @returns the VertexData of the box
  22126. */
  22127. static CreateBox(options: {
  22128. size?: number;
  22129. width?: number;
  22130. height?: number;
  22131. depth?: number;
  22132. faceUV?: Vector4[];
  22133. faceColors?: Color4[];
  22134. sideOrientation?: number;
  22135. frontUVs?: Vector4;
  22136. backUVs?: Vector4;
  22137. }): VertexData;
  22138. /**
  22139. * Creates the VertexData for a tiled box
  22140. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22141. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22142. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22143. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22145. * @returns the VertexData of the box
  22146. */
  22147. static CreateTiledBox(options: {
  22148. pattern?: number;
  22149. width?: number;
  22150. height?: number;
  22151. depth?: number;
  22152. tileSize?: number;
  22153. tileWidth?: number;
  22154. tileHeight?: number;
  22155. alignHorizontal?: number;
  22156. alignVertical?: number;
  22157. faceUV?: Vector4[];
  22158. faceColors?: Color4[];
  22159. sideOrientation?: number;
  22160. }): VertexData;
  22161. /**
  22162. * Creates the VertexData for a tiled plane
  22163. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22164. * * pattern a limited pattern arrangement depending on the number
  22165. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22166. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22167. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22169. * * 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)
  22170. * * 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)
  22171. * @returns the VertexData of the tiled plane
  22172. */
  22173. static CreateTiledPlane(options: {
  22174. pattern?: number;
  22175. tileSize?: number;
  22176. tileWidth?: number;
  22177. tileHeight?: number;
  22178. size?: number;
  22179. width?: number;
  22180. height?: number;
  22181. alignHorizontal?: number;
  22182. alignVertical?: number;
  22183. sideOrientation?: number;
  22184. frontUVs?: Vector4;
  22185. backUVs?: Vector4;
  22186. }): VertexData;
  22187. /**
  22188. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22190. * * segments sets the number of horizontal strips optional, default 32
  22191. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22192. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22193. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22194. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22195. * * 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
  22196. * * 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
  22197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22198. * * 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)
  22199. * * 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)
  22200. * @returns the VertexData of the ellipsoid
  22201. */
  22202. static CreateSphere(options: {
  22203. segments?: number;
  22204. diameter?: number;
  22205. diameterX?: number;
  22206. diameterY?: number;
  22207. diameterZ?: number;
  22208. arc?: number;
  22209. slice?: number;
  22210. sideOrientation?: number;
  22211. frontUVs?: Vector4;
  22212. backUVs?: Vector4;
  22213. }): VertexData;
  22214. /**
  22215. * Creates the VertexData for a cylinder, cone or prism
  22216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22217. * * height sets the height (y direction) of the cylinder, optional, default 2
  22218. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22219. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22220. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22221. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22222. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22223. * * 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
  22224. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22225. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22226. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22227. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22229. * * 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)
  22230. * * 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)
  22231. * @returns the VertexData of the cylinder, cone or prism
  22232. */
  22233. static CreateCylinder(options: {
  22234. height?: number;
  22235. diameterTop?: number;
  22236. diameterBottom?: number;
  22237. diameter?: number;
  22238. tessellation?: number;
  22239. subdivisions?: number;
  22240. arc?: number;
  22241. faceColors?: Color4[];
  22242. faceUV?: Vector4[];
  22243. hasRings?: boolean;
  22244. enclose?: boolean;
  22245. sideOrientation?: number;
  22246. frontUVs?: Vector4;
  22247. backUVs?: Vector4;
  22248. }): VertexData;
  22249. /**
  22250. * Creates the VertexData for a torus
  22251. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22252. * * diameter the diameter of the torus, optional default 1
  22253. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22254. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22255. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22256. * * 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)
  22257. * * 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)
  22258. * @returns the VertexData of the torus
  22259. */
  22260. static CreateTorus(options: {
  22261. diameter?: number;
  22262. thickness?: number;
  22263. tessellation?: number;
  22264. sideOrientation?: number;
  22265. frontUVs?: Vector4;
  22266. backUVs?: Vector4;
  22267. }): VertexData;
  22268. /**
  22269. * Creates the VertexData of the LineSystem
  22270. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22271. * - lines an array of lines, each line being an array of successive Vector3
  22272. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22273. * @returns the VertexData of the LineSystem
  22274. */
  22275. static CreateLineSystem(options: {
  22276. lines: Vector3[][];
  22277. colors?: Nullable<Color4[][]>;
  22278. }): VertexData;
  22279. /**
  22280. * Create the VertexData for a DashedLines
  22281. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22282. * - points an array successive Vector3
  22283. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22284. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22285. * - dashNb the intended total number of dashes, optional, default 200
  22286. * @returns the VertexData for the DashedLines
  22287. */
  22288. static CreateDashedLines(options: {
  22289. points: Vector3[];
  22290. dashSize?: number;
  22291. gapSize?: number;
  22292. dashNb?: number;
  22293. }): VertexData;
  22294. /**
  22295. * Creates the VertexData for a Ground
  22296. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22297. * - width the width (x direction) of the ground, optional, default 1
  22298. * - height the height (z direction) of the ground, optional, default 1
  22299. * - subdivisions the number of subdivisions per side, optional, default 1
  22300. * @returns the VertexData of the Ground
  22301. */
  22302. static CreateGround(options: {
  22303. width?: number;
  22304. height?: number;
  22305. subdivisions?: number;
  22306. subdivisionsX?: number;
  22307. subdivisionsY?: number;
  22308. }): VertexData;
  22309. /**
  22310. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22311. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22312. * * xmin the ground minimum X coordinate, optional, default -1
  22313. * * zmin the ground minimum Z coordinate, optional, default -1
  22314. * * xmax the ground maximum X coordinate, optional, default 1
  22315. * * zmax the ground maximum Z coordinate, optional, default 1
  22316. * * 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}
  22317. * * 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}
  22318. * @returns the VertexData of the TiledGround
  22319. */
  22320. static CreateTiledGround(options: {
  22321. xmin: number;
  22322. zmin: number;
  22323. xmax: number;
  22324. zmax: number;
  22325. subdivisions?: {
  22326. w: number;
  22327. h: number;
  22328. };
  22329. precision?: {
  22330. w: number;
  22331. h: number;
  22332. };
  22333. }): VertexData;
  22334. /**
  22335. * Creates the VertexData of the Ground designed from a heightmap
  22336. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22337. * * width the width (x direction) of the ground
  22338. * * height the height (z direction) of the ground
  22339. * * subdivisions the number of subdivisions per side
  22340. * * minHeight the minimum altitude on the ground, optional, default 0
  22341. * * maxHeight the maximum altitude on the ground, optional default 1
  22342. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22343. * * buffer the array holding the image color data
  22344. * * bufferWidth the width of image
  22345. * * bufferHeight the height of image
  22346. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22347. * @returns the VertexData of the Ground designed from a heightmap
  22348. */
  22349. static CreateGroundFromHeightMap(options: {
  22350. width: number;
  22351. height: number;
  22352. subdivisions: number;
  22353. minHeight: number;
  22354. maxHeight: number;
  22355. colorFilter: Color3;
  22356. buffer: Uint8Array;
  22357. bufferWidth: number;
  22358. bufferHeight: number;
  22359. alphaFilter: number;
  22360. }): VertexData;
  22361. /**
  22362. * Creates the VertexData for a Plane
  22363. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22364. * * size sets the width and height of the plane to the value of size, optional default 1
  22365. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22366. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22368. * * 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)
  22369. * * 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)
  22370. * @returns the VertexData of the box
  22371. */
  22372. static CreatePlane(options: {
  22373. size?: number;
  22374. width?: number;
  22375. height?: number;
  22376. sideOrientation?: number;
  22377. frontUVs?: Vector4;
  22378. backUVs?: Vector4;
  22379. }): VertexData;
  22380. /**
  22381. * Creates the VertexData of the Disc or regular Polygon
  22382. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22383. * * radius the radius of the disc, optional default 0.5
  22384. * * tessellation the number of polygon sides, optional, default 64
  22385. * * 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
  22386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22387. * * 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)
  22388. * * 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)
  22389. * @returns the VertexData of the box
  22390. */
  22391. static CreateDisc(options: {
  22392. radius?: number;
  22393. tessellation?: number;
  22394. arc?: number;
  22395. sideOrientation?: number;
  22396. frontUVs?: Vector4;
  22397. backUVs?: Vector4;
  22398. }): VertexData;
  22399. /**
  22400. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22401. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22402. * @param polygon a mesh built from polygonTriangulation.build()
  22403. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22404. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22405. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22406. * @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)
  22407. * @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)
  22408. * @returns the VertexData of the Polygon
  22409. */
  22410. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22411. /**
  22412. * Creates the VertexData of the IcoSphere
  22413. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22414. * * radius the radius of the IcoSphere, optional default 1
  22415. * * radiusX allows stretching in the x direction, optional, default radius
  22416. * * radiusY allows stretching in the y direction, optional, default radius
  22417. * * radiusZ allows stretching in the z direction, optional, default radius
  22418. * * flat when true creates a flat shaded mesh, optional, default true
  22419. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * * 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)
  22422. * * 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)
  22423. * @returns the VertexData of the IcoSphere
  22424. */
  22425. static CreateIcoSphere(options: {
  22426. radius?: number;
  22427. radiusX?: number;
  22428. radiusY?: number;
  22429. radiusZ?: number;
  22430. flat?: boolean;
  22431. subdivisions?: number;
  22432. sideOrientation?: number;
  22433. frontUVs?: Vector4;
  22434. backUVs?: Vector4;
  22435. }): VertexData;
  22436. /**
  22437. * Creates the VertexData for a Polyhedron
  22438. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22439. * * type provided types are:
  22440. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22441. * * 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)
  22442. * * size the size of the IcoSphere, optional default 1
  22443. * * sizeX allows stretching in the x direction, optional, default size
  22444. * * sizeY allows stretching in the y direction, optional, default size
  22445. * * sizeZ allows stretching in the z direction, optional, default size
  22446. * * 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
  22447. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22448. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22449. * * flat when true creates a flat shaded mesh, optional, default true
  22450. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22452. * * 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)
  22453. * * 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)
  22454. * @returns the VertexData of the Polyhedron
  22455. */
  22456. static CreatePolyhedron(options: {
  22457. type?: number;
  22458. size?: number;
  22459. sizeX?: number;
  22460. sizeY?: number;
  22461. sizeZ?: number;
  22462. custom?: any;
  22463. faceUV?: Vector4[];
  22464. faceColors?: Color4[];
  22465. flat?: boolean;
  22466. sideOrientation?: number;
  22467. frontUVs?: Vector4;
  22468. backUVs?: Vector4;
  22469. }): VertexData;
  22470. /**
  22471. * Creates the VertexData for a TorusKnot
  22472. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22473. * * radius the radius of the torus knot, optional, default 2
  22474. * * tube the thickness of the tube, optional, default 0.5
  22475. * * radialSegments the number of sides on each tube segments, optional, default 32
  22476. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22477. * * p the number of windings around the z axis, optional, default 2
  22478. * * q the number of windings around the x axis, optional, default 3
  22479. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22480. * * 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)
  22481. * * 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)
  22482. * @returns the VertexData of the Torus Knot
  22483. */
  22484. static CreateTorusKnot(options: {
  22485. radius?: number;
  22486. tube?: number;
  22487. radialSegments?: number;
  22488. tubularSegments?: number;
  22489. p?: number;
  22490. q?: number;
  22491. sideOrientation?: number;
  22492. frontUVs?: Vector4;
  22493. backUVs?: Vector4;
  22494. }): VertexData;
  22495. /**
  22496. * Compute normals for given positions and indices
  22497. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22498. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22499. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22500. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22501. * * facetNormals : optional array of facet normals (vector3)
  22502. * * facetPositions : optional array of facet positions (vector3)
  22503. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22504. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22505. * * bInfo : optional bounding info, required for facetPartitioning computation
  22506. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22507. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22508. * * useRightHandedSystem: optional boolean to for right handed system computation
  22509. * * depthSort : optional boolean to enable the facet depth sort computation
  22510. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22511. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22512. */
  22513. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22514. facetNormals?: any;
  22515. facetPositions?: any;
  22516. facetPartitioning?: any;
  22517. ratio?: number;
  22518. bInfo?: any;
  22519. bbSize?: Vector3;
  22520. subDiv?: any;
  22521. useRightHandedSystem?: boolean;
  22522. depthSort?: boolean;
  22523. distanceTo?: Vector3;
  22524. depthSortedFacets?: any;
  22525. }): void;
  22526. /** @hidden */
  22527. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22528. /**
  22529. * Applies VertexData created from the imported parameters to the geometry
  22530. * @param parsedVertexData the parsed data from an imported file
  22531. * @param geometry the geometry to apply the VertexData to
  22532. */
  22533. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22534. }
  22535. }
  22536. declare module BABYLON {
  22537. /**
  22538. * Defines a target to use with MorphTargetManager
  22539. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22540. */
  22541. export class MorphTarget implements IAnimatable {
  22542. /** defines the name of the target */
  22543. name: string;
  22544. /**
  22545. * Gets or sets the list of animations
  22546. */
  22547. animations: Animation[];
  22548. private _scene;
  22549. private _positions;
  22550. private _normals;
  22551. private _tangents;
  22552. private _uvs;
  22553. private _influence;
  22554. private _uniqueId;
  22555. /**
  22556. * Observable raised when the influence changes
  22557. */
  22558. onInfluenceChanged: Observable<boolean>;
  22559. /** @hidden */
  22560. _onDataLayoutChanged: Observable<void>;
  22561. /**
  22562. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22563. */
  22564. get influence(): number;
  22565. set influence(influence: number);
  22566. /**
  22567. * Gets or sets the id of the morph Target
  22568. */
  22569. id: string;
  22570. private _animationPropertiesOverride;
  22571. /**
  22572. * Gets or sets the animation properties override
  22573. */
  22574. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22575. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22576. /**
  22577. * Creates a new MorphTarget
  22578. * @param name defines the name of the target
  22579. * @param influence defines the influence to use
  22580. * @param scene defines the scene the morphtarget belongs to
  22581. */
  22582. constructor(
  22583. /** defines the name of the target */
  22584. name: string, influence?: number, scene?: Nullable<Scene>);
  22585. /**
  22586. * Gets the unique ID of this manager
  22587. */
  22588. get uniqueId(): number;
  22589. /**
  22590. * Gets a boolean defining if the target contains position data
  22591. */
  22592. get hasPositions(): boolean;
  22593. /**
  22594. * Gets a boolean defining if the target contains normal data
  22595. */
  22596. get hasNormals(): boolean;
  22597. /**
  22598. * Gets a boolean defining if the target contains tangent data
  22599. */
  22600. get hasTangents(): boolean;
  22601. /**
  22602. * Gets a boolean defining if the target contains texture coordinates data
  22603. */
  22604. get hasUVs(): boolean;
  22605. /**
  22606. * Affects position data to this target
  22607. * @param data defines the position data to use
  22608. */
  22609. setPositions(data: Nullable<FloatArray>): void;
  22610. /**
  22611. * Gets the position data stored in this target
  22612. * @returns a FloatArray containing the position data (or null if not present)
  22613. */
  22614. getPositions(): Nullable<FloatArray>;
  22615. /**
  22616. * Affects normal data to this target
  22617. * @param data defines the normal data to use
  22618. */
  22619. setNormals(data: Nullable<FloatArray>): void;
  22620. /**
  22621. * Gets the normal data stored in this target
  22622. * @returns a FloatArray containing the normal data (or null if not present)
  22623. */
  22624. getNormals(): Nullable<FloatArray>;
  22625. /**
  22626. * Affects tangent data to this target
  22627. * @param data defines the tangent data to use
  22628. */
  22629. setTangents(data: Nullable<FloatArray>): void;
  22630. /**
  22631. * Gets the tangent data stored in this target
  22632. * @returns a FloatArray containing the tangent data (or null if not present)
  22633. */
  22634. getTangents(): Nullable<FloatArray>;
  22635. /**
  22636. * Affects texture coordinates data to this target
  22637. * @param data defines the texture coordinates data to use
  22638. */
  22639. setUVs(data: Nullable<FloatArray>): void;
  22640. /**
  22641. * Gets the texture coordinates data stored in this target
  22642. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22643. */
  22644. getUVs(): Nullable<FloatArray>;
  22645. /**
  22646. * Clone the current target
  22647. * @returns a new MorphTarget
  22648. */
  22649. clone(): MorphTarget;
  22650. /**
  22651. * Serializes the current target into a Serialization object
  22652. * @returns the serialized object
  22653. */
  22654. serialize(): any;
  22655. /**
  22656. * Returns the string "MorphTarget"
  22657. * @returns "MorphTarget"
  22658. */
  22659. getClassName(): string;
  22660. /**
  22661. * Creates a new target from serialized data
  22662. * @param serializationObject defines the serialized data to use
  22663. * @returns a new MorphTarget
  22664. */
  22665. static Parse(serializationObject: any): MorphTarget;
  22666. /**
  22667. * Creates a MorphTarget from mesh data
  22668. * @param mesh defines the source mesh
  22669. * @param name defines the name to use for the new target
  22670. * @param influence defines the influence to attach to the target
  22671. * @returns a new MorphTarget
  22672. */
  22673. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22674. }
  22675. }
  22676. declare module BABYLON {
  22677. /**
  22678. * This class is used to deform meshes using morphing between different targets
  22679. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22680. */
  22681. export class MorphTargetManager {
  22682. private _targets;
  22683. private _targetInfluenceChangedObservers;
  22684. private _targetDataLayoutChangedObservers;
  22685. private _activeTargets;
  22686. private _scene;
  22687. private _influences;
  22688. private _supportsNormals;
  22689. private _supportsTangents;
  22690. private _supportsUVs;
  22691. private _vertexCount;
  22692. private _uniqueId;
  22693. private _tempInfluences;
  22694. /**
  22695. * Gets or sets a boolean indicating if normals must be morphed
  22696. */
  22697. enableNormalMorphing: boolean;
  22698. /**
  22699. * Gets or sets a boolean indicating if tangents must be morphed
  22700. */
  22701. enableTangentMorphing: boolean;
  22702. /**
  22703. * Gets or sets a boolean indicating if UV must be morphed
  22704. */
  22705. enableUVMorphing: boolean;
  22706. /**
  22707. * Creates a new MorphTargetManager
  22708. * @param scene defines the current scene
  22709. */
  22710. constructor(scene?: Nullable<Scene>);
  22711. /**
  22712. * Gets the unique ID of this manager
  22713. */
  22714. get uniqueId(): number;
  22715. /**
  22716. * Gets the number of vertices handled by this manager
  22717. */
  22718. get vertexCount(): number;
  22719. /**
  22720. * Gets a boolean indicating if this manager supports morphing of normals
  22721. */
  22722. get supportsNormals(): boolean;
  22723. /**
  22724. * Gets a boolean indicating if this manager supports morphing of tangents
  22725. */
  22726. get supportsTangents(): boolean;
  22727. /**
  22728. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22729. */
  22730. get supportsUVs(): boolean;
  22731. /**
  22732. * Gets the number of targets stored in this manager
  22733. */
  22734. get numTargets(): number;
  22735. /**
  22736. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22737. */
  22738. get numInfluencers(): number;
  22739. /**
  22740. * Gets the list of influences (one per target)
  22741. */
  22742. get influences(): Float32Array;
  22743. /**
  22744. * Gets the active target at specified index. An active target is a target with an influence > 0
  22745. * @param index defines the index to check
  22746. * @returns the requested target
  22747. */
  22748. getActiveTarget(index: number): MorphTarget;
  22749. /**
  22750. * Gets the target at specified index
  22751. * @param index defines the index to check
  22752. * @returns the requested target
  22753. */
  22754. getTarget(index: number): MorphTarget;
  22755. /**
  22756. * Add a new target to this manager
  22757. * @param target defines the target to add
  22758. */
  22759. addTarget(target: MorphTarget): void;
  22760. /**
  22761. * Removes a target from the manager
  22762. * @param target defines the target to remove
  22763. */
  22764. removeTarget(target: MorphTarget): void;
  22765. /**
  22766. * Clone the current manager
  22767. * @returns a new MorphTargetManager
  22768. */
  22769. clone(): MorphTargetManager;
  22770. /**
  22771. * Serializes the current manager into a Serialization object
  22772. * @returns the serialized object
  22773. */
  22774. serialize(): any;
  22775. private _syncActiveTargets;
  22776. /**
  22777. * Syncrhonize the targets with all the meshes using this morph target manager
  22778. */
  22779. synchronize(): void;
  22780. /**
  22781. * Creates a new MorphTargetManager from serialized data
  22782. * @param serializationObject defines the serialized data
  22783. * @param scene defines the hosting scene
  22784. * @returns the new MorphTargetManager
  22785. */
  22786. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22787. }
  22788. }
  22789. declare module BABYLON {
  22790. /**
  22791. * Class used to represent a specific level of detail of a mesh
  22792. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22793. */
  22794. export class MeshLODLevel {
  22795. /** Defines the distance where this level should start being displayed */
  22796. distance: number;
  22797. /** Defines the mesh to use to render this level */
  22798. mesh: Nullable<Mesh>;
  22799. /**
  22800. * Creates a new LOD level
  22801. * @param distance defines the distance where this level should star being displayed
  22802. * @param mesh defines the mesh to use to render this level
  22803. */
  22804. constructor(
  22805. /** Defines the distance where this level should start being displayed */
  22806. distance: number,
  22807. /** Defines the mesh to use to render this level */
  22808. mesh: Nullable<Mesh>);
  22809. }
  22810. }
  22811. declare module BABYLON {
  22812. /**
  22813. * Mesh representing the gorund
  22814. */
  22815. export class GroundMesh extends Mesh {
  22816. /** If octree should be generated */
  22817. generateOctree: boolean;
  22818. private _heightQuads;
  22819. /** @hidden */
  22820. _subdivisionsX: number;
  22821. /** @hidden */
  22822. _subdivisionsY: number;
  22823. /** @hidden */
  22824. _width: number;
  22825. /** @hidden */
  22826. _height: number;
  22827. /** @hidden */
  22828. _minX: number;
  22829. /** @hidden */
  22830. _maxX: number;
  22831. /** @hidden */
  22832. _minZ: number;
  22833. /** @hidden */
  22834. _maxZ: number;
  22835. constructor(name: string, scene: Scene);
  22836. /**
  22837. * "GroundMesh"
  22838. * @returns "GroundMesh"
  22839. */
  22840. getClassName(): string;
  22841. /**
  22842. * The minimum of x and y subdivisions
  22843. */
  22844. get subdivisions(): number;
  22845. /**
  22846. * X subdivisions
  22847. */
  22848. get subdivisionsX(): number;
  22849. /**
  22850. * Y subdivisions
  22851. */
  22852. get subdivisionsY(): number;
  22853. /**
  22854. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22855. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22856. * @param chunksCount the number of subdivisions for x and y
  22857. * @param octreeBlocksSize (Default: 32)
  22858. */
  22859. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22860. /**
  22861. * Returns a height (y) value in the Worl system :
  22862. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22863. * @param x x coordinate
  22864. * @param z z coordinate
  22865. * @returns the ground y position if (x, z) are outside the ground surface.
  22866. */
  22867. getHeightAtCoordinates(x: number, z: number): number;
  22868. /**
  22869. * Returns a normalized vector (Vector3) orthogonal to the ground
  22870. * at the ground coordinates (x, z) expressed in the World system.
  22871. * @param x x coordinate
  22872. * @param z z coordinate
  22873. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22874. */
  22875. getNormalAtCoordinates(x: number, z: number): Vector3;
  22876. /**
  22877. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22878. * at the ground coordinates (x, z) expressed in the World system.
  22879. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22880. * @param x x coordinate
  22881. * @param z z coordinate
  22882. * @param ref vector to store the result
  22883. * @returns the GroundMesh.
  22884. */
  22885. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22886. /**
  22887. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22888. * if the ground has been updated.
  22889. * This can be used in the render loop.
  22890. * @returns the GroundMesh.
  22891. */
  22892. updateCoordinateHeights(): GroundMesh;
  22893. private _getFacetAt;
  22894. private _initHeightQuads;
  22895. private _computeHeightQuads;
  22896. /**
  22897. * Serializes this ground mesh
  22898. * @param serializationObject object to write serialization to
  22899. */
  22900. serialize(serializationObject: any): void;
  22901. /**
  22902. * Parses a serialized ground mesh
  22903. * @param parsedMesh the serialized mesh
  22904. * @param scene the scene to create the ground mesh in
  22905. * @returns the created ground mesh
  22906. */
  22907. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22908. }
  22909. }
  22910. declare module BABYLON {
  22911. /**
  22912. * Interface for Physics-Joint data
  22913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22914. */
  22915. export interface PhysicsJointData {
  22916. /**
  22917. * The main pivot of the joint
  22918. */
  22919. mainPivot?: Vector3;
  22920. /**
  22921. * The connected pivot of the joint
  22922. */
  22923. connectedPivot?: Vector3;
  22924. /**
  22925. * The main axis of the joint
  22926. */
  22927. mainAxis?: Vector3;
  22928. /**
  22929. * The connected axis of the joint
  22930. */
  22931. connectedAxis?: Vector3;
  22932. /**
  22933. * The collision of the joint
  22934. */
  22935. collision?: boolean;
  22936. /**
  22937. * Native Oimo/Cannon/Energy data
  22938. */
  22939. nativeParams?: any;
  22940. }
  22941. /**
  22942. * This is a holder class for the physics joint created by the physics plugin
  22943. * It holds a set of functions to control the underlying joint
  22944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22945. */
  22946. export class PhysicsJoint {
  22947. /**
  22948. * The type of the physics joint
  22949. */
  22950. type: number;
  22951. /**
  22952. * The data for the physics joint
  22953. */
  22954. jointData: PhysicsJointData;
  22955. private _physicsJoint;
  22956. protected _physicsPlugin: IPhysicsEnginePlugin;
  22957. /**
  22958. * Initializes the physics joint
  22959. * @param type The type of the physics joint
  22960. * @param jointData The data for the physics joint
  22961. */
  22962. constructor(
  22963. /**
  22964. * The type of the physics joint
  22965. */
  22966. type: number,
  22967. /**
  22968. * The data for the physics joint
  22969. */
  22970. jointData: PhysicsJointData);
  22971. /**
  22972. * Gets the physics joint
  22973. */
  22974. get physicsJoint(): any;
  22975. /**
  22976. * Sets the physics joint
  22977. */
  22978. set physicsJoint(newJoint: any);
  22979. /**
  22980. * Sets the physics plugin
  22981. */
  22982. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22983. /**
  22984. * Execute a function that is physics-plugin specific.
  22985. * @param {Function} func the function that will be executed.
  22986. * It accepts two parameters: the physics world and the physics joint
  22987. */
  22988. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22989. /**
  22990. * Distance-Joint type
  22991. */
  22992. static DistanceJoint: number;
  22993. /**
  22994. * Hinge-Joint type
  22995. */
  22996. static HingeJoint: number;
  22997. /**
  22998. * Ball-and-Socket joint type
  22999. */
  23000. static BallAndSocketJoint: number;
  23001. /**
  23002. * Wheel-Joint type
  23003. */
  23004. static WheelJoint: number;
  23005. /**
  23006. * Slider-Joint type
  23007. */
  23008. static SliderJoint: number;
  23009. /**
  23010. * Prismatic-Joint type
  23011. */
  23012. static PrismaticJoint: number;
  23013. /**
  23014. * Universal-Joint type
  23015. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23016. */
  23017. static UniversalJoint: number;
  23018. /**
  23019. * Hinge-Joint 2 type
  23020. */
  23021. static Hinge2Joint: number;
  23022. /**
  23023. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23024. */
  23025. static PointToPointJoint: number;
  23026. /**
  23027. * Spring-Joint type
  23028. */
  23029. static SpringJoint: number;
  23030. /**
  23031. * Lock-Joint type
  23032. */
  23033. static LockJoint: number;
  23034. }
  23035. /**
  23036. * A class representing a physics distance joint
  23037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23038. */
  23039. export class DistanceJoint extends PhysicsJoint {
  23040. /**
  23041. *
  23042. * @param jointData The data for the Distance-Joint
  23043. */
  23044. constructor(jointData: DistanceJointData);
  23045. /**
  23046. * Update the predefined distance.
  23047. * @param maxDistance The maximum preferred distance
  23048. * @param minDistance The minimum preferred distance
  23049. */
  23050. updateDistance(maxDistance: number, minDistance?: number): void;
  23051. }
  23052. /**
  23053. * Represents a Motor-Enabled Joint
  23054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23055. */
  23056. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23057. /**
  23058. * Initializes the Motor-Enabled Joint
  23059. * @param type The type of the joint
  23060. * @param jointData The physica joint data for the joint
  23061. */
  23062. constructor(type: number, jointData: PhysicsJointData);
  23063. /**
  23064. * Set the motor values.
  23065. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23066. * @param force the force to apply
  23067. * @param maxForce max force for this motor.
  23068. */
  23069. setMotor(force?: number, maxForce?: number): void;
  23070. /**
  23071. * Set the motor's limits.
  23072. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23073. * @param upperLimit The upper limit of the motor
  23074. * @param lowerLimit The lower limit of the motor
  23075. */
  23076. setLimit(upperLimit: number, lowerLimit?: number): void;
  23077. }
  23078. /**
  23079. * This class represents a single physics Hinge-Joint
  23080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23081. */
  23082. export class HingeJoint extends MotorEnabledJoint {
  23083. /**
  23084. * Initializes the Hinge-Joint
  23085. * @param jointData The joint data for the Hinge-Joint
  23086. */
  23087. constructor(jointData: PhysicsJointData);
  23088. /**
  23089. * Set the motor values.
  23090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23091. * @param {number} force the force to apply
  23092. * @param {number} maxForce max force for this motor.
  23093. */
  23094. setMotor(force?: number, maxForce?: number): void;
  23095. /**
  23096. * Set the motor's limits.
  23097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23098. * @param upperLimit The upper limit of the motor
  23099. * @param lowerLimit The lower limit of the motor
  23100. */
  23101. setLimit(upperLimit: number, lowerLimit?: number): void;
  23102. }
  23103. /**
  23104. * This class represents a dual hinge physics joint (same as wheel joint)
  23105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23106. */
  23107. export class Hinge2Joint extends MotorEnabledJoint {
  23108. /**
  23109. * Initializes the Hinge2-Joint
  23110. * @param jointData The joint data for the Hinge2-Joint
  23111. */
  23112. constructor(jointData: PhysicsJointData);
  23113. /**
  23114. * Set the motor values.
  23115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23116. * @param {number} targetSpeed the speed the motor is to reach
  23117. * @param {number} maxForce max force for this motor.
  23118. * @param {motorIndex} the motor's index, 0 or 1.
  23119. */
  23120. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23121. /**
  23122. * Set the motor limits.
  23123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23124. * @param {number} upperLimit the upper limit
  23125. * @param {number} lowerLimit lower limit
  23126. * @param {motorIndex} the motor's index, 0 or 1.
  23127. */
  23128. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23129. }
  23130. /**
  23131. * Interface for a motor enabled joint
  23132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23133. */
  23134. export interface IMotorEnabledJoint {
  23135. /**
  23136. * Physics joint
  23137. */
  23138. physicsJoint: any;
  23139. /**
  23140. * Sets the motor of the motor-enabled joint
  23141. * @param force The force of the motor
  23142. * @param maxForce The maximum force of the motor
  23143. * @param motorIndex The index of the motor
  23144. */
  23145. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23146. /**
  23147. * Sets the limit of the motor
  23148. * @param upperLimit The upper limit of the motor
  23149. * @param lowerLimit The lower limit of the motor
  23150. * @param motorIndex The index of the motor
  23151. */
  23152. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23153. }
  23154. /**
  23155. * Joint data for a Distance-Joint
  23156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23157. */
  23158. export interface DistanceJointData extends PhysicsJointData {
  23159. /**
  23160. * Max distance the 2 joint objects can be apart
  23161. */
  23162. maxDistance: number;
  23163. }
  23164. /**
  23165. * Joint data from a spring joint
  23166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23167. */
  23168. export interface SpringJointData extends PhysicsJointData {
  23169. /**
  23170. * Length of the spring
  23171. */
  23172. length: number;
  23173. /**
  23174. * Stiffness of the spring
  23175. */
  23176. stiffness: number;
  23177. /**
  23178. * Damping of the spring
  23179. */
  23180. damping: number;
  23181. /** this callback will be called when applying the force to the impostors. */
  23182. forceApplicationCallback: () => void;
  23183. }
  23184. }
  23185. declare module BABYLON {
  23186. /**
  23187. * Holds the data for the raycast result
  23188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23189. */
  23190. export class PhysicsRaycastResult {
  23191. private _hasHit;
  23192. private _hitDistance;
  23193. private _hitNormalWorld;
  23194. private _hitPointWorld;
  23195. private _rayFromWorld;
  23196. private _rayToWorld;
  23197. /**
  23198. * Gets if there was a hit
  23199. */
  23200. get hasHit(): boolean;
  23201. /**
  23202. * Gets the distance from the hit
  23203. */
  23204. get hitDistance(): number;
  23205. /**
  23206. * Gets the hit normal/direction in the world
  23207. */
  23208. get hitNormalWorld(): Vector3;
  23209. /**
  23210. * Gets the hit point in the world
  23211. */
  23212. get hitPointWorld(): Vector3;
  23213. /**
  23214. * Gets the ray "start point" of the ray in the world
  23215. */
  23216. get rayFromWorld(): Vector3;
  23217. /**
  23218. * Gets the ray "end point" of the ray in the world
  23219. */
  23220. get rayToWorld(): Vector3;
  23221. /**
  23222. * Sets the hit data (normal & point in world space)
  23223. * @param hitNormalWorld defines the normal in world space
  23224. * @param hitPointWorld defines the point in world space
  23225. */
  23226. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23227. /**
  23228. * Sets the distance from the start point to the hit point
  23229. * @param distance
  23230. */
  23231. setHitDistance(distance: number): void;
  23232. /**
  23233. * Calculates the distance manually
  23234. */
  23235. calculateHitDistance(): void;
  23236. /**
  23237. * Resets all the values to default
  23238. * @param from The from point on world space
  23239. * @param to The to point on world space
  23240. */
  23241. reset(from?: Vector3, to?: Vector3): void;
  23242. }
  23243. /**
  23244. * Interface for the size containing width and height
  23245. */
  23246. interface IXYZ {
  23247. /**
  23248. * X
  23249. */
  23250. x: number;
  23251. /**
  23252. * Y
  23253. */
  23254. y: number;
  23255. /**
  23256. * Z
  23257. */
  23258. z: number;
  23259. }
  23260. }
  23261. declare module BABYLON {
  23262. /**
  23263. * Interface used to describe a physics joint
  23264. */
  23265. export interface PhysicsImpostorJoint {
  23266. /** Defines the main impostor to which the joint is linked */
  23267. mainImpostor: PhysicsImpostor;
  23268. /** Defines the impostor that is connected to the main impostor using this joint */
  23269. connectedImpostor: PhysicsImpostor;
  23270. /** Defines the joint itself */
  23271. joint: PhysicsJoint;
  23272. }
  23273. /** @hidden */
  23274. export interface IPhysicsEnginePlugin {
  23275. world: any;
  23276. name: string;
  23277. setGravity(gravity: Vector3): void;
  23278. setTimeStep(timeStep: number): void;
  23279. getTimeStep(): number;
  23280. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23281. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23282. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23283. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23284. removePhysicsBody(impostor: PhysicsImpostor): void;
  23285. generateJoint(joint: PhysicsImpostorJoint): void;
  23286. removeJoint(joint: PhysicsImpostorJoint): void;
  23287. isSupported(): boolean;
  23288. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23289. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23290. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23291. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23293. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23294. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23295. getBodyMass(impostor: PhysicsImpostor): number;
  23296. getBodyFriction(impostor: PhysicsImpostor): number;
  23297. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23298. getBodyRestitution(impostor: PhysicsImpostor): number;
  23299. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23300. getBodyPressure?(impostor: PhysicsImpostor): number;
  23301. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23302. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23303. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23304. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23305. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23306. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23307. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23308. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23309. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23310. sleepBody(impostor: PhysicsImpostor): void;
  23311. wakeUpBody(impostor: PhysicsImpostor): void;
  23312. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23313. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23314. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23315. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23316. getRadius(impostor: PhysicsImpostor): number;
  23317. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23318. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23319. dispose(): void;
  23320. }
  23321. /**
  23322. * Interface used to define a physics engine
  23323. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23324. */
  23325. export interface IPhysicsEngine {
  23326. /**
  23327. * Gets the gravity vector used by the simulation
  23328. */
  23329. gravity: Vector3;
  23330. /**
  23331. * Sets the gravity vector used by the simulation
  23332. * @param gravity defines the gravity vector to use
  23333. */
  23334. setGravity(gravity: Vector3): void;
  23335. /**
  23336. * Set the time step of the physics engine.
  23337. * Default is 1/60.
  23338. * To slow it down, enter 1/600 for example.
  23339. * To speed it up, 1/30
  23340. * @param newTimeStep the new timestep to apply to this world.
  23341. */
  23342. setTimeStep(newTimeStep: number): void;
  23343. /**
  23344. * Get the time step of the physics engine.
  23345. * @returns the current time step
  23346. */
  23347. getTimeStep(): number;
  23348. /**
  23349. * Set the sub time step of the physics engine.
  23350. * Default is 0 meaning there is no sub steps
  23351. * To increase physics resolution precision, set a small value (like 1 ms)
  23352. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23353. */
  23354. setSubTimeStep(subTimeStep: number): void;
  23355. /**
  23356. * Get the sub time step of the physics engine.
  23357. * @returns the current sub time step
  23358. */
  23359. getSubTimeStep(): number;
  23360. /**
  23361. * Release all resources
  23362. */
  23363. dispose(): void;
  23364. /**
  23365. * Gets the name of the current physics plugin
  23366. * @returns the name of the plugin
  23367. */
  23368. getPhysicsPluginName(): string;
  23369. /**
  23370. * Adding a new impostor for the impostor tracking.
  23371. * This will be done by the impostor itself.
  23372. * @param impostor the impostor to add
  23373. */
  23374. addImpostor(impostor: PhysicsImpostor): void;
  23375. /**
  23376. * Remove an impostor from the engine.
  23377. * This impostor and its mesh will not longer be updated by the physics engine.
  23378. * @param impostor the impostor to remove
  23379. */
  23380. removeImpostor(impostor: PhysicsImpostor): void;
  23381. /**
  23382. * Add a joint to the physics engine
  23383. * @param mainImpostor defines the main impostor to which the joint is added.
  23384. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23385. * @param joint defines the joint that will connect both impostors.
  23386. */
  23387. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23388. /**
  23389. * Removes a joint from the simulation
  23390. * @param mainImpostor defines the impostor used with the joint
  23391. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23392. * @param joint defines the joint to remove
  23393. */
  23394. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23395. /**
  23396. * Gets the current plugin used to run the simulation
  23397. * @returns current plugin
  23398. */
  23399. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23400. /**
  23401. * Gets the list of physic impostors
  23402. * @returns an array of PhysicsImpostor
  23403. */
  23404. getImpostors(): Array<PhysicsImpostor>;
  23405. /**
  23406. * Gets the impostor for a physics enabled object
  23407. * @param object defines the object impersonated by the impostor
  23408. * @returns the PhysicsImpostor or null if not found
  23409. */
  23410. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23411. /**
  23412. * Gets the impostor for a physics body object
  23413. * @param body defines physics body used by the impostor
  23414. * @returns the PhysicsImpostor or null if not found
  23415. */
  23416. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23417. /**
  23418. * Does a raycast in the physics world
  23419. * @param from when should the ray start?
  23420. * @param to when should the ray end?
  23421. * @returns PhysicsRaycastResult
  23422. */
  23423. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23424. /**
  23425. * Called by the scene. No need to call it.
  23426. * @param delta defines the timespam between frames
  23427. */
  23428. _step(delta: number): void;
  23429. }
  23430. }
  23431. declare module BABYLON {
  23432. /**
  23433. * The interface for the physics imposter parameters
  23434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23435. */
  23436. export interface PhysicsImpostorParameters {
  23437. /**
  23438. * The mass of the physics imposter
  23439. */
  23440. mass: number;
  23441. /**
  23442. * The friction of the physics imposter
  23443. */
  23444. friction?: number;
  23445. /**
  23446. * The coefficient of restitution of the physics imposter
  23447. */
  23448. restitution?: number;
  23449. /**
  23450. * The native options of the physics imposter
  23451. */
  23452. nativeOptions?: any;
  23453. /**
  23454. * Specifies if the parent should be ignored
  23455. */
  23456. ignoreParent?: boolean;
  23457. /**
  23458. * Specifies if bi-directional transformations should be disabled
  23459. */
  23460. disableBidirectionalTransformation?: boolean;
  23461. /**
  23462. * The pressure inside the physics imposter, soft object only
  23463. */
  23464. pressure?: number;
  23465. /**
  23466. * The stiffness the physics imposter, soft object only
  23467. */
  23468. stiffness?: number;
  23469. /**
  23470. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23471. */
  23472. velocityIterations?: number;
  23473. /**
  23474. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23475. */
  23476. positionIterations?: number;
  23477. /**
  23478. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23479. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23480. * Add to fix multiple points
  23481. */
  23482. fixedPoints?: number;
  23483. /**
  23484. * The collision margin around a soft object
  23485. */
  23486. margin?: number;
  23487. /**
  23488. * The collision margin around a soft object
  23489. */
  23490. damping?: number;
  23491. /**
  23492. * The path for a rope based on an extrusion
  23493. */
  23494. path?: any;
  23495. /**
  23496. * The shape of an extrusion used for a rope based on an extrusion
  23497. */
  23498. shape?: any;
  23499. }
  23500. /**
  23501. * Interface for a physics-enabled object
  23502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23503. */
  23504. export interface IPhysicsEnabledObject {
  23505. /**
  23506. * The position of the physics-enabled object
  23507. */
  23508. position: Vector3;
  23509. /**
  23510. * The rotation of the physics-enabled object
  23511. */
  23512. rotationQuaternion: Nullable<Quaternion>;
  23513. /**
  23514. * The scale of the physics-enabled object
  23515. */
  23516. scaling: Vector3;
  23517. /**
  23518. * The rotation of the physics-enabled object
  23519. */
  23520. rotation?: Vector3;
  23521. /**
  23522. * The parent of the physics-enabled object
  23523. */
  23524. parent?: any;
  23525. /**
  23526. * The bounding info of the physics-enabled object
  23527. * @returns The bounding info of the physics-enabled object
  23528. */
  23529. getBoundingInfo(): BoundingInfo;
  23530. /**
  23531. * Computes the world matrix
  23532. * @param force Specifies if the world matrix should be computed by force
  23533. * @returns A world matrix
  23534. */
  23535. computeWorldMatrix(force: boolean): Matrix;
  23536. /**
  23537. * Gets the world matrix
  23538. * @returns A world matrix
  23539. */
  23540. getWorldMatrix?(): Matrix;
  23541. /**
  23542. * Gets the child meshes
  23543. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23544. * @returns An array of abstract meshes
  23545. */
  23546. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23547. /**
  23548. * Gets the vertex data
  23549. * @param kind The type of vertex data
  23550. * @returns A nullable array of numbers, or a float32 array
  23551. */
  23552. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23553. /**
  23554. * Gets the indices from the mesh
  23555. * @returns A nullable array of index arrays
  23556. */
  23557. getIndices?(): Nullable<IndicesArray>;
  23558. /**
  23559. * Gets the scene from the mesh
  23560. * @returns the indices array or null
  23561. */
  23562. getScene?(): Scene;
  23563. /**
  23564. * Gets the absolute position from the mesh
  23565. * @returns the absolute position
  23566. */
  23567. getAbsolutePosition(): Vector3;
  23568. /**
  23569. * Gets the absolute pivot point from the mesh
  23570. * @returns the absolute pivot point
  23571. */
  23572. getAbsolutePivotPoint(): Vector3;
  23573. /**
  23574. * Rotates the mesh
  23575. * @param axis The axis of rotation
  23576. * @param amount The amount of rotation
  23577. * @param space The space of the rotation
  23578. * @returns The rotation transform node
  23579. */
  23580. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23581. /**
  23582. * Translates the mesh
  23583. * @param axis The axis of translation
  23584. * @param distance The distance of translation
  23585. * @param space The space of the translation
  23586. * @returns The transform node
  23587. */
  23588. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23589. /**
  23590. * Sets the absolute position of the mesh
  23591. * @param absolutePosition The absolute position of the mesh
  23592. * @returns The transform node
  23593. */
  23594. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23595. /**
  23596. * Gets the class name of the mesh
  23597. * @returns The class name
  23598. */
  23599. getClassName(): string;
  23600. }
  23601. /**
  23602. * Represents a physics imposter
  23603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23604. */
  23605. export class PhysicsImpostor {
  23606. /**
  23607. * The physics-enabled object used as the physics imposter
  23608. */
  23609. object: IPhysicsEnabledObject;
  23610. /**
  23611. * The type of the physics imposter
  23612. */
  23613. type: number;
  23614. private _options;
  23615. private _scene?;
  23616. /**
  23617. * The default object size of the imposter
  23618. */
  23619. static DEFAULT_OBJECT_SIZE: Vector3;
  23620. /**
  23621. * The identity quaternion of the imposter
  23622. */
  23623. static IDENTITY_QUATERNION: Quaternion;
  23624. /** @hidden */
  23625. _pluginData: any;
  23626. private _physicsEngine;
  23627. private _physicsBody;
  23628. private _bodyUpdateRequired;
  23629. private _onBeforePhysicsStepCallbacks;
  23630. private _onAfterPhysicsStepCallbacks;
  23631. /** @hidden */
  23632. _onPhysicsCollideCallbacks: Array<{
  23633. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23634. otherImpostors: Array<PhysicsImpostor>;
  23635. }>;
  23636. private _deltaPosition;
  23637. private _deltaRotation;
  23638. private _deltaRotationConjugated;
  23639. /** @hidden */
  23640. _isFromLine: boolean;
  23641. private _parent;
  23642. private _isDisposed;
  23643. private static _tmpVecs;
  23644. private static _tmpQuat;
  23645. /**
  23646. * Specifies if the physics imposter is disposed
  23647. */
  23648. get isDisposed(): boolean;
  23649. /**
  23650. * Gets the mass of the physics imposter
  23651. */
  23652. get mass(): number;
  23653. set mass(value: number);
  23654. /**
  23655. * Gets the coefficient of friction
  23656. */
  23657. get friction(): number;
  23658. /**
  23659. * Sets the coefficient of friction
  23660. */
  23661. set friction(value: number);
  23662. /**
  23663. * Gets the coefficient of restitution
  23664. */
  23665. get restitution(): number;
  23666. /**
  23667. * Sets the coefficient of restitution
  23668. */
  23669. set restitution(value: number);
  23670. /**
  23671. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23672. */
  23673. get pressure(): number;
  23674. /**
  23675. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23676. */
  23677. set pressure(value: number);
  23678. /**
  23679. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23680. */
  23681. get stiffness(): number;
  23682. /**
  23683. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23684. */
  23685. set stiffness(value: number);
  23686. /**
  23687. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23688. */
  23689. get velocityIterations(): number;
  23690. /**
  23691. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23692. */
  23693. set velocityIterations(value: number);
  23694. /**
  23695. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23696. */
  23697. get positionIterations(): number;
  23698. /**
  23699. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23700. */
  23701. set positionIterations(value: number);
  23702. /**
  23703. * The unique id of the physics imposter
  23704. * set by the physics engine when adding this impostor to the array
  23705. */
  23706. uniqueId: number;
  23707. /**
  23708. * @hidden
  23709. */
  23710. soft: boolean;
  23711. /**
  23712. * @hidden
  23713. */
  23714. segments: number;
  23715. private _joints;
  23716. /**
  23717. * Initializes the physics imposter
  23718. * @param object The physics-enabled object used as the physics imposter
  23719. * @param type The type of the physics imposter
  23720. * @param _options The options for the physics imposter
  23721. * @param _scene The Babylon scene
  23722. */
  23723. constructor(
  23724. /**
  23725. * The physics-enabled object used as the physics imposter
  23726. */
  23727. object: IPhysicsEnabledObject,
  23728. /**
  23729. * The type of the physics imposter
  23730. */
  23731. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23732. /**
  23733. * This function will completly initialize this impostor.
  23734. * It will create a new body - but only if this mesh has no parent.
  23735. * If it has, this impostor will not be used other than to define the impostor
  23736. * of the child mesh.
  23737. * @hidden
  23738. */
  23739. _init(): void;
  23740. private _getPhysicsParent;
  23741. /**
  23742. * Should a new body be generated.
  23743. * @returns boolean specifying if body initialization is required
  23744. */
  23745. isBodyInitRequired(): boolean;
  23746. /**
  23747. * Sets the updated scaling
  23748. * @param updated Specifies if the scaling is updated
  23749. */
  23750. setScalingUpdated(): void;
  23751. /**
  23752. * Force a regeneration of this or the parent's impostor's body.
  23753. * Use under cautious - This will remove all joints already implemented.
  23754. */
  23755. forceUpdate(): void;
  23756. /**
  23757. * Gets the body that holds this impostor. Either its own, or its parent.
  23758. */
  23759. get physicsBody(): any;
  23760. /**
  23761. * Get the parent of the physics imposter
  23762. * @returns Physics imposter or null
  23763. */
  23764. get parent(): Nullable<PhysicsImpostor>;
  23765. /**
  23766. * Sets the parent of the physics imposter
  23767. */
  23768. set parent(value: Nullable<PhysicsImpostor>);
  23769. /**
  23770. * Set the physics body. Used mainly by the physics engine/plugin
  23771. */
  23772. set physicsBody(physicsBody: any);
  23773. /**
  23774. * Resets the update flags
  23775. */
  23776. resetUpdateFlags(): void;
  23777. /**
  23778. * Gets the object extend size
  23779. * @returns the object extend size
  23780. */
  23781. getObjectExtendSize(): Vector3;
  23782. /**
  23783. * Gets the object center
  23784. * @returns The object center
  23785. */
  23786. getObjectCenter(): Vector3;
  23787. /**
  23788. * Get a specific parameter from the options parameters
  23789. * @param paramName The object parameter name
  23790. * @returns The object parameter
  23791. */
  23792. getParam(paramName: string): any;
  23793. /**
  23794. * Sets a specific parameter in the options given to the physics plugin
  23795. * @param paramName The parameter name
  23796. * @param value The value of the parameter
  23797. */
  23798. setParam(paramName: string, value: number): void;
  23799. /**
  23800. * Specifically change the body's mass option. Won't recreate the physics body object
  23801. * @param mass The mass of the physics imposter
  23802. */
  23803. setMass(mass: number): void;
  23804. /**
  23805. * Gets the linear velocity
  23806. * @returns linear velocity or null
  23807. */
  23808. getLinearVelocity(): Nullable<Vector3>;
  23809. /**
  23810. * Sets the linear velocity
  23811. * @param velocity linear velocity or null
  23812. */
  23813. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23814. /**
  23815. * Gets the angular velocity
  23816. * @returns angular velocity or null
  23817. */
  23818. getAngularVelocity(): Nullable<Vector3>;
  23819. /**
  23820. * Sets the angular velocity
  23821. * @param velocity The velocity or null
  23822. */
  23823. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23824. /**
  23825. * Execute a function with the physics plugin native code
  23826. * Provide a function the will have two variables - the world object and the physics body object
  23827. * @param func The function to execute with the physics plugin native code
  23828. */
  23829. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23830. /**
  23831. * Register a function that will be executed before the physics world is stepping forward
  23832. * @param func The function to execute before the physics world is stepped forward
  23833. */
  23834. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23835. /**
  23836. * Unregister a function that will be executed before the physics world is stepping forward
  23837. * @param func The function to execute before the physics world is stepped forward
  23838. */
  23839. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23840. /**
  23841. * Register a function that will be executed after the physics step
  23842. * @param func The function to execute after physics step
  23843. */
  23844. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23845. /**
  23846. * Unregisters a function that will be executed after the physics step
  23847. * @param func The function to execute after physics step
  23848. */
  23849. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23850. /**
  23851. * register a function that will be executed when this impostor collides against a different body
  23852. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23853. * @param func Callback that is executed on collision
  23854. */
  23855. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23856. /**
  23857. * Unregisters the physics imposter on contact
  23858. * @param collideAgainst The physics object to collide against
  23859. * @param func Callback to execute on collision
  23860. */
  23861. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23862. private _tmpQuat;
  23863. private _tmpQuat2;
  23864. /**
  23865. * Get the parent rotation
  23866. * @returns The parent rotation
  23867. */
  23868. getParentsRotation(): Quaternion;
  23869. /**
  23870. * this function is executed by the physics engine.
  23871. */
  23872. beforeStep: () => void;
  23873. /**
  23874. * this function is executed by the physics engine
  23875. */
  23876. afterStep: () => void;
  23877. /**
  23878. * Legacy collision detection event support
  23879. */
  23880. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23881. /**
  23882. * event and body object due to cannon's event-based architecture.
  23883. */
  23884. onCollide: (e: {
  23885. body: any;
  23886. }) => void;
  23887. /**
  23888. * Apply a force
  23889. * @param force The force to apply
  23890. * @param contactPoint The contact point for the force
  23891. * @returns The physics imposter
  23892. */
  23893. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23894. /**
  23895. * Apply an impulse
  23896. * @param force The impulse force
  23897. * @param contactPoint The contact point for the impulse force
  23898. * @returns The physics imposter
  23899. */
  23900. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23901. /**
  23902. * A help function to create a joint
  23903. * @param otherImpostor A physics imposter used to create a joint
  23904. * @param jointType The type of joint
  23905. * @param jointData The data for the joint
  23906. * @returns The physics imposter
  23907. */
  23908. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23909. /**
  23910. * Add a joint to this impostor with a different impostor
  23911. * @param otherImpostor A physics imposter used to add a joint
  23912. * @param joint The joint to add
  23913. * @returns The physics imposter
  23914. */
  23915. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23916. /**
  23917. * Add an anchor to a cloth impostor
  23918. * @param otherImpostor rigid impostor to anchor to
  23919. * @param width ratio across width from 0 to 1
  23920. * @param height ratio up height from 0 to 1
  23921. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23922. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23923. * @returns impostor the soft imposter
  23924. */
  23925. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23926. /**
  23927. * Add a hook to a rope impostor
  23928. * @param otherImpostor rigid impostor to anchor to
  23929. * @param length ratio across rope from 0 to 1
  23930. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23931. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23932. * @returns impostor the rope imposter
  23933. */
  23934. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23935. /**
  23936. * Will keep this body still, in a sleep mode.
  23937. * @returns the physics imposter
  23938. */
  23939. sleep(): PhysicsImpostor;
  23940. /**
  23941. * Wake the body up.
  23942. * @returns The physics imposter
  23943. */
  23944. wakeUp(): PhysicsImpostor;
  23945. /**
  23946. * Clones the physics imposter
  23947. * @param newObject The physics imposter clones to this physics-enabled object
  23948. * @returns A nullable physics imposter
  23949. */
  23950. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23951. /**
  23952. * Disposes the physics imposter
  23953. */
  23954. dispose(): void;
  23955. /**
  23956. * Sets the delta position
  23957. * @param position The delta position amount
  23958. */
  23959. setDeltaPosition(position: Vector3): void;
  23960. /**
  23961. * Sets the delta rotation
  23962. * @param rotation The delta rotation amount
  23963. */
  23964. setDeltaRotation(rotation: Quaternion): void;
  23965. /**
  23966. * Gets the box size of the physics imposter and stores the result in the input parameter
  23967. * @param result Stores the box size
  23968. * @returns The physics imposter
  23969. */
  23970. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23971. /**
  23972. * Gets the radius of the physics imposter
  23973. * @returns Radius of the physics imposter
  23974. */
  23975. getRadius(): number;
  23976. /**
  23977. * Sync a bone with this impostor
  23978. * @param bone The bone to sync to the impostor.
  23979. * @param boneMesh The mesh that the bone is influencing.
  23980. * @param jointPivot The pivot of the joint / bone in local space.
  23981. * @param distToJoint Optional distance from the impostor to the joint.
  23982. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23983. */
  23984. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23985. /**
  23986. * Sync impostor to a bone
  23987. * @param bone The bone that the impostor will be synced to.
  23988. * @param boneMesh The mesh that the bone is influencing.
  23989. * @param jointPivot The pivot of the joint / bone in local space.
  23990. * @param distToJoint Optional distance from the impostor to the joint.
  23991. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23992. * @param boneAxis Optional vector3 axis the bone is aligned with
  23993. */
  23994. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23995. /**
  23996. * No-Imposter type
  23997. */
  23998. static NoImpostor: number;
  23999. /**
  24000. * Sphere-Imposter type
  24001. */
  24002. static SphereImpostor: number;
  24003. /**
  24004. * Box-Imposter type
  24005. */
  24006. static BoxImpostor: number;
  24007. /**
  24008. * Plane-Imposter type
  24009. */
  24010. static PlaneImpostor: number;
  24011. /**
  24012. * Mesh-imposter type
  24013. */
  24014. static MeshImpostor: number;
  24015. /**
  24016. * Capsule-Impostor type (Ammo.js plugin only)
  24017. */
  24018. static CapsuleImpostor: number;
  24019. /**
  24020. * Cylinder-Imposter type
  24021. */
  24022. static CylinderImpostor: number;
  24023. /**
  24024. * Particle-Imposter type
  24025. */
  24026. static ParticleImpostor: number;
  24027. /**
  24028. * Heightmap-Imposter type
  24029. */
  24030. static HeightmapImpostor: number;
  24031. /**
  24032. * ConvexHull-Impostor type (Ammo.js plugin only)
  24033. */
  24034. static ConvexHullImpostor: number;
  24035. /**
  24036. * Custom-Imposter type (Ammo.js plugin only)
  24037. */
  24038. static CustomImpostor: number;
  24039. /**
  24040. * Rope-Imposter type
  24041. */
  24042. static RopeImpostor: number;
  24043. /**
  24044. * Cloth-Imposter type
  24045. */
  24046. static ClothImpostor: number;
  24047. /**
  24048. * Softbody-Imposter type
  24049. */
  24050. static SoftbodyImpostor: number;
  24051. }
  24052. }
  24053. declare module BABYLON {
  24054. /**
  24055. * @hidden
  24056. **/
  24057. export class _CreationDataStorage {
  24058. closePath?: boolean;
  24059. closeArray?: boolean;
  24060. idx: number[];
  24061. dashSize: number;
  24062. gapSize: number;
  24063. path3D: Path3D;
  24064. pathArray: Vector3[][];
  24065. arc: number;
  24066. radius: number;
  24067. cap: number;
  24068. tessellation: number;
  24069. }
  24070. /**
  24071. * @hidden
  24072. **/
  24073. class _InstanceDataStorage {
  24074. visibleInstances: any;
  24075. batchCache: _InstancesBatch;
  24076. instancesBufferSize: number;
  24077. instancesBuffer: Nullable<Buffer>;
  24078. instancesData: Float32Array;
  24079. overridenInstanceCount: number;
  24080. isFrozen: boolean;
  24081. previousBatch: Nullable<_InstancesBatch>;
  24082. hardwareInstancedRendering: boolean;
  24083. sideOrientation: number;
  24084. manualUpdate: boolean;
  24085. }
  24086. /**
  24087. * @hidden
  24088. **/
  24089. export class _InstancesBatch {
  24090. mustReturn: boolean;
  24091. visibleInstances: Nullable<InstancedMesh[]>[];
  24092. renderSelf: boolean[];
  24093. hardwareInstancedRendering: boolean[];
  24094. }
  24095. /**
  24096. * Class used to represent renderable models
  24097. */
  24098. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24099. /**
  24100. * Mesh side orientation : usually the external or front surface
  24101. */
  24102. static readonly FRONTSIDE: number;
  24103. /**
  24104. * Mesh side orientation : usually the internal or back surface
  24105. */
  24106. static readonly BACKSIDE: number;
  24107. /**
  24108. * Mesh side orientation : both internal and external or front and back surfaces
  24109. */
  24110. static readonly DOUBLESIDE: number;
  24111. /**
  24112. * Mesh side orientation : by default, `FRONTSIDE`
  24113. */
  24114. static readonly DEFAULTSIDE: number;
  24115. /**
  24116. * Mesh cap setting : no cap
  24117. */
  24118. static readonly NO_CAP: number;
  24119. /**
  24120. * Mesh cap setting : one cap at the beginning of the mesh
  24121. */
  24122. static readonly CAP_START: number;
  24123. /**
  24124. * Mesh cap setting : one cap at the end of the mesh
  24125. */
  24126. static readonly CAP_END: number;
  24127. /**
  24128. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24129. */
  24130. static readonly CAP_ALL: number;
  24131. /**
  24132. * Mesh pattern setting : no flip or rotate
  24133. */
  24134. static readonly NO_FLIP: number;
  24135. /**
  24136. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24137. */
  24138. static readonly FLIP_TILE: number;
  24139. /**
  24140. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24141. */
  24142. static readonly ROTATE_TILE: number;
  24143. /**
  24144. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24145. */
  24146. static readonly FLIP_ROW: number;
  24147. /**
  24148. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24149. */
  24150. static readonly ROTATE_ROW: number;
  24151. /**
  24152. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24153. */
  24154. static readonly FLIP_N_ROTATE_TILE: number;
  24155. /**
  24156. * Mesh pattern setting : rotate pattern and rotate
  24157. */
  24158. static readonly FLIP_N_ROTATE_ROW: number;
  24159. /**
  24160. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24161. */
  24162. static readonly CENTER: number;
  24163. /**
  24164. * Mesh tile positioning : part tiles on left
  24165. */
  24166. static readonly LEFT: number;
  24167. /**
  24168. * Mesh tile positioning : part tiles on right
  24169. */
  24170. static readonly RIGHT: number;
  24171. /**
  24172. * Mesh tile positioning : part tiles on top
  24173. */
  24174. static readonly TOP: number;
  24175. /**
  24176. * Mesh tile positioning : part tiles on bottom
  24177. */
  24178. static readonly BOTTOM: number;
  24179. /**
  24180. * Gets the default side orientation.
  24181. * @param orientation the orientation to value to attempt to get
  24182. * @returns the default orientation
  24183. * @hidden
  24184. */
  24185. static _GetDefaultSideOrientation(orientation?: number): number;
  24186. private _internalMeshDataInfo;
  24187. /**
  24188. * An event triggered before rendering the mesh
  24189. */
  24190. get onBeforeRenderObservable(): Observable<Mesh>;
  24191. /**
  24192. * An event triggered before binding the mesh
  24193. */
  24194. get onBeforeBindObservable(): Observable<Mesh>;
  24195. /**
  24196. * An event triggered after rendering the mesh
  24197. */
  24198. get onAfterRenderObservable(): Observable<Mesh>;
  24199. /**
  24200. * An event triggered before drawing the mesh
  24201. */
  24202. get onBeforeDrawObservable(): Observable<Mesh>;
  24203. private _onBeforeDrawObserver;
  24204. /**
  24205. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24206. */
  24207. set onBeforeDraw(callback: () => void);
  24208. get hasInstances(): boolean;
  24209. /**
  24210. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24211. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24212. */
  24213. delayLoadState: number;
  24214. /**
  24215. * Gets the list of instances created from this mesh
  24216. * it is not supposed to be modified manually.
  24217. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24218. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24219. */
  24220. instances: InstancedMesh[];
  24221. /**
  24222. * Gets the file containing delay loading data for this mesh
  24223. */
  24224. delayLoadingFile: string;
  24225. /** @hidden */
  24226. _binaryInfo: any;
  24227. /**
  24228. * User defined function used to change how LOD level selection is done
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24230. */
  24231. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24232. /**
  24233. * Gets or sets the morph target manager
  24234. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24235. */
  24236. get morphTargetManager(): Nullable<MorphTargetManager>;
  24237. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24238. /** @hidden */
  24239. _creationDataStorage: Nullable<_CreationDataStorage>;
  24240. /** @hidden */
  24241. _geometry: Nullable<Geometry>;
  24242. /** @hidden */
  24243. _delayInfo: Array<string>;
  24244. /** @hidden */
  24245. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24246. /** @hidden */
  24247. _instanceDataStorage: _InstanceDataStorage;
  24248. private _effectiveMaterial;
  24249. /** @hidden */
  24250. _shouldGenerateFlatShading: boolean;
  24251. /** @hidden */
  24252. _originalBuilderSideOrientation: number;
  24253. /**
  24254. * Use this property to change the original side orientation defined at construction time
  24255. */
  24256. overrideMaterialSideOrientation: Nullable<number>;
  24257. /**
  24258. * Gets the source mesh (the one used to clone this one from)
  24259. */
  24260. get source(): Nullable<Mesh>;
  24261. /**
  24262. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24263. */
  24264. get isUnIndexed(): boolean;
  24265. set isUnIndexed(value: boolean);
  24266. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24267. get worldMatrixInstancedBuffer(): Float32Array;
  24268. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24269. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24270. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24271. /**
  24272. * @constructor
  24273. * @param name The value used by scene.getMeshByName() to do a lookup.
  24274. * @param scene The scene to add this mesh to.
  24275. * @param parent The parent of this mesh, if it has one
  24276. * @param source An optional Mesh from which geometry is shared, cloned.
  24277. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24278. * When false, achieved by calling a clone(), also passing False.
  24279. * This will make creation of children, recursive.
  24280. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24281. */
  24282. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24283. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24284. doNotInstantiate: boolean;
  24285. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24286. /**
  24287. * Gets the class name
  24288. * @returns the string "Mesh".
  24289. */
  24290. getClassName(): string;
  24291. /** @hidden */
  24292. get _isMesh(): boolean;
  24293. /**
  24294. * Returns a description of this mesh
  24295. * @param fullDetails define if full details about this mesh must be used
  24296. * @returns a descriptive string representing this mesh
  24297. */
  24298. toString(fullDetails?: boolean): string;
  24299. /** @hidden */
  24300. _unBindEffect(): void;
  24301. /**
  24302. * Gets a boolean indicating if this mesh has LOD
  24303. */
  24304. get hasLODLevels(): boolean;
  24305. /**
  24306. * Gets the list of MeshLODLevel associated with the current mesh
  24307. * @returns an array of MeshLODLevel
  24308. */
  24309. getLODLevels(): MeshLODLevel[];
  24310. private _sortLODLevels;
  24311. /**
  24312. * Add a mesh as LOD level triggered at the given distance.
  24313. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24314. * @param distance The distance from the center of the object to show this level
  24315. * @param mesh The mesh to be added as LOD level (can be null)
  24316. * @return This mesh (for chaining)
  24317. */
  24318. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24319. /**
  24320. * Returns the LOD level mesh at the passed distance or null if not found.
  24321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24322. * @param distance The distance from the center of the object to show this level
  24323. * @returns a Mesh or `null`
  24324. */
  24325. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24326. /**
  24327. * Remove a mesh from the LOD array
  24328. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24329. * @param mesh defines the mesh to be removed
  24330. * @return This mesh (for chaining)
  24331. */
  24332. removeLODLevel(mesh: Mesh): Mesh;
  24333. /**
  24334. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24335. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24336. * @param camera defines the camera to use to compute distance
  24337. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24338. * @return This mesh (for chaining)
  24339. */
  24340. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24341. /**
  24342. * Gets the mesh internal Geometry object
  24343. */
  24344. get geometry(): Nullable<Geometry>;
  24345. /**
  24346. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24347. * @returns the total number of vertices
  24348. */
  24349. getTotalVertices(): number;
  24350. /**
  24351. * Returns the content of an associated vertex buffer
  24352. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24353. * - VertexBuffer.PositionKind
  24354. * - VertexBuffer.UVKind
  24355. * - VertexBuffer.UV2Kind
  24356. * - VertexBuffer.UV3Kind
  24357. * - VertexBuffer.UV4Kind
  24358. * - VertexBuffer.UV5Kind
  24359. * - VertexBuffer.UV6Kind
  24360. * - VertexBuffer.ColorKind
  24361. * - VertexBuffer.MatricesIndicesKind
  24362. * - VertexBuffer.MatricesIndicesExtraKind
  24363. * - VertexBuffer.MatricesWeightsKind
  24364. * - VertexBuffer.MatricesWeightsExtraKind
  24365. * @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
  24366. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24367. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24368. */
  24369. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24370. /**
  24371. * Returns the mesh VertexBuffer object from the requested `kind`
  24372. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24373. * - VertexBuffer.PositionKind
  24374. * - VertexBuffer.NormalKind
  24375. * - VertexBuffer.UVKind
  24376. * - VertexBuffer.UV2Kind
  24377. * - VertexBuffer.UV3Kind
  24378. * - VertexBuffer.UV4Kind
  24379. * - VertexBuffer.UV5Kind
  24380. * - VertexBuffer.UV6Kind
  24381. * - VertexBuffer.ColorKind
  24382. * - VertexBuffer.MatricesIndicesKind
  24383. * - VertexBuffer.MatricesIndicesExtraKind
  24384. * - VertexBuffer.MatricesWeightsKind
  24385. * - VertexBuffer.MatricesWeightsExtraKind
  24386. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24387. */
  24388. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24389. /**
  24390. * Tests if a specific vertex buffer is associated with this mesh
  24391. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24392. * - VertexBuffer.PositionKind
  24393. * - VertexBuffer.NormalKind
  24394. * - VertexBuffer.UVKind
  24395. * - VertexBuffer.UV2Kind
  24396. * - VertexBuffer.UV3Kind
  24397. * - VertexBuffer.UV4Kind
  24398. * - VertexBuffer.UV5Kind
  24399. * - VertexBuffer.UV6Kind
  24400. * - VertexBuffer.ColorKind
  24401. * - VertexBuffer.MatricesIndicesKind
  24402. * - VertexBuffer.MatricesIndicesExtraKind
  24403. * - VertexBuffer.MatricesWeightsKind
  24404. * - VertexBuffer.MatricesWeightsExtraKind
  24405. * @returns a boolean
  24406. */
  24407. isVerticesDataPresent(kind: string): boolean;
  24408. /**
  24409. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24410. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24411. * - VertexBuffer.PositionKind
  24412. * - VertexBuffer.UVKind
  24413. * - VertexBuffer.UV2Kind
  24414. * - VertexBuffer.UV3Kind
  24415. * - VertexBuffer.UV4Kind
  24416. * - VertexBuffer.UV5Kind
  24417. * - VertexBuffer.UV6Kind
  24418. * - VertexBuffer.ColorKind
  24419. * - VertexBuffer.MatricesIndicesKind
  24420. * - VertexBuffer.MatricesIndicesExtraKind
  24421. * - VertexBuffer.MatricesWeightsKind
  24422. * - VertexBuffer.MatricesWeightsExtraKind
  24423. * @returns a boolean
  24424. */
  24425. isVertexBufferUpdatable(kind: string): boolean;
  24426. /**
  24427. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24428. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24429. * - VertexBuffer.PositionKind
  24430. * - VertexBuffer.NormalKind
  24431. * - VertexBuffer.UVKind
  24432. * - VertexBuffer.UV2Kind
  24433. * - VertexBuffer.UV3Kind
  24434. * - VertexBuffer.UV4Kind
  24435. * - VertexBuffer.UV5Kind
  24436. * - VertexBuffer.UV6Kind
  24437. * - VertexBuffer.ColorKind
  24438. * - VertexBuffer.MatricesIndicesKind
  24439. * - VertexBuffer.MatricesIndicesExtraKind
  24440. * - VertexBuffer.MatricesWeightsKind
  24441. * - VertexBuffer.MatricesWeightsExtraKind
  24442. * @returns an array of strings
  24443. */
  24444. getVerticesDataKinds(): string[];
  24445. /**
  24446. * Returns a positive integer : the total number of indices in this mesh geometry.
  24447. * @returns the numner of indices or zero if the mesh has no geometry.
  24448. */
  24449. getTotalIndices(): number;
  24450. /**
  24451. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24452. * @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.
  24453. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24454. * @returns the indices array or an empty array if the mesh has no geometry
  24455. */
  24456. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24457. get isBlocked(): boolean;
  24458. /**
  24459. * Determine if the current mesh is ready to be rendered
  24460. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24461. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24462. * @returns true if all associated assets are ready (material, textures, shaders)
  24463. */
  24464. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24465. /**
  24466. * 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.
  24467. */
  24468. get areNormalsFrozen(): boolean;
  24469. /**
  24470. * 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.
  24471. * @returns the current mesh
  24472. */
  24473. freezeNormals(): Mesh;
  24474. /**
  24475. * 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
  24476. * @returns the current mesh
  24477. */
  24478. unfreezeNormals(): Mesh;
  24479. /**
  24480. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24481. */
  24482. set overridenInstanceCount(count: number);
  24483. /** @hidden */
  24484. _preActivate(): Mesh;
  24485. /** @hidden */
  24486. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24487. /** @hidden */
  24488. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24489. /**
  24490. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24491. * This means the mesh underlying bounding box and sphere are recomputed.
  24492. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24493. * @returns the current mesh
  24494. */
  24495. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24496. /** @hidden */
  24497. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24498. /**
  24499. * This function will subdivide the mesh into multiple submeshes
  24500. * @param count defines the expected number of submeshes
  24501. */
  24502. subdivide(count: number): void;
  24503. /**
  24504. * Copy a FloatArray into a specific associated vertex buffer
  24505. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24506. * - VertexBuffer.PositionKind
  24507. * - VertexBuffer.UVKind
  24508. * - VertexBuffer.UV2Kind
  24509. * - VertexBuffer.UV3Kind
  24510. * - VertexBuffer.UV4Kind
  24511. * - VertexBuffer.UV5Kind
  24512. * - VertexBuffer.UV6Kind
  24513. * - VertexBuffer.ColorKind
  24514. * - VertexBuffer.MatricesIndicesKind
  24515. * - VertexBuffer.MatricesIndicesExtraKind
  24516. * - VertexBuffer.MatricesWeightsKind
  24517. * - VertexBuffer.MatricesWeightsExtraKind
  24518. * @param data defines the data source
  24519. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24520. * @param stride defines the data stride size (can be null)
  24521. * @returns the current mesh
  24522. */
  24523. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24524. /**
  24525. * Delete a vertex buffer associated with this mesh
  24526. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24527. * - VertexBuffer.PositionKind
  24528. * - VertexBuffer.UVKind
  24529. * - VertexBuffer.UV2Kind
  24530. * - VertexBuffer.UV3Kind
  24531. * - VertexBuffer.UV4Kind
  24532. * - VertexBuffer.UV5Kind
  24533. * - VertexBuffer.UV6Kind
  24534. * - VertexBuffer.ColorKind
  24535. * - VertexBuffer.MatricesIndicesKind
  24536. * - VertexBuffer.MatricesIndicesExtraKind
  24537. * - VertexBuffer.MatricesWeightsKind
  24538. * - VertexBuffer.MatricesWeightsExtraKind
  24539. */
  24540. removeVerticesData(kind: string): void;
  24541. /**
  24542. * Flags an associated vertex buffer as updatable
  24543. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24544. * - VertexBuffer.PositionKind
  24545. * - VertexBuffer.UVKind
  24546. * - VertexBuffer.UV2Kind
  24547. * - VertexBuffer.UV3Kind
  24548. * - VertexBuffer.UV4Kind
  24549. * - VertexBuffer.UV5Kind
  24550. * - VertexBuffer.UV6Kind
  24551. * - VertexBuffer.ColorKind
  24552. * - VertexBuffer.MatricesIndicesKind
  24553. * - VertexBuffer.MatricesIndicesExtraKind
  24554. * - VertexBuffer.MatricesWeightsKind
  24555. * - VertexBuffer.MatricesWeightsExtraKind
  24556. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24557. */
  24558. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24559. /**
  24560. * Sets the mesh global Vertex Buffer
  24561. * @param buffer defines the buffer to use
  24562. * @returns the current mesh
  24563. */
  24564. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24565. /**
  24566. * Update a specific associated vertex buffer
  24567. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24568. * - VertexBuffer.PositionKind
  24569. * - VertexBuffer.UVKind
  24570. * - VertexBuffer.UV2Kind
  24571. * - VertexBuffer.UV3Kind
  24572. * - VertexBuffer.UV4Kind
  24573. * - VertexBuffer.UV5Kind
  24574. * - VertexBuffer.UV6Kind
  24575. * - VertexBuffer.ColorKind
  24576. * - VertexBuffer.MatricesIndicesKind
  24577. * - VertexBuffer.MatricesIndicesExtraKind
  24578. * - VertexBuffer.MatricesWeightsKind
  24579. * - VertexBuffer.MatricesWeightsExtraKind
  24580. * @param data defines the data source
  24581. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24582. * @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)
  24583. * @returns the current mesh
  24584. */
  24585. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24586. /**
  24587. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24588. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24589. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24590. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24591. * @returns the current mesh
  24592. */
  24593. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24594. /**
  24595. * Creates a un-shared specific occurence of the geometry for the mesh.
  24596. * @returns the current mesh
  24597. */
  24598. makeGeometryUnique(): Mesh;
  24599. /**
  24600. * Set the index buffer of this mesh
  24601. * @param indices defines the source data
  24602. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24603. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24604. * @returns the current mesh
  24605. */
  24606. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24607. /**
  24608. * Update the current index buffer
  24609. * @param indices defines the source data
  24610. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24611. * @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)
  24612. * @returns the current mesh
  24613. */
  24614. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24615. /**
  24616. * Invert the geometry to move from a right handed system to a left handed one.
  24617. * @returns the current mesh
  24618. */
  24619. toLeftHanded(): Mesh;
  24620. /** @hidden */
  24621. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24622. /** @hidden */
  24623. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24624. /**
  24625. * Registers for this mesh a javascript function called just before the rendering process
  24626. * @param func defines the function to call before rendering this mesh
  24627. * @returns the current mesh
  24628. */
  24629. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24630. /**
  24631. * Disposes a previously registered javascript function called before the rendering
  24632. * @param func defines the function to remove
  24633. * @returns the current mesh
  24634. */
  24635. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24636. /**
  24637. * Registers for this mesh a javascript function called just after the rendering is complete
  24638. * @param func defines the function to call after rendering this mesh
  24639. * @returns the current mesh
  24640. */
  24641. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24642. /**
  24643. * Disposes a previously registered javascript function called after the rendering.
  24644. * @param func defines the function to remove
  24645. * @returns the current mesh
  24646. */
  24647. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24648. /** @hidden */
  24649. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24650. /** @hidden */
  24651. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24652. /** @hidden */
  24653. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24654. /** @hidden */
  24655. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24656. /** @hidden */
  24657. _rebuild(): void;
  24658. /** @hidden */
  24659. _freeze(): void;
  24660. /** @hidden */
  24661. _unFreeze(): void;
  24662. /**
  24663. * 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
  24664. * @param subMesh defines the subMesh to render
  24665. * @param enableAlphaMode defines if alpha mode can be changed
  24666. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24667. * @returns the current mesh
  24668. */
  24669. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24670. private _onBeforeDraw;
  24671. /**
  24672. * Renormalize the mesh and patch it up if there are no weights
  24673. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24674. * However in the case of zero weights then we set just a single influence to 1.
  24675. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24676. */
  24677. cleanMatrixWeights(): void;
  24678. private normalizeSkinFourWeights;
  24679. private normalizeSkinWeightsAndExtra;
  24680. /**
  24681. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24682. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24683. * the user know there was an issue with importing the mesh
  24684. * @returns a validation object with skinned, valid and report string
  24685. */
  24686. validateSkinning(): {
  24687. skinned: boolean;
  24688. valid: boolean;
  24689. report: string;
  24690. };
  24691. /** @hidden */
  24692. _checkDelayState(): Mesh;
  24693. private _queueLoad;
  24694. /**
  24695. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24696. * A mesh is in the frustum if its bounding box intersects the frustum
  24697. * @param frustumPlanes defines the frustum to test
  24698. * @returns true if the mesh is in the frustum planes
  24699. */
  24700. isInFrustum(frustumPlanes: Plane[]): boolean;
  24701. /**
  24702. * Sets the mesh material by the material or multiMaterial `id` property
  24703. * @param id is a string identifying the material or the multiMaterial
  24704. * @returns the current mesh
  24705. */
  24706. setMaterialByID(id: string): Mesh;
  24707. /**
  24708. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24709. * @returns an array of IAnimatable
  24710. */
  24711. getAnimatables(): IAnimatable[];
  24712. /**
  24713. * Modifies the mesh geometry according to the passed transformation matrix.
  24714. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24715. * The mesh normals are modified using the same transformation.
  24716. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24717. * @param transform defines the transform matrix to use
  24718. * @see http://doc.babylonjs.com/resources/baking_transformations
  24719. * @returns the current mesh
  24720. */
  24721. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24722. /**
  24723. * Modifies the mesh geometry according to its own current World Matrix.
  24724. * The mesh World Matrix is then reset.
  24725. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24726. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24727. * @see http://doc.babylonjs.com/resources/baking_transformations
  24728. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24729. * @returns the current mesh
  24730. */
  24731. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24732. /** @hidden */
  24733. get _positions(): Nullable<Vector3[]>;
  24734. /** @hidden */
  24735. _resetPointsArrayCache(): Mesh;
  24736. /** @hidden */
  24737. _generatePointsArray(): boolean;
  24738. /**
  24739. * Returns a new Mesh object generated from the current mesh properties.
  24740. * This method must not get confused with createInstance()
  24741. * @param name is a string, the name given to the new mesh
  24742. * @param newParent can be any Node object (default `null`)
  24743. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24744. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24745. * @returns a new mesh
  24746. */
  24747. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24748. /**
  24749. * Releases resources associated with this mesh.
  24750. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24751. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24752. */
  24753. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24754. /** @hidden */
  24755. _disposeInstanceSpecificData(): void;
  24756. /**
  24757. * Modifies the mesh geometry according to a displacement map.
  24758. * 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.
  24759. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24760. * @param url is a string, the URL from the image file is to be downloaded.
  24761. * @param minHeight is the lower limit of the displacement.
  24762. * @param maxHeight is the upper limit of the displacement.
  24763. * @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.
  24764. * @param uvOffset is an optional vector2 used to offset UV.
  24765. * @param uvScale is an optional vector2 used to scale UV.
  24766. * @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.
  24767. * @returns the Mesh.
  24768. */
  24769. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24770. /**
  24771. * Modifies the mesh geometry according to a displacementMap buffer.
  24772. * 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.
  24773. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24774. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24775. * @param heightMapWidth is the width of the buffer image.
  24776. * @param heightMapHeight is the height of the buffer image.
  24777. * @param minHeight is the lower limit of the displacement.
  24778. * @param maxHeight is the upper limit of the displacement.
  24779. * @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.
  24780. * @param uvOffset is an optional vector2 used to offset UV.
  24781. * @param uvScale is an optional vector2 used to scale UV.
  24782. * @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.
  24783. * @returns the Mesh.
  24784. */
  24785. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24786. /**
  24787. * Modify the mesh to get a flat shading rendering.
  24788. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24789. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24790. * @returns current mesh
  24791. */
  24792. convertToFlatShadedMesh(): Mesh;
  24793. /**
  24794. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24795. * In other words, more vertices, no more indices and a single bigger VBO.
  24796. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24797. * @returns current mesh
  24798. */
  24799. convertToUnIndexedMesh(): Mesh;
  24800. /**
  24801. * Inverses facet orientations.
  24802. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24803. * @param flipNormals will also inverts the normals
  24804. * @returns current mesh
  24805. */
  24806. flipFaces(flipNormals?: boolean): Mesh;
  24807. /**
  24808. * Increase the number of facets and hence vertices in a mesh
  24809. * Vertex normals are interpolated from existing vertex normals
  24810. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24811. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24812. */
  24813. increaseVertices(numberPerEdge: number): void;
  24814. /**
  24815. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24816. * This will undo any application of covertToFlatShadedMesh
  24817. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24818. */
  24819. forceSharedVertices(): void;
  24820. /** @hidden */
  24821. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24822. /** @hidden */
  24823. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24824. /**
  24825. * Creates a new InstancedMesh object from the mesh model.
  24826. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24827. * @param name defines the name of the new instance
  24828. * @returns a new InstancedMesh
  24829. */
  24830. createInstance(name: string): InstancedMesh;
  24831. /**
  24832. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24833. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24834. * @returns the current mesh
  24835. */
  24836. synchronizeInstances(): Mesh;
  24837. /**
  24838. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24839. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24840. * This should be used together with the simplification to avoid disappearing triangles.
  24841. * @param successCallback an optional success callback to be called after the optimization finished.
  24842. * @returns the current mesh
  24843. */
  24844. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24845. /**
  24846. * Serialize current mesh
  24847. * @param serializationObject defines the object which will receive the serialization data
  24848. */
  24849. serialize(serializationObject: any): void;
  24850. /** @hidden */
  24851. _syncGeometryWithMorphTargetManager(): void;
  24852. /** @hidden */
  24853. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24854. /**
  24855. * Returns a new Mesh object parsed from the source provided.
  24856. * @param parsedMesh is the source
  24857. * @param scene defines the hosting scene
  24858. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24859. * @returns a new Mesh
  24860. */
  24861. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24862. /**
  24863. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24864. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24865. * @param name defines the name of the mesh to create
  24866. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24867. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24868. * @param closePath creates a seam between the first and the last points of each path of the path array
  24869. * @param offset is taken in account only if the `pathArray` is containing a single path
  24870. * @param scene defines the hosting scene
  24871. * @param updatable defines if the mesh must be flagged as updatable
  24872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24873. * @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)
  24874. * @returns a new Mesh
  24875. */
  24876. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24877. /**
  24878. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24879. * @param name defines the name of the mesh to create
  24880. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24881. * @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
  24882. * @param scene defines the hosting scene
  24883. * @param updatable defines if the mesh must be flagged as updatable
  24884. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24885. * @returns a new Mesh
  24886. */
  24887. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24888. /**
  24889. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24890. * @param name defines the name of the mesh to create
  24891. * @param size sets the size (float) of each box side (default 1)
  24892. * @param scene defines the hosting scene
  24893. * @param updatable defines if the mesh must be flagged as updatable
  24894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24895. * @returns a new Mesh
  24896. */
  24897. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24898. /**
  24899. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24900. * @param name defines the name of the mesh to create
  24901. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24902. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24903. * @param scene defines the hosting scene
  24904. * @param updatable defines if the mesh must be flagged as updatable
  24905. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24906. * @returns a new Mesh
  24907. */
  24908. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24909. /**
  24910. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24911. * @param name defines the name of the mesh to create
  24912. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24913. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24914. * @param scene defines the hosting scene
  24915. * @returns a new Mesh
  24916. */
  24917. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24918. /**
  24919. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24920. * @param name defines the name of the mesh to create
  24921. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24922. * @param diameterTop set the top cap diameter (floats, default 1)
  24923. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24924. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24925. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24932. /**
  24933. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param diameter sets the diameter size (float) of the torus (default 1)
  24936. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24937. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24938. * @param scene defines the hosting scene
  24939. * @param updatable defines if the mesh must be flagged as updatable
  24940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24941. * @returns a new Mesh
  24942. */
  24943. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24944. /**
  24945. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24946. * @param name defines the name of the mesh to create
  24947. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24948. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24949. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24950. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24951. * @param p the number of windings on X axis (positive integers, default 2)
  24952. * @param q the number of windings on Y axis (positive integers, default 3)
  24953. * @param scene defines the hosting scene
  24954. * @param updatable defines if the mesh must be flagged as updatable
  24955. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24956. * @returns a new Mesh
  24957. */
  24958. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24959. /**
  24960. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24961. * @param name defines the name of the mesh to create
  24962. * @param points is an array successive Vector3
  24963. * @param scene defines the hosting scene
  24964. * @param updatable defines if the mesh must be flagged as updatable
  24965. * @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).
  24966. * @returns a new Mesh
  24967. */
  24968. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24969. /**
  24970. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24971. * @param name defines the name of the mesh to create
  24972. * @param points is an array successive Vector3
  24973. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24974. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24975. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24976. * @param scene defines the hosting scene
  24977. * @param updatable defines if the mesh must be flagged as updatable
  24978. * @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)
  24979. * @returns a new Mesh
  24980. */
  24981. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24982. /**
  24983. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24984. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24985. * 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.
  24986. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24987. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24988. * Remember you can only change the shape positions, not their number when updating a polygon.
  24989. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24990. * @param name defines the name of the mesh to create
  24991. * @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
  24992. * @param scene defines the hosting scene
  24993. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24994. * @param updatable defines if the mesh must be flagged as updatable
  24995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24996. * @param earcutInjection can be used to inject your own earcut reference
  24997. * @returns a new Mesh
  24998. */
  24999. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25000. /**
  25001. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25002. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25003. * @param name defines the name of the mesh to create
  25004. * @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
  25005. * @param depth defines the height of extrusion
  25006. * @param scene defines the hosting scene
  25007. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25010. * @param earcutInjection can be used to inject your own earcut reference
  25011. * @returns a new Mesh
  25012. */
  25013. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25014. /**
  25015. * Creates an extruded shape mesh.
  25016. * 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
  25017. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25018. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25019. * @param name defines the name of the mesh to create
  25020. * @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
  25021. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25022. * @param scale is the value to scale the shape
  25023. * @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
  25024. * @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
  25025. * @param scene defines the hosting scene
  25026. * @param updatable defines if the mesh must be flagged as updatable
  25027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25028. * @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)
  25029. * @returns a new Mesh
  25030. */
  25031. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25032. /**
  25033. * Creates an custom extruded shape mesh.
  25034. * The custom extrusion is a parametric shape.
  25035. * It has no predefined shape. Its final shape will depend on the input parameters.
  25036. * Please consider using the same method from the MeshBuilder class instead
  25037. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25038. * @param name defines the name of the mesh to create
  25039. * @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
  25040. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25041. * @param scaleFunction is a custom Javascript function called on each path point
  25042. * @param rotationFunction is a custom Javascript function called on each path point
  25043. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25044. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25045. * @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
  25046. * @param scene defines the hosting scene
  25047. * @param updatable defines if the mesh must be flagged as updatable
  25048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25049. * @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)
  25050. * @returns a new Mesh
  25051. */
  25052. 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;
  25053. /**
  25054. * Creates lathe mesh.
  25055. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25056. * Please consider using the same method from the MeshBuilder class instead
  25057. * @param name defines the name of the mesh to create
  25058. * @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
  25059. * @param radius is the radius value of the lathe
  25060. * @param tessellation is the side number of the lathe.
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25067. /**
  25068. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25069. * @param name defines the name of the mesh to create
  25070. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25071. * @param scene defines the hosting scene
  25072. * @param updatable defines if the mesh must be flagged as updatable
  25073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25074. * @returns a new Mesh
  25075. */
  25076. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25077. /**
  25078. * Creates a ground mesh.
  25079. * Please consider using the same method from the MeshBuilder class instead
  25080. * @param name defines the name of the mesh to create
  25081. * @param width set the width of the ground
  25082. * @param height set the height of the ground
  25083. * @param subdivisions sets the number of subdivisions per side
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @returns a new Mesh
  25087. */
  25088. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25089. /**
  25090. * Creates a tiled ground mesh.
  25091. * Please consider using the same method from the MeshBuilder class instead
  25092. * @param name defines the name of the mesh to create
  25093. * @param xmin set the ground minimum X coordinate
  25094. * @param zmin set the ground minimum Y coordinate
  25095. * @param xmax set the ground maximum X coordinate
  25096. * @param zmax set the ground maximum Z coordinate
  25097. * @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
  25098. * @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
  25099. * @param scene defines the hosting scene
  25100. * @param updatable defines if the mesh must be flagged as updatable
  25101. * @returns a new Mesh
  25102. */
  25103. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25104. w: number;
  25105. h: number;
  25106. }, precision: {
  25107. w: number;
  25108. h: number;
  25109. }, scene: Scene, updatable?: boolean): Mesh;
  25110. /**
  25111. * Creates a ground mesh from a height map.
  25112. * Please consider using the same method from the MeshBuilder class instead
  25113. * @see http://doc.babylonjs.com/babylon101/height_map
  25114. * @param name defines the name of the mesh to create
  25115. * @param url sets the URL of the height map image resource
  25116. * @param width set the ground width size
  25117. * @param height set the ground height size
  25118. * @param subdivisions sets the number of subdivision per side
  25119. * @param minHeight is the minimum altitude on the ground
  25120. * @param maxHeight is the maximum altitude on the ground
  25121. * @param scene defines the hosting scene
  25122. * @param updatable defines if the mesh must be flagged as updatable
  25123. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25124. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25125. * @returns a new Mesh
  25126. */
  25127. 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;
  25128. /**
  25129. * Creates a tube mesh.
  25130. * The tube is a parametric shape.
  25131. * It has no predefined shape. Its final shape will depend on the input parameters.
  25132. * Please consider using the same method from the MeshBuilder class instead
  25133. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25134. * @param name defines the name of the mesh to create
  25135. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25136. * @param radius sets the tube radius size
  25137. * @param tessellation is the number of sides on the tubular surface
  25138. * @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
  25139. * @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
  25140. * @param scene defines the hosting scene
  25141. * @param updatable defines if the mesh must be flagged as updatable
  25142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25143. * @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)
  25144. * @returns a new Mesh
  25145. */
  25146. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25147. (i: number, distance: number): number;
  25148. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25149. /**
  25150. * Creates a polyhedron mesh.
  25151. * Please consider using the same method from the MeshBuilder class instead.
  25152. * * 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
  25153. * * The parameter `size` (positive float, default 1) sets the polygon size
  25154. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25155. * * 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`
  25156. * * 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
  25157. * * 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)`)
  25158. * * 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
  25159. * * 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
  25160. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25161. * * 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
  25162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25163. * @param name defines the name of the mesh to create
  25164. * @param options defines the options used to create the mesh
  25165. * @param scene defines the hosting scene
  25166. * @returns a new Mesh
  25167. */
  25168. static CreatePolyhedron(name: string, options: {
  25169. type?: number;
  25170. size?: number;
  25171. sizeX?: number;
  25172. sizeY?: number;
  25173. sizeZ?: number;
  25174. custom?: any;
  25175. faceUV?: Vector4[];
  25176. faceColors?: Color4[];
  25177. updatable?: boolean;
  25178. sideOrientation?: number;
  25179. }, scene: Scene): Mesh;
  25180. /**
  25181. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25182. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25183. * * 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`)
  25184. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25185. * * 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
  25186. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25187. * * 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
  25188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25189. * @param name defines the name of the mesh
  25190. * @param options defines the options used to create the mesh
  25191. * @param scene defines the hosting scene
  25192. * @returns a new Mesh
  25193. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25194. */
  25195. static CreateIcoSphere(name: string, options: {
  25196. radius?: number;
  25197. flat?: boolean;
  25198. subdivisions?: number;
  25199. sideOrientation?: number;
  25200. updatable?: boolean;
  25201. }, scene: Scene): Mesh;
  25202. /**
  25203. * Creates a decal mesh.
  25204. * Please consider using the same method from the MeshBuilder class instead.
  25205. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25206. * @param name defines the name of the mesh
  25207. * @param sourceMesh defines the mesh receiving the decal
  25208. * @param position sets the position of the decal in world coordinates
  25209. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25210. * @param size sets the decal scaling
  25211. * @param angle sets the angle to rotate the decal
  25212. * @returns a new Mesh
  25213. */
  25214. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25215. /**
  25216. * Prepare internal position array for software CPU skinning
  25217. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25218. */
  25219. setPositionsForCPUSkinning(): Float32Array;
  25220. /**
  25221. * Prepare internal normal array for software CPU skinning
  25222. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25223. */
  25224. setNormalsForCPUSkinning(): Float32Array;
  25225. /**
  25226. * Updates the vertex buffer by applying transformation from the bones
  25227. * @param skeleton defines the skeleton to apply to current mesh
  25228. * @returns the current mesh
  25229. */
  25230. applySkeleton(skeleton: Skeleton): Mesh;
  25231. /**
  25232. * 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
  25233. * @param meshes defines the list of meshes to scan
  25234. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25235. */
  25236. static MinMax(meshes: AbstractMesh[]): {
  25237. min: Vector3;
  25238. max: Vector3;
  25239. };
  25240. /**
  25241. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25242. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25243. * @returns a vector3
  25244. */
  25245. static Center(meshesOrMinMaxVector: {
  25246. min: Vector3;
  25247. max: Vector3;
  25248. } | AbstractMesh[]): Vector3;
  25249. /**
  25250. * Merge the array of meshes into a single mesh for performance reasons.
  25251. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25252. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25253. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25254. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25255. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25256. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25257. * @returns a new mesh
  25258. */
  25259. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25260. /** @hidden */
  25261. addInstance(instance: InstancedMesh): void;
  25262. /** @hidden */
  25263. removeInstance(instance: InstancedMesh): void;
  25264. }
  25265. }
  25266. declare module BABYLON {
  25267. /**
  25268. * This is the base class of all the camera used in the application.
  25269. * @see http://doc.babylonjs.com/features/cameras
  25270. */
  25271. export class Camera extends Node {
  25272. /** @hidden */
  25273. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25274. /**
  25275. * This is the default projection mode used by the cameras.
  25276. * It helps recreating a feeling of perspective and better appreciate depth.
  25277. * This is the best way to simulate real life cameras.
  25278. */
  25279. static readonly PERSPECTIVE_CAMERA: number;
  25280. /**
  25281. * This helps creating camera with an orthographic mode.
  25282. * 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.
  25283. */
  25284. static readonly ORTHOGRAPHIC_CAMERA: number;
  25285. /**
  25286. * This is the default FOV mode for perspective cameras.
  25287. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25288. */
  25289. static readonly FOVMODE_VERTICAL_FIXED: number;
  25290. /**
  25291. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25292. */
  25293. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25294. /**
  25295. * This specifies ther is no need for a camera rig.
  25296. * Basically only one eye is rendered corresponding to the camera.
  25297. */
  25298. static readonly RIG_MODE_NONE: number;
  25299. /**
  25300. * Simulates a camera Rig with one blue eye and one red eye.
  25301. * This can be use with 3d blue and red glasses.
  25302. */
  25303. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25304. /**
  25305. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25306. */
  25307. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25308. /**
  25309. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25310. */
  25311. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25312. /**
  25313. * Defines that both eyes of the camera will be rendered over under each other.
  25314. */
  25315. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25316. /**
  25317. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25318. */
  25319. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25320. /**
  25321. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25322. */
  25323. static readonly RIG_MODE_VR: number;
  25324. /**
  25325. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25326. */
  25327. static readonly RIG_MODE_WEBVR: number;
  25328. /**
  25329. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25330. */
  25331. static readonly RIG_MODE_CUSTOM: number;
  25332. /**
  25333. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25334. */
  25335. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25336. /**
  25337. * Define the input manager associated with the camera.
  25338. */
  25339. inputs: CameraInputsManager<Camera>;
  25340. /** @hidden */
  25341. _position: Vector3;
  25342. /**
  25343. * Define the current local position of the camera in the scene
  25344. */
  25345. get position(): Vector3;
  25346. set position(newPosition: Vector3);
  25347. /**
  25348. * The vector the camera should consider as up.
  25349. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25350. */
  25351. upVector: Vector3;
  25352. /**
  25353. * Define the current limit on the left side for an orthographic camera
  25354. * In scene unit
  25355. */
  25356. orthoLeft: Nullable<number>;
  25357. /**
  25358. * Define the current limit on the right side for an orthographic camera
  25359. * In scene unit
  25360. */
  25361. orthoRight: Nullable<number>;
  25362. /**
  25363. * Define the current limit on the bottom side for an orthographic camera
  25364. * In scene unit
  25365. */
  25366. orthoBottom: Nullable<number>;
  25367. /**
  25368. * Define the current limit on the top side for an orthographic camera
  25369. * In scene unit
  25370. */
  25371. orthoTop: Nullable<number>;
  25372. /**
  25373. * Field Of View is set in Radians. (default is 0.8)
  25374. */
  25375. fov: number;
  25376. /**
  25377. * Define the minimum distance the camera can see from.
  25378. * This is important to note that the depth buffer are not infinite and the closer it starts
  25379. * the more your scene might encounter depth fighting issue.
  25380. */
  25381. minZ: number;
  25382. /**
  25383. * Define the maximum distance the camera can see to.
  25384. * This is important to note that the depth buffer are not infinite and the further it end
  25385. * the more your scene might encounter depth fighting issue.
  25386. */
  25387. maxZ: number;
  25388. /**
  25389. * Define the default inertia of the camera.
  25390. * This helps giving a smooth feeling to the camera movement.
  25391. */
  25392. inertia: number;
  25393. /**
  25394. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25395. */
  25396. mode: number;
  25397. /**
  25398. * Define wether the camera is intermediate.
  25399. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25400. */
  25401. isIntermediate: boolean;
  25402. /**
  25403. * Define the viewport of the camera.
  25404. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25405. */
  25406. viewport: Viewport;
  25407. /**
  25408. * Restricts the camera to viewing objects with the same layerMask.
  25409. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25410. */
  25411. layerMask: number;
  25412. /**
  25413. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25414. */
  25415. fovMode: number;
  25416. /**
  25417. * Rig mode of the camera.
  25418. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25419. * This is normally controlled byt the camera themselves as internal use.
  25420. */
  25421. cameraRigMode: number;
  25422. /**
  25423. * Defines the distance between both "eyes" in case of a RIG
  25424. */
  25425. interaxialDistance: number;
  25426. /**
  25427. * Defines if stereoscopic rendering is done side by side or over under.
  25428. */
  25429. isStereoscopicSideBySide: boolean;
  25430. /**
  25431. * 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
  25432. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25433. * else in the scene. (Eg. security camera)
  25434. *
  25435. * 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)
  25436. */
  25437. customRenderTargets: RenderTargetTexture[];
  25438. /**
  25439. * When set, the camera will render to this render target instead of the default canvas
  25440. *
  25441. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25442. */
  25443. outputRenderTarget: Nullable<RenderTargetTexture>;
  25444. /**
  25445. * Observable triggered when the camera view matrix has changed.
  25446. */
  25447. onViewMatrixChangedObservable: Observable<Camera>;
  25448. /**
  25449. * Observable triggered when the camera Projection matrix has changed.
  25450. */
  25451. onProjectionMatrixChangedObservable: Observable<Camera>;
  25452. /**
  25453. * Observable triggered when the inputs have been processed.
  25454. */
  25455. onAfterCheckInputsObservable: Observable<Camera>;
  25456. /**
  25457. * Observable triggered when reset has been called and applied to the camera.
  25458. */
  25459. onRestoreStateObservable: Observable<Camera>;
  25460. /**
  25461. * Is this camera a part of a rig system?
  25462. */
  25463. isRigCamera: boolean;
  25464. /**
  25465. * If isRigCamera set to true this will be set with the parent camera.
  25466. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25467. */
  25468. rigParent?: Camera;
  25469. /** @hidden */
  25470. _cameraRigParams: any;
  25471. /** @hidden */
  25472. _rigCameras: Camera[];
  25473. /** @hidden */
  25474. _rigPostProcess: Nullable<PostProcess>;
  25475. protected _webvrViewMatrix: Matrix;
  25476. /** @hidden */
  25477. _skipRendering: boolean;
  25478. /** @hidden */
  25479. _projectionMatrix: Matrix;
  25480. /** @hidden */
  25481. _postProcesses: Nullable<PostProcess>[];
  25482. /** @hidden */
  25483. _activeMeshes: SmartArray<AbstractMesh>;
  25484. protected _globalPosition: Vector3;
  25485. /** @hidden */
  25486. _computedViewMatrix: Matrix;
  25487. private _doNotComputeProjectionMatrix;
  25488. private _transformMatrix;
  25489. private _frustumPlanes;
  25490. private _refreshFrustumPlanes;
  25491. private _storedFov;
  25492. private _stateStored;
  25493. /**
  25494. * Instantiates a new camera object.
  25495. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25496. * @see http://doc.babylonjs.com/features/cameras
  25497. * @param name Defines the name of the camera in the scene
  25498. * @param position Defines the position of the camera
  25499. * @param scene Defines the scene the camera belongs too
  25500. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25501. */
  25502. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25503. /**
  25504. * Store current camera state (fov, position, etc..)
  25505. * @returns the camera
  25506. */
  25507. storeState(): Camera;
  25508. /**
  25509. * Restores the camera state values if it has been stored. You must call storeState() first
  25510. */
  25511. protected _restoreStateValues(): boolean;
  25512. /**
  25513. * Restored camera state. You must call storeState() first.
  25514. * @returns true if restored and false otherwise
  25515. */
  25516. restoreState(): boolean;
  25517. /**
  25518. * Gets the class name of the camera.
  25519. * @returns the class name
  25520. */
  25521. getClassName(): string;
  25522. /** @hidden */
  25523. readonly _isCamera: boolean;
  25524. /**
  25525. * Gets a string representation of the camera useful for debug purpose.
  25526. * @param fullDetails Defines that a more verboe level of logging is required
  25527. * @returns the string representation
  25528. */
  25529. toString(fullDetails?: boolean): string;
  25530. /**
  25531. * Gets the current world space position of the camera.
  25532. */
  25533. get globalPosition(): Vector3;
  25534. /**
  25535. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25536. * @returns the active meshe list
  25537. */
  25538. getActiveMeshes(): SmartArray<AbstractMesh>;
  25539. /**
  25540. * Check wether a mesh is part of the current active mesh list of the camera
  25541. * @param mesh Defines the mesh to check
  25542. * @returns true if active, false otherwise
  25543. */
  25544. isActiveMesh(mesh: Mesh): boolean;
  25545. /**
  25546. * Is this camera ready to be used/rendered
  25547. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25548. * @return true if the camera is ready
  25549. */
  25550. isReady(completeCheck?: boolean): boolean;
  25551. /** @hidden */
  25552. _initCache(): void;
  25553. /** @hidden */
  25554. _updateCache(ignoreParentClass?: boolean): void;
  25555. /** @hidden */
  25556. _isSynchronized(): boolean;
  25557. /** @hidden */
  25558. _isSynchronizedViewMatrix(): boolean;
  25559. /** @hidden */
  25560. _isSynchronizedProjectionMatrix(): boolean;
  25561. /**
  25562. * Attach the input controls to a specific dom element to get the input from.
  25563. * @param element Defines the element the controls should be listened from
  25564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25565. */
  25566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25567. /**
  25568. * Detach the current controls from the specified dom element.
  25569. * @param element Defines the element to stop listening the inputs from
  25570. */
  25571. detachControl(element: HTMLElement): void;
  25572. /**
  25573. * Update the camera state according to the different inputs gathered during the frame.
  25574. */
  25575. update(): void;
  25576. /** @hidden */
  25577. _checkInputs(): void;
  25578. /** @hidden */
  25579. get rigCameras(): Camera[];
  25580. /**
  25581. * Gets the post process used by the rig cameras
  25582. */
  25583. get rigPostProcess(): Nullable<PostProcess>;
  25584. /**
  25585. * Internal, gets the first post proces.
  25586. * @returns the first post process to be run on this camera.
  25587. */
  25588. _getFirstPostProcess(): Nullable<PostProcess>;
  25589. private _cascadePostProcessesToRigCams;
  25590. /**
  25591. * Attach a post process to the camera.
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25593. * @param postProcess The post process to attach to the camera
  25594. * @param insertAt The position of the post process in case several of them are in use in the scene
  25595. * @returns the position the post process has been inserted at
  25596. */
  25597. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25598. /**
  25599. * Detach a post process to the camera.
  25600. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25601. * @param postProcess The post process to detach from the camera
  25602. */
  25603. detachPostProcess(postProcess: PostProcess): void;
  25604. /**
  25605. * Gets the current world matrix of the camera
  25606. */
  25607. getWorldMatrix(): Matrix;
  25608. /** @hidden */
  25609. _getViewMatrix(): Matrix;
  25610. /**
  25611. * Gets the current view matrix of the camera.
  25612. * @param force forces the camera to recompute the matrix without looking at the cached state
  25613. * @returns the view matrix
  25614. */
  25615. getViewMatrix(force?: boolean): Matrix;
  25616. /**
  25617. * Freeze the projection matrix.
  25618. * It will prevent the cache check of the camera projection compute and can speed up perf
  25619. * if no parameter of the camera are meant to change
  25620. * @param projection Defines manually a projection if necessary
  25621. */
  25622. freezeProjectionMatrix(projection?: Matrix): void;
  25623. /**
  25624. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25625. */
  25626. unfreezeProjectionMatrix(): void;
  25627. /**
  25628. * Gets the current projection matrix of the camera.
  25629. * @param force forces the camera to recompute the matrix without looking at the cached state
  25630. * @returns the projection matrix
  25631. */
  25632. getProjectionMatrix(force?: boolean): Matrix;
  25633. /**
  25634. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25635. * @returns a Matrix
  25636. */
  25637. getTransformationMatrix(): Matrix;
  25638. private _updateFrustumPlanes;
  25639. /**
  25640. * Checks if a cullable object (mesh...) is in the camera frustum
  25641. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25642. * @param target The object to check
  25643. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25644. * @returns true if the object is in frustum otherwise false
  25645. */
  25646. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25647. /**
  25648. * Checks if a cullable object (mesh...) is in the camera frustum
  25649. * Unlike isInFrustum this cheks the full bounding box
  25650. * @param target The object to check
  25651. * @returns true if the object is in frustum otherwise false
  25652. */
  25653. isCompletelyInFrustum(target: ICullable): boolean;
  25654. /**
  25655. * Gets a ray in the forward direction from the camera.
  25656. * @param length Defines the length of the ray to create
  25657. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25658. * @param origin Defines the start point of the ray which defaults to the camera position
  25659. * @returns the forward ray
  25660. */
  25661. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25662. /**
  25663. * Releases resources associated with this node.
  25664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25666. */
  25667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25668. /** @hidden */
  25669. _isLeftCamera: boolean;
  25670. /**
  25671. * Gets the left camera of a rig setup in case of Rigged Camera
  25672. */
  25673. get isLeftCamera(): boolean;
  25674. /** @hidden */
  25675. _isRightCamera: boolean;
  25676. /**
  25677. * Gets the right camera of a rig setup in case of Rigged Camera
  25678. */
  25679. get isRightCamera(): boolean;
  25680. /**
  25681. * Gets the left camera of a rig setup in case of Rigged Camera
  25682. */
  25683. get leftCamera(): Nullable<FreeCamera>;
  25684. /**
  25685. * Gets the right camera of a rig setup in case of Rigged Camera
  25686. */
  25687. get rightCamera(): Nullable<FreeCamera>;
  25688. /**
  25689. * Gets the left camera target of a rig setup in case of Rigged Camera
  25690. * @returns the target position
  25691. */
  25692. getLeftTarget(): Nullable<Vector3>;
  25693. /**
  25694. * Gets the right camera target of a rig setup in case of Rigged Camera
  25695. * @returns the target position
  25696. */
  25697. getRightTarget(): Nullable<Vector3>;
  25698. /**
  25699. * @hidden
  25700. */
  25701. setCameraRigMode(mode: number, rigParams: any): void;
  25702. /** @hidden */
  25703. static _setStereoscopicRigMode(camera: Camera): void;
  25704. /** @hidden */
  25705. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25706. /** @hidden */
  25707. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25708. /** @hidden */
  25709. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25710. /** @hidden */
  25711. _getVRProjectionMatrix(): Matrix;
  25712. protected _updateCameraRotationMatrix(): void;
  25713. protected _updateWebVRCameraRotationMatrix(): void;
  25714. /**
  25715. * This function MUST be overwritten by the different WebVR cameras available.
  25716. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25717. * @hidden
  25718. */
  25719. _getWebVRProjectionMatrix(): Matrix;
  25720. /**
  25721. * This function MUST be overwritten by the different WebVR cameras available.
  25722. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25723. * @hidden
  25724. */
  25725. _getWebVRViewMatrix(): Matrix;
  25726. /** @hidden */
  25727. setCameraRigParameter(name: string, value: any): void;
  25728. /**
  25729. * needs to be overridden by children so sub has required properties to be copied
  25730. * @hidden
  25731. */
  25732. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25733. /**
  25734. * May need to be overridden by children
  25735. * @hidden
  25736. */
  25737. _updateRigCameras(): void;
  25738. /** @hidden */
  25739. _setupInputs(): void;
  25740. /**
  25741. * Serialiaze the camera setup to a json represention
  25742. * @returns the JSON representation
  25743. */
  25744. serialize(): any;
  25745. /**
  25746. * Clones the current camera.
  25747. * @param name The cloned camera name
  25748. * @returns the cloned camera
  25749. */
  25750. clone(name: string): Camera;
  25751. /**
  25752. * Gets the direction of the camera relative to a given local axis.
  25753. * @param localAxis Defines the reference axis to provide a relative direction.
  25754. * @return the direction
  25755. */
  25756. getDirection(localAxis: Vector3): Vector3;
  25757. /**
  25758. * Returns the current camera absolute rotation
  25759. */
  25760. get absoluteRotation(): Quaternion;
  25761. /**
  25762. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25763. * @param localAxis Defines the reference axis to provide a relative direction.
  25764. * @param result Defines the vector to store the result in
  25765. */
  25766. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25767. /**
  25768. * Gets a camera constructor for a given camera type
  25769. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25770. * @param name The name of the camera the result will be able to instantiate
  25771. * @param scene The scene the result will construct the camera in
  25772. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25773. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25774. * @returns a factory method to construc the camera
  25775. */
  25776. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25777. /**
  25778. * Compute the world matrix of the camera.
  25779. * @returns the camera world matrix
  25780. */
  25781. computeWorldMatrix(): Matrix;
  25782. /**
  25783. * Parse a JSON and creates the camera from the parsed information
  25784. * @param parsedCamera The JSON to parse
  25785. * @param scene The scene to instantiate the camera in
  25786. * @returns the newly constructed camera
  25787. */
  25788. static Parse(parsedCamera: any, scene: Scene): Camera;
  25789. }
  25790. }
  25791. declare module BABYLON {
  25792. /**
  25793. * Class containing static functions to help procedurally build meshes
  25794. */
  25795. export class DiscBuilder {
  25796. /**
  25797. * Creates a plane polygonal mesh. By default, this is a disc
  25798. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25799. * * 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
  25800. * * 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
  25801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25802. * * 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
  25803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25804. * @param name defines the name of the mesh
  25805. * @param options defines the options used to create the mesh
  25806. * @param scene defines the hosting scene
  25807. * @returns the plane polygonal mesh
  25808. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25809. */
  25810. static CreateDisc(name: string, options: {
  25811. radius?: number;
  25812. tessellation?: number;
  25813. arc?: number;
  25814. updatable?: boolean;
  25815. sideOrientation?: number;
  25816. frontUVs?: Vector4;
  25817. backUVs?: Vector4;
  25818. }, scene?: Nullable<Scene>): Mesh;
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. /**
  25823. * This represents all the required information to add a fresnel effect on a material:
  25824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25825. */
  25826. export class FresnelParameters {
  25827. private _isEnabled;
  25828. /**
  25829. * Define if the fresnel effect is enable or not.
  25830. */
  25831. get isEnabled(): boolean;
  25832. set isEnabled(value: boolean);
  25833. /**
  25834. * Define the color used on edges (grazing angle)
  25835. */
  25836. leftColor: Color3;
  25837. /**
  25838. * Define the color used on center
  25839. */
  25840. rightColor: Color3;
  25841. /**
  25842. * Define bias applied to computed fresnel term
  25843. */
  25844. bias: number;
  25845. /**
  25846. * Defined the power exponent applied to fresnel term
  25847. */
  25848. power: number;
  25849. /**
  25850. * Clones the current fresnel and its valuues
  25851. * @returns a clone fresnel configuration
  25852. */
  25853. clone(): FresnelParameters;
  25854. /**
  25855. * Serializes the current fresnel parameters to a JSON representation.
  25856. * @return the JSON serialization
  25857. */
  25858. serialize(): any;
  25859. /**
  25860. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25861. * @param parsedFresnelParameters Define the JSON representation
  25862. * @returns the parsed parameters
  25863. */
  25864. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25865. }
  25866. }
  25867. declare module BABYLON {
  25868. /**
  25869. * Base class of materials working in push mode in babylon JS
  25870. * @hidden
  25871. */
  25872. export class PushMaterial extends Material {
  25873. protected _activeEffect: Effect;
  25874. protected _normalMatrix: Matrix;
  25875. /**
  25876. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25877. * This means that the material can keep using a previous shader while a new one is being compiled.
  25878. * This is mostly used when shader parallel compilation is supported (true by default)
  25879. */
  25880. allowShaderHotSwapping: boolean;
  25881. constructor(name: string, scene: Scene);
  25882. getEffect(): Effect;
  25883. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25884. /**
  25885. * Binds the given world matrix to the active effect
  25886. *
  25887. * @param world the matrix to bind
  25888. */
  25889. bindOnlyWorldMatrix(world: Matrix): void;
  25890. /**
  25891. * Binds the given normal matrix to the active effect
  25892. *
  25893. * @param normalMatrix the matrix to bind
  25894. */
  25895. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25896. bind(world: Matrix, mesh?: Mesh): void;
  25897. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25898. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25899. }
  25900. }
  25901. declare module BABYLON {
  25902. /**
  25903. * This groups all the flags used to control the materials channel.
  25904. */
  25905. export class MaterialFlags {
  25906. private static _DiffuseTextureEnabled;
  25907. /**
  25908. * Are diffuse textures enabled in the application.
  25909. */
  25910. static get DiffuseTextureEnabled(): boolean;
  25911. static set DiffuseTextureEnabled(value: boolean);
  25912. private static _AmbientTextureEnabled;
  25913. /**
  25914. * Are ambient textures enabled in the application.
  25915. */
  25916. static get AmbientTextureEnabled(): boolean;
  25917. static set AmbientTextureEnabled(value: boolean);
  25918. private static _OpacityTextureEnabled;
  25919. /**
  25920. * Are opacity textures enabled in the application.
  25921. */
  25922. static get OpacityTextureEnabled(): boolean;
  25923. static set OpacityTextureEnabled(value: boolean);
  25924. private static _ReflectionTextureEnabled;
  25925. /**
  25926. * Are reflection textures enabled in the application.
  25927. */
  25928. static get ReflectionTextureEnabled(): boolean;
  25929. static set ReflectionTextureEnabled(value: boolean);
  25930. private static _EmissiveTextureEnabled;
  25931. /**
  25932. * Are emissive textures enabled in the application.
  25933. */
  25934. static get EmissiveTextureEnabled(): boolean;
  25935. static set EmissiveTextureEnabled(value: boolean);
  25936. private static _SpecularTextureEnabled;
  25937. /**
  25938. * Are specular textures enabled in the application.
  25939. */
  25940. static get SpecularTextureEnabled(): boolean;
  25941. static set SpecularTextureEnabled(value: boolean);
  25942. private static _BumpTextureEnabled;
  25943. /**
  25944. * Are bump textures enabled in the application.
  25945. */
  25946. static get BumpTextureEnabled(): boolean;
  25947. static set BumpTextureEnabled(value: boolean);
  25948. private static _LightmapTextureEnabled;
  25949. /**
  25950. * Are lightmap textures enabled in the application.
  25951. */
  25952. static get LightmapTextureEnabled(): boolean;
  25953. static set LightmapTextureEnabled(value: boolean);
  25954. private static _RefractionTextureEnabled;
  25955. /**
  25956. * Are refraction textures enabled in the application.
  25957. */
  25958. static get RefractionTextureEnabled(): boolean;
  25959. static set RefractionTextureEnabled(value: boolean);
  25960. private static _ColorGradingTextureEnabled;
  25961. /**
  25962. * Are color grading textures enabled in the application.
  25963. */
  25964. static get ColorGradingTextureEnabled(): boolean;
  25965. static set ColorGradingTextureEnabled(value: boolean);
  25966. private static _FresnelEnabled;
  25967. /**
  25968. * Are fresnels enabled in the application.
  25969. */
  25970. static get FresnelEnabled(): boolean;
  25971. static set FresnelEnabled(value: boolean);
  25972. private static _ClearCoatTextureEnabled;
  25973. /**
  25974. * Are clear coat textures enabled in the application.
  25975. */
  25976. static get ClearCoatTextureEnabled(): boolean;
  25977. static set ClearCoatTextureEnabled(value: boolean);
  25978. private static _ClearCoatBumpTextureEnabled;
  25979. /**
  25980. * Are clear coat bump textures enabled in the application.
  25981. */
  25982. static get ClearCoatBumpTextureEnabled(): boolean;
  25983. static set ClearCoatBumpTextureEnabled(value: boolean);
  25984. private static _ClearCoatTintTextureEnabled;
  25985. /**
  25986. * Are clear coat tint textures enabled in the application.
  25987. */
  25988. static get ClearCoatTintTextureEnabled(): boolean;
  25989. static set ClearCoatTintTextureEnabled(value: boolean);
  25990. private static _SheenTextureEnabled;
  25991. /**
  25992. * Are sheen textures enabled in the application.
  25993. */
  25994. static get SheenTextureEnabled(): boolean;
  25995. static set SheenTextureEnabled(value: boolean);
  25996. private static _AnisotropicTextureEnabled;
  25997. /**
  25998. * Are anisotropic textures enabled in the application.
  25999. */
  26000. static get AnisotropicTextureEnabled(): boolean;
  26001. static set AnisotropicTextureEnabled(value: boolean);
  26002. private static _ThicknessTextureEnabled;
  26003. /**
  26004. * Are thickness textures enabled in the application.
  26005. */
  26006. static get ThicknessTextureEnabled(): boolean;
  26007. static set ThicknessTextureEnabled(value: boolean);
  26008. }
  26009. }
  26010. declare module BABYLON {
  26011. /** @hidden */
  26012. export var defaultFragmentDeclaration: {
  26013. name: string;
  26014. shader: string;
  26015. };
  26016. }
  26017. declare module BABYLON {
  26018. /** @hidden */
  26019. export var defaultUboDeclaration: {
  26020. name: string;
  26021. shader: string;
  26022. };
  26023. }
  26024. declare module BABYLON {
  26025. /** @hidden */
  26026. export var lightFragmentDeclaration: {
  26027. name: string;
  26028. shader: string;
  26029. };
  26030. }
  26031. declare module BABYLON {
  26032. /** @hidden */
  26033. export var lightUboDeclaration: {
  26034. name: string;
  26035. shader: string;
  26036. };
  26037. }
  26038. declare module BABYLON {
  26039. /** @hidden */
  26040. export var lightsFragmentFunctions: {
  26041. name: string;
  26042. shader: string;
  26043. };
  26044. }
  26045. declare module BABYLON {
  26046. /** @hidden */
  26047. export var shadowsFragmentFunctions: {
  26048. name: string;
  26049. shader: string;
  26050. };
  26051. }
  26052. declare module BABYLON {
  26053. /** @hidden */
  26054. export var fresnelFunction: {
  26055. name: string;
  26056. shader: string;
  26057. };
  26058. }
  26059. declare module BABYLON {
  26060. /** @hidden */
  26061. export var reflectionFunction: {
  26062. name: string;
  26063. shader: string;
  26064. };
  26065. }
  26066. declare module BABYLON {
  26067. /** @hidden */
  26068. export var bumpFragmentFunctions: {
  26069. name: string;
  26070. shader: string;
  26071. };
  26072. }
  26073. declare module BABYLON {
  26074. /** @hidden */
  26075. export var logDepthDeclaration: {
  26076. name: string;
  26077. shader: string;
  26078. };
  26079. }
  26080. declare module BABYLON {
  26081. /** @hidden */
  26082. export var bumpFragment: {
  26083. name: string;
  26084. shader: string;
  26085. };
  26086. }
  26087. declare module BABYLON {
  26088. /** @hidden */
  26089. export var depthPrePass: {
  26090. name: string;
  26091. shader: string;
  26092. };
  26093. }
  26094. declare module BABYLON {
  26095. /** @hidden */
  26096. export var lightFragment: {
  26097. name: string;
  26098. shader: string;
  26099. };
  26100. }
  26101. declare module BABYLON {
  26102. /** @hidden */
  26103. export var logDepthFragment: {
  26104. name: string;
  26105. shader: string;
  26106. };
  26107. }
  26108. declare module BABYLON {
  26109. /** @hidden */
  26110. export var defaultPixelShader: {
  26111. name: string;
  26112. shader: string;
  26113. };
  26114. }
  26115. declare module BABYLON {
  26116. /** @hidden */
  26117. export var defaultVertexDeclaration: {
  26118. name: string;
  26119. shader: string;
  26120. };
  26121. }
  26122. declare module BABYLON {
  26123. /** @hidden */
  26124. export var bumpVertexDeclaration: {
  26125. name: string;
  26126. shader: string;
  26127. };
  26128. }
  26129. declare module BABYLON {
  26130. /** @hidden */
  26131. export var bumpVertex: {
  26132. name: string;
  26133. shader: string;
  26134. };
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var fogVertex: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var shadowsVertex: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var pointCloudVertex: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var logDepthVertex: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var defaultVertexShader: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26174. MAINUV1: boolean;
  26175. MAINUV2: boolean;
  26176. DIFFUSE: boolean;
  26177. DIFFUSEDIRECTUV: number;
  26178. AMBIENT: boolean;
  26179. AMBIENTDIRECTUV: number;
  26180. OPACITY: boolean;
  26181. OPACITYDIRECTUV: number;
  26182. OPACITYRGB: boolean;
  26183. REFLECTION: boolean;
  26184. EMISSIVE: boolean;
  26185. EMISSIVEDIRECTUV: number;
  26186. SPECULAR: boolean;
  26187. SPECULARDIRECTUV: number;
  26188. BUMP: boolean;
  26189. BUMPDIRECTUV: number;
  26190. PARALLAX: boolean;
  26191. PARALLAXOCCLUSION: boolean;
  26192. SPECULAROVERALPHA: boolean;
  26193. CLIPPLANE: boolean;
  26194. CLIPPLANE2: boolean;
  26195. CLIPPLANE3: boolean;
  26196. CLIPPLANE4: boolean;
  26197. CLIPPLANE5: boolean;
  26198. CLIPPLANE6: boolean;
  26199. ALPHATEST: boolean;
  26200. DEPTHPREPASS: boolean;
  26201. ALPHAFROMDIFFUSE: boolean;
  26202. POINTSIZE: boolean;
  26203. FOG: boolean;
  26204. SPECULARTERM: boolean;
  26205. DIFFUSEFRESNEL: boolean;
  26206. OPACITYFRESNEL: boolean;
  26207. REFLECTIONFRESNEL: boolean;
  26208. REFRACTIONFRESNEL: boolean;
  26209. EMISSIVEFRESNEL: boolean;
  26210. FRESNEL: boolean;
  26211. NORMAL: boolean;
  26212. UV1: boolean;
  26213. UV2: boolean;
  26214. VERTEXCOLOR: boolean;
  26215. VERTEXALPHA: boolean;
  26216. NUM_BONE_INFLUENCERS: number;
  26217. BonesPerMesh: number;
  26218. BONETEXTURE: boolean;
  26219. INSTANCES: boolean;
  26220. GLOSSINESS: boolean;
  26221. ROUGHNESS: boolean;
  26222. EMISSIVEASILLUMINATION: boolean;
  26223. LINKEMISSIVEWITHDIFFUSE: boolean;
  26224. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26225. LIGHTMAP: boolean;
  26226. LIGHTMAPDIRECTUV: number;
  26227. OBJECTSPACE_NORMALMAP: boolean;
  26228. USELIGHTMAPASSHADOWMAP: boolean;
  26229. REFLECTIONMAP_3D: boolean;
  26230. REFLECTIONMAP_SPHERICAL: boolean;
  26231. REFLECTIONMAP_PLANAR: boolean;
  26232. REFLECTIONMAP_CUBIC: boolean;
  26233. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26234. REFLECTIONMAP_PROJECTION: boolean;
  26235. REFLECTIONMAP_SKYBOX: boolean;
  26236. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26237. REFLECTIONMAP_EXPLICIT: boolean;
  26238. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26239. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26240. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26241. INVERTCUBICMAP: boolean;
  26242. LOGARITHMICDEPTH: boolean;
  26243. REFRACTION: boolean;
  26244. REFRACTIONMAP_3D: boolean;
  26245. REFLECTIONOVERALPHA: boolean;
  26246. TWOSIDEDLIGHTING: boolean;
  26247. SHADOWFLOAT: boolean;
  26248. MORPHTARGETS: boolean;
  26249. MORPHTARGETS_NORMAL: boolean;
  26250. MORPHTARGETS_TANGENT: boolean;
  26251. MORPHTARGETS_UV: boolean;
  26252. NUM_MORPH_INFLUENCERS: number;
  26253. NONUNIFORMSCALING: boolean;
  26254. PREMULTIPLYALPHA: boolean;
  26255. IMAGEPROCESSING: boolean;
  26256. VIGNETTE: boolean;
  26257. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26258. VIGNETTEBLENDMODEOPAQUE: boolean;
  26259. TONEMAPPING: boolean;
  26260. TONEMAPPING_ACES: boolean;
  26261. CONTRAST: boolean;
  26262. COLORCURVES: boolean;
  26263. COLORGRADING: boolean;
  26264. COLORGRADING3D: boolean;
  26265. SAMPLER3DGREENDEPTH: boolean;
  26266. SAMPLER3DBGRMAP: boolean;
  26267. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26268. MULTIVIEW: boolean;
  26269. /**
  26270. * If the reflection texture on this material is in linear color space
  26271. * @hidden
  26272. */
  26273. IS_REFLECTION_LINEAR: boolean;
  26274. /**
  26275. * If the refraction texture on this material is in linear color space
  26276. * @hidden
  26277. */
  26278. IS_REFRACTION_LINEAR: boolean;
  26279. EXPOSURE: boolean;
  26280. constructor();
  26281. setReflectionMode(modeToEnable: string): void;
  26282. }
  26283. /**
  26284. * This is the default material used in Babylon. It is the best trade off between quality
  26285. * and performances.
  26286. * @see http://doc.babylonjs.com/babylon101/materials
  26287. */
  26288. export class StandardMaterial extends PushMaterial {
  26289. private _diffuseTexture;
  26290. /**
  26291. * The basic texture of the material as viewed under a light.
  26292. */
  26293. diffuseTexture: Nullable<BaseTexture>;
  26294. private _ambientTexture;
  26295. /**
  26296. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26297. */
  26298. ambientTexture: Nullable<BaseTexture>;
  26299. private _opacityTexture;
  26300. /**
  26301. * Define the transparency of the material from a texture.
  26302. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26303. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26304. */
  26305. opacityTexture: Nullable<BaseTexture>;
  26306. private _reflectionTexture;
  26307. /**
  26308. * Define the texture used to display the reflection.
  26309. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26310. */
  26311. reflectionTexture: Nullable<BaseTexture>;
  26312. private _emissiveTexture;
  26313. /**
  26314. * Define texture of the material as if self lit.
  26315. * This will be mixed in the final result even in the absence of light.
  26316. */
  26317. emissiveTexture: Nullable<BaseTexture>;
  26318. private _specularTexture;
  26319. /**
  26320. * Define how the color and intensity of the highlight given by the light in the material.
  26321. */
  26322. specularTexture: Nullable<BaseTexture>;
  26323. private _bumpTexture;
  26324. /**
  26325. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26326. * 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.
  26327. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26328. */
  26329. bumpTexture: Nullable<BaseTexture>;
  26330. private _lightmapTexture;
  26331. /**
  26332. * Complex lighting can be computationally expensive to compute at runtime.
  26333. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26334. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26335. */
  26336. lightmapTexture: Nullable<BaseTexture>;
  26337. private _refractionTexture;
  26338. /**
  26339. * Define the texture used to display the refraction.
  26340. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26341. */
  26342. refractionTexture: Nullable<BaseTexture>;
  26343. /**
  26344. * The color of the material lit by the environmental background lighting.
  26345. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26346. */
  26347. ambientColor: Color3;
  26348. /**
  26349. * The basic color of the material as viewed under a light.
  26350. */
  26351. diffuseColor: Color3;
  26352. /**
  26353. * Define how the color and intensity of the highlight given by the light in the material.
  26354. */
  26355. specularColor: Color3;
  26356. /**
  26357. * Define the color of the material as if self lit.
  26358. * This will be mixed in the final result even in the absence of light.
  26359. */
  26360. emissiveColor: Color3;
  26361. /**
  26362. * Defines how sharp are the highlights in the material.
  26363. * The bigger the value the sharper giving a more glossy feeling to the result.
  26364. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26365. */
  26366. specularPower: number;
  26367. private _useAlphaFromDiffuseTexture;
  26368. /**
  26369. * Does the transparency come from the diffuse texture alpha channel.
  26370. */
  26371. useAlphaFromDiffuseTexture: boolean;
  26372. private _useEmissiveAsIllumination;
  26373. /**
  26374. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26375. */
  26376. useEmissiveAsIllumination: boolean;
  26377. private _linkEmissiveWithDiffuse;
  26378. /**
  26379. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26380. * the emissive level when the final color is close to one.
  26381. */
  26382. linkEmissiveWithDiffuse: boolean;
  26383. private _useSpecularOverAlpha;
  26384. /**
  26385. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26386. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26387. */
  26388. useSpecularOverAlpha: boolean;
  26389. private _useReflectionOverAlpha;
  26390. /**
  26391. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26392. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26393. */
  26394. useReflectionOverAlpha: boolean;
  26395. private _disableLighting;
  26396. /**
  26397. * Does lights from the scene impacts this material.
  26398. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26399. */
  26400. disableLighting: boolean;
  26401. private _useObjectSpaceNormalMap;
  26402. /**
  26403. * Allows using an object space normal map (instead of tangent space).
  26404. */
  26405. useObjectSpaceNormalMap: boolean;
  26406. private _useParallax;
  26407. /**
  26408. * Is parallax enabled or not.
  26409. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26410. */
  26411. useParallax: boolean;
  26412. private _useParallaxOcclusion;
  26413. /**
  26414. * Is parallax occlusion enabled or not.
  26415. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26416. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26417. */
  26418. useParallaxOcclusion: boolean;
  26419. /**
  26420. * 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.
  26421. */
  26422. parallaxScaleBias: number;
  26423. private _roughness;
  26424. /**
  26425. * Helps to define how blurry the reflections should appears in the material.
  26426. */
  26427. roughness: number;
  26428. /**
  26429. * In case of refraction, define the value of the index of refraction.
  26430. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26431. */
  26432. indexOfRefraction: number;
  26433. /**
  26434. * Invert the refraction texture alongside the y axis.
  26435. * It can be useful with procedural textures or probe for instance.
  26436. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26437. */
  26438. invertRefractionY: boolean;
  26439. /**
  26440. * Defines the alpha limits in alpha test mode.
  26441. */
  26442. alphaCutOff: number;
  26443. private _useLightmapAsShadowmap;
  26444. /**
  26445. * In case of light mapping, define whether the map contains light or shadow informations.
  26446. */
  26447. useLightmapAsShadowmap: boolean;
  26448. private _diffuseFresnelParameters;
  26449. /**
  26450. * Define the diffuse fresnel parameters of the material.
  26451. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26452. */
  26453. diffuseFresnelParameters: FresnelParameters;
  26454. private _opacityFresnelParameters;
  26455. /**
  26456. * Define the opacity fresnel parameters of the material.
  26457. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26458. */
  26459. opacityFresnelParameters: FresnelParameters;
  26460. private _reflectionFresnelParameters;
  26461. /**
  26462. * Define the reflection fresnel parameters of the material.
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26464. */
  26465. reflectionFresnelParameters: FresnelParameters;
  26466. private _refractionFresnelParameters;
  26467. /**
  26468. * Define the refraction fresnel parameters of the material.
  26469. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26470. */
  26471. refractionFresnelParameters: FresnelParameters;
  26472. private _emissiveFresnelParameters;
  26473. /**
  26474. * Define the emissive fresnel parameters of the material.
  26475. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26476. */
  26477. emissiveFresnelParameters: FresnelParameters;
  26478. private _useReflectionFresnelFromSpecular;
  26479. /**
  26480. * If true automatically deducts the fresnels values from the material specularity.
  26481. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26482. */
  26483. useReflectionFresnelFromSpecular: boolean;
  26484. private _useGlossinessFromSpecularMapAlpha;
  26485. /**
  26486. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26487. */
  26488. useGlossinessFromSpecularMapAlpha: boolean;
  26489. private _maxSimultaneousLights;
  26490. /**
  26491. * Defines the maximum number of lights that can be used in the material
  26492. */
  26493. maxSimultaneousLights: number;
  26494. private _invertNormalMapX;
  26495. /**
  26496. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26497. */
  26498. invertNormalMapX: boolean;
  26499. private _invertNormalMapY;
  26500. /**
  26501. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26502. */
  26503. invertNormalMapY: boolean;
  26504. private _twoSidedLighting;
  26505. /**
  26506. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26507. */
  26508. twoSidedLighting: boolean;
  26509. /**
  26510. * Default configuration related to image processing available in the standard Material.
  26511. */
  26512. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26513. /**
  26514. * Gets the image processing configuration used either in this material.
  26515. */
  26516. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26517. /**
  26518. * Sets the Default image processing configuration used either in the this material.
  26519. *
  26520. * If sets to null, the scene one is in use.
  26521. */
  26522. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26523. /**
  26524. * Keep track of the image processing observer to allow dispose and replace.
  26525. */
  26526. private _imageProcessingObserver;
  26527. /**
  26528. * Attaches a new image processing configuration to the Standard Material.
  26529. * @param configuration
  26530. */
  26531. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26532. /**
  26533. * Gets wether the color curves effect is enabled.
  26534. */
  26535. get cameraColorCurvesEnabled(): boolean;
  26536. /**
  26537. * Sets wether the color curves effect is enabled.
  26538. */
  26539. set cameraColorCurvesEnabled(value: boolean);
  26540. /**
  26541. * Gets wether the color grading effect is enabled.
  26542. */
  26543. get cameraColorGradingEnabled(): boolean;
  26544. /**
  26545. * Gets wether the color grading effect is enabled.
  26546. */
  26547. set cameraColorGradingEnabled(value: boolean);
  26548. /**
  26549. * Gets wether tonemapping is enabled or not.
  26550. */
  26551. get cameraToneMappingEnabled(): boolean;
  26552. /**
  26553. * Sets wether tonemapping is enabled or not
  26554. */
  26555. set cameraToneMappingEnabled(value: boolean);
  26556. /**
  26557. * The camera exposure used on this material.
  26558. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26559. * This corresponds to a photographic exposure.
  26560. */
  26561. get cameraExposure(): number;
  26562. /**
  26563. * The camera exposure used on this material.
  26564. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26565. * This corresponds to a photographic exposure.
  26566. */
  26567. set cameraExposure(value: number);
  26568. /**
  26569. * Gets The camera contrast used on this material.
  26570. */
  26571. get cameraContrast(): number;
  26572. /**
  26573. * Sets The camera contrast used on this material.
  26574. */
  26575. set cameraContrast(value: number);
  26576. /**
  26577. * Gets the Color Grading 2D Lookup Texture.
  26578. */
  26579. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26580. /**
  26581. * Sets the Color Grading 2D Lookup Texture.
  26582. */
  26583. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26584. /**
  26585. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26586. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26587. * 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;
  26588. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26589. */
  26590. get cameraColorCurves(): Nullable<ColorCurves>;
  26591. /**
  26592. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26593. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26594. * 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;
  26595. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26596. */
  26597. set cameraColorCurves(value: Nullable<ColorCurves>);
  26598. /**
  26599. * Custom callback helping to override the default shader used in the material.
  26600. */
  26601. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26602. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26603. protected _worldViewProjectionMatrix: Matrix;
  26604. protected _globalAmbientColor: Color3;
  26605. protected _useLogarithmicDepth: boolean;
  26606. protected _rebuildInParallel: boolean;
  26607. /**
  26608. * Instantiates a new standard material.
  26609. * This is the default material used in Babylon. It is the best trade off between quality
  26610. * and performances.
  26611. * @see http://doc.babylonjs.com/babylon101/materials
  26612. * @param name Define the name of the material in the scene
  26613. * @param scene Define the scene the material belong to
  26614. */
  26615. constructor(name: string, scene: Scene);
  26616. /**
  26617. * Gets a boolean indicating that current material needs to register RTT
  26618. */
  26619. get hasRenderTargetTextures(): boolean;
  26620. /**
  26621. * Gets the current class name of the material e.g. "StandardMaterial"
  26622. * Mainly use in serialization.
  26623. * @returns the class name
  26624. */
  26625. getClassName(): string;
  26626. /**
  26627. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26628. * You can try switching to logarithmic depth.
  26629. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26630. */
  26631. get useLogarithmicDepth(): boolean;
  26632. set useLogarithmicDepth(value: boolean);
  26633. /**
  26634. * Specifies if the material will require alpha blending
  26635. * @returns a boolean specifying if alpha blending is needed
  26636. */
  26637. needAlphaBlending(): boolean;
  26638. /**
  26639. * Specifies if this material should be rendered in alpha test mode
  26640. * @returns a boolean specifying if an alpha test is needed.
  26641. */
  26642. needAlphaTesting(): boolean;
  26643. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26644. /**
  26645. * Get the texture used for alpha test purpose.
  26646. * @returns the diffuse texture in case of the standard material.
  26647. */
  26648. getAlphaTestTexture(): Nullable<BaseTexture>;
  26649. /**
  26650. * Get if the submesh is ready to be used and all its information available.
  26651. * Child classes can use it to update shaders
  26652. * @param mesh defines the mesh to check
  26653. * @param subMesh defines which submesh to check
  26654. * @param useInstances specifies that instances should be used
  26655. * @returns a boolean indicating that the submesh is ready or not
  26656. */
  26657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26658. /**
  26659. * Builds the material UBO layouts.
  26660. * Used internally during the effect preparation.
  26661. */
  26662. buildUniformLayout(): void;
  26663. /**
  26664. * Unbinds the material from the mesh
  26665. */
  26666. unbind(): void;
  26667. /**
  26668. * Binds the submesh to this material by preparing the effect and shader to draw
  26669. * @param world defines the world transformation matrix
  26670. * @param mesh defines the mesh containing the submesh
  26671. * @param subMesh defines the submesh to bind the material to
  26672. */
  26673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26674. /**
  26675. * Get the list of animatables in the material.
  26676. * @returns the list of animatables object used in the material
  26677. */
  26678. getAnimatables(): IAnimatable[];
  26679. /**
  26680. * Gets the active textures from the material
  26681. * @returns an array of textures
  26682. */
  26683. getActiveTextures(): BaseTexture[];
  26684. /**
  26685. * Specifies if the material uses a texture
  26686. * @param texture defines the texture to check against the material
  26687. * @returns a boolean specifying if the material uses the texture
  26688. */
  26689. hasTexture(texture: BaseTexture): boolean;
  26690. /**
  26691. * Disposes the material
  26692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26694. */
  26695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26696. /**
  26697. * Makes a duplicate of the material, and gives it a new name
  26698. * @param name defines the new name for the duplicated material
  26699. * @returns the cloned material
  26700. */
  26701. clone(name: string): StandardMaterial;
  26702. /**
  26703. * Serializes this material in a JSON representation
  26704. * @returns the serialized material object
  26705. */
  26706. serialize(): any;
  26707. /**
  26708. * Creates a standard material from parsed material data
  26709. * @param source defines the JSON representation of the material
  26710. * @param scene defines the hosting scene
  26711. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26712. * @returns a new standard material
  26713. */
  26714. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26715. /**
  26716. * Are diffuse textures enabled in the application.
  26717. */
  26718. static get DiffuseTextureEnabled(): boolean;
  26719. static set DiffuseTextureEnabled(value: boolean);
  26720. /**
  26721. * Are ambient textures enabled in the application.
  26722. */
  26723. static get AmbientTextureEnabled(): boolean;
  26724. static set AmbientTextureEnabled(value: boolean);
  26725. /**
  26726. * Are opacity textures enabled in the application.
  26727. */
  26728. static get OpacityTextureEnabled(): boolean;
  26729. static set OpacityTextureEnabled(value: boolean);
  26730. /**
  26731. * Are reflection textures enabled in the application.
  26732. */
  26733. static get ReflectionTextureEnabled(): boolean;
  26734. static set ReflectionTextureEnabled(value: boolean);
  26735. /**
  26736. * Are emissive textures enabled in the application.
  26737. */
  26738. static get EmissiveTextureEnabled(): boolean;
  26739. static set EmissiveTextureEnabled(value: boolean);
  26740. /**
  26741. * Are specular textures enabled in the application.
  26742. */
  26743. static get SpecularTextureEnabled(): boolean;
  26744. static set SpecularTextureEnabled(value: boolean);
  26745. /**
  26746. * Are bump textures enabled in the application.
  26747. */
  26748. static get BumpTextureEnabled(): boolean;
  26749. static set BumpTextureEnabled(value: boolean);
  26750. /**
  26751. * Are lightmap textures enabled in the application.
  26752. */
  26753. static get LightmapTextureEnabled(): boolean;
  26754. static set LightmapTextureEnabled(value: boolean);
  26755. /**
  26756. * Are refraction textures enabled in the application.
  26757. */
  26758. static get RefractionTextureEnabled(): boolean;
  26759. static set RefractionTextureEnabled(value: boolean);
  26760. /**
  26761. * Are color grading textures enabled in the application.
  26762. */
  26763. static get ColorGradingTextureEnabled(): boolean;
  26764. static set ColorGradingTextureEnabled(value: boolean);
  26765. /**
  26766. * Are fresnels enabled in the application.
  26767. */
  26768. static get FresnelEnabled(): boolean;
  26769. static set FresnelEnabled(value: boolean);
  26770. }
  26771. }
  26772. declare module BABYLON {
  26773. /**
  26774. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26775. *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.
  26776. * The SPS is also a particle system. It provides some methods to manage the particles.
  26777. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26778. *
  26779. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26780. */
  26781. export class SolidParticleSystem implements IDisposable {
  26782. /**
  26783. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26784. * Example : var p = SPS.particles[i];
  26785. */
  26786. particles: SolidParticle[];
  26787. /**
  26788. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26789. */
  26790. nbParticles: number;
  26791. /**
  26792. * If the particles must ever face the camera (default false). Useful for planar particles.
  26793. */
  26794. billboard: boolean;
  26795. /**
  26796. * Recompute normals when adding a shape
  26797. */
  26798. recomputeNormals: boolean;
  26799. /**
  26800. * This a counter ofr your own usage. It's not set by any SPS functions.
  26801. */
  26802. counter: number;
  26803. /**
  26804. * The SPS name. This name is also given to the underlying mesh.
  26805. */
  26806. name: string;
  26807. /**
  26808. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26809. */
  26810. mesh: Mesh;
  26811. /**
  26812. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26813. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26814. */
  26815. vars: any;
  26816. /**
  26817. * This array is populated when the SPS is set as 'pickable'.
  26818. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26819. * Each element of this array is an object `{idx: int, faceId: int}`.
  26820. * `idx` is the picked particle index in the `SPS.particles` array
  26821. * `faceId` is the picked face index counted within this particle.
  26822. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26823. */
  26824. pickedParticles: {
  26825. idx: number;
  26826. faceId: number;
  26827. }[];
  26828. /**
  26829. * This array is populated when `enableDepthSort` is set to true.
  26830. * Each element of this array is an instance of the class DepthSortedParticle.
  26831. */
  26832. depthSortedParticles: DepthSortedParticle[];
  26833. /**
  26834. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26835. * @hidden
  26836. */
  26837. _bSphereOnly: boolean;
  26838. /**
  26839. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26840. * @hidden
  26841. */
  26842. _bSphereRadiusFactor: number;
  26843. private _scene;
  26844. private _positions;
  26845. private _indices;
  26846. private _normals;
  26847. private _colors;
  26848. private _uvs;
  26849. private _indices32;
  26850. private _positions32;
  26851. private _normals32;
  26852. private _fixedNormal32;
  26853. private _colors32;
  26854. private _uvs32;
  26855. private _index;
  26856. private _updatable;
  26857. private _pickable;
  26858. private _isVisibilityBoxLocked;
  26859. private _alwaysVisible;
  26860. private _depthSort;
  26861. private _expandable;
  26862. private _shapeCounter;
  26863. private _copy;
  26864. private _color;
  26865. private _computeParticleColor;
  26866. private _computeParticleTexture;
  26867. private _computeParticleRotation;
  26868. private _computeParticleVertex;
  26869. private _computeBoundingBox;
  26870. private _depthSortParticles;
  26871. private _camera;
  26872. private _mustUnrotateFixedNormals;
  26873. private _particlesIntersect;
  26874. private _needs32Bits;
  26875. private _isNotBuilt;
  26876. private _lastParticleId;
  26877. private _idxOfId;
  26878. private _multimaterialEnabled;
  26879. private _useModelMaterial;
  26880. private _indicesByMaterial;
  26881. private _materialIndexes;
  26882. private _depthSortFunction;
  26883. private _materialSortFunction;
  26884. private _materials;
  26885. private _multimaterial;
  26886. private _materialIndexesById;
  26887. private _defaultMaterial;
  26888. private _autoUpdateSubMeshes;
  26889. /**
  26890. * Creates a SPS (Solid Particle System) object.
  26891. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26892. * @param scene (Scene) is the scene in which the SPS is added.
  26893. * @param options defines the options of the sps e.g.
  26894. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26895. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26896. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26897. * * 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.
  26898. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26899. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26900. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26901. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26902. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26903. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26904. */
  26905. constructor(name: string, scene: Scene, options?: {
  26906. updatable?: boolean;
  26907. isPickable?: boolean;
  26908. enableDepthSort?: boolean;
  26909. particleIntersection?: boolean;
  26910. boundingSphereOnly?: boolean;
  26911. bSphereRadiusFactor?: number;
  26912. expandable?: boolean;
  26913. useModelMaterial?: boolean;
  26914. enableMultiMaterial?: boolean;
  26915. });
  26916. /**
  26917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26919. * @returns the created mesh
  26920. */
  26921. buildMesh(): Mesh;
  26922. /**
  26923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26925. * Thus the particles generated from `digest()` have their property `position` set yet.
  26926. * @param mesh ( Mesh ) is the mesh to be digested
  26927. * @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
  26928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26930. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26931. * @returns the current SPS
  26932. */
  26933. digest(mesh: Mesh, options?: {
  26934. facetNb?: number;
  26935. number?: number;
  26936. delta?: number;
  26937. storage?: [];
  26938. }): SolidParticleSystem;
  26939. /**
  26940. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26941. * @hidden
  26942. */
  26943. private _unrotateFixedNormals;
  26944. /**
  26945. * Resets the temporary working copy particle
  26946. * @hidden
  26947. */
  26948. private _resetCopy;
  26949. /**
  26950. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26951. * @param p the current index in the positions array to be updated
  26952. * @param ind the current index in the indices array
  26953. * @param shape a Vector3 array, the shape geometry
  26954. * @param positions the positions array to be updated
  26955. * @param meshInd the shape indices array
  26956. * @param indices the indices array to be updated
  26957. * @param meshUV the shape uv array
  26958. * @param uvs the uv array to be updated
  26959. * @param meshCol the shape color array
  26960. * @param colors the color array to be updated
  26961. * @param meshNor the shape normals array
  26962. * @param normals the normals array to be updated
  26963. * @param idx the particle index
  26964. * @param idxInShape the particle index in its shape
  26965. * @param options the addShape() method passed options
  26966. * @model the particle model
  26967. * @hidden
  26968. */
  26969. private _meshBuilder;
  26970. /**
  26971. * Returns a shape Vector3 array from positions float array
  26972. * @param positions float array
  26973. * @returns a vector3 array
  26974. * @hidden
  26975. */
  26976. private _posToShape;
  26977. /**
  26978. * Returns a shapeUV array from a float uvs (array deep copy)
  26979. * @param uvs as a float array
  26980. * @returns a shapeUV array
  26981. * @hidden
  26982. */
  26983. private _uvsToShapeUV;
  26984. /**
  26985. * Adds a new particle object in the particles array
  26986. * @param idx particle index in particles array
  26987. * @param id particle id
  26988. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26989. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26990. * @param model particle ModelShape object
  26991. * @param shapeId model shape identifier
  26992. * @param idxInShape index of the particle in the current model
  26993. * @param bInfo model bounding info object
  26994. * @param storage target storage array, if any
  26995. * @hidden
  26996. */
  26997. private _addParticle;
  26998. /**
  26999. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27000. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27001. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27002. * @param nb (positive integer) the number of particles to be created from this model
  27003. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27004. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27005. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27006. * @returns the number of shapes in the system
  27007. */
  27008. addShape(mesh: Mesh, nb: number, options?: {
  27009. positionFunction?: any;
  27010. vertexFunction?: any;
  27011. storage?: [];
  27012. }): number;
  27013. /**
  27014. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27015. * @hidden
  27016. */
  27017. private _rebuildParticle;
  27018. /**
  27019. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27020. * @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.
  27021. * @returns the SPS.
  27022. */
  27023. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27024. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27025. * Returns an array with the removed particles.
  27026. * 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.
  27027. * The SPS can't be empty so at least one particle needs to remain in place.
  27028. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27029. * @param start index of the first particle to remove
  27030. * @param end index of the last particle to remove (included)
  27031. * @returns an array populated with the removed particles
  27032. */
  27033. removeParticles(start: number, end: number): SolidParticle[];
  27034. /**
  27035. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27036. * @param solidParticleArray an array populated with Solid Particles objects
  27037. * @returns the SPS
  27038. */
  27039. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27040. /**
  27041. * Creates a new particle and modifies the SPS mesh geometry :
  27042. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27043. * - calls _addParticle() to populate the particle array
  27044. * factorized code from addShape() and insertParticlesFromArray()
  27045. * @param idx particle index in the particles array
  27046. * @param i particle index in its shape
  27047. * @param modelShape particle ModelShape object
  27048. * @param shape shape vertex array
  27049. * @param meshInd shape indices array
  27050. * @param meshUV shape uv array
  27051. * @param meshCol shape color array
  27052. * @param meshNor shape normals array
  27053. * @param bbInfo shape bounding info
  27054. * @param storage target particle storage
  27055. * @options addShape() passed options
  27056. * @hidden
  27057. */
  27058. private _insertNewParticle;
  27059. /**
  27060. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27061. * This method calls `updateParticle()` for each particle of the SPS.
  27062. * For an animated SPS, it is usually called within the render loop.
  27063. * 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.
  27064. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27065. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27066. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27067. * @returns the SPS.
  27068. */
  27069. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27070. /**
  27071. * Disposes the SPS.
  27072. */
  27073. dispose(): void;
  27074. /**
  27075. * Returns a SolidParticle object from its identifier : particle.id
  27076. * @param id (integer) the particle Id
  27077. * @returns the searched particle or null if not found in the SPS.
  27078. */
  27079. getParticleById(id: number): Nullable<SolidParticle>;
  27080. /**
  27081. * Returns a new array populated with the particles having the passed shapeId.
  27082. * @param shapeId (integer) the shape identifier
  27083. * @returns a new solid particle array
  27084. */
  27085. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27086. /**
  27087. * Populates the passed array "ref" with the particles having the passed shapeId.
  27088. * @param shapeId the shape identifier
  27089. * @returns the SPS
  27090. * @param ref
  27091. */
  27092. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27093. /**
  27094. * Computes the required SubMeshes according the materials assigned to the particles.
  27095. * @returns the solid particle system.
  27096. * Does nothing if called before the SPS mesh is built.
  27097. */
  27098. computeSubMeshes(): SolidParticleSystem;
  27099. /**
  27100. * Sorts the solid particles by material when MultiMaterial is enabled.
  27101. * Updates the indices32 array.
  27102. * Updates the indicesByMaterial array.
  27103. * Updates the mesh indices array.
  27104. * @returns the SPS
  27105. * @hidden
  27106. */
  27107. private _sortParticlesByMaterial;
  27108. /**
  27109. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27110. * @hidden
  27111. */
  27112. private _setMaterialIndexesById;
  27113. /**
  27114. * Returns an array with unique values of Materials from the passed array
  27115. * @param array the material array to be checked and filtered
  27116. * @hidden
  27117. */
  27118. private _filterUniqueMaterialId;
  27119. /**
  27120. * Sets a new Standard Material as _defaultMaterial if not already set.
  27121. * @hidden
  27122. */
  27123. private _setDefaultMaterial;
  27124. /**
  27125. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27126. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27127. * @returns the SPS.
  27128. */
  27129. refreshVisibleSize(): SolidParticleSystem;
  27130. /**
  27131. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27132. * @param size the size (float) of the visibility box
  27133. * note : this doesn't lock the SPS mesh bounding box.
  27134. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27135. */
  27136. setVisibilityBox(size: number): void;
  27137. /**
  27138. * Gets whether the SPS as always visible or not
  27139. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27140. */
  27141. get isAlwaysVisible(): boolean;
  27142. /**
  27143. * Sets the SPS as always visible or not
  27144. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27145. */
  27146. set isAlwaysVisible(val: boolean);
  27147. /**
  27148. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27149. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27150. */
  27151. set isVisibilityBoxLocked(val: boolean);
  27152. /**
  27153. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27155. */
  27156. get isVisibilityBoxLocked(): boolean;
  27157. /**
  27158. * Tells to `setParticles()` to compute the particle rotations or not.
  27159. * Default value : true. The SPS is faster when it's set to false.
  27160. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27161. */
  27162. set computeParticleRotation(val: boolean);
  27163. /**
  27164. * Tells to `setParticles()` to compute the particle colors or not.
  27165. * Default value : true. The SPS is faster when it's set to false.
  27166. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27167. */
  27168. set computeParticleColor(val: boolean);
  27169. set computeParticleTexture(val: boolean);
  27170. /**
  27171. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27172. * Default value : false. The SPS is faster when it's set to false.
  27173. * Note : the particle custom vertex positions aren't stored values.
  27174. */
  27175. set computeParticleVertex(val: boolean);
  27176. /**
  27177. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27178. */
  27179. set computeBoundingBox(val: boolean);
  27180. /**
  27181. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27182. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27183. * Default : `true`
  27184. */
  27185. set depthSortParticles(val: boolean);
  27186. /**
  27187. * Gets if `setParticles()` computes the particle rotations or not.
  27188. * Default value : true. The SPS is faster when it's set to false.
  27189. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27190. */
  27191. get computeParticleRotation(): boolean;
  27192. /**
  27193. * Gets if `setParticles()` computes the particle colors or not.
  27194. * Default value : true. The SPS is faster when it's set to false.
  27195. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27196. */
  27197. get computeParticleColor(): boolean;
  27198. /**
  27199. * Gets if `setParticles()` computes the particle textures or not.
  27200. * Default value : true. The SPS is faster when it's set to false.
  27201. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27202. */
  27203. get computeParticleTexture(): boolean;
  27204. /**
  27205. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27206. * Default value : false. The SPS is faster when it's set to false.
  27207. * Note : the particle custom vertex positions aren't stored values.
  27208. */
  27209. get computeParticleVertex(): boolean;
  27210. /**
  27211. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27212. */
  27213. get computeBoundingBox(): boolean;
  27214. /**
  27215. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27216. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27217. * Default : `true`
  27218. */
  27219. get depthSortParticles(): boolean;
  27220. /**
  27221. * Gets if the SPS is created as expandable at construction time.
  27222. * Default : `false`
  27223. */
  27224. get expandable(): boolean;
  27225. /**
  27226. * Gets if the SPS supports the Multi Materials
  27227. */
  27228. get multimaterialEnabled(): boolean;
  27229. /**
  27230. * Gets if the SPS uses the model materials for its own multimaterial.
  27231. */
  27232. get useModelMaterial(): boolean;
  27233. /**
  27234. * The SPS used material array.
  27235. */
  27236. get materials(): Material[];
  27237. /**
  27238. * Sets the SPS MultiMaterial from the passed materials.
  27239. * Note : the passed array is internally copied and not used then by reference.
  27240. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27241. */
  27242. setMultiMaterial(materials: Material[]): void;
  27243. /**
  27244. * The SPS computed multimaterial object
  27245. */
  27246. get multimaterial(): MultiMaterial;
  27247. set multimaterial(mm: MultiMaterial);
  27248. /**
  27249. * If the subMeshes must be updated on the next call to setParticles()
  27250. */
  27251. get autoUpdateSubMeshes(): boolean;
  27252. set autoUpdateSubMeshes(val: boolean);
  27253. /**
  27254. * This function does nothing. It may be overwritten to set all the particle first values.
  27255. * The SPS doesn't call this function, you may have to call it by your own.
  27256. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27257. */
  27258. initParticles(): void;
  27259. /**
  27260. * This function does nothing. It may be overwritten to recycle a particle.
  27261. * The SPS doesn't call this function, you may have to call it by your own.
  27262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27263. * @param particle The particle to recycle
  27264. * @returns the recycled particle
  27265. */
  27266. recycleParticle(particle: SolidParticle): SolidParticle;
  27267. /**
  27268. * Updates a particle : this function should be overwritten by the user.
  27269. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27270. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27271. * @example : just set a particle position or velocity and recycle conditions
  27272. * @param particle The particle to update
  27273. * @returns the updated particle
  27274. */
  27275. updateParticle(particle: SolidParticle): SolidParticle;
  27276. /**
  27277. * Updates a vertex of a particle : it can be overwritten by the user.
  27278. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27279. * @param particle the current particle
  27280. * @param vertex the current index of the current particle
  27281. * @param pt the index of the current vertex in the particle shape
  27282. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27283. * @example : just set a vertex particle position
  27284. * @returns the updated vertex
  27285. */
  27286. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27287. /**
  27288. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27289. * This does nothing and may be overwritten by the user.
  27290. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27291. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27292. * @param update the boolean update value actually passed to setParticles()
  27293. */
  27294. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27295. /**
  27296. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27297. * This will be passed three parameters.
  27298. * This does nothing and may be overwritten by the user.
  27299. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27300. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27301. * @param update the boolean update value actually passed to setParticles()
  27302. */
  27303. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27304. }
  27305. }
  27306. declare module BABYLON {
  27307. /**
  27308. * Represents one particle of a solid particle system.
  27309. */
  27310. export class SolidParticle {
  27311. /**
  27312. * particle global index
  27313. */
  27314. idx: number;
  27315. /**
  27316. * particle identifier
  27317. */
  27318. id: number;
  27319. /**
  27320. * The color of the particle
  27321. */
  27322. color: Nullable<Color4>;
  27323. /**
  27324. * The world space position of the particle.
  27325. */
  27326. position: Vector3;
  27327. /**
  27328. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27329. */
  27330. rotation: Vector3;
  27331. /**
  27332. * The world space rotation quaternion of the particle.
  27333. */
  27334. rotationQuaternion: Nullable<Quaternion>;
  27335. /**
  27336. * The scaling of the particle.
  27337. */
  27338. scaling: Vector3;
  27339. /**
  27340. * The uvs of the particle.
  27341. */
  27342. uvs: Vector4;
  27343. /**
  27344. * The current speed of the particle.
  27345. */
  27346. velocity: Vector3;
  27347. /**
  27348. * The pivot point in the particle local space.
  27349. */
  27350. pivot: Vector3;
  27351. /**
  27352. * Must the particle be translated from its pivot point in its local space ?
  27353. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27354. * Default : false
  27355. */
  27356. translateFromPivot: boolean;
  27357. /**
  27358. * Is the particle active or not ?
  27359. */
  27360. alive: boolean;
  27361. /**
  27362. * Is the particle visible or not ?
  27363. */
  27364. isVisible: boolean;
  27365. /**
  27366. * Index of this particle in the global "positions" array (Internal use)
  27367. * @hidden
  27368. */
  27369. _pos: number;
  27370. /**
  27371. * @hidden Index of this particle in the global "indices" array (Internal use)
  27372. */
  27373. _ind: number;
  27374. /**
  27375. * @hidden ModelShape of this particle (Internal use)
  27376. */
  27377. _model: ModelShape;
  27378. /**
  27379. * ModelShape id of this particle
  27380. */
  27381. shapeId: number;
  27382. /**
  27383. * Index of the particle in its shape id
  27384. */
  27385. idxInShape: number;
  27386. /**
  27387. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27388. */
  27389. _modelBoundingInfo: BoundingInfo;
  27390. /**
  27391. * @hidden Particle BoundingInfo object (Internal use)
  27392. */
  27393. _boundingInfo: BoundingInfo;
  27394. /**
  27395. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27396. */
  27397. _sps: SolidParticleSystem;
  27398. /**
  27399. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27400. */
  27401. _stillInvisible: boolean;
  27402. /**
  27403. * @hidden Last computed particle rotation matrix
  27404. */
  27405. _rotationMatrix: number[];
  27406. /**
  27407. * Parent particle Id, if any.
  27408. * Default null.
  27409. */
  27410. parentId: Nullable<number>;
  27411. /**
  27412. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27413. */
  27414. materialIndex: Nullable<number>;
  27415. /**
  27416. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27417. * The possible values are :
  27418. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27419. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27420. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27421. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27422. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27423. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27424. * */
  27425. cullingStrategy: number;
  27426. /**
  27427. * @hidden Internal global position in the SPS.
  27428. */
  27429. _globalPosition: Vector3;
  27430. /**
  27431. * Creates a Solid Particle object.
  27432. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27433. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27434. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27435. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27436. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27437. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27438. * @param shapeId (integer) is the model shape identifier in the SPS.
  27439. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27440. * @param sps defines the sps it is associated to
  27441. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27442. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27443. */
  27444. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27445. /**
  27446. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27447. * @param target the particle target
  27448. * @returns the current particle
  27449. */
  27450. copyToRef(target: SolidParticle): SolidParticle;
  27451. /**
  27452. * Legacy support, changed scale to scaling
  27453. */
  27454. get scale(): Vector3;
  27455. /**
  27456. * Legacy support, changed scale to scaling
  27457. */
  27458. set scale(scale: Vector3);
  27459. /**
  27460. * Legacy support, changed quaternion to rotationQuaternion
  27461. */
  27462. get quaternion(): Nullable<Quaternion>;
  27463. /**
  27464. * Legacy support, changed quaternion to rotationQuaternion
  27465. */
  27466. set quaternion(q: Nullable<Quaternion>);
  27467. /**
  27468. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27469. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27470. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27471. * @returns true if it intersects
  27472. */
  27473. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27474. /**
  27475. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27476. * A particle is in the frustum if its bounding box intersects the frustum
  27477. * @param frustumPlanes defines the frustum to test
  27478. * @returns true if the particle is in the frustum planes
  27479. */
  27480. isInFrustum(frustumPlanes: Plane[]): boolean;
  27481. /**
  27482. * get the rotation matrix of the particle
  27483. * @hidden
  27484. */
  27485. getRotationMatrix(m: Matrix): void;
  27486. }
  27487. /**
  27488. * Represents the shape of the model used by one particle of a solid particle system.
  27489. * SPS internal tool, don't use it manually.
  27490. */
  27491. export class ModelShape {
  27492. /**
  27493. * The shape id
  27494. * @hidden
  27495. */
  27496. shapeID: number;
  27497. /**
  27498. * flat array of model positions (internal use)
  27499. * @hidden
  27500. */
  27501. _shape: Vector3[];
  27502. /**
  27503. * flat array of model UVs (internal use)
  27504. * @hidden
  27505. */
  27506. _shapeUV: number[];
  27507. /**
  27508. * color array of the model
  27509. * @hidden
  27510. */
  27511. _shapeColors: number[];
  27512. /**
  27513. * indices array of the model
  27514. * @hidden
  27515. */
  27516. _indices: number[];
  27517. /**
  27518. * normals array of the model
  27519. * @hidden
  27520. */
  27521. _normals: number[];
  27522. /**
  27523. * length of the shape in the model indices array (internal use)
  27524. * @hidden
  27525. */
  27526. _indicesLength: number;
  27527. /**
  27528. * Custom position function (internal use)
  27529. * @hidden
  27530. */
  27531. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27532. /**
  27533. * Custom vertex function (internal use)
  27534. * @hidden
  27535. */
  27536. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27537. /**
  27538. * Model material (internal use)
  27539. * @hidden
  27540. */
  27541. _material: Nullable<Material>;
  27542. /**
  27543. * 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.
  27544. * SPS internal tool, don't use it manually.
  27545. * @hidden
  27546. */
  27547. 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>);
  27548. }
  27549. /**
  27550. * Represents a Depth Sorted Particle in the solid particle system.
  27551. * @hidden
  27552. */
  27553. export class DepthSortedParticle {
  27554. /**
  27555. * Index of the particle in the "indices" array
  27556. */
  27557. ind: number;
  27558. /**
  27559. * Length of the particle shape in the "indices" array
  27560. */
  27561. indicesLength: number;
  27562. /**
  27563. * Squared distance from the particle to the camera
  27564. */
  27565. sqDistance: number;
  27566. /**
  27567. * Material index when used with MultiMaterials
  27568. */
  27569. materialIndex: number;
  27570. /**
  27571. * Creates a new sorted particle
  27572. * @param materialIndex
  27573. */
  27574. constructor(ind: number, indLength: number, materialIndex: number);
  27575. }
  27576. }
  27577. declare module BABYLON {
  27578. /**
  27579. * @hidden
  27580. */
  27581. export class _MeshCollisionData {
  27582. _checkCollisions: boolean;
  27583. _collisionMask: number;
  27584. _collisionGroup: number;
  27585. _collider: Nullable<Collider>;
  27586. _oldPositionForCollisions: Vector3;
  27587. _diffPositionForCollisions: Vector3;
  27588. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27589. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27590. }
  27591. }
  27592. declare module BABYLON {
  27593. /** @hidden */
  27594. class _FacetDataStorage {
  27595. facetPositions: Vector3[];
  27596. facetNormals: Vector3[];
  27597. facetPartitioning: number[][];
  27598. facetNb: number;
  27599. partitioningSubdivisions: number;
  27600. partitioningBBoxRatio: number;
  27601. facetDataEnabled: boolean;
  27602. facetParameters: any;
  27603. bbSize: Vector3;
  27604. subDiv: {
  27605. max: number;
  27606. X: number;
  27607. Y: number;
  27608. Z: number;
  27609. };
  27610. facetDepthSort: boolean;
  27611. facetDepthSortEnabled: boolean;
  27612. depthSortedIndices: IndicesArray;
  27613. depthSortedFacets: {
  27614. ind: number;
  27615. sqDistance: number;
  27616. }[];
  27617. facetDepthSortFunction: (f1: {
  27618. ind: number;
  27619. sqDistance: number;
  27620. }, f2: {
  27621. ind: number;
  27622. sqDistance: number;
  27623. }) => number;
  27624. facetDepthSortFrom: Vector3;
  27625. facetDepthSortOrigin: Vector3;
  27626. invertedMatrix: Matrix;
  27627. }
  27628. /**
  27629. * @hidden
  27630. **/
  27631. class _InternalAbstractMeshDataInfo {
  27632. _hasVertexAlpha: boolean;
  27633. _useVertexColors: boolean;
  27634. _numBoneInfluencers: number;
  27635. _applyFog: boolean;
  27636. _receiveShadows: boolean;
  27637. _facetData: _FacetDataStorage;
  27638. _visibility: number;
  27639. _skeleton: Nullable<Skeleton>;
  27640. _layerMask: number;
  27641. _computeBonesUsingShaders: boolean;
  27642. _isActive: boolean;
  27643. _onlyForInstances: boolean;
  27644. _isActiveIntermediate: boolean;
  27645. _onlyForInstancesIntermediate: boolean;
  27646. _actAsRegularMesh: boolean;
  27647. }
  27648. /**
  27649. * Class used to store all common mesh properties
  27650. */
  27651. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27652. /** No occlusion */
  27653. static OCCLUSION_TYPE_NONE: number;
  27654. /** Occlusion set to optimisitic */
  27655. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27656. /** Occlusion set to strict */
  27657. static OCCLUSION_TYPE_STRICT: number;
  27658. /** Use an accurante occlusion algorithm */
  27659. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27660. /** Use a conservative occlusion algorithm */
  27661. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27662. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27663. * Test order :
  27664. * Is the bounding sphere outside the frustum ?
  27665. * If not, are the bounding box vertices outside the frustum ?
  27666. * It not, then the cullable object is in the frustum.
  27667. */
  27668. static readonly CULLINGSTRATEGY_STANDARD: number;
  27669. /** Culling strategy : Bounding Sphere Only.
  27670. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27671. * It's also less accurate than the standard because some not visible objects can still be selected.
  27672. * Test : is the bounding sphere outside the frustum ?
  27673. * If not, then the cullable object is in the frustum.
  27674. */
  27675. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27676. /** Culling strategy : Optimistic Inclusion.
  27677. * This in an inclusion test first, then the standard exclusion test.
  27678. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27679. * 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.
  27680. * Anyway, it's as accurate as the standard strategy.
  27681. * Test :
  27682. * Is the cullable object bounding sphere center in the frustum ?
  27683. * If not, apply the default culling strategy.
  27684. */
  27685. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27686. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27687. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27688. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27689. * 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.
  27690. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27691. * Test :
  27692. * Is the cullable object bounding sphere center in the frustum ?
  27693. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27694. */
  27695. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27696. /**
  27697. * No billboard
  27698. */
  27699. static get BILLBOARDMODE_NONE(): number;
  27700. /** Billboard on X axis */
  27701. static get BILLBOARDMODE_X(): number;
  27702. /** Billboard on Y axis */
  27703. static get BILLBOARDMODE_Y(): number;
  27704. /** Billboard on Z axis */
  27705. static get BILLBOARDMODE_Z(): number;
  27706. /** Billboard on all axes */
  27707. static get BILLBOARDMODE_ALL(): number;
  27708. /** Billboard on using position instead of orientation */
  27709. static get BILLBOARDMODE_USE_POSITION(): number;
  27710. /** @hidden */
  27711. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27712. /**
  27713. * The culling strategy to use to check whether the mesh must be rendered or not.
  27714. * This value can be changed at any time and will be used on the next render mesh selection.
  27715. * The possible values are :
  27716. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27717. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27718. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27719. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27720. * Please read each static variable documentation to get details about the culling process.
  27721. * */
  27722. cullingStrategy: number;
  27723. /**
  27724. * Gets the number of facets in the mesh
  27725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27726. */
  27727. get facetNb(): number;
  27728. /**
  27729. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27731. */
  27732. get partitioningSubdivisions(): number;
  27733. set partitioningSubdivisions(nb: number);
  27734. /**
  27735. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27736. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27738. */
  27739. get partitioningBBoxRatio(): number;
  27740. set partitioningBBoxRatio(ratio: number);
  27741. /**
  27742. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27743. * Works only for updatable meshes.
  27744. * Doesn't work with multi-materials
  27745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27746. */
  27747. get mustDepthSortFacets(): boolean;
  27748. set mustDepthSortFacets(sort: boolean);
  27749. /**
  27750. * The location (Vector3) where the facet depth sort must be computed from.
  27751. * By default, the active camera position.
  27752. * Used only when facet depth sort is enabled
  27753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27754. */
  27755. get facetDepthSortFrom(): Vector3;
  27756. set facetDepthSortFrom(location: Vector3);
  27757. /**
  27758. * gets a boolean indicating if facetData is enabled
  27759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27760. */
  27761. get isFacetDataEnabled(): boolean;
  27762. /** @hidden */
  27763. _updateNonUniformScalingState(value: boolean): boolean;
  27764. /**
  27765. * An event triggered when this mesh collides with another one
  27766. */
  27767. onCollideObservable: Observable<AbstractMesh>;
  27768. /** Set a function to call when this mesh collides with another one */
  27769. set onCollide(callback: () => void);
  27770. /**
  27771. * An event triggered when the collision's position changes
  27772. */
  27773. onCollisionPositionChangeObservable: Observable<Vector3>;
  27774. /** Set a function to call when the collision's position changes */
  27775. set onCollisionPositionChange(callback: () => void);
  27776. /**
  27777. * An event triggered when material is changed
  27778. */
  27779. onMaterialChangedObservable: Observable<AbstractMesh>;
  27780. /**
  27781. * Gets or sets the orientation for POV movement & rotation
  27782. */
  27783. definedFacingForward: boolean;
  27784. /** @hidden */
  27785. _occlusionQuery: Nullable<WebGLQuery>;
  27786. /** @hidden */
  27787. _renderingGroup: Nullable<RenderingGroup>;
  27788. /**
  27789. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27790. */
  27791. get visibility(): number;
  27792. /**
  27793. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27794. */
  27795. set visibility(value: number);
  27796. /** Gets or sets the alpha index used to sort transparent meshes
  27797. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27798. */
  27799. alphaIndex: number;
  27800. /**
  27801. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27802. */
  27803. isVisible: boolean;
  27804. /**
  27805. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27806. */
  27807. isPickable: boolean;
  27808. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27809. showSubMeshesBoundingBox: boolean;
  27810. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27811. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27812. */
  27813. isBlocker: boolean;
  27814. /**
  27815. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27816. */
  27817. enablePointerMoveEvents: boolean;
  27818. /**
  27819. * Specifies the rendering group id for this mesh (0 by default)
  27820. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27821. */
  27822. renderingGroupId: number;
  27823. private _material;
  27824. /** Gets or sets current material */
  27825. get material(): Nullable<Material>;
  27826. set material(value: Nullable<Material>);
  27827. /**
  27828. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27829. * @see http://doc.babylonjs.com/babylon101/shadows
  27830. */
  27831. get receiveShadows(): boolean;
  27832. set receiveShadows(value: boolean);
  27833. /** Defines color to use when rendering outline */
  27834. outlineColor: Color3;
  27835. /** Define width to use when rendering outline */
  27836. outlineWidth: number;
  27837. /** Defines color to use when rendering overlay */
  27838. overlayColor: Color3;
  27839. /** Defines alpha to use when rendering overlay */
  27840. overlayAlpha: number;
  27841. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27842. get hasVertexAlpha(): boolean;
  27843. set hasVertexAlpha(value: boolean);
  27844. /** 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) */
  27845. get useVertexColors(): boolean;
  27846. set useVertexColors(value: boolean);
  27847. /**
  27848. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27849. */
  27850. get computeBonesUsingShaders(): boolean;
  27851. set computeBonesUsingShaders(value: boolean);
  27852. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27853. get numBoneInfluencers(): number;
  27854. set numBoneInfluencers(value: number);
  27855. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27856. get applyFog(): boolean;
  27857. set applyFog(value: boolean);
  27858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27859. useOctreeForRenderingSelection: boolean;
  27860. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27861. useOctreeForPicking: boolean;
  27862. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27863. useOctreeForCollisions: boolean;
  27864. /**
  27865. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27866. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27867. */
  27868. get layerMask(): number;
  27869. set layerMask(value: number);
  27870. /**
  27871. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27872. */
  27873. alwaysSelectAsActiveMesh: boolean;
  27874. /**
  27875. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27876. */
  27877. doNotSyncBoundingInfo: boolean;
  27878. /**
  27879. * Gets or sets the current action manager
  27880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27881. */
  27882. actionManager: Nullable<AbstractActionManager>;
  27883. private _meshCollisionData;
  27884. /**
  27885. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27887. */
  27888. ellipsoid: Vector3;
  27889. /**
  27890. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27891. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27892. */
  27893. ellipsoidOffset: Vector3;
  27894. /**
  27895. * Gets or sets a collision mask used to mask collisions (default is -1).
  27896. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27897. */
  27898. get collisionMask(): number;
  27899. set collisionMask(mask: number);
  27900. /**
  27901. * Gets or sets the current collision group mask (-1 by default).
  27902. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27903. */
  27904. get collisionGroup(): number;
  27905. set collisionGroup(mask: number);
  27906. /**
  27907. * Defines edge width used when edgesRenderer is enabled
  27908. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27909. */
  27910. edgesWidth: number;
  27911. /**
  27912. * Defines edge color used when edgesRenderer is enabled
  27913. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27914. */
  27915. edgesColor: Color4;
  27916. /** @hidden */
  27917. _edgesRenderer: Nullable<IEdgesRenderer>;
  27918. /** @hidden */
  27919. _masterMesh: Nullable<AbstractMesh>;
  27920. /** @hidden */
  27921. _boundingInfo: Nullable<BoundingInfo>;
  27922. /** @hidden */
  27923. _renderId: number;
  27924. /**
  27925. * Gets or sets the list of subMeshes
  27926. * @see http://doc.babylonjs.com/how_to/multi_materials
  27927. */
  27928. subMeshes: SubMesh[];
  27929. /** @hidden */
  27930. _intersectionsInProgress: AbstractMesh[];
  27931. /** @hidden */
  27932. _unIndexed: boolean;
  27933. /** @hidden */
  27934. _lightSources: Light[];
  27935. /** Gets the list of lights affecting that mesh */
  27936. get lightSources(): Light[];
  27937. /** @hidden */
  27938. get _positions(): Nullable<Vector3[]>;
  27939. /** @hidden */
  27940. _waitingData: {
  27941. lods: Nullable<any>;
  27942. actions: Nullable<any>;
  27943. freezeWorldMatrix: Nullable<boolean>;
  27944. };
  27945. /** @hidden */
  27946. _bonesTransformMatrices: Nullable<Float32Array>;
  27947. /** @hidden */
  27948. _transformMatrixTexture: Nullable<RawTexture>;
  27949. /**
  27950. * Gets or sets a skeleton to apply skining transformations
  27951. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27952. */
  27953. set skeleton(value: Nullable<Skeleton>);
  27954. get skeleton(): Nullable<Skeleton>;
  27955. /**
  27956. * An event triggered when the mesh is rebuilt.
  27957. */
  27958. onRebuildObservable: Observable<AbstractMesh>;
  27959. /**
  27960. * Creates a new AbstractMesh
  27961. * @param name defines the name of the mesh
  27962. * @param scene defines the hosting scene
  27963. */
  27964. constructor(name: string, scene?: Nullable<Scene>);
  27965. /**
  27966. * Returns the string "AbstractMesh"
  27967. * @returns "AbstractMesh"
  27968. */
  27969. getClassName(): string;
  27970. /**
  27971. * Gets a string representation of the current mesh
  27972. * @param fullDetails defines a boolean indicating if full details must be included
  27973. * @returns a string representation of the current mesh
  27974. */
  27975. toString(fullDetails?: boolean): string;
  27976. /**
  27977. * @hidden
  27978. */
  27979. protected _getEffectiveParent(): Nullable<Node>;
  27980. /** @hidden */
  27981. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27982. /** @hidden */
  27983. _rebuild(): void;
  27984. /** @hidden */
  27985. _resyncLightSources(): void;
  27986. /** @hidden */
  27987. _resyncLightSource(light: Light): void;
  27988. /** @hidden */
  27989. _unBindEffect(): void;
  27990. /** @hidden */
  27991. _removeLightSource(light: Light, dispose: boolean): void;
  27992. private _markSubMeshesAsDirty;
  27993. /** @hidden */
  27994. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27995. /** @hidden */
  27996. _markSubMeshesAsAttributesDirty(): void;
  27997. /** @hidden */
  27998. _markSubMeshesAsMiscDirty(): void;
  27999. /**
  28000. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28001. */
  28002. get scaling(): Vector3;
  28003. set scaling(newScaling: Vector3);
  28004. /**
  28005. * Returns true if the mesh is blocked. Implemented by child classes
  28006. */
  28007. get isBlocked(): boolean;
  28008. /**
  28009. * Returns the mesh itself by default. Implemented by child classes
  28010. * @param camera defines the camera to use to pick the right LOD level
  28011. * @returns the currentAbstractMesh
  28012. */
  28013. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28014. /**
  28015. * Returns 0 by default. Implemented by child classes
  28016. * @returns an integer
  28017. */
  28018. getTotalVertices(): number;
  28019. /**
  28020. * Returns a positive integer : the total number of indices in this mesh geometry.
  28021. * @returns the numner of indices or zero if the mesh has no geometry.
  28022. */
  28023. getTotalIndices(): number;
  28024. /**
  28025. * Returns null by default. Implemented by child classes
  28026. * @returns null
  28027. */
  28028. getIndices(): Nullable<IndicesArray>;
  28029. /**
  28030. * Returns the array of the requested vertex data kind. Implemented by child classes
  28031. * @param kind defines the vertex data kind to use
  28032. * @returns null
  28033. */
  28034. getVerticesData(kind: string): Nullable<FloatArray>;
  28035. /**
  28036. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28037. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28038. * Note that a new underlying VertexBuffer object is created each call.
  28039. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28040. * @param kind defines vertex data kind:
  28041. * * VertexBuffer.PositionKind
  28042. * * VertexBuffer.UVKind
  28043. * * VertexBuffer.UV2Kind
  28044. * * VertexBuffer.UV3Kind
  28045. * * VertexBuffer.UV4Kind
  28046. * * VertexBuffer.UV5Kind
  28047. * * VertexBuffer.UV6Kind
  28048. * * VertexBuffer.ColorKind
  28049. * * VertexBuffer.MatricesIndicesKind
  28050. * * VertexBuffer.MatricesIndicesExtraKind
  28051. * * VertexBuffer.MatricesWeightsKind
  28052. * * VertexBuffer.MatricesWeightsExtraKind
  28053. * @param data defines the data source
  28054. * @param updatable defines if the data must be flagged as updatable (or static)
  28055. * @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
  28056. * @returns the current mesh
  28057. */
  28058. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28059. /**
  28060. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28061. * If the mesh has no geometry, it is simply returned as it is.
  28062. * @param kind defines vertex data kind:
  28063. * * VertexBuffer.PositionKind
  28064. * * VertexBuffer.UVKind
  28065. * * VertexBuffer.UV2Kind
  28066. * * VertexBuffer.UV3Kind
  28067. * * VertexBuffer.UV4Kind
  28068. * * VertexBuffer.UV5Kind
  28069. * * VertexBuffer.UV6Kind
  28070. * * VertexBuffer.ColorKind
  28071. * * VertexBuffer.MatricesIndicesKind
  28072. * * VertexBuffer.MatricesIndicesExtraKind
  28073. * * VertexBuffer.MatricesWeightsKind
  28074. * * VertexBuffer.MatricesWeightsExtraKind
  28075. * @param data defines the data source
  28076. * @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
  28077. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28078. * @returns the current mesh
  28079. */
  28080. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28081. /**
  28082. * Sets the mesh indices,
  28083. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28084. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28085. * @param totalVertices Defines the total number of vertices
  28086. * @returns the current mesh
  28087. */
  28088. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28089. /**
  28090. * Gets a boolean indicating if specific vertex data is present
  28091. * @param kind defines the vertex data kind to use
  28092. * @returns true is data kind is present
  28093. */
  28094. isVerticesDataPresent(kind: string): boolean;
  28095. /**
  28096. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28097. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28098. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28099. * @returns a BoundingInfo
  28100. */
  28101. getBoundingInfo(): BoundingInfo;
  28102. /**
  28103. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28104. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28105. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28106. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28107. * @returns the current mesh
  28108. */
  28109. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28110. /**
  28111. * Overwrite the current bounding info
  28112. * @param boundingInfo defines the new bounding info
  28113. * @returns the current mesh
  28114. */
  28115. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28116. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28117. get useBones(): boolean;
  28118. /** @hidden */
  28119. _preActivate(): void;
  28120. /** @hidden */
  28121. _preActivateForIntermediateRendering(renderId: number): void;
  28122. /** @hidden */
  28123. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28124. /** @hidden */
  28125. _postActivate(): void;
  28126. /** @hidden */
  28127. _freeze(): void;
  28128. /** @hidden */
  28129. _unFreeze(): void;
  28130. /**
  28131. * Gets the current world matrix
  28132. * @returns a Matrix
  28133. */
  28134. getWorldMatrix(): Matrix;
  28135. /** @hidden */
  28136. _getWorldMatrixDeterminant(): number;
  28137. /**
  28138. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28139. */
  28140. get isAnInstance(): boolean;
  28141. /**
  28142. * Gets a boolean indicating if this mesh has instances
  28143. */
  28144. get hasInstances(): boolean;
  28145. /**
  28146. * Perform relative position change from the point of view of behind the front of the mesh.
  28147. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28148. * Supports definition of mesh facing forward or backward
  28149. * @param amountRight defines the distance on the right axis
  28150. * @param amountUp defines the distance on the up axis
  28151. * @param amountForward defines the distance on the forward axis
  28152. * @returns the current mesh
  28153. */
  28154. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28155. /**
  28156. * Calculate relative position change from the point of view of behind the front of the mesh.
  28157. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28158. * Supports definition of mesh facing forward or backward
  28159. * @param amountRight defines the distance on the right axis
  28160. * @param amountUp defines the distance on the up axis
  28161. * @param amountForward defines the distance on the forward axis
  28162. * @returns the new displacement vector
  28163. */
  28164. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28165. /**
  28166. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28167. * Supports definition of mesh facing forward or backward
  28168. * @param flipBack defines the flip
  28169. * @param twirlClockwise defines the twirl
  28170. * @param tiltRight defines the tilt
  28171. * @returns the current mesh
  28172. */
  28173. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28174. /**
  28175. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28176. * Supports definition of mesh facing forward or backward.
  28177. * @param flipBack defines the flip
  28178. * @param twirlClockwise defines the twirl
  28179. * @param tiltRight defines the tilt
  28180. * @returns the new rotation vector
  28181. */
  28182. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28183. /**
  28184. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28185. * This means the mesh underlying bounding box and sphere are recomputed.
  28186. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28187. * @returns the current mesh
  28188. */
  28189. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28190. /** @hidden */
  28191. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28192. /** @hidden */
  28193. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28194. /** @hidden */
  28195. _updateBoundingInfo(): AbstractMesh;
  28196. /** @hidden */
  28197. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28198. /** @hidden */
  28199. protected _afterComputeWorldMatrix(): void;
  28200. /** @hidden */
  28201. get _effectiveMesh(): AbstractMesh;
  28202. /**
  28203. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28204. * A mesh is in the frustum if its bounding box intersects the frustum
  28205. * @param frustumPlanes defines the frustum to test
  28206. * @returns true if the mesh is in the frustum planes
  28207. */
  28208. isInFrustum(frustumPlanes: Plane[]): boolean;
  28209. /**
  28210. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28211. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28212. * @param frustumPlanes defines the frustum to test
  28213. * @returns true if the mesh is completely in the frustum planes
  28214. */
  28215. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28216. /**
  28217. * True if the mesh intersects another mesh or a SolidParticle object
  28218. * @param mesh defines a target mesh or SolidParticle to test
  28219. * @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)
  28220. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28221. * @returns true if there is an intersection
  28222. */
  28223. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28224. /**
  28225. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28226. * @param point defines the point to test
  28227. * @returns true if there is an intersection
  28228. */
  28229. intersectsPoint(point: Vector3): boolean;
  28230. /**
  28231. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28232. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28233. */
  28234. get checkCollisions(): boolean;
  28235. set checkCollisions(collisionEnabled: boolean);
  28236. /**
  28237. * Gets Collider object used to compute collisions (not physics)
  28238. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28239. */
  28240. get collider(): Nullable<Collider>;
  28241. /**
  28242. * Move the mesh using collision engine
  28243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28244. * @param displacement defines the requested displacement vector
  28245. * @returns the current mesh
  28246. */
  28247. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28248. private _onCollisionPositionChange;
  28249. /** @hidden */
  28250. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28251. /** @hidden */
  28252. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28253. /** @hidden */
  28254. _checkCollision(collider: Collider): AbstractMesh;
  28255. /** @hidden */
  28256. _generatePointsArray(): boolean;
  28257. /**
  28258. * Checks if the passed Ray intersects with the mesh
  28259. * @param ray defines the ray to use
  28260. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28261. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28262. * @returns the picking info
  28263. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28264. */
  28265. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28266. /**
  28267. * Clones the current mesh
  28268. * @param name defines the mesh name
  28269. * @param newParent defines the new mesh parent
  28270. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28271. * @returns the new mesh
  28272. */
  28273. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28274. /**
  28275. * Disposes all the submeshes of the current meshnp
  28276. * @returns the current mesh
  28277. */
  28278. releaseSubMeshes(): AbstractMesh;
  28279. /**
  28280. * Releases resources associated with this abstract mesh.
  28281. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28282. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28283. */
  28284. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28285. /**
  28286. * Adds the passed mesh as a child to the current mesh
  28287. * @param mesh defines the child mesh
  28288. * @returns the current mesh
  28289. */
  28290. addChild(mesh: AbstractMesh): AbstractMesh;
  28291. /**
  28292. * Removes the passed mesh from the current mesh children list
  28293. * @param mesh defines the child mesh
  28294. * @returns the current mesh
  28295. */
  28296. removeChild(mesh: AbstractMesh): AbstractMesh;
  28297. /** @hidden */
  28298. private _initFacetData;
  28299. /**
  28300. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28301. * This method can be called within the render loop.
  28302. * 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
  28303. * @returns the current mesh
  28304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28305. */
  28306. updateFacetData(): AbstractMesh;
  28307. /**
  28308. * Returns the facetLocalNormals array.
  28309. * The normals are expressed in the mesh local spac
  28310. * @returns an array of Vector3
  28311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28312. */
  28313. getFacetLocalNormals(): Vector3[];
  28314. /**
  28315. * Returns the facetLocalPositions array.
  28316. * The facet positions are expressed in the mesh local space
  28317. * @returns an array of Vector3
  28318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28319. */
  28320. getFacetLocalPositions(): Vector3[];
  28321. /**
  28322. * Returns the facetLocalPartioning array
  28323. * @returns an array of array of numbers
  28324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28325. */
  28326. getFacetLocalPartitioning(): number[][];
  28327. /**
  28328. * Returns the i-th facet position in the world system.
  28329. * This method allocates a new Vector3 per call
  28330. * @param i defines the facet index
  28331. * @returns a new Vector3
  28332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28333. */
  28334. getFacetPosition(i: number): Vector3;
  28335. /**
  28336. * Sets the reference Vector3 with the i-th facet position in the world system
  28337. * @param i defines the facet index
  28338. * @param ref defines the target vector
  28339. * @returns the current mesh
  28340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28341. */
  28342. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28343. /**
  28344. * Returns the i-th facet normal in the world system.
  28345. * This method allocates a new Vector3 per call
  28346. * @param i defines the facet index
  28347. * @returns a new Vector3
  28348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28349. */
  28350. getFacetNormal(i: number): Vector3;
  28351. /**
  28352. * Sets the reference Vector3 with the i-th facet normal in the world system
  28353. * @param i defines the facet index
  28354. * @param ref defines the target vector
  28355. * @returns the current mesh
  28356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28357. */
  28358. getFacetNormalToRef(i: number, ref: Vector3): this;
  28359. /**
  28360. * 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)
  28361. * @param x defines x coordinate
  28362. * @param y defines y coordinate
  28363. * @param z defines z coordinate
  28364. * @returns the array of facet indexes
  28365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28366. */
  28367. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28368. /**
  28369. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28370. * @param projected sets as the (x,y,z) world projection on the facet
  28371. * @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
  28372. * @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
  28373. * @param x defines x coordinate
  28374. * @param y defines y coordinate
  28375. * @param z defines z coordinate
  28376. * @returns the face index if found (or null instead)
  28377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28378. */
  28379. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28380. /**
  28381. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28382. * @param projected sets as the (x,y,z) local projection on the facet
  28383. * @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
  28384. * @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
  28385. * @param x defines x coordinate
  28386. * @param y defines y coordinate
  28387. * @param z defines z coordinate
  28388. * @returns the face index if found (or null instead)
  28389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28390. */
  28391. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28392. /**
  28393. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28394. * @returns the parameters
  28395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28396. */
  28397. getFacetDataParameters(): any;
  28398. /**
  28399. * Disables the feature FacetData and frees the related memory
  28400. * @returns the current mesh
  28401. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28402. */
  28403. disableFacetData(): AbstractMesh;
  28404. /**
  28405. * Updates the AbstractMesh indices array
  28406. * @param indices defines the data source
  28407. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28408. * @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)
  28409. * @returns the current mesh
  28410. */
  28411. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28412. /**
  28413. * Creates new normals data for the mesh
  28414. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28415. * @returns the current mesh
  28416. */
  28417. createNormals(updatable: boolean): AbstractMesh;
  28418. /**
  28419. * Align the mesh with a normal
  28420. * @param normal defines the normal to use
  28421. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28422. * @returns the current mesh
  28423. */
  28424. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28425. /** @hidden */
  28426. _checkOcclusionQuery(): boolean;
  28427. /**
  28428. * Disables the mesh edge rendering mode
  28429. * @returns the currentAbstractMesh
  28430. */
  28431. disableEdgesRendering(): AbstractMesh;
  28432. /**
  28433. * Enables the edge rendering mode on the mesh.
  28434. * This mode makes the mesh edges visible
  28435. * @param epsilon defines the maximal distance between two angles to detect a face
  28436. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28437. * @returns the currentAbstractMesh
  28438. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28439. */
  28440. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28441. }
  28442. }
  28443. declare module BABYLON {
  28444. /**
  28445. * Interface used to define ActionEvent
  28446. */
  28447. export interface IActionEvent {
  28448. /** The mesh or sprite that triggered the action */
  28449. source: any;
  28450. /** The X mouse cursor position at the time of the event */
  28451. pointerX: number;
  28452. /** The Y mouse cursor position at the time of the event */
  28453. pointerY: number;
  28454. /** The mesh that is currently pointed at (can be null) */
  28455. meshUnderPointer: Nullable<AbstractMesh>;
  28456. /** the original (browser) event that triggered the ActionEvent */
  28457. sourceEvent?: any;
  28458. /** additional data for the event */
  28459. additionalData?: any;
  28460. }
  28461. /**
  28462. * ActionEvent is the event being sent when an action is triggered.
  28463. */
  28464. export class ActionEvent implements IActionEvent {
  28465. /** The mesh or sprite that triggered the action */
  28466. source: any;
  28467. /** The X mouse cursor position at the time of the event */
  28468. pointerX: number;
  28469. /** The Y mouse cursor position at the time of the event */
  28470. pointerY: number;
  28471. /** The mesh that is currently pointed at (can be null) */
  28472. meshUnderPointer: Nullable<AbstractMesh>;
  28473. /** the original (browser) event that triggered the ActionEvent */
  28474. sourceEvent?: any;
  28475. /** additional data for the event */
  28476. additionalData?: any;
  28477. /**
  28478. * Creates a new ActionEvent
  28479. * @param source The mesh or sprite that triggered the action
  28480. * @param pointerX The X mouse cursor position at the time of the event
  28481. * @param pointerY The Y mouse cursor position at the time of the event
  28482. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28483. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28484. * @param additionalData additional data for the event
  28485. */
  28486. constructor(
  28487. /** The mesh or sprite that triggered the action */
  28488. source: any,
  28489. /** The X mouse cursor position at the time of the event */
  28490. pointerX: number,
  28491. /** The Y mouse cursor position at the time of the event */
  28492. pointerY: number,
  28493. /** The mesh that is currently pointed at (can be null) */
  28494. meshUnderPointer: Nullable<AbstractMesh>,
  28495. /** the original (browser) event that triggered the ActionEvent */
  28496. sourceEvent?: any,
  28497. /** additional data for the event */
  28498. additionalData?: any);
  28499. /**
  28500. * Helper function to auto-create an ActionEvent from a source mesh.
  28501. * @param source The source mesh that triggered the event
  28502. * @param evt The original (browser) event
  28503. * @param additionalData additional data for the event
  28504. * @returns the new ActionEvent
  28505. */
  28506. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28507. /**
  28508. * Helper function to auto-create an ActionEvent from a source sprite
  28509. * @param source The source sprite that triggered the event
  28510. * @param scene Scene associated with the sprite
  28511. * @param evt The original (browser) event
  28512. * @param additionalData additional data for the event
  28513. * @returns the new ActionEvent
  28514. */
  28515. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28516. /**
  28517. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28518. * @param scene the scene where the event occurred
  28519. * @param evt The original (browser) event
  28520. * @returns the new ActionEvent
  28521. */
  28522. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28523. /**
  28524. * Helper function to auto-create an ActionEvent from a primitive
  28525. * @param prim defines the target primitive
  28526. * @param pointerPos defines the pointer position
  28527. * @param evt The original (browser) event
  28528. * @param additionalData additional data for the event
  28529. * @returns the new ActionEvent
  28530. */
  28531. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28532. }
  28533. }
  28534. declare module BABYLON {
  28535. /**
  28536. * Abstract class used to decouple action Manager from scene and meshes.
  28537. * Do not instantiate.
  28538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28539. */
  28540. export abstract class AbstractActionManager implements IDisposable {
  28541. /** Gets the list of active triggers */
  28542. static Triggers: {
  28543. [key: string]: number;
  28544. };
  28545. /** Gets the cursor to use when hovering items */
  28546. hoverCursor: string;
  28547. /** Gets the list of actions */
  28548. actions: IAction[];
  28549. /**
  28550. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28551. */
  28552. isRecursive: boolean;
  28553. /**
  28554. * Releases all associated resources
  28555. */
  28556. abstract dispose(): void;
  28557. /**
  28558. * Does this action manager has pointer triggers
  28559. */
  28560. abstract get hasPointerTriggers(): boolean;
  28561. /**
  28562. * Does this action manager has pick triggers
  28563. */
  28564. abstract get hasPickTriggers(): boolean;
  28565. /**
  28566. * Process a specific trigger
  28567. * @param trigger defines the trigger to process
  28568. * @param evt defines the event details to be processed
  28569. */
  28570. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28571. /**
  28572. * Does this action manager handles actions of any of the given triggers
  28573. * @param triggers defines the triggers to be tested
  28574. * @return a boolean indicating whether one (or more) of the triggers is handled
  28575. */
  28576. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28577. /**
  28578. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28579. * speed.
  28580. * @param triggerA defines the trigger to be tested
  28581. * @param triggerB defines the trigger to be tested
  28582. * @return a boolean indicating whether one (or more) of the triggers is handled
  28583. */
  28584. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28585. /**
  28586. * Does this action manager handles actions of a given trigger
  28587. * @param trigger defines the trigger to be tested
  28588. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28589. * @return whether the trigger is handled
  28590. */
  28591. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28592. /**
  28593. * Serialize this manager to a JSON object
  28594. * @param name defines the property name to store this manager
  28595. * @returns a JSON representation of this manager
  28596. */
  28597. abstract serialize(name: string): any;
  28598. /**
  28599. * Registers an action to this action manager
  28600. * @param action defines the action to be registered
  28601. * @return the action amended (prepared) after registration
  28602. */
  28603. abstract registerAction(action: IAction): Nullable<IAction>;
  28604. /**
  28605. * Unregisters an action to this action manager
  28606. * @param action defines the action to be unregistered
  28607. * @return a boolean indicating whether the action has been unregistered
  28608. */
  28609. abstract unregisterAction(action: IAction): Boolean;
  28610. /**
  28611. * Does exist one action manager with at least one trigger
  28612. **/
  28613. static get HasTriggers(): boolean;
  28614. /**
  28615. * Does exist one action manager with at least one pick trigger
  28616. **/
  28617. static get HasPickTriggers(): boolean;
  28618. /**
  28619. * Does exist one action manager that handles actions of a given trigger
  28620. * @param trigger defines the trigger to be tested
  28621. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28622. **/
  28623. static HasSpecificTrigger(trigger: number): boolean;
  28624. }
  28625. }
  28626. declare module BABYLON {
  28627. /**
  28628. * Defines how a node can be built from a string name.
  28629. */
  28630. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28631. /**
  28632. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28633. */
  28634. export class Node implements IBehaviorAware<Node> {
  28635. /** @hidden */
  28636. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28637. private static _NodeConstructors;
  28638. /**
  28639. * Add a new node constructor
  28640. * @param type defines the type name of the node to construct
  28641. * @param constructorFunc defines the constructor function
  28642. */
  28643. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28644. /**
  28645. * Returns a node constructor based on type name
  28646. * @param type defines the type name
  28647. * @param name defines the new node name
  28648. * @param scene defines the hosting scene
  28649. * @param options defines optional options to transmit to constructors
  28650. * @returns the new constructor or null
  28651. */
  28652. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28653. /**
  28654. * Gets or sets the name of the node
  28655. */
  28656. name: string;
  28657. /**
  28658. * Gets or sets the id of the node
  28659. */
  28660. id: string;
  28661. /**
  28662. * Gets or sets the unique id of the node
  28663. */
  28664. uniqueId: number;
  28665. /**
  28666. * Gets or sets a string used to store user defined state for the node
  28667. */
  28668. state: string;
  28669. /**
  28670. * Gets or sets an object used to store user defined information for the node
  28671. */
  28672. metadata: any;
  28673. /**
  28674. * For internal use only. Please do not use.
  28675. */
  28676. reservedDataStore: any;
  28677. /**
  28678. * List of inspectable custom properties (used by the Inspector)
  28679. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28680. */
  28681. inspectableCustomProperties: IInspectable[];
  28682. private _doNotSerialize;
  28683. /**
  28684. * Gets or sets a boolean used to define if the node must be serialized
  28685. */
  28686. get doNotSerialize(): boolean;
  28687. set doNotSerialize(value: boolean);
  28688. /** @hidden */
  28689. _isDisposed: boolean;
  28690. /**
  28691. * Gets a list of Animations associated with the node
  28692. */
  28693. animations: Animation[];
  28694. protected _ranges: {
  28695. [name: string]: Nullable<AnimationRange>;
  28696. };
  28697. /**
  28698. * Callback raised when the node is ready to be used
  28699. */
  28700. onReady: Nullable<(node: Node) => void>;
  28701. private _isEnabled;
  28702. private _isParentEnabled;
  28703. private _isReady;
  28704. /** @hidden */
  28705. _currentRenderId: number;
  28706. private _parentUpdateId;
  28707. /** @hidden */
  28708. _childUpdateId: number;
  28709. /** @hidden */
  28710. _waitingParentId: Nullable<string>;
  28711. /** @hidden */
  28712. _scene: Scene;
  28713. /** @hidden */
  28714. _cache: any;
  28715. private _parentNode;
  28716. private _children;
  28717. /** @hidden */
  28718. _worldMatrix: Matrix;
  28719. /** @hidden */
  28720. _worldMatrixDeterminant: number;
  28721. /** @hidden */
  28722. _worldMatrixDeterminantIsDirty: boolean;
  28723. /** @hidden */
  28724. private _sceneRootNodesIndex;
  28725. /**
  28726. * Gets a boolean indicating if the node has been disposed
  28727. * @returns true if the node was disposed
  28728. */
  28729. isDisposed(): boolean;
  28730. /**
  28731. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28732. * @see https://doc.babylonjs.com/how_to/parenting
  28733. */
  28734. set parent(parent: Nullable<Node>);
  28735. get parent(): Nullable<Node>;
  28736. /** @hidden */
  28737. _addToSceneRootNodes(): void;
  28738. /** @hidden */
  28739. _removeFromSceneRootNodes(): void;
  28740. private _animationPropertiesOverride;
  28741. /**
  28742. * Gets or sets the animation properties override
  28743. */
  28744. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28745. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28746. /**
  28747. * Gets a string idenfifying the name of the class
  28748. * @returns "Node" string
  28749. */
  28750. getClassName(): string;
  28751. /** @hidden */
  28752. readonly _isNode: boolean;
  28753. /**
  28754. * An event triggered when the mesh is disposed
  28755. */
  28756. onDisposeObservable: Observable<Node>;
  28757. private _onDisposeObserver;
  28758. /**
  28759. * Sets a callback that will be raised when the node will be disposed
  28760. */
  28761. set onDispose(callback: () => void);
  28762. /**
  28763. * Creates a new Node
  28764. * @param name the name and id to be given to this node
  28765. * @param scene the scene this node will be added to
  28766. */
  28767. constructor(name: string, scene?: Nullable<Scene>);
  28768. /**
  28769. * Gets the scene of the node
  28770. * @returns a scene
  28771. */
  28772. getScene(): Scene;
  28773. /**
  28774. * Gets the engine of the node
  28775. * @returns a Engine
  28776. */
  28777. getEngine(): Engine;
  28778. private _behaviors;
  28779. /**
  28780. * Attach a behavior to the node
  28781. * @see http://doc.babylonjs.com/features/behaviour
  28782. * @param behavior defines the behavior to attach
  28783. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28784. * @returns the current Node
  28785. */
  28786. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28787. /**
  28788. * Remove an attached behavior
  28789. * @see http://doc.babylonjs.com/features/behaviour
  28790. * @param behavior defines the behavior to attach
  28791. * @returns the current Node
  28792. */
  28793. removeBehavior(behavior: Behavior<Node>): Node;
  28794. /**
  28795. * Gets the list of attached behaviors
  28796. * @see http://doc.babylonjs.com/features/behaviour
  28797. */
  28798. get behaviors(): Behavior<Node>[];
  28799. /**
  28800. * Gets an attached behavior by name
  28801. * @param name defines the name of the behavior to look for
  28802. * @see http://doc.babylonjs.com/features/behaviour
  28803. * @returns null if behavior was not found else the requested behavior
  28804. */
  28805. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28806. /**
  28807. * Returns the latest update of the World matrix
  28808. * @returns a Matrix
  28809. */
  28810. getWorldMatrix(): Matrix;
  28811. /** @hidden */
  28812. _getWorldMatrixDeterminant(): number;
  28813. /**
  28814. * Returns directly the latest state of the mesh World matrix.
  28815. * A Matrix is returned.
  28816. */
  28817. get worldMatrixFromCache(): Matrix;
  28818. /** @hidden */
  28819. _initCache(): void;
  28820. /** @hidden */
  28821. updateCache(force?: boolean): void;
  28822. /** @hidden */
  28823. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28824. /** @hidden */
  28825. _updateCache(ignoreParentClass?: boolean): void;
  28826. /** @hidden */
  28827. _isSynchronized(): boolean;
  28828. /** @hidden */
  28829. _markSyncedWithParent(): void;
  28830. /** @hidden */
  28831. isSynchronizedWithParent(): boolean;
  28832. /** @hidden */
  28833. isSynchronized(): boolean;
  28834. /**
  28835. * Is this node ready to be used/rendered
  28836. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28837. * @return true if the node is ready
  28838. */
  28839. isReady(completeCheck?: boolean): boolean;
  28840. /**
  28841. * Is this node enabled?
  28842. * 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
  28843. * @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
  28844. * @return whether this node (and its parent) is enabled
  28845. */
  28846. isEnabled(checkAncestors?: boolean): boolean;
  28847. /** @hidden */
  28848. protected _syncParentEnabledState(): void;
  28849. /**
  28850. * Set the enabled state of this node
  28851. * @param value defines the new enabled state
  28852. */
  28853. setEnabled(value: boolean): void;
  28854. /**
  28855. * Is this node a descendant of the given node?
  28856. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28857. * @param ancestor defines the parent node to inspect
  28858. * @returns a boolean indicating if this node is a descendant of the given node
  28859. */
  28860. isDescendantOf(ancestor: Node): boolean;
  28861. /** @hidden */
  28862. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28863. /**
  28864. * Will return all nodes that have this node as ascendant
  28865. * @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
  28866. * @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
  28867. * @return all children nodes of all types
  28868. */
  28869. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28870. /**
  28871. * Get all child-meshes of this node
  28872. * @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)
  28873. * @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
  28874. * @returns an array of AbstractMesh
  28875. */
  28876. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28877. /**
  28878. * Get all direct children of this node
  28879. * @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
  28880. * @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)
  28881. * @returns an array of Node
  28882. */
  28883. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28884. /** @hidden */
  28885. _setReady(state: boolean): void;
  28886. /**
  28887. * Get an animation by name
  28888. * @param name defines the name of the animation to look for
  28889. * @returns null if not found else the requested animation
  28890. */
  28891. getAnimationByName(name: string): Nullable<Animation>;
  28892. /**
  28893. * Creates an animation range for this node
  28894. * @param name defines the name of the range
  28895. * @param from defines the starting key
  28896. * @param to defines the end key
  28897. */
  28898. createAnimationRange(name: string, from: number, to: number): void;
  28899. /**
  28900. * Delete a specific animation range
  28901. * @param name defines the name of the range to delete
  28902. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28903. */
  28904. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28905. /**
  28906. * Get an animation range by name
  28907. * @param name defines the name of the animation range to look for
  28908. * @returns null if not found else the requested animation range
  28909. */
  28910. getAnimationRange(name: string): Nullable<AnimationRange>;
  28911. /**
  28912. * Gets the list of all animation ranges defined on this node
  28913. * @returns an array
  28914. */
  28915. getAnimationRanges(): Nullable<AnimationRange>[];
  28916. /**
  28917. * Will start the animation sequence
  28918. * @param name defines the range frames for animation sequence
  28919. * @param loop defines if the animation should loop (false by default)
  28920. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28921. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28922. * @returns the object created for this animation. If range does not exist, it will return null
  28923. */
  28924. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28925. /**
  28926. * Serialize animation ranges into a JSON compatible object
  28927. * @returns serialization object
  28928. */
  28929. serializeAnimationRanges(): any;
  28930. /**
  28931. * Computes the world matrix of the node
  28932. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28933. * @returns the world matrix
  28934. */
  28935. computeWorldMatrix(force?: boolean): Matrix;
  28936. /**
  28937. * Releases resources associated with this node.
  28938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28940. */
  28941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28942. /**
  28943. * Parse animation range data from a serialization object and store them into a given node
  28944. * @param node defines where to store the animation ranges
  28945. * @param parsedNode defines the serialization object to read data from
  28946. * @param scene defines the hosting scene
  28947. */
  28948. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28949. /**
  28950. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28951. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28952. * @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
  28953. * @returns the new bounding vectors
  28954. */
  28955. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28956. min: Vector3;
  28957. max: Vector3;
  28958. };
  28959. }
  28960. }
  28961. declare module BABYLON {
  28962. /**
  28963. * @hidden
  28964. */
  28965. export class _IAnimationState {
  28966. key: number;
  28967. repeatCount: number;
  28968. workValue?: any;
  28969. loopMode?: number;
  28970. offsetValue?: any;
  28971. highLimitValue?: any;
  28972. }
  28973. /**
  28974. * Class used to store any kind of animation
  28975. */
  28976. export class Animation {
  28977. /**Name of the animation */
  28978. name: string;
  28979. /**Property to animate */
  28980. targetProperty: string;
  28981. /**The frames per second of the animation */
  28982. framePerSecond: number;
  28983. /**The data type of the animation */
  28984. dataType: number;
  28985. /**The loop mode of the animation */
  28986. loopMode?: number | undefined;
  28987. /**Specifies if blending should be enabled */
  28988. enableBlending?: boolean | undefined;
  28989. /**
  28990. * Use matrix interpolation instead of using direct key value when animating matrices
  28991. */
  28992. static AllowMatricesInterpolation: boolean;
  28993. /**
  28994. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28995. */
  28996. static AllowMatrixDecomposeForInterpolation: boolean;
  28997. /**
  28998. * Stores the key frames of the animation
  28999. */
  29000. private _keys;
  29001. /**
  29002. * Stores the easing function of the animation
  29003. */
  29004. private _easingFunction;
  29005. /**
  29006. * @hidden Internal use only
  29007. */
  29008. _runtimeAnimations: RuntimeAnimation[];
  29009. /**
  29010. * The set of event that will be linked to this animation
  29011. */
  29012. private _events;
  29013. /**
  29014. * Stores an array of target property paths
  29015. */
  29016. targetPropertyPath: string[];
  29017. /**
  29018. * Stores the blending speed of the animation
  29019. */
  29020. blendingSpeed: number;
  29021. /**
  29022. * Stores the animation ranges for the animation
  29023. */
  29024. private _ranges;
  29025. /**
  29026. * @hidden Internal use
  29027. */
  29028. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29029. /**
  29030. * Sets up an animation
  29031. * @param property The property to animate
  29032. * @param animationType The animation type to apply
  29033. * @param framePerSecond The frames per second of the animation
  29034. * @param easingFunction The easing function used in the animation
  29035. * @returns The created animation
  29036. */
  29037. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29038. /**
  29039. * Create and start an animation on a node
  29040. * @param name defines the name of the global animation that will be run on all nodes
  29041. * @param node defines the root node where the animation will take place
  29042. * @param targetProperty defines property to animate
  29043. * @param framePerSecond defines the number of frame per second yo use
  29044. * @param totalFrame defines the number of frames in total
  29045. * @param from defines the initial value
  29046. * @param to defines the final value
  29047. * @param loopMode defines which loop mode you want to use (off by default)
  29048. * @param easingFunction defines the easing function to use (linear by default)
  29049. * @param onAnimationEnd defines the callback to call when animation end
  29050. * @returns the animatable created for this animation
  29051. */
  29052. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29053. /**
  29054. * Create and start an animation on a node and its descendants
  29055. * @param name defines the name of the global animation that will be run on all nodes
  29056. * @param node defines the root node where the animation will take place
  29057. * @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
  29058. * @param targetProperty defines property to animate
  29059. * @param framePerSecond defines the number of frame per second to use
  29060. * @param totalFrame defines the number of frames in total
  29061. * @param from defines the initial value
  29062. * @param to defines the final value
  29063. * @param loopMode defines which loop mode you want to use (off by default)
  29064. * @param easingFunction defines the easing function to use (linear by default)
  29065. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29066. * @returns the list of animatables created for all nodes
  29067. * @example https://www.babylonjs-playground.com/#MH0VLI
  29068. */
  29069. 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[]>;
  29070. /**
  29071. * Creates a new animation, merges it with the existing animations and starts it
  29072. * @param name Name of the animation
  29073. * @param node Node which contains the scene that begins the animations
  29074. * @param targetProperty Specifies which property to animate
  29075. * @param framePerSecond The frames per second of the animation
  29076. * @param totalFrame The total number of frames
  29077. * @param from The frame at the beginning of the animation
  29078. * @param to The frame at the end of the animation
  29079. * @param loopMode Specifies the loop mode of the animation
  29080. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29081. * @param onAnimationEnd Callback to run once the animation is complete
  29082. * @returns Nullable animation
  29083. */
  29084. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29085. /**
  29086. * Transition property of an host to the target Value
  29087. * @param property The property to transition
  29088. * @param targetValue The target Value of the property
  29089. * @param host The object where the property to animate belongs
  29090. * @param scene Scene used to run the animation
  29091. * @param frameRate Framerate (in frame/s) to use
  29092. * @param transition The transition type we want to use
  29093. * @param duration The duration of the animation, in milliseconds
  29094. * @param onAnimationEnd Callback trigger at the end of the animation
  29095. * @returns Nullable animation
  29096. */
  29097. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29098. /**
  29099. * Return the array of runtime animations currently using this animation
  29100. */
  29101. get runtimeAnimations(): RuntimeAnimation[];
  29102. /**
  29103. * Specifies if any of the runtime animations are currently running
  29104. */
  29105. get hasRunningRuntimeAnimations(): boolean;
  29106. /**
  29107. * Initializes the animation
  29108. * @param name Name of the animation
  29109. * @param targetProperty Property to animate
  29110. * @param framePerSecond The frames per second of the animation
  29111. * @param dataType The data type of the animation
  29112. * @param loopMode The loop mode of the animation
  29113. * @param enableBlending Specifies if blending should be enabled
  29114. */
  29115. constructor(
  29116. /**Name of the animation */
  29117. name: string,
  29118. /**Property to animate */
  29119. targetProperty: string,
  29120. /**The frames per second of the animation */
  29121. framePerSecond: number,
  29122. /**The data type of the animation */
  29123. dataType: number,
  29124. /**The loop mode of the animation */
  29125. loopMode?: number | undefined,
  29126. /**Specifies if blending should be enabled */
  29127. enableBlending?: boolean | undefined);
  29128. /**
  29129. * Converts the animation to a string
  29130. * @param fullDetails support for multiple levels of logging within scene loading
  29131. * @returns String form of the animation
  29132. */
  29133. toString(fullDetails?: boolean): string;
  29134. /**
  29135. * Add an event to this animation
  29136. * @param event Event to add
  29137. */
  29138. addEvent(event: AnimationEvent): void;
  29139. /**
  29140. * Remove all events found at the given frame
  29141. * @param frame The frame to remove events from
  29142. */
  29143. removeEvents(frame: number): void;
  29144. /**
  29145. * Retrieves all the events from the animation
  29146. * @returns Events from the animation
  29147. */
  29148. getEvents(): AnimationEvent[];
  29149. /**
  29150. * Creates an animation range
  29151. * @param name Name of the animation range
  29152. * @param from Starting frame of the animation range
  29153. * @param to Ending frame of the animation
  29154. */
  29155. createRange(name: string, from: number, to: number): void;
  29156. /**
  29157. * Deletes an animation range by name
  29158. * @param name Name of the animation range to delete
  29159. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29160. */
  29161. deleteRange(name: string, deleteFrames?: boolean): void;
  29162. /**
  29163. * Gets the animation range by name, or null if not defined
  29164. * @param name Name of the animation range
  29165. * @returns Nullable animation range
  29166. */
  29167. getRange(name: string): Nullable<AnimationRange>;
  29168. /**
  29169. * Gets the key frames from the animation
  29170. * @returns The key frames of the animation
  29171. */
  29172. getKeys(): Array<IAnimationKey>;
  29173. /**
  29174. * Gets the highest frame rate of the animation
  29175. * @returns Highest frame rate of the animation
  29176. */
  29177. getHighestFrame(): number;
  29178. /**
  29179. * Gets the easing function of the animation
  29180. * @returns Easing function of the animation
  29181. */
  29182. getEasingFunction(): IEasingFunction;
  29183. /**
  29184. * Sets the easing function of the animation
  29185. * @param easingFunction A custom mathematical formula for animation
  29186. */
  29187. setEasingFunction(easingFunction: EasingFunction): void;
  29188. /**
  29189. * Interpolates a scalar linearly
  29190. * @param startValue Start value of the animation curve
  29191. * @param endValue End value of the animation curve
  29192. * @param gradient Scalar amount to interpolate
  29193. * @returns Interpolated scalar value
  29194. */
  29195. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29196. /**
  29197. * Interpolates a scalar cubically
  29198. * @param startValue Start value of the animation curve
  29199. * @param outTangent End tangent of the animation
  29200. * @param endValue End value of the animation curve
  29201. * @param inTangent Start tangent of the animation curve
  29202. * @param gradient Scalar amount to interpolate
  29203. * @returns Interpolated scalar value
  29204. */
  29205. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29206. /**
  29207. * Interpolates a quaternion using a spherical linear interpolation
  29208. * @param startValue Start value of the animation curve
  29209. * @param endValue End value of the animation curve
  29210. * @param gradient Scalar amount to interpolate
  29211. * @returns Interpolated quaternion value
  29212. */
  29213. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29214. /**
  29215. * Interpolates a quaternion cubically
  29216. * @param startValue Start value of the animation curve
  29217. * @param outTangent End tangent of the animation curve
  29218. * @param endValue End value of the animation curve
  29219. * @param inTangent Start tangent of the animation curve
  29220. * @param gradient Scalar amount to interpolate
  29221. * @returns Interpolated quaternion value
  29222. */
  29223. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29224. /**
  29225. * Interpolates a Vector3 linearl
  29226. * @param startValue Start value of the animation curve
  29227. * @param endValue End value of the animation curve
  29228. * @param gradient Scalar amount to interpolate
  29229. * @returns Interpolated scalar value
  29230. */
  29231. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29232. /**
  29233. * Interpolates a Vector3 cubically
  29234. * @param startValue Start value of the animation curve
  29235. * @param outTangent End tangent of the animation
  29236. * @param endValue End value of the animation curve
  29237. * @param inTangent Start tangent of the animation curve
  29238. * @param gradient Scalar amount to interpolate
  29239. * @returns InterpolatedVector3 value
  29240. */
  29241. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29242. /**
  29243. * Interpolates a Vector2 linearly
  29244. * @param startValue Start value of the animation curve
  29245. * @param endValue End value of the animation curve
  29246. * @param gradient Scalar amount to interpolate
  29247. * @returns Interpolated Vector2 value
  29248. */
  29249. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29250. /**
  29251. * Interpolates a Vector2 cubically
  29252. * @param startValue Start value of the animation curve
  29253. * @param outTangent End tangent of the animation
  29254. * @param endValue End value of the animation curve
  29255. * @param inTangent Start tangent of the animation curve
  29256. * @param gradient Scalar amount to interpolate
  29257. * @returns Interpolated Vector2 value
  29258. */
  29259. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29260. /**
  29261. * Interpolates a size linearly
  29262. * @param startValue Start value of the animation curve
  29263. * @param endValue End value of the animation curve
  29264. * @param gradient Scalar amount to interpolate
  29265. * @returns Interpolated Size value
  29266. */
  29267. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29268. /**
  29269. * Interpolates a Color3 linearly
  29270. * @param startValue Start value of the animation curve
  29271. * @param endValue End value of the animation curve
  29272. * @param gradient Scalar amount to interpolate
  29273. * @returns Interpolated Color3 value
  29274. */
  29275. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29276. /**
  29277. * Interpolates a Color4 linearly
  29278. * @param startValue Start value of the animation curve
  29279. * @param endValue End value of the animation curve
  29280. * @param gradient Scalar amount to interpolate
  29281. * @returns Interpolated Color3 value
  29282. */
  29283. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29284. /**
  29285. * @hidden Internal use only
  29286. */
  29287. _getKeyValue(value: any): any;
  29288. /**
  29289. * @hidden Internal use only
  29290. */
  29291. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29292. /**
  29293. * Defines the function to use to interpolate matrices
  29294. * @param startValue defines the start matrix
  29295. * @param endValue defines the end matrix
  29296. * @param gradient defines the gradient between both matrices
  29297. * @param result defines an optional target matrix where to store the interpolation
  29298. * @returns the interpolated matrix
  29299. */
  29300. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29301. /**
  29302. * Makes a copy of the animation
  29303. * @returns Cloned animation
  29304. */
  29305. clone(): Animation;
  29306. /**
  29307. * Sets the key frames of the animation
  29308. * @param values The animation key frames to set
  29309. */
  29310. setKeys(values: Array<IAnimationKey>): void;
  29311. /**
  29312. * Serializes the animation to an object
  29313. * @returns Serialized object
  29314. */
  29315. serialize(): any;
  29316. /**
  29317. * Float animation type
  29318. */
  29319. static readonly ANIMATIONTYPE_FLOAT: number;
  29320. /**
  29321. * Vector3 animation type
  29322. */
  29323. static readonly ANIMATIONTYPE_VECTOR3: number;
  29324. /**
  29325. * Quaternion animation type
  29326. */
  29327. static readonly ANIMATIONTYPE_QUATERNION: number;
  29328. /**
  29329. * Matrix animation type
  29330. */
  29331. static readonly ANIMATIONTYPE_MATRIX: number;
  29332. /**
  29333. * Color3 animation type
  29334. */
  29335. static readonly ANIMATIONTYPE_COLOR3: number;
  29336. /**
  29337. * Color3 animation type
  29338. */
  29339. static readonly ANIMATIONTYPE_COLOR4: number;
  29340. /**
  29341. * Vector2 animation type
  29342. */
  29343. static readonly ANIMATIONTYPE_VECTOR2: number;
  29344. /**
  29345. * Size animation type
  29346. */
  29347. static readonly ANIMATIONTYPE_SIZE: number;
  29348. /**
  29349. * Relative Loop Mode
  29350. */
  29351. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29352. /**
  29353. * Cycle Loop Mode
  29354. */
  29355. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29356. /**
  29357. * Constant Loop Mode
  29358. */
  29359. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29360. /** @hidden */
  29361. static _UniversalLerp(left: any, right: any, amount: number): any;
  29362. /**
  29363. * Parses an animation object and creates an animation
  29364. * @param parsedAnimation Parsed animation object
  29365. * @returns Animation object
  29366. */
  29367. static Parse(parsedAnimation: any): Animation;
  29368. /**
  29369. * Appends the serialized animations from the source animations
  29370. * @param source Source containing the animations
  29371. * @param destination Target to store the animations
  29372. */
  29373. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29374. }
  29375. }
  29376. declare module BABYLON {
  29377. /**
  29378. * Interface containing an array of animations
  29379. */
  29380. export interface IAnimatable {
  29381. /**
  29382. * Array of animations
  29383. */
  29384. animations: Nullable<Array<Animation>>;
  29385. }
  29386. }
  29387. declare module BABYLON {
  29388. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29389. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29390. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29391. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29392. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29393. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29394. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29395. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29396. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29397. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29398. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29399. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29400. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29401. /**
  29402. * Decorator used to define property that can be serialized as reference to a camera
  29403. * @param sourceName defines the name of the property to decorate
  29404. */
  29405. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29406. /**
  29407. * Class used to help serialization objects
  29408. */
  29409. export class SerializationHelper {
  29410. /** @hidden */
  29411. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29412. /** @hidden */
  29413. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29414. /** @hidden */
  29415. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29416. /** @hidden */
  29417. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29418. /**
  29419. * Appends the serialized animations from the source animations
  29420. * @param source Source containing the animations
  29421. * @param destination Target to store the animations
  29422. */
  29423. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29424. /**
  29425. * Static function used to serialized a specific entity
  29426. * @param entity defines the entity to serialize
  29427. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29428. * @returns a JSON compatible object representing the serialization of the entity
  29429. */
  29430. static Serialize<T>(entity: T, serializationObject?: any): any;
  29431. /**
  29432. * Creates a new entity from a serialization data object
  29433. * @param creationFunction defines a function used to instanciated the new entity
  29434. * @param source defines the source serialization data
  29435. * @param scene defines the hosting scene
  29436. * @param rootUrl defines the root url for resources
  29437. * @returns a new entity
  29438. */
  29439. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29440. /**
  29441. * Clones an object
  29442. * @param creationFunction defines the function used to instanciate the new object
  29443. * @param source defines the source object
  29444. * @returns the cloned object
  29445. */
  29446. static Clone<T>(creationFunction: () => T, source: T): T;
  29447. /**
  29448. * Instanciates a new object based on a source one (some data will be shared between both object)
  29449. * @param creationFunction defines the function used to instanciate the new object
  29450. * @param source defines the source object
  29451. * @returns the new object
  29452. */
  29453. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29454. }
  29455. }
  29456. declare module BABYLON {
  29457. /**
  29458. * Class used to manipulate GUIDs
  29459. */
  29460. export class GUID {
  29461. /**
  29462. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29463. * Be aware Math.random() could cause collisions, but:
  29464. * "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"
  29465. * @returns a pseudo random id
  29466. */
  29467. static RandomId(): string;
  29468. }
  29469. }
  29470. declare module BABYLON {
  29471. /**
  29472. * Base class of all the textures in babylon.
  29473. * It groups all the common properties the materials, post process, lights... might need
  29474. * in order to make a correct use of the texture.
  29475. */
  29476. export class BaseTexture implements IAnimatable {
  29477. /**
  29478. * Default anisotropic filtering level for the application.
  29479. * It is set to 4 as a good tradeoff between perf and quality.
  29480. */
  29481. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29482. /**
  29483. * Gets or sets the unique id of the texture
  29484. */
  29485. uniqueId: number;
  29486. /**
  29487. * Define the name of the texture.
  29488. */
  29489. name: string;
  29490. /**
  29491. * Gets or sets an object used to store user defined information.
  29492. */
  29493. metadata: any;
  29494. /**
  29495. * For internal use only. Please do not use.
  29496. */
  29497. reservedDataStore: any;
  29498. private _hasAlpha;
  29499. /**
  29500. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29501. */
  29502. set hasAlpha(value: boolean);
  29503. get hasAlpha(): boolean;
  29504. /**
  29505. * Defines if the alpha value should be determined via the rgb values.
  29506. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29507. */
  29508. getAlphaFromRGB: boolean;
  29509. /**
  29510. * Intensity or strength of the texture.
  29511. * It is commonly used by materials to fine tune the intensity of the texture
  29512. */
  29513. level: number;
  29514. /**
  29515. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29516. * This is part of the texture as textures usually maps to one uv set.
  29517. */
  29518. coordinatesIndex: number;
  29519. private _coordinatesMode;
  29520. /**
  29521. * How a texture is mapped.
  29522. *
  29523. * | Value | Type | Description |
  29524. * | ----- | ----------------------------------- | ----------- |
  29525. * | 0 | EXPLICIT_MODE | |
  29526. * | 1 | SPHERICAL_MODE | |
  29527. * | 2 | PLANAR_MODE | |
  29528. * | 3 | CUBIC_MODE | |
  29529. * | 4 | PROJECTION_MODE | |
  29530. * | 5 | SKYBOX_MODE | |
  29531. * | 6 | INVCUBIC_MODE | |
  29532. * | 7 | EQUIRECTANGULAR_MODE | |
  29533. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29534. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29535. */
  29536. set coordinatesMode(value: number);
  29537. get coordinatesMode(): number;
  29538. /**
  29539. * | Value | Type | Description |
  29540. * | ----- | ------------------ | ----------- |
  29541. * | 0 | CLAMP_ADDRESSMODE | |
  29542. * | 1 | WRAP_ADDRESSMODE | |
  29543. * | 2 | MIRROR_ADDRESSMODE | |
  29544. */
  29545. wrapU: number;
  29546. /**
  29547. * | Value | Type | Description |
  29548. * | ----- | ------------------ | ----------- |
  29549. * | 0 | CLAMP_ADDRESSMODE | |
  29550. * | 1 | WRAP_ADDRESSMODE | |
  29551. * | 2 | MIRROR_ADDRESSMODE | |
  29552. */
  29553. wrapV: number;
  29554. /**
  29555. * | Value | Type | Description |
  29556. * | ----- | ------------------ | ----------- |
  29557. * | 0 | CLAMP_ADDRESSMODE | |
  29558. * | 1 | WRAP_ADDRESSMODE | |
  29559. * | 2 | MIRROR_ADDRESSMODE | |
  29560. */
  29561. wrapR: number;
  29562. /**
  29563. * With compliant hardware and browser (supporting anisotropic filtering)
  29564. * this defines the level of anisotropic filtering in the texture.
  29565. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29566. */
  29567. anisotropicFilteringLevel: number;
  29568. /**
  29569. * Define if the texture is a cube texture or if false a 2d texture.
  29570. */
  29571. get isCube(): boolean;
  29572. set isCube(value: boolean);
  29573. /**
  29574. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29575. */
  29576. get is3D(): boolean;
  29577. set is3D(value: boolean);
  29578. /**
  29579. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29580. */
  29581. get is2DArray(): boolean;
  29582. set is2DArray(value: boolean);
  29583. /**
  29584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29585. * HDR texture are usually stored in linear space.
  29586. * This only impacts the PBR and Background materials
  29587. */
  29588. gammaSpace: boolean;
  29589. /**
  29590. * Gets or sets whether or not the texture contains RGBD data.
  29591. */
  29592. get isRGBD(): boolean;
  29593. set isRGBD(value: boolean);
  29594. /**
  29595. * Is Z inverted in the texture (useful in a cube texture).
  29596. */
  29597. invertZ: boolean;
  29598. /**
  29599. * Are mip maps generated for this texture or not.
  29600. */
  29601. get noMipmap(): boolean;
  29602. /**
  29603. * @hidden
  29604. */
  29605. lodLevelInAlpha: boolean;
  29606. /**
  29607. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29608. */
  29609. get lodGenerationOffset(): number;
  29610. set lodGenerationOffset(value: number);
  29611. /**
  29612. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29613. */
  29614. get lodGenerationScale(): number;
  29615. set lodGenerationScale(value: number);
  29616. /**
  29617. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29618. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29619. * average roughness values.
  29620. */
  29621. get linearSpecularLOD(): boolean;
  29622. set linearSpecularLOD(value: boolean);
  29623. /**
  29624. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29625. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29626. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29627. */
  29628. get irradianceTexture(): Nullable<BaseTexture>;
  29629. set irradianceTexture(value: Nullable<BaseTexture>);
  29630. /**
  29631. * Define if the texture is a render target.
  29632. */
  29633. isRenderTarget: boolean;
  29634. /**
  29635. * Define the unique id of the texture in the scene.
  29636. */
  29637. get uid(): string;
  29638. /**
  29639. * Return a string representation of the texture.
  29640. * @returns the texture as a string
  29641. */
  29642. toString(): string;
  29643. /**
  29644. * Get the class name of the texture.
  29645. * @returns "BaseTexture"
  29646. */
  29647. getClassName(): string;
  29648. /**
  29649. * Define the list of animation attached to the texture.
  29650. */
  29651. animations: Animation[];
  29652. /**
  29653. * An event triggered when the texture is disposed.
  29654. */
  29655. onDisposeObservable: Observable<BaseTexture>;
  29656. private _onDisposeObserver;
  29657. /**
  29658. * Callback triggered when the texture has been disposed.
  29659. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29660. */
  29661. set onDispose(callback: () => void);
  29662. /**
  29663. * Define the current state of the loading sequence when in delayed load mode.
  29664. */
  29665. delayLoadState: number;
  29666. private _scene;
  29667. /** @hidden */
  29668. _texture: Nullable<InternalTexture>;
  29669. private _uid;
  29670. /**
  29671. * Define if the texture is preventinga material to render or not.
  29672. * If not and the texture is not ready, the engine will use a default black texture instead.
  29673. */
  29674. get isBlocking(): boolean;
  29675. /**
  29676. * Instantiates a new BaseTexture.
  29677. * Base class of all the textures in babylon.
  29678. * It groups all the common properties the materials, post process, lights... might need
  29679. * in order to make a correct use of the texture.
  29680. * @param scene Define the scene the texture blongs to
  29681. */
  29682. constructor(scene: Nullable<Scene>);
  29683. /**
  29684. * Get the scene the texture belongs to.
  29685. * @returns the scene or null if undefined
  29686. */
  29687. getScene(): Nullable<Scene>;
  29688. /**
  29689. * Get the texture transform matrix used to offset tile the texture for istance.
  29690. * @returns the transformation matrix
  29691. */
  29692. getTextureMatrix(): Matrix;
  29693. /**
  29694. * Get the texture reflection matrix used to rotate/transform the reflection.
  29695. * @returns the reflection matrix
  29696. */
  29697. getReflectionTextureMatrix(): Matrix;
  29698. /**
  29699. * Get the underlying lower level texture from Babylon.
  29700. * @returns the insternal texture
  29701. */
  29702. getInternalTexture(): Nullable<InternalTexture>;
  29703. /**
  29704. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29705. * @returns true if ready or not blocking
  29706. */
  29707. isReadyOrNotBlocking(): boolean;
  29708. /**
  29709. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29710. * @returns true if fully ready
  29711. */
  29712. isReady(): boolean;
  29713. private _cachedSize;
  29714. /**
  29715. * Get the size of the texture.
  29716. * @returns the texture size.
  29717. */
  29718. getSize(): ISize;
  29719. /**
  29720. * Get the base size of the texture.
  29721. * It can be different from the size if the texture has been resized for POT for instance
  29722. * @returns the base size
  29723. */
  29724. getBaseSize(): ISize;
  29725. /**
  29726. * Update the sampling mode of the texture.
  29727. * Default is Trilinear mode.
  29728. *
  29729. * | Value | Type | Description |
  29730. * | ----- | ------------------ | ----------- |
  29731. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29732. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29733. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29734. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29735. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29736. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29737. * | 7 | NEAREST_LINEAR | |
  29738. * | 8 | NEAREST_NEAREST | |
  29739. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29740. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29741. * | 11 | LINEAR_LINEAR | |
  29742. * | 12 | LINEAR_NEAREST | |
  29743. *
  29744. * > _mag_: magnification filter (close to the viewer)
  29745. * > _min_: minification filter (far from the viewer)
  29746. * > _mip_: filter used between mip map levels
  29747. *@param samplingMode Define the new sampling mode of the texture
  29748. */
  29749. updateSamplingMode(samplingMode: number): void;
  29750. /**
  29751. * Scales the texture if is `canRescale()`
  29752. * @param ratio the resize factor we want to use to rescale
  29753. */
  29754. scale(ratio: number): void;
  29755. /**
  29756. * Get if the texture can rescale.
  29757. */
  29758. get canRescale(): boolean;
  29759. /** @hidden */
  29760. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29761. /** @hidden */
  29762. _rebuild(): void;
  29763. /**
  29764. * Triggers the load sequence in delayed load mode.
  29765. */
  29766. delayLoad(): void;
  29767. /**
  29768. * Clones the texture.
  29769. * @returns the cloned texture
  29770. */
  29771. clone(): Nullable<BaseTexture>;
  29772. /**
  29773. * Get the texture underlying type (INT, FLOAT...)
  29774. */
  29775. get textureType(): number;
  29776. /**
  29777. * Get the texture underlying format (RGB, RGBA...)
  29778. */
  29779. get textureFormat(): number;
  29780. /**
  29781. * Indicates that textures need to be re-calculated for all materials
  29782. */
  29783. protected _markAllSubMeshesAsTexturesDirty(): void;
  29784. /**
  29785. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29786. * This will returns an RGBA array buffer containing either in values (0-255) or
  29787. * float values (0-1) depending of the underlying buffer type.
  29788. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29789. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29790. * @param buffer defines a user defined buffer to fill with data (can be null)
  29791. * @returns The Array buffer containing the pixels data.
  29792. */
  29793. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29794. /**
  29795. * Release and destroy the underlying lower level texture aka internalTexture.
  29796. */
  29797. releaseInternalTexture(): void;
  29798. /** @hidden */
  29799. get _lodTextureHigh(): Nullable<BaseTexture>;
  29800. /** @hidden */
  29801. get _lodTextureMid(): Nullable<BaseTexture>;
  29802. /** @hidden */
  29803. get _lodTextureLow(): Nullable<BaseTexture>;
  29804. /**
  29805. * Dispose the texture and release its associated resources.
  29806. */
  29807. dispose(): void;
  29808. /**
  29809. * Serialize the texture into a JSON representation that can be parsed later on.
  29810. * @returns the JSON representation of the texture
  29811. */
  29812. serialize(): any;
  29813. /**
  29814. * Helper function to be called back once a list of texture contains only ready textures.
  29815. * @param textures Define the list of textures to wait for
  29816. * @param callback Define the callback triggered once the entire list will be ready
  29817. */
  29818. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29819. }
  29820. }
  29821. declare module BABYLON {
  29822. /**
  29823. * Options to be used when creating an effect.
  29824. */
  29825. export interface IEffectCreationOptions {
  29826. /**
  29827. * Atrributes that will be used in the shader.
  29828. */
  29829. attributes: string[];
  29830. /**
  29831. * Uniform varible names that will be set in the shader.
  29832. */
  29833. uniformsNames: string[];
  29834. /**
  29835. * Uniform buffer variable names that will be set in the shader.
  29836. */
  29837. uniformBuffersNames: string[];
  29838. /**
  29839. * Sampler texture variable names that will be set in the shader.
  29840. */
  29841. samplers: string[];
  29842. /**
  29843. * Define statements that will be set in the shader.
  29844. */
  29845. defines: any;
  29846. /**
  29847. * Possible fallbacks for this effect to improve performance when needed.
  29848. */
  29849. fallbacks: Nullable<IEffectFallbacks>;
  29850. /**
  29851. * Callback that will be called when the shader is compiled.
  29852. */
  29853. onCompiled: Nullable<(effect: Effect) => void>;
  29854. /**
  29855. * Callback that will be called if an error occurs during shader compilation.
  29856. */
  29857. onError: Nullable<(effect: Effect, errors: string) => void>;
  29858. /**
  29859. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29860. */
  29861. indexParameters?: any;
  29862. /**
  29863. * Max number of lights that can be used in the shader.
  29864. */
  29865. maxSimultaneousLights?: number;
  29866. /**
  29867. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29868. */
  29869. transformFeedbackVaryings?: Nullable<string[]>;
  29870. }
  29871. /**
  29872. * Effect containing vertex and fragment shader that can be executed on an object.
  29873. */
  29874. export class Effect implements IDisposable {
  29875. /**
  29876. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29877. */
  29878. static ShadersRepository: string;
  29879. /**
  29880. * Name of the effect.
  29881. */
  29882. name: any;
  29883. /**
  29884. * String container all the define statements that should be set on the shader.
  29885. */
  29886. defines: string;
  29887. /**
  29888. * Callback that will be called when the shader is compiled.
  29889. */
  29890. onCompiled: Nullable<(effect: Effect) => void>;
  29891. /**
  29892. * Callback that will be called if an error occurs during shader compilation.
  29893. */
  29894. onError: Nullable<(effect: Effect, errors: string) => void>;
  29895. /**
  29896. * Callback that will be called when effect is bound.
  29897. */
  29898. onBind: Nullable<(effect: Effect) => void>;
  29899. /**
  29900. * Unique ID of the effect.
  29901. */
  29902. uniqueId: number;
  29903. /**
  29904. * Observable that will be called when the shader is compiled.
  29905. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29906. */
  29907. onCompileObservable: Observable<Effect>;
  29908. /**
  29909. * Observable that will be called if an error occurs during shader compilation.
  29910. */
  29911. onErrorObservable: Observable<Effect>;
  29912. /** @hidden */
  29913. _onBindObservable: Nullable<Observable<Effect>>;
  29914. /**
  29915. * @hidden
  29916. * Specifies if the effect was previously ready
  29917. */
  29918. _wasPreviouslyReady: boolean;
  29919. /**
  29920. * Observable that will be called when effect is bound.
  29921. */
  29922. get onBindObservable(): Observable<Effect>;
  29923. /** @hidden */
  29924. _bonesComputationForcedToCPU: boolean;
  29925. private static _uniqueIdSeed;
  29926. private _engine;
  29927. private _uniformBuffersNames;
  29928. private _uniformsNames;
  29929. private _samplerList;
  29930. private _samplers;
  29931. private _isReady;
  29932. private _compilationError;
  29933. private _allFallbacksProcessed;
  29934. private _attributesNames;
  29935. private _attributes;
  29936. private _attributeLocationByName;
  29937. private _uniforms;
  29938. /**
  29939. * Key for the effect.
  29940. * @hidden
  29941. */
  29942. _key: string;
  29943. private _indexParameters;
  29944. private _fallbacks;
  29945. private _vertexSourceCode;
  29946. private _fragmentSourceCode;
  29947. private _vertexSourceCodeOverride;
  29948. private _fragmentSourceCodeOverride;
  29949. private _transformFeedbackVaryings;
  29950. /**
  29951. * Compiled shader to webGL program.
  29952. * @hidden
  29953. */
  29954. _pipelineContext: Nullable<IPipelineContext>;
  29955. private _valueCache;
  29956. private static _baseCache;
  29957. /**
  29958. * Instantiates an effect.
  29959. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29960. * @param baseName Name of the effect.
  29961. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29962. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29963. * @param samplers List of sampler variables that will be passed to the shader.
  29964. * @param engine Engine to be used to render the effect
  29965. * @param defines Define statements to be added to the shader.
  29966. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29967. * @param onCompiled Callback that will be called when the shader is compiled.
  29968. * @param onError Callback that will be called if an error occurs during shader compilation.
  29969. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29970. */
  29971. 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);
  29972. private _useFinalCode;
  29973. /**
  29974. * Unique key for this effect
  29975. */
  29976. get key(): string;
  29977. /**
  29978. * If the effect has been compiled and prepared.
  29979. * @returns if the effect is compiled and prepared.
  29980. */
  29981. isReady(): boolean;
  29982. private _isReadyInternal;
  29983. /**
  29984. * The engine the effect was initialized with.
  29985. * @returns the engine.
  29986. */
  29987. getEngine(): Engine;
  29988. /**
  29989. * The pipeline context for this effect
  29990. * @returns the associated pipeline context
  29991. */
  29992. getPipelineContext(): Nullable<IPipelineContext>;
  29993. /**
  29994. * The set of names of attribute variables for the shader.
  29995. * @returns An array of attribute names.
  29996. */
  29997. getAttributesNames(): string[];
  29998. /**
  29999. * Returns the attribute at the given index.
  30000. * @param index The index of the attribute.
  30001. * @returns The location of the attribute.
  30002. */
  30003. getAttributeLocation(index: number): number;
  30004. /**
  30005. * Returns the attribute based on the name of the variable.
  30006. * @param name of the attribute to look up.
  30007. * @returns the attribute location.
  30008. */
  30009. getAttributeLocationByName(name: string): number;
  30010. /**
  30011. * The number of attributes.
  30012. * @returns the numnber of attributes.
  30013. */
  30014. getAttributesCount(): number;
  30015. /**
  30016. * Gets the index of a uniform variable.
  30017. * @param uniformName of the uniform to look up.
  30018. * @returns the index.
  30019. */
  30020. getUniformIndex(uniformName: string): number;
  30021. /**
  30022. * Returns the attribute based on the name of the variable.
  30023. * @param uniformName of the uniform to look up.
  30024. * @returns the location of the uniform.
  30025. */
  30026. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30027. /**
  30028. * Returns an array of sampler variable names
  30029. * @returns The array of sampler variable neames.
  30030. */
  30031. getSamplers(): string[];
  30032. /**
  30033. * The error from the last compilation.
  30034. * @returns the error string.
  30035. */
  30036. getCompilationError(): string;
  30037. /**
  30038. * Gets a boolean indicating that all fallbacks were used during compilation
  30039. * @returns true if all fallbacks were used
  30040. */
  30041. allFallbacksProcessed(): boolean;
  30042. /**
  30043. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30044. * @param func The callback to be used.
  30045. */
  30046. executeWhenCompiled(func: (effect: Effect) => void): void;
  30047. private _checkIsReady;
  30048. private _loadShader;
  30049. /**
  30050. * Recompiles the webGL program
  30051. * @param vertexSourceCode The source code for the vertex shader.
  30052. * @param fragmentSourceCode The source code for the fragment shader.
  30053. * @param onCompiled Callback called when completed.
  30054. * @param onError Callback called on error.
  30055. * @hidden
  30056. */
  30057. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30058. /**
  30059. * Prepares the effect
  30060. * @hidden
  30061. */
  30062. _prepareEffect(): void;
  30063. private _processCompilationErrors;
  30064. /**
  30065. * Checks if the effect is supported. (Must be called after compilation)
  30066. */
  30067. get isSupported(): boolean;
  30068. /**
  30069. * Binds a texture to the engine to be used as output of the shader.
  30070. * @param channel Name of the output variable.
  30071. * @param texture Texture to bind.
  30072. * @hidden
  30073. */
  30074. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30075. /**
  30076. * Sets a texture on the engine to be used in the shader.
  30077. * @param channel Name of the sampler variable.
  30078. * @param texture Texture to set.
  30079. */
  30080. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30081. /**
  30082. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30083. * @param channel Name of the sampler variable.
  30084. * @param texture Texture to set.
  30085. */
  30086. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30087. /**
  30088. * Sets an array of textures on the engine to be used in the shader.
  30089. * @param channel Name of the variable.
  30090. * @param textures Textures to set.
  30091. */
  30092. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30093. /**
  30094. * 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)
  30095. * @param channel Name of the sampler variable.
  30096. * @param postProcess Post process to get the input texture from.
  30097. */
  30098. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30099. /**
  30100. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30101. * 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)
  30102. * @param channel Name of the sampler variable.
  30103. * @param postProcess Post process to get the output texture from.
  30104. */
  30105. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30106. /** @hidden */
  30107. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30108. /** @hidden */
  30109. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30110. /** @hidden */
  30111. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30112. /** @hidden */
  30113. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30114. /**
  30115. * Binds a buffer to a uniform.
  30116. * @param buffer Buffer to bind.
  30117. * @param name Name of the uniform variable to bind to.
  30118. */
  30119. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30120. /**
  30121. * Binds block to a uniform.
  30122. * @param blockName Name of the block to bind.
  30123. * @param index Index to bind.
  30124. */
  30125. bindUniformBlock(blockName: string, index: number): void;
  30126. /**
  30127. * Sets an interger value on a uniform variable.
  30128. * @param uniformName Name of the variable.
  30129. * @param value Value to be set.
  30130. * @returns this effect.
  30131. */
  30132. setInt(uniformName: string, value: number): Effect;
  30133. /**
  30134. * Sets an int array on a uniform variable.
  30135. * @param uniformName Name of the variable.
  30136. * @param array array to be set.
  30137. * @returns this effect.
  30138. */
  30139. setIntArray(uniformName: string, array: Int32Array): Effect;
  30140. /**
  30141. * 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)
  30142. * @param uniformName Name of the variable.
  30143. * @param array array to be set.
  30144. * @returns this effect.
  30145. */
  30146. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30147. /**
  30148. * 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)
  30149. * @param uniformName Name of the variable.
  30150. * @param array array to be set.
  30151. * @returns this effect.
  30152. */
  30153. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30154. /**
  30155. * 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)
  30156. * @param uniformName Name of the variable.
  30157. * @param array array to be set.
  30158. * @returns this effect.
  30159. */
  30160. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30161. /**
  30162. * Sets an float array on a uniform variable.
  30163. * @param uniformName Name of the variable.
  30164. * @param array array to be set.
  30165. * @returns this effect.
  30166. */
  30167. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30168. /**
  30169. * 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)
  30170. * @param uniformName Name of the variable.
  30171. * @param array array to be set.
  30172. * @returns this effect.
  30173. */
  30174. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30175. /**
  30176. * 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)
  30177. * @param uniformName Name of the variable.
  30178. * @param array array to be set.
  30179. * @returns this effect.
  30180. */
  30181. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30182. /**
  30183. * 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)
  30184. * @param uniformName Name of the variable.
  30185. * @param array array to be set.
  30186. * @returns this effect.
  30187. */
  30188. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30189. /**
  30190. * Sets an array on a uniform variable.
  30191. * @param uniformName Name of the variable.
  30192. * @param array array to be set.
  30193. * @returns this effect.
  30194. */
  30195. setArray(uniformName: string, array: number[]): Effect;
  30196. /**
  30197. * 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)
  30198. * @param uniformName Name of the variable.
  30199. * @param array array to be set.
  30200. * @returns this effect.
  30201. */
  30202. setArray2(uniformName: string, array: number[]): Effect;
  30203. /**
  30204. * 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)
  30205. * @param uniformName Name of the variable.
  30206. * @param array array to be set.
  30207. * @returns this effect.
  30208. */
  30209. setArray3(uniformName: string, array: number[]): Effect;
  30210. /**
  30211. * 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)
  30212. * @param uniformName Name of the variable.
  30213. * @param array array to be set.
  30214. * @returns this effect.
  30215. */
  30216. setArray4(uniformName: string, array: number[]): Effect;
  30217. /**
  30218. * Sets matrices on a uniform variable.
  30219. * @param uniformName Name of the variable.
  30220. * @param matrices matrices to be set.
  30221. * @returns this effect.
  30222. */
  30223. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30224. /**
  30225. * Sets matrix on a uniform variable.
  30226. * @param uniformName Name of the variable.
  30227. * @param matrix matrix to be set.
  30228. * @returns this effect.
  30229. */
  30230. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30231. /**
  30232. * 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)
  30233. * @param uniformName Name of the variable.
  30234. * @param matrix matrix to be set.
  30235. * @returns this effect.
  30236. */
  30237. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30238. /**
  30239. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30240. * @param uniformName Name of the variable.
  30241. * @param matrix matrix to be set.
  30242. * @returns this effect.
  30243. */
  30244. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30245. /**
  30246. * Sets a float on a uniform variable.
  30247. * @param uniformName Name of the variable.
  30248. * @param value value to be set.
  30249. * @returns this effect.
  30250. */
  30251. setFloat(uniformName: string, value: number): Effect;
  30252. /**
  30253. * Sets a boolean on a uniform variable.
  30254. * @param uniformName Name of the variable.
  30255. * @param bool value to be set.
  30256. * @returns this effect.
  30257. */
  30258. setBool(uniformName: string, bool: boolean): Effect;
  30259. /**
  30260. * Sets a Vector2 on a uniform variable.
  30261. * @param uniformName Name of the variable.
  30262. * @param vector2 vector2 to be set.
  30263. * @returns this effect.
  30264. */
  30265. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30266. /**
  30267. * Sets a float2 on a uniform variable.
  30268. * @param uniformName Name of the variable.
  30269. * @param x First float in float2.
  30270. * @param y Second float in float2.
  30271. * @returns this effect.
  30272. */
  30273. setFloat2(uniformName: string, x: number, y: number): Effect;
  30274. /**
  30275. * Sets a Vector3 on a uniform variable.
  30276. * @param uniformName Name of the variable.
  30277. * @param vector3 Value to be set.
  30278. * @returns this effect.
  30279. */
  30280. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30281. /**
  30282. * Sets a float3 on a uniform variable.
  30283. * @param uniformName Name of the variable.
  30284. * @param x First float in float3.
  30285. * @param y Second float in float3.
  30286. * @param z Third float in float3.
  30287. * @returns this effect.
  30288. */
  30289. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30290. /**
  30291. * Sets a Vector4 on a uniform variable.
  30292. * @param uniformName Name of the variable.
  30293. * @param vector4 Value to be set.
  30294. * @returns this effect.
  30295. */
  30296. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30297. /**
  30298. * Sets a float4 on a uniform variable.
  30299. * @param uniformName Name of the variable.
  30300. * @param x First float in float4.
  30301. * @param y Second float in float4.
  30302. * @param z Third float in float4.
  30303. * @param w Fourth float in float4.
  30304. * @returns this effect.
  30305. */
  30306. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30307. /**
  30308. * Sets a Color3 on a uniform variable.
  30309. * @param uniformName Name of the variable.
  30310. * @param color3 Value to be set.
  30311. * @returns this effect.
  30312. */
  30313. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30314. /**
  30315. * Sets a Color4 on a uniform variable.
  30316. * @param uniformName Name of the variable.
  30317. * @param color3 Value to be set.
  30318. * @param alpha Alpha value to be set.
  30319. * @returns this effect.
  30320. */
  30321. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30322. /**
  30323. * Sets a Color4 on a uniform variable
  30324. * @param uniformName defines the name of the variable
  30325. * @param color4 defines the value to be set
  30326. * @returns this effect.
  30327. */
  30328. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30329. /** Release all associated resources */
  30330. dispose(): void;
  30331. /**
  30332. * This function will add a new shader to the shader store
  30333. * @param name the name of the shader
  30334. * @param pixelShader optional pixel shader content
  30335. * @param vertexShader optional vertex shader content
  30336. */
  30337. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30338. /**
  30339. * Store of each shader (The can be looked up using effect.key)
  30340. */
  30341. static ShadersStore: {
  30342. [key: string]: string;
  30343. };
  30344. /**
  30345. * Store of each included file for a shader (The can be looked up using effect.key)
  30346. */
  30347. static IncludesShadersStore: {
  30348. [key: string]: string;
  30349. };
  30350. /**
  30351. * Resets the cache of effects.
  30352. */
  30353. static ResetCache(): void;
  30354. }
  30355. }
  30356. declare module BABYLON {
  30357. /**
  30358. * Interface used to describe the capabilities of the engine relatively to the current browser
  30359. */
  30360. export interface EngineCapabilities {
  30361. /** Maximum textures units per fragment shader */
  30362. maxTexturesImageUnits: number;
  30363. /** Maximum texture units per vertex shader */
  30364. maxVertexTextureImageUnits: number;
  30365. /** Maximum textures units in the entire pipeline */
  30366. maxCombinedTexturesImageUnits: number;
  30367. /** Maximum texture size */
  30368. maxTextureSize: number;
  30369. /** Maximum texture samples */
  30370. maxSamples?: number;
  30371. /** Maximum cube texture size */
  30372. maxCubemapTextureSize: number;
  30373. /** Maximum render texture size */
  30374. maxRenderTextureSize: number;
  30375. /** Maximum number of vertex attributes */
  30376. maxVertexAttribs: number;
  30377. /** Maximum number of varyings */
  30378. maxVaryingVectors: number;
  30379. /** Maximum number of uniforms per vertex shader */
  30380. maxVertexUniformVectors: number;
  30381. /** Maximum number of uniforms per fragment shader */
  30382. maxFragmentUniformVectors: number;
  30383. /** Defines if standard derivates (dx/dy) are supported */
  30384. standardDerivatives: boolean;
  30385. /** Defines if s3tc texture compression is supported */
  30386. s3tc?: WEBGL_compressed_texture_s3tc;
  30387. /** Defines if pvrtc texture compression is supported */
  30388. pvrtc: any;
  30389. /** Defines if etc1 texture compression is supported */
  30390. etc1: any;
  30391. /** Defines if etc2 texture compression is supported */
  30392. etc2: any;
  30393. /** Defines if astc texture compression is supported */
  30394. astc: any;
  30395. /** Defines if float textures are supported */
  30396. textureFloat: boolean;
  30397. /** Defines if vertex array objects are supported */
  30398. vertexArrayObject: boolean;
  30399. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30400. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30401. /** Gets the maximum level of anisotropy supported */
  30402. maxAnisotropy: number;
  30403. /** Defines if instancing is supported */
  30404. instancedArrays: boolean;
  30405. /** Defines if 32 bits indices are supported */
  30406. uintIndices: boolean;
  30407. /** Defines if high precision shaders are supported */
  30408. highPrecisionShaderSupported: boolean;
  30409. /** Defines if depth reading in the fragment shader is supported */
  30410. fragmentDepthSupported: boolean;
  30411. /** Defines if float texture linear filtering is supported*/
  30412. textureFloatLinearFiltering: boolean;
  30413. /** Defines if rendering to float textures is supported */
  30414. textureFloatRender: boolean;
  30415. /** Defines if half float textures are supported*/
  30416. textureHalfFloat: boolean;
  30417. /** Defines if half float texture linear filtering is supported*/
  30418. textureHalfFloatLinearFiltering: boolean;
  30419. /** Defines if rendering to half float textures is supported */
  30420. textureHalfFloatRender: boolean;
  30421. /** Defines if textureLOD shader command is supported */
  30422. textureLOD: boolean;
  30423. /** Defines if draw buffers extension is supported */
  30424. drawBuffersExtension: boolean;
  30425. /** Defines if depth textures are supported */
  30426. depthTextureExtension: boolean;
  30427. /** Defines if float color buffer are supported */
  30428. colorBufferFloat: boolean;
  30429. /** Gets disjoint timer query extension (null if not supported) */
  30430. timerQuery?: EXT_disjoint_timer_query;
  30431. /** Defines if timestamp can be used with timer query */
  30432. canUseTimestampForTimerQuery: boolean;
  30433. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30434. multiview?: any;
  30435. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30436. oculusMultiview?: any;
  30437. /** Function used to let the system compiles shaders in background */
  30438. parallelShaderCompile?: {
  30439. COMPLETION_STATUS_KHR: number;
  30440. };
  30441. /** Max number of texture samples for MSAA */
  30442. maxMSAASamples: number;
  30443. /** Defines if the blend min max extension is supported */
  30444. blendMinMax: boolean;
  30445. }
  30446. }
  30447. declare module BABYLON {
  30448. /**
  30449. * @hidden
  30450. **/
  30451. export class DepthCullingState {
  30452. private _isDepthTestDirty;
  30453. private _isDepthMaskDirty;
  30454. private _isDepthFuncDirty;
  30455. private _isCullFaceDirty;
  30456. private _isCullDirty;
  30457. private _isZOffsetDirty;
  30458. private _isFrontFaceDirty;
  30459. private _depthTest;
  30460. private _depthMask;
  30461. private _depthFunc;
  30462. private _cull;
  30463. private _cullFace;
  30464. private _zOffset;
  30465. private _frontFace;
  30466. /**
  30467. * Initializes the state.
  30468. */
  30469. constructor();
  30470. get isDirty(): boolean;
  30471. get zOffset(): number;
  30472. set zOffset(value: number);
  30473. get cullFace(): Nullable<number>;
  30474. set cullFace(value: Nullable<number>);
  30475. get cull(): Nullable<boolean>;
  30476. set cull(value: Nullable<boolean>);
  30477. get depthFunc(): Nullable<number>;
  30478. set depthFunc(value: Nullable<number>);
  30479. get depthMask(): boolean;
  30480. set depthMask(value: boolean);
  30481. get depthTest(): boolean;
  30482. set depthTest(value: boolean);
  30483. get frontFace(): Nullable<number>;
  30484. set frontFace(value: Nullable<number>);
  30485. reset(): void;
  30486. apply(gl: WebGLRenderingContext): void;
  30487. }
  30488. }
  30489. declare module BABYLON {
  30490. /**
  30491. * @hidden
  30492. **/
  30493. export class StencilState {
  30494. /** 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 */
  30495. static readonly ALWAYS: number;
  30496. /** Passed to stencilOperation to specify that stencil value must be kept */
  30497. static readonly KEEP: number;
  30498. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30499. static readonly REPLACE: number;
  30500. private _isStencilTestDirty;
  30501. private _isStencilMaskDirty;
  30502. private _isStencilFuncDirty;
  30503. private _isStencilOpDirty;
  30504. private _stencilTest;
  30505. private _stencilMask;
  30506. private _stencilFunc;
  30507. private _stencilFuncRef;
  30508. private _stencilFuncMask;
  30509. private _stencilOpStencilFail;
  30510. private _stencilOpDepthFail;
  30511. private _stencilOpStencilDepthPass;
  30512. get isDirty(): boolean;
  30513. get stencilFunc(): number;
  30514. set stencilFunc(value: number);
  30515. get stencilFuncRef(): number;
  30516. set stencilFuncRef(value: number);
  30517. get stencilFuncMask(): number;
  30518. set stencilFuncMask(value: number);
  30519. get stencilOpStencilFail(): number;
  30520. set stencilOpStencilFail(value: number);
  30521. get stencilOpDepthFail(): number;
  30522. set stencilOpDepthFail(value: number);
  30523. get stencilOpStencilDepthPass(): number;
  30524. set stencilOpStencilDepthPass(value: number);
  30525. get stencilMask(): number;
  30526. set stencilMask(value: number);
  30527. get stencilTest(): boolean;
  30528. set stencilTest(value: boolean);
  30529. constructor();
  30530. reset(): void;
  30531. apply(gl: WebGLRenderingContext): void;
  30532. }
  30533. }
  30534. declare module BABYLON {
  30535. /**
  30536. * @hidden
  30537. **/
  30538. export class AlphaState {
  30539. private _isAlphaBlendDirty;
  30540. private _isBlendFunctionParametersDirty;
  30541. private _isBlendEquationParametersDirty;
  30542. private _isBlendConstantsDirty;
  30543. private _alphaBlend;
  30544. private _blendFunctionParameters;
  30545. private _blendEquationParameters;
  30546. private _blendConstants;
  30547. /**
  30548. * Initializes the state.
  30549. */
  30550. constructor();
  30551. get isDirty(): boolean;
  30552. get alphaBlend(): boolean;
  30553. set alphaBlend(value: boolean);
  30554. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30555. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30556. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30557. reset(): void;
  30558. apply(gl: WebGLRenderingContext): void;
  30559. }
  30560. }
  30561. declare module BABYLON {
  30562. /** @hidden */
  30563. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30564. attributeProcessor(attribute: string): string;
  30565. varyingProcessor(varying: string, isFragment: boolean): string;
  30566. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30567. }
  30568. }
  30569. declare module BABYLON {
  30570. /**
  30571. * Interface for attribute information associated with buffer instanciation
  30572. */
  30573. export interface InstancingAttributeInfo {
  30574. /**
  30575. * Name of the GLSL attribute
  30576. * if attribute index is not specified, this is used to retrieve the index from the effect
  30577. */
  30578. attributeName: string;
  30579. /**
  30580. * Index/offset of the attribute in the vertex shader
  30581. * if not specified, this will be computes from the name.
  30582. */
  30583. index?: number;
  30584. /**
  30585. * size of the attribute, 1, 2, 3 or 4
  30586. */
  30587. attributeSize: number;
  30588. /**
  30589. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30590. */
  30591. offset: number;
  30592. /**
  30593. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30594. * default to 1
  30595. */
  30596. divisor?: number;
  30597. /**
  30598. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30599. * default is FLOAT
  30600. */
  30601. attributeType?: number;
  30602. /**
  30603. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30604. */
  30605. normalized?: boolean;
  30606. }
  30607. }
  30608. declare module BABYLON {
  30609. interface ThinEngine {
  30610. /**
  30611. * Update a video texture
  30612. * @param texture defines the texture to update
  30613. * @param video defines the video element to use
  30614. * @param invertY defines if data must be stored with Y axis inverted
  30615. */
  30616. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30617. }
  30618. }
  30619. declare module BABYLON {
  30620. /**
  30621. * Settings for finer control over video usage
  30622. */
  30623. export interface VideoTextureSettings {
  30624. /**
  30625. * Applies `autoplay` to video, if specified
  30626. */
  30627. autoPlay?: boolean;
  30628. /**
  30629. * Applies `loop` to video, if specified
  30630. */
  30631. loop?: boolean;
  30632. /**
  30633. * Automatically updates internal texture from video at every frame in the render loop
  30634. */
  30635. autoUpdateTexture: boolean;
  30636. /**
  30637. * Image src displayed during the video loading or until the user interacts with the video.
  30638. */
  30639. poster?: string;
  30640. }
  30641. /**
  30642. * If you want to display a video in your scene, this is the special texture for that.
  30643. * This special texture works similar to other textures, with the exception of a few parameters.
  30644. * @see https://doc.babylonjs.com/how_to/video_texture
  30645. */
  30646. export class VideoTexture extends Texture {
  30647. /**
  30648. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30649. */
  30650. readonly autoUpdateTexture: boolean;
  30651. /**
  30652. * The video instance used by the texture internally
  30653. */
  30654. readonly video: HTMLVideoElement;
  30655. private _onUserActionRequestedObservable;
  30656. /**
  30657. * Event triggerd when a dom action is required by the user to play the video.
  30658. * This happens due to recent changes in browser policies preventing video to auto start.
  30659. */
  30660. get onUserActionRequestedObservable(): Observable<Texture>;
  30661. private _generateMipMaps;
  30662. private _engine;
  30663. private _stillImageCaptured;
  30664. private _displayingPosterTexture;
  30665. private _settings;
  30666. private _createInternalTextureOnEvent;
  30667. private _frameId;
  30668. private _currentSrc;
  30669. /**
  30670. * Creates a video texture.
  30671. * If you want to display a video in your scene, this is the special texture for that.
  30672. * This special texture works similar to other textures, with the exception of a few parameters.
  30673. * @see https://doc.babylonjs.com/how_to/video_texture
  30674. * @param name optional name, will detect from video source, if not defined
  30675. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30676. * @param scene is obviously the current scene.
  30677. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30678. * @param invertY is false by default but can be used to invert video on Y axis
  30679. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30680. * @param settings allows finer control over video usage
  30681. */
  30682. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30683. private _getName;
  30684. private _getVideo;
  30685. private _createInternalTexture;
  30686. private reset;
  30687. /**
  30688. * @hidden Internal method to initiate `update`.
  30689. */
  30690. _rebuild(): void;
  30691. /**
  30692. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30693. */
  30694. update(): void;
  30695. /**
  30696. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30697. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30698. */
  30699. updateTexture(isVisible: boolean): void;
  30700. protected _updateInternalTexture: () => void;
  30701. /**
  30702. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30703. * @param url New url.
  30704. */
  30705. updateURL(url: string): void;
  30706. /**
  30707. * Clones the texture.
  30708. * @returns the cloned texture
  30709. */
  30710. clone(): VideoTexture;
  30711. /**
  30712. * Dispose the texture and release its associated resources.
  30713. */
  30714. dispose(): void;
  30715. /**
  30716. * Creates a video texture straight from a stream.
  30717. * @param scene Define the scene the texture should be created in
  30718. * @param stream Define the stream the texture should be created from
  30719. * @returns The created video texture as a promise
  30720. */
  30721. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30722. /**
  30723. * Creates a video texture straight from your WebCam video feed.
  30724. * @param scene Define the scene the texture should be created in
  30725. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30726. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30727. * @returns The created video texture as a promise
  30728. */
  30729. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30730. minWidth: number;
  30731. maxWidth: number;
  30732. minHeight: number;
  30733. maxHeight: number;
  30734. deviceId: string;
  30735. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30736. /**
  30737. * Creates a video texture straight from your WebCam video feed.
  30738. * @param scene Define the scene the texture should be created in
  30739. * @param onReady Define a callback to triggered once the texture will be ready
  30740. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30741. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30742. */
  30743. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30744. minWidth: number;
  30745. maxWidth: number;
  30746. minHeight: number;
  30747. maxHeight: number;
  30748. deviceId: string;
  30749. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30750. }
  30751. }
  30752. declare module BABYLON {
  30753. /**
  30754. * Defines the interface used by objects working like Scene
  30755. * @hidden
  30756. */
  30757. interface ISceneLike {
  30758. _addPendingData(data: any): void;
  30759. _removePendingData(data: any): void;
  30760. offlineProvider: IOfflineProvider;
  30761. }
  30762. /** Interface defining initialization parameters for Engine class */
  30763. export interface EngineOptions extends WebGLContextAttributes {
  30764. /**
  30765. * Defines if the engine should no exceed a specified device ratio
  30766. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30767. */
  30768. limitDeviceRatio?: number;
  30769. /**
  30770. * Defines if webvr should be enabled automatically
  30771. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30772. */
  30773. autoEnableWebVR?: boolean;
  30774. /**
  30775. * Defines if webgl2 should be turned off even if supported
  30776. * @see http://doc.babylonjs.com/features/webgl2
  30777. */
  30778. disableWebGL2Support?: boolean;
  30779. /**
  30780. * Defines if webaudio should be initialized as well
  30781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30782. */
  30783. audioEngine?: boolean;
  30784. /**
  30785. * Defines if animations should run using a deterministic lock step
  30786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30787. */
  30788. deterministicLockstep?: boolean;
  30789. /** Defines the maximum steps to use with deterministic lock step mode */
  30790. lockstepMaxSteps?: number;
  30791. /** Defines the seconds between each deterministic lock step */
  30792. timeStep?: number;
  30793. /**
  30794. * Defines that engine should ignore context lost events
  30795. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30796. */
  30797. doNotHandleContextLost?: boolean;
  30798. /**
  30799. * Defines that engine should ignore modifying touch action attribute and style
  30800. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30801. */
  30802. doNotHandleTouchAction?: boolean;
  30803. /**
  30804. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30805. */
  30806. useHighPrecisionFloats?: boolean;
  30807. }
  30808. /**
  30809. * The base engine class (root of all engines)
  30810. */
  30811. export class ThinEngine {
  30812. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30813. static ExceptionList: ({
  30814. key: string;
  30815. capture: string;
  30816. captureConstraint: number;
  30817. targets: string[];
  30818. } | {
  30819. key: string;
  30820. capture: null;
  30821. captureConstraint: null;
  30822. targets: string[];
  30823. })[];
  30824. /** @hidden */
  30825. static _TextureLoaders: IInternalTextureLoader[];
  30826. /**
  30827. * Returns the current npm package of the sdk
  30828. */
  30829. static get NpmPackage(): string;
  30830. /**
  30831. * Returns the current version of the framework
  30832. */
  30833. static get Version(): string;
  30834. /**
  30835. * Returns a string describing the current engine
  30836. */
  30837. get description(): string;
  30838. /**
  30839. * Gets or sets the epsilon value used by collision engine
  30840. */
  30841. static CollisionsEpsilon: number;
  30842. /**
  30843. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30844. */
  30845. static get ShadersRepository(): string;
  30846. static set ShadersRepository(value: string);
  30847. /**
  30848. * Gets or sets the textures that the engine should not attempt to load as compressed
  30849. */
  30850. protected _excludedCompressedTextures: string[];
  30851. /**
  30852. * Filters the compressed texture formats to only include
  30853. * files that are not included in the skippable list
  30854. *
  30855. * @param url the current extension
  30856. * @param textureFormatInUse the current compressed texture format
  30857. * @returns "format" string
  30858. */
  30859. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30860. /** @hidden */
  30861. _shaderProcessor: IShaderProcessor;
  30862. /**
  30863. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30864. */
  30865. forcePOTTextures: boolean;
  30866. /**
  30867. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30868. */
  30869. isFullscreen: boolean;
  30870. /**
  30871. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30872. */
  30873. cullBackFaces: boolean;
  30874. /**
  30875. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30876. */
  30877. renderEvenInBackground: boolean;
  30878. /**
  30879. * Gets or sets a boolean indicating that cache can be kept between frames
  30880. */
  30881. preventCacheWipeBetweenFrames: boolean;
  30882. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30883. validateShaderPrograms: boolean;
  30884. /**
  30885. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30886. * This can provide greater z depth for distant objects.
  30887. */
  30888. useReverseDepthBuffer: boolean;
  30889. /**
  30890. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30891. */
  30892. disableUniformBuffers: boolean;
  30893. /** @hidden */
  30894. _uniformBuffers: UniformBuffer[];
  30895. /**
  30896. * Gets a boolean indicating that the engine supports uniform buffers
  30897. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30898. */
  30899. get supportsUniformBuffers(): boolean;
  30900. /** @hidden */
  30901. _gl: WebGLRenderingContext;
  30902. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30903. protected _windowIsBackground: boolean;
  30904. protected _webGLVersion: number;
  30905. protected _creationOptions: EngineOptions;
  30906. protected _highPrecisionShadersAllowed: boolean;
  30907. /** @hidden */
  30908. get _shouldUseHighPrecisionShader(): boolean;
  30909. /**
  30910. * Gets a boolean indicating that only power of 2 textures are supported
  30911. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30912. */
  30913. get needPOTTextures(): boolean;
  30914. /** @hidden */
  30915. _badOS: boolean;
  30916. /** @hidden */
  30917. _badDesktopOS: boolean;
  30918. private _hardwareScalingLevel;
  30919. /** @hidden */
  30920. _caps: EngineCapabilities;
  30921. private _isStencilEnable;
  30922. private _glVersion;
  30923. private _glRenderer;
  30924. private _glVendor;
  30925. /** @hidden */
  30926. _videoTextureSupported: boolean;
  30927. protected _renderingQueueLaunched: boolean;
  30928. protected _activeRenderLoops: (() => void)[];
  30929. /**
  30930. * Observable signaled when a context lost event is raised
  30931. */
  30932. onContextLostObservable: Observable<ThinEngine>;
  30933. /**
  30934. * Observable signaled when a context restored event is raised
  30935. */
  30936. onContextRestoredObservable: Observable<ThinEngine>;
  30937. private _onContextLost;
  30938. private _onContextRestored;
  30939. protected _contextWasLost: boolean;
  30940. /** @hidden */
  30941. _doNotHandleContextLost: boolean;
  30942. /**
  30943. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30945. */
  30946. get doNotHandleContextLost(): boolean;
  30947. set doNotHandleContextLost(value: boolean);
  30948. /**
  30949. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30950. */
  30951. disableVertexArrayObjects: boolean;
  30952. /** @hidden */
  30953. protected _colorWrite: boolean;
  30954. /** @hidden */
  30955. protected _colorWriteChanged: boolean;
  30956. /** @hidden */
  30957. protected _depthCullingState: DepthCullingState;
  30958. /** @hidden */
  30959. protected _stencilState: StencilState;
  30960. /** @hidden */
  30961. _alphaState: AlphaState;
  30962. /** @hidden */
  30963. _alphaMode: number;
  30964. /** @hidden */
  30965. _alphaEquation: number;
  30966. /** @hidden */
  30967. _internalTexturesCache: InternalTexture[];
  30968. /** @hidden */
  30969. protected _activeChannel: number;
  30970. private _currentTextureChannel;
  30971. /** @hidden */
  30972. protected _boundTexturesCache: {
  30973. [key: string]: Nullable<InternalTexture>;
  30974. };
  30975. /** @hidden */
  30976. protected _currentEffect: Nullable<Effect>;
  30977. /** @hidden */
  30978. protected _currentProgram: Nullable<WebGLProgram>;
  30979. private _compiledEffects;
  30980. private _vertexAttribArraysEnabled;
  30981. /** @hidden */
  30982. protected _cachedViewport: Nullable<IViewportLike>;
  30983. private _cachedVertexArrayObject;
  30984. /** @hidden */
  30985. protected _cachedVertexBuffers: any;
  30986. /** @hidden */
  30987. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30988. /** @hidden */
  30989. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30990. /** @hidden */
  30991. _currentRenderTarget: Nullable<InternalTexture>;
  30992. private _uintIndicesCurrentlySet;
  30993. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30994. /** @hidden */
  30995. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30996. private _currentBufferPointers;
  30997. private _currentInstanceLocations;
  30998. private _currentInstanceBuffers;
  30999. private _textureUnits;
  31000. /** @hidden */
  31001. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31002. /** @hidden */
  31003. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31004. /** @hidden */
  31005. _boundRenderFunction: any;
  31006. private _vaoRecordInProgress;
  31007. private _mustWipeVertexAttributes;
  31008. private _emptyTexture;
  31009. private _emptyCubeTexture;
  31010. private _emptyTexture3D;
  31011. private _emptyTexture2DArray;
  31012. /** @hidden */
  31013. _frameHandler: number;
  31014. private _nextFreeTextureSlots;
  31015. private _maxSimultaneousTextures;
  31016. private _activeRequests;
  31017. protected _texturesSupported: string[];
  31018. /** @hidden */
  31019. _textureFormatInUse: Nullable<string>;
  31020. protected get _supportsHardwareTextureRescaling(): boolean;
  31021. /**
  31022. * Gets the list of texture formats supported
  31023. */
  31024. get texturesSupported(): Array<string>;
  31025. /**
  31026. * Gets the list of texture formats in use
  31027. */
  31028. get textureFormatInUse(): Nullable<string>;
  31029. /**
  31030. * Gets the current viewport
  31031. */
  31032. get currentViewport(): Nullable<IViewportLike>;
  31033. /**
  31034. * Gets the default empty texture
  31035. */
  31036. get emptyTexture(): InternalTexture;
  31037. /**
  31038. * Gets the default empty 3D texture
  31039. */
  31040. get emptyTexture3D(): InternalTexture;
  31041. /**
  31042. * Gets the default empty 2D array texture
  31043. */
  31044. get emptyTexture2DArray(): InternalTexture;
  31045. /**
  31046. * Gets the default empty cube texture
  31047. */
  31048. get emptyCubeTexture(): InternalTexture;
  31049. /**
  31050. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31051. */
  31052. readonly premultipliedAlpha: boolean;
  31053. /**
  31054. * Observable event triggered before each texture is initialized
  31055. */
  31056. onBeforeTextureInitObservable: Observable<Texture>;
  31057. /**
  31058. * Creates a new engine
  31059. * @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
  31060. * @param antialias defines enable antialiasing (default: false)
  31061. * @param options defines further options to be sent to the getContext() function
  31062. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31063. */
  31064. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31065. private _rebuildInternalTextures;
  31066. private _rebuildEffects;
  31067. /**
  31068. * Gets a boolean indicating if all created effects are ready
  31069. * @returns true if all effects are ready
  31070. */
  31071. areAllEffectsReady(): boolean;
  31072. protected _rebuildBuffers(): void;
  31073. private _initGLContext;
  31074. /**
  31075. * Gets version of the current webGL context
  31076. */
  31077. get webGLVersion(): number;
  31078. /**
  31079. * Gets a string idenfifying the name of the class
  31080. * @returns "Engine" string
  31081. */
  31082. getClassName(): string;
  31083. /**
  31084. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31085. */
  31086. get isStencilEnable(): boolean;
  31087. /** @hidden */
  31088. _prepareWorkingCanvas(): void;
  31089. /**
  31090. * Reset the texture cache to empty state
  31091. */
  31092. resetTextureCache(): void;
  31093. /**
  31094. * Gets an object containing information about the current webGL context
  31095. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31096. */
  31097. getGlInfo(): {
  31098. vendor: string;
  31099. renderer: string;
  31100. version: string;
  31101. };
  31102. /**
  31103. * Defines the hardware scaling level.
  31104. * By default the hardware scaling level is computed from the window device ratio.
  31105. * 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.
  31106. * @param level defines the level to use
  31107. */
  31108. setHardwareScalingLevel(level: number): void;
  31109. /**
  31110. * Gets the current hardware scaling level.
  31111. * By default the hardware scaling level is computed from the window device ratio.
  31112. * 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.
  31113. * @returns a number indicating the current hardware scaling level
  31114. */
  31115. getHardwareScalingLevel(): number;
  31116. /**
  31117. * Gets the list of loaded textures
  31118. * @returns an array containing all loaded textures
  31119. */
  31120. getLoadedTexturesCache(): InternalTexture[];
  31121. /**
  31122. * Gets the object containing all engine capabilities
  31123. * @returns the EngineCapabilities object
  31124. */
  31125. getCaps(): EngineCapabilities;
  31126. /**
  31127. * stop executing a render loop function and remove it from the execution array
  31128. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31129. */
  31130. stopRenderLoop(renderFunction?: () => void): void;
  31131. /** @hidden */
  31132. _renderLoop(): void;
  31133. /**
  31134. * Gets the HTML canvas attached with the current webGL context
  31135. * @returns a HTML canvas
  31136. */
  31137. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31138. /**
  31139. * Gets host window
  31140. * @returns the host window object
  31141. */
  31142. getHostWindow(): Nullable<Window>;
  31143. /**
  31144. * Gets the current render width
  31145. * @param useScreen defines if screen size must be used (or the current render target if any)
  31146. * @returns a number defining the current render width
  31147. */
  31148. getRenderWidth(useScreen?: boolean): number;
  31149. /**
  31150. * Gets the current render height
  31151. * @param useScreen defines if screen size must be used (or the current render target if any)
  31152. * @returns a number defining the current render height
  31153. */
  31154. getRenderHeight(useScreen?: boolean): number;
  31155. /**
  31156. * Can be used to override the current requestAnimationFrame requester.
  31157. * @hidden
  31158. */
  31159. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31160. /**
  31161. * Register and execute a render loop. The engine can have more than one render function
  31162. * @param renderFunction defines the function to continuously execute
  31163. */
  31164. runRenderLoop(renderFunction: () => void): void;
  31165. /**
  31166. * Clear the current render buffer or the current render target (if any is set up)
  31167. * @param color defines the color to use
  31168. * @param backBuffer defines if the back buffer must be cleared
  31169. * @param depth defines if the depth buffer must be cleared
  31170. * @param stencil defines if the stencil buffer must be cleared
  31171. */
  31172. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31173. private _viewportCached;
  31174. /** @hidden */
  31175. _viewport(x: number, y: number, width: number, height: number): void;
  31176. /**
  31177. * Set the WebGL's viewport
  31178. * @param viewport defines the viewport element to be used
  31179. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31180. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31181. */
  31182. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31183. /**
  31184. * Begin a new frame
  31185. */
  31186. beginFrame(): void;
  31187. /**
  31188. * Enf the current frame
  31189. */
  31190. endFrame(): void;
  31191. /**
  31192. * Resize the view according to the canvas' size
  31193. */
  31194. resize(): void;
  31195. /**
  31196. * Force a specific size of the canvas
  31197. * @param width defines the new canvas' width
  31198. * @param height defines the new canvas' height
  31199. */
  31200. setSize(width: number, height: number): void;
  31201. /**
  31202. * Binds the frame buffer to the specified texture.
  31203. * @param texture The texture to render to or null for the default canvas
  31204. * @param faceIndex The face of the texture to render to in case of cube texture
  31205. * @param requiredWidth The width of the target to render to
  31206. * @param requiredHeight The height of the target to render to
  31207. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31208. * @param lodLevel defines the lod level to bind to the frame buffer
  31209. * @param layer defines the 2d array index to bind to frame buffer to
  31210. */
  31211. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31212. /** @hidden */
  31213. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31214. /**
  31215. * Unbind the current render target texture from the webGL context
  31216. * @param texture defines the render target texture to unbind
  31217. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31218. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31219. */
  31220. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31221. /**
  31222. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31223. */
  31224. flushFramebuffer(): void;
  31225. /**
  31226. * Unbind the current render target and bind the default framebuffer
  31227. */
  31228. restoreDefaultFramebuffer(): void;
  31229. /** @hidden */
  31230. protected _resetVertexBufferBinding(): void;
  31231. /**
  31232. * Creates a vertex buffer
  31233. * @param data the data for the vertex buffer
  31234. * @returns the new WebGL static buffer
  31235. */
  31236. createVertexBuffer(data: DataArray): DataBuffer;
  31237. private _createVertexBuffer;
  31238. /**
  31239. * Creates a dynamic vertex buffer
  31240. * @param data the data for the dynamic vertex buffer
  31241. * @returns the new WebGL dynamic buffer
  31242. */
  31243. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31244. protected _resetIndexBufferBinding(): void;
  31245. /**
  31246. * Creates a new index buffer
  31247. * @param indices defines the content of the index buffer
  31248. * @param updatable defines if the index buffer must be updatable
  31249. * @returns a new webGL buffer
  31250. */
  31251. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31252. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31253. /**
  31254. * Bind a webGL buffer to the webGL context
  31255. * @param buffer defines the buffer to bind
  31256. */
  31257. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31258. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31259. private bindBuffer;
  31260. /**
  31261. * update the bound buffer with the given data
  31262. * @param data defines the data to update
  31263. */
  31264. updateArrayBuffer(data: Float32Array): void;
  31265. private _vertexAttribPointer;
  31266. /** @hidden */
  31267. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31268. private _bindVertexBuffersAttributes;
  31269. /**
  31270. * Records a vertex array object
  31271. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31272. * @param vertexBuffers defines the list of vertex buffers to store
  31273. * @param indexBuffer defines the index buffer to store
  31274. * @param effect defines the effect to store
  31275. * @returns the new vertex array object
  31276. */
  31277. recordVertexArrayObject(vertexBuffers: {
  31278. [key: string]: VertexBuffer;
  31279. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31280. /**
  31281. * Bind a specific vertex array object
  31282. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31283. * @param vertexArrayObject defines the vertex array object to bind
  31284. * @param indexBuffer defines the index buffer to bind
  31285. */
  31286. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31287. /**
  31288. * Bind webGl buffers directly to the webGL context
  31289. * @param vertexBuffer defines the vertex buffer to bind
  31290. * @param indexBuffer defines the index buffer to bind
  31291. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31292. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31293. * @param effect defines the effect associated with the vertex buffer
  31294. */
  31295. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31296. private _unbindVertexArrayObject;
  31297. /**
  31298. * Bind a list of vertex buffers to the webGL context
  31299. * @param vertexBuffers defines the list of vertex buffers to bind
  31300. * @param indexBuffer defines the index buffer to bind
  31301. * @param effect defines the effect associated with the vertex buffers
  31302. */
  31303. bindBuffers(vertexBuffers: {
  31304. [key: string]: Nullable<VertexBuffer>;
  31305. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31306. /**
  31307. * Unbind all instance attributes
  31308. */
  31309. unbindInstanceAttributes(): void;
  31310. /**
  31311. * Release and free the memory of a vertex array object
  31312. * @param vao defines the vertex array object to delete
  31313. */
  31314. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31315. /** @hidden */
  31316. _releaseBuffer(buffer: DataBuffer): boolean;
  31317. protected _deleteBuffer(buffer: DataBuffer): void;
  31318. /**
  31319. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31320. * @param instancesBuffer defines the webGL buffer to update and bind
  31321. * @param data defines the data to store in the buffer
  31322. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31323. */
  31324. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31325. /**
  31326. * Bind the content of a webGL buffer used with instanciation
  31327. * @param instancesBuffer defines the webGL buffer to bind
  31328. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31329. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31330. */
  31331. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31332. /**
  31333. * Disable the instance attribute corresponding to the name in parameter
  31334. * @param name defines the name of the attribute to disable
  31335. */
  31336. disableInstanceAttributeByName(name: string): void;
  31337. /**
  31338. * Disable the instance attribute corresponding to the location in parameter
  31339. * @param attributeLocation defines the attribute location of the attribute to disable
  31340. */
  31341. disableInstanceAttribute(attributeLocation: number): void;
  31342. /**
  31343. * Disable the attribute corresponding to the location in parameter
  31344. * @param attributeLocation defines the attribute location of the attribute to disable
  31345. */
  31346. disableAttributeByIndex(attributeLocation: number): void;
  31347. /**
  31348. * Send a draw order
  31349. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31350. * @param indexStart defines the starting index
  31351. * @param indexCount defines the number of index to draw
  31352. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31353. */
  31354. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31355. /**
  31356. * Draw a list of points
  31357. * @param verticesStart defines the index of first vertex to draw
  31358. * @param verticesCount defines the count of vertices to draw
  31359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31360. */
  31361. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31362. /**
  31363. * Draw a list of unindexed primitives
  31364. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31365. * @param verticesStart defines the index of first vertex to draw
  31366. * @param verticesCount defines the count of vertices to draw
  31367. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31368. */
  31369. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31370. /**
  31371. * Draw a list of indexed primitives
  31372. * @param fillMode defines the primitive to use
  31373. * @param indexStart defines the starting index
  31374. * @param indexCount defines the number of index to draw
  31375. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31376. */
  31377. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31378. /**
  31379. * Draw a list of unindexed primitives
  31380. * @param fillMode defines the primitive to use
  31381. * @param verticesStart defines the index of first vertex to draw
  31382. * @param verticesCount defines the count of vertices to draw
  31383. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31384. */
  31385. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31386. private _drawMode;
  31387. /** @hidden */
  31388. protected _reportDrawCall(): void;
  31389. /** @hidden */
  31390. _releaseEffect(effect: Effect): void;
  31391. /** @hidden */
  31392. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31393. /**
  31394. * Create a new effect (used to store vertex/fragment shaders)
  31395. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31396. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31397. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31398. * @param samplers defines an array of string used to represent textures
  31399. * @param defines defines the string containing the defines to use to compile the shaders
  31400. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31401. * @param onCompiled defines a function to call when the effect creation is successful
  31402. * @param onError defines a function to call when the effect creation has failed
  31403. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31404. * @returns the new Effect
  31405. */
  31406. 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;
  31407. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31408. private _compileShader;
  31409. private _compileRawShader;
  31410. /**
  31411. * Directly creates a webGL program
  31412. * @param pipelineContext defines the pipeline context to attach to
  31413. * @param vertexCode defines the vertex shader code to use
  31414. * @param fragmentCode defines the fragment shader code to use
  31415. * @param context defines the webGL context to use (if not set, the current one will be used)
  31416. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31417. * @returns the new webGL program
  31418. */
  31419. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31420. /**
  31421. * Creates a webGL program
  31422. * @param pipelineContext defines the pipeline context to attach to
  31423. * @param vertexCode defines the vertex shader code to use
  31424. * @param fragmentCode defines the fragment shader code to use
  31425. * @param defines defines the string containing the defines to use to compile the shaders
  31426. * @param context defines the webGL context to use (if not set, the current one will be used)
  31427. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31428. * @returns the new webGL program
  31429. */
  31430. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31431. /**
  31432. * Creates a new pipeline context
  31433. * @returns the new pipeline
  31434. */
  31435. createPipelineContext(): IPipelineContext;
  31436. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31437. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31438. /** @hidden */
  31439. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31440. /** @hidden */
  31441. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31442. /** @hidden */
  31443. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31444. /**
  31445. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31446. * @param pipelineContext defines the pipeline context to use
  31447. * @param uniformsNames defines the list of uniform names
  31448. * @returns an array of webGL uniform locations
  31449. */
  31450. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31451. /**
  31452. * Gets the lsit of active attributes for a given webGL program
  31453. * @param pipelineContext defines the pipeline context to use
  31454. * @param attributesNames defines the list of attribute names to get
  31455. * @returns an array of indices indicating the offset of each attribute
  31456. */
  31457. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31458. /**
  31459. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31460. * @param effect defines the effect to activate
  31461. */
  31462. enableEffect(effect: Nullable<Effect>): void;
  31463. /**
  31464. * Set the value of an uniform to a number (int)
  31465. * @param uniform defines the webGL uniform location where to store the value
  31466. * @param value defines the int number to store
  31467. */
  31468. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31469. /**
  31470. * Set the value of an uniform to an array of int32
  31471. * @param uniform defines the webGL uniform location where to store the value
  31472. * @param array defines the array of int32 to store
  31473. */
  31474. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31475. /**
  31476. * Set the value of an uniform to an array of int32 (stored as vec2)
  31477. * @param uniform defines the webGL uniform location where to store the value
  31478. * @param array defines the array of int32 to store
  31479. */
  31480. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31481. /**
  31482. * Set the value of an uniform to an array of int32 (stored as vec3)
  31483. * @param uniform defines the webGL uniform location where to store the value
  31484. * @param array defines the array of int32 to store
  31485. */
  31486. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31487. /**
  31488. * Set the value of an uniform to an array of int32 (stored as vec4)
  31489. * @param uniform defines the webGL uniform location where to store the value
  31490. * @param array defines the array of int32 to store
  31491. */
  31492. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31493. /**
  31494. * Set the value of an uniform to an array of number
  31495. * @param uniform defines the webGL uniform location where to store the value
  31496. * @param array defines the array of number to store
  31497. */
  31498. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31499. /**
  31500. * Set the value of an uniform to an array of number (stored as vec2)
  31501. * @param uniform defines the webGL uniform location where to store the value
  31502. * @param array defines the array of number to store
  31503. */
  31504. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31505. /**
  31506. * Set the value of an uniform to an array of number (stored as vec3)
  31507. * @param uniform defines the webGL uniform location where to store the value
  31508. * @param array defines the array of number to store
  31509. */
  31510. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31511. /**
  31512. * Set the value of an uniform to an array of number (stored as vec4)
  31513. * @param uniform defines the webGL uniform location where to store the value
  31514. * @param array defines the array of number to store
  31515. */
  31516. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31517. /**
  31518. * Set the value of an uniform to an array of float32 (stored as matrices)
  31519. * @param uniform defines the webGL uniform location where to store the value
  31520. * @param matrices defines the array of float32 to store
  31521. */
  31522. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31523. /**
  31524. * Set the value of an uniform to a matrix (3x3)
  31525. * @param uniform defines the webGL uniform location where to store the value
  31526. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31527. */
  31528. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31529. /**
  31530. * Set the value of an uniform to a matrix (2x2)
  31531. * @param uniform defines the webGL uniform location where to store the value
  31532. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31533. */
  31534. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31535. /**
  31536. * Set the value of an uniform to a number (float)
  31537. * @param uniform defines the webGL uniform location where to store the value
  31538. * @param value defines the float number to store
  31539. */
  31540. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31541. /**
  31542. * Set the value of an uniform to a vec2
  31543. * @param uniform defines the webGL uniform location where to store the value
  31544. * @param x defines the 1st component of the value
  31545. * @param y defines the 2nd component of the value
  31546. */
  31547. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31548. /**
  31549. * Set the value of an uniform to a vec3
  31550. * @param uniform defines the webGL uniform location where to store the value
  31551. * @param x defines the 1st component of the value
  31552. * @param y defines the 2nd component of the value
  31553. * @param z defines the 3rd component of the value
  31554. */
  31555. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31556. /**
  31557. * Set the value of an uniform to a vec4
  31558. * @param uniform defines the webGL uniform location where to store the value
  31559. * @param x defines the 1st component of the value
  31560. * @param y defines the 2nd component of the value
  31561. * @param z defines the 3rd component of the value
  31562. * @param w defines the 4th component of the value
  31563. */
  31564. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31565. /**
  31566. * Apply all cached states (depth, culling, stencil and alpha)
  31567. */
  31568. applyStates(): void;
  31569. /**
  31570. * Enable or disable color writing
  31571. * @param enable defines the state to set
  31572. */
  31573. setColorWrite(enable: boolean): void;
  31574. /**
  31575. * Gets a boolean indicating if color writing is enabled
  31576. * @returns the current color writing state
  31577. */
  31578. getColorWrite(): boolean;
  31579. /**
  31580. * Gets the depth culling state manager
  31581. */
  31582. get depthCullingState(): DepthCullingState;
  31583. /**
  31584. * Gets the alpha state manager
  31585. */
  31586. get alphaState(): AlphaState;
  31587. /**
  31588. * Gets the stencil state manager
  31589. */
  31590. get stencilState(): StencilState;
  31591. /**
  31592. * Clears the list of texture accessible through engine.
  31593. * This can help preventing texture load conflict due to name collision.
  31594. */
  31595. clearInternalTexturesCache(): void;
  31596. /**
  31597. * Force the entire cache to be cleared
  31598. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31599. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31600. */
  31601. wipeCaches(bruteForce?: boolean): void;
  31602. /** @hidden */
  31603. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31604. min: number;
  31605. mag: number;
  31606. };
  31607. /** @hidden */
  31608. _createTexture(): WebGLTexture;
  31609. /**
  31610. * Usually called from Texture.ts.
  31611. * Passed information to create a WebGLTexture
  31612. * @param urlArg defines a value which contains one of the following:
  31613. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31614. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31615. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31616. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31617. * @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)
  31618. * @param scene needed for loading to the correct scene
  31619. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31620. * @param onLoad optional callback to be called upon successful completion
  31621. * @param onError optional callback to be called upon failure
  31622. * @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
  31623. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31624. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31625. * @param forcedExtension defines the extension to use to pick the right loader
  31626. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31627. * @param mimeType defines an optional mime type
  31628. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31629. */
  31630. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  31631. /**
  31632. * Loads an image as an HTMLImageElement.
  31633. * @param input url string, ArrayBuffer, or Blob to load
  31634. * @param onLoad callback called when the image successfully loads
  31635. * @param onError callback called when the image fails to load
  31636. * @param offlineProvider offline provider for caching
  31637. * @param mimeType optional mime type
  31638. * @returns the HTMLImageElement of the loaded image
  31639. * @hidden
  31640. */
  31641. 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>;
  31642. /**
  31643. * @hidden
  31644. */
  31645. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31646. /**
  31647. * Creates a raw texture
  31648. * @param data defines the data to store in the texture
  31649. * @param width defines the width of the texture
  31650. * @param height defines the height of the texture
  31651. * @param format defines the format of the data
  31652. * @param generateMipMaps defines if the engine should generate the mip levels
  31653. * @param invertY defines if data must be stored with Y axis inverted
  31654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31655. * @param compression defines the compression used (null by default)
  31656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31657. * @returns the raw texture inside an InternalTexture
  31658. */
  31659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31660. /**
  31661. * Creates a new raw cube texture
  31662. * @param data defines the array of data to use to create each face
  31663. * @param size defines the size of the textures
  31664. * @param format defines the format of the data
  31665. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31666. * @param generateMipMaps defines if the engine should generate the mip levels
  31667. * @param invertY defines if data must be stored with Y axis inverted
  31668. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31669. * @param compression defines the compression used (null by default)
  31670. * @returns the cube texture as an InternalTexture
  31671. */
  31672. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31673. /**
  31674. * Creates a new raw 3D texture
  31675. * @param data defines the data used to create the texture
  31676. * @param width defines the width of the texture
  31677. * @param height defines the height of the texture
  31678. * @param depth defines the depth of the texture
  31679. * @param format defines the format of the texture
  31680. * @param generateMipMaps defines if the engine must generate mip levels
  31681. * @param invertY defines if data must be stored with Y axis inverted
  31682. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31683. * @param compression defines the compressed used (can be null)
  31684. * @param textureType defines the compressed used (can be null)
  31685. * @returns a new raw 3D texture (stored in an InternalTexture)
  31686. */
  31687. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31688. /**
  31689. * Creates a new raw 2D array texture
  31690. * @param data defines the data used to create the texture
  31691. * @param width defines the width of the texture
  31692. * @param height defines the height of the texture
  31693. * @param depth defines the number of layers of the texture
  31694. * @param format defines the format of the texture
  31695. * @param generateMipMaps defines if the engine must generate mip levels
  31696. * @param invertY defines if data must be stored with Y axis inverted
  31697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31698. * @param compression defines the compressed used (can be null)
  31699. * @param textureType defines the compressed used (can be null)
  31700. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31701. */
  31702. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31703. private _unpackFlipYCached;
  31704. /**
  31705. * In case you are sharing the context with other applications, it might
  31706. * be interested to not cache the unpack flip y state to ensure a consistent
  31707. * value would be set.
  31708. */
  31709. enableUnpackFlipYCached: boolean;
  31710. /** @hidden */
  31711. _unpackFlipY(value: boolean): void;
  31712. /** @hidden */
  31713. _getUnpackAlignement(): number;
  31714. private _getTextureTarget;
  31715. /**
  31716. * Update the sampling mode of a given texture
  31717. * @param samplingMode defines the required sampling mode
  31718. * @param texture defines the texture to update
  31719. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31720. */
  31721. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31722. /**
  31723. * Update the sampling mode of a given texture
  31724. * @param texture defines the texture to update
  31725. * @param wrapU defines the texture wrap mode of the u coordinates
  31726. * @param wrapV defines the texture wrap mode of the v coordinates
  31727. * @param wrapR defines the texture wrap mode of the r coordinates
  31728. */
  31729. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31730. /** @hidden */
  31731. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31732. width: number;
  31733. height: number;
  31734. layers?: number;
  31735. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31736. /** @hidden */
  31737. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31738. /** @hidden */
  31739. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31740. /**
  31741. * Update a portion of an internal texture
  31742. * @param texture defines the texture to update
  31743. * @param imageData defines the data to store into the texture
  31744. * @param xOffset defines the x coordinates of the update rectangle
  31745. * @param yOffset defines the y coordinates of the update rectangle
  31746. * @param width defines the width of the update rectangle
  31747. * @param height defines the height of the update rectangle
  31748. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31749. * @param lod defines the lod level to update (0 by default)
  31750. */
  31751. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31752. /** @hidden */
  31753. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31754. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31755. private _prepareWebGLTexture;
  31756. /** @hidden */
  31757. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31758. private _getDepthStencilBuffer;
  31759. /** @hidden */
  31760. _releaseFramebufferObjects(texture: InternalTexture): void;
  31761. /** @hidden */
  31762. _releaseTexture(texture: InternalTexture): void;
  31763. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31764. protected _setProgram(program: WebGLProgram): void;
  31765. protected _boundUniforms: {
  31766. [key: number]: WebGLUniformLocation;
  31767. };
  31768. /**
  31769. * Binds an effect to the webGL context
  31770. * @param effect defines the effect to bind
  31771. */
  31772. bindSamplers(effect: Effect): void;
  31773. private _activateCurrentTexture;
  31774. /** @hidden */
  31775. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31776. /** @hidden */
  31777. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31778. /**
  31779. * Unbind all textures from the webGL context
  31780. */
  31781. unbindAllTextures(): void;
  31782. /**
  31783. * Sets a texture to the according uniform.
  31784. * @param channel The texture channel
  31785. * @param uniform The uniform to set
  31786. * @param texture The texture to apply
  31787. */
  31788. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31789. private _bindSamplerUniformToChannel;
  31790. private _getTextureWrapMode;
  31791. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31792. /**
  31793. * Sets an array of texture to the webGL context
  31794. * @param channel defines the channel where the texture array must be set
  31795. * @param uniform defines the associated uniform location
  31796. * @param textures defines the array of textures to bind
  31797. */
  31798. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31799. /** @hidden */
  31800. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31801. private _setTextureParameterFloat;
  31802. private _setTextureParameterInteger;
  31803. /**
  31804. * Unbind all vertex attributes from the webGL context
  31805. */
  31806. unbindAllAttributes(): void;
  31807. /**
  31808. * 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
  31809. */
  31810. releaseEffects(): void;
  31811. /**
  31812. * Dispose and release all associated resources
  31813. */
  31814. dispose(): void;
  31815. /**
  31816. * Attach a new callback raised when context lost event is fired
  31817. * @param callback defines the callback to call
  31818. */
  31819. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31820. /**
  31821. * Attach a new callback raised when context restored event is fired
  31822. * @param callback defines the callback to call
  31823. */
  31824. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31825. /**
  31826. * Get the current error code of the webGL context
  31827. * @returns the error code
  31828. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31829. */
  31830. getError(): number;
  31831. private _canRenderToFloatFramebuffer;
  31832. private _canRenderToHalfFloatFramebuffer;
  31833. private _canRenderToFramebuffer;
  31834. /** @hidden */
  31835. _getWebGLTextureType(type: number): number;
  31836. /** @hidden */
  31837. _getInternalFormat(format: number): number;
  31838. /** @hidden */
  31839. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31840. /** @hidden */
  31841. _getRGBAMultiSampleBufferFormat(type: number): number;
  31842. /** @hidden */
  31843. _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;
  31844. /**
  31845. * Loads a file from a url
  31846. * @param url url to load
  31847. * @param onSuccess callback called when the file successfully loads
  31848. * @param onProgress callback called while file is loading (if the server supports this mode)
  31849. * @param offlineProvider defines the offline provider for caching
  31850. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31851. * @param onError callback called when the file fails to load
  31852. * @returns a file request object
  31853. * @hidden
  31854. */
  31855. 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;
  31856. /**
  31857. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31858. * @param x defines the x coordinate of the rectangle where pixels must be read
  31859. * @param y defines the y coordinate of the rectangle where pixels must be read
  31860. * @param width defines the width of the rectangle where pixels must be read
  31861. * @param height defines the height of the rectangle where pixels must be read
  31862. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31863. * @returns a Uint8Array containing RGBA colors
  31864. */
  31865. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31866. private static _isSupported;
  31867. /**
  31868. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31869. * @returns true if the engine can be created
  31870. * @ignorenaming
  31871. */
  31872. static isSupported(): boolean;
  31873. /**
  31874. * Find the next highest power of two.
  31875. * @param x Number to start search from.
  31876. * @return Next highest power of two.
  31877. */
  31878. static CeilingPOT(x: number): number;
  31879. /**
  31880. * Find the next lowest power of two.
  31881. * @param x Number to start search from.
  31882. * @return Next lowest power of two.
  31883. */
  31884. static FloorPOT(x: number): number;
  31885. /**
  31886. * Find the nearest power of two.
  31887. * @param x Number to start search from.
  31888. * @return Next nearest power of two.
  31889. */
  31890. static NearestPOT(x: number): number;
  31891. /**
  31892. * Get the closest exponent of two
  31893. * @param value defines the value to approximate
  31894. * @param max defines the maximum value to return
  31895. * @param mode defines how to define the closest value
  31896. * @returns closest exponent of two of the given value
  31897. */
  31898. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31899. /**
  31900. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31901. * @param func - the function to be called
  31902. * @param requester - the object that will request the next frame. Falls back to window.
  31903. * @returns frame number
  31904. */
  31905. static QueueNewFrame(func: () => void, requester?: any): number;
  31906. /**
  31907. * Gets host document
  31908. * @returns the host document object
  31909. */
  31910. getHostDocument(): Nullable<Document>;
  31911. }
  31912. }
  31913. declare module BABYLON {
  31914. /**
  31915. * Class representing spherical harmonics coefficients to the 3rd degree
  31916. */
  31917. export class SphericalHarmonics {
  31918. /**
  31919. * Defines whether or not the harmonics have been prescaled for rendering.
  31920. */
  31921. preScaled: boolean;
  31922. /**
  31923. * The l0,0 coefficients of the spherical harmonics
  31924. */
  31925. l00: Vector3;
  31926. /**
  31927. * The l1,-1 coefficients of the spherical harmonics
  31928. */
  31929. l1_1: Vector3;
  31930. /**
  31931. * The l1,0 coefficients of the spherical harmonics
  31932. */
  31933. l10: Vector3;
  31934. /**
  31935. * The l1,1 coefficients of the spherical harmonics
  31936. */
  31937. l11: Vector3;
  31938. /**
  31939. * The l2,-2 coefficients of the spherical harmonics
  31940. */
  31941. l2_2: Vector3;
  31942. /**
  31943. * The l2,-1 coefficients of the spherical harmonics
  31944. */
  31945. l2_1: Vector3;
  31946. /**
  31947. * The l2,0 coefficients of the spherical harmonics
  31948. */
  31949. l20: Vector3;
  31950. /**
  31951. * The l2,1 coefficients of the spherical harmonics
  31952. */
  31953. l21: Vector3;
  31954. /**
  31955. * The l2,2 coefficients of the spherical harmonics
  31956. */
  31957. l22: Vector3;
  31958. /**
  31959. * Adds a light to the spherical harmonics
  31960. * @param direction the direction of the light
  31961. * @param color the color of the light
  31962. * @param deltaSolidAngle the delta solid angle of the light
  31963. */
  31964. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31965. /**
  31966. * Scales the spherical harmonics by the given amount
  31967. * @param scale the amount to scale
  31968. */
  31969. scaleInPlace(scale: number): void;
  31970. /**
  31971. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31972. *
  31973. * ```
  31974. * E_lm = A_l * L_lm
  31975. * ```
  31976. *
  31977. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31978. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31979. * the scaling factors are given in equation 9.
  31980. */
  31981. convertIncidentRadianceToIrradiance(): void;
  31982. /**
  31983. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31984. *
  31985. * ```
  31986. * L = (1/pi) * E * rho
  31987. * ```
  31988. *
  31989. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31990. */
  31991. convertIrradianceToLambertianRadiance(): void;
  31992. /**
  31993. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31994. * required operations at run time.
  31995. *
  31996. * This is simply done by scaling back the SH with Ylm constants parameter.
  31997. * The trigonometric part being applied by the shader at run time.
  31998. */
  31999. preScaleForRendering(): void;
  32000. /**
  32001. * Constructs a spherical harmonics from an array.
  32002. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32003. * @returns the spherical harmonics
  32004. */
  32005. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32006. /**
  32007. * Gets the spherical harmonics from polynomial
  32008. * @param polynomial the spherical polynomial
  32009. * @returns the spherical harmonics
  32010. */
  32011. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32012. }
  32013. /**
  32014. * Class representing spherical polynomial coefficients to the 3rd degree
  32015. */
  32016. export class SphericalPolynomial {
  32017. private _harmonics;
  32018. /**
  32019. * The spherical harmonics used to create the polynomials.
  32020. */
  32021. get preScaledHarmonics(): SphericalHarmonics;
  32022. /**
  32023. * The x coefficients of the spherical polynomial
  32024. */
  32025. x: Vector3;
  32026. /**
  32027. * The y coefficients of the spherical polynomial
  32028. */
  32029. y: Vector3;
  32030. /**
  32031. * The z coefficients of the spherical polynomial
  32032. */
  32033. z: Vector3;
  32034. /**
  32035. * The xx coefficients of the spherical polynomial
  32036. */
  32037. xx: Vector3;
  32038. /**
  32039. * The yy coefficients of the spherical polynomial
  32040. */
  32041. yy: Vector3;
  32042. /**
  32043. * The zz coefficients of the spherical polynomial
  32044. */
  32045. zz: Vector3;
  32046. /**
  32047. * The xy coefficients of the spherical polynomial
  32048. */
  32049. xy: Vector3;
  32050. /**
  32051. * The yz coefficients of the spherical polynomial
  32052. */
  32053. yz: Vector3;
  32054. /**
  32055. * The zx coefficients of the spherical polynomial
  32056. */
  32057. zx: Vector3;
  32058. /**
  32059. * Adds an ambient color to the spherical polynomial
  32060. * @param color the color to add
  32061. */
  32062. addAmbient(color: Color3): void;
  32063. /**
  32064. * Scales the spherical polynomial by the given amount
  32065. * @param scale the amount to scale
  32066. */
  32067. scaleInPlace(scale: number): void;
  32068. /**
  32069. * Gets the spherical polynomial from harmonics
  32070. * @param harmonics the spherical harmonics
  32071. * @returns the spherical polynomial
  32072. */
  32073. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32074. /**
  32075. * Constructs a spherical polynomial from an array.
  32076. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32077. * @returns the spherical polynomial
  32078. */
  32079. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32080. }
  32081. }
  32082. declare module BABYLON {
  32083. /**
  32084. * Defines the source of the internal texture
  32085. */
  32086. export enum InternalTextureSource {
  32087. /**
  32088. * The source of the texture data is unknown
  32089. */
  32090. Unknown = 0,
  32091. /**
  32092. * Texture data comes from an URL
  32093. */
  32094. Url = 1,
  32095. /**
  32096. * Texture data is only used for temporary storage
  32097. */
  32098. Temp = 2,
  32099. /**
  32100. * Texture data comes from raw data (ArrayBuffer)
  32101. */
  32102. Raw = 3,
  32103. /**
  32104. * Texture content is dynamic (video or dynamic texture)
  32105. */
  32106. Dynamic = 4,
  32107. /**
  32108. * Texture content is generated by rendering to it
  32109. */
  32110. RenderTarget = 5,
  32111. /**
  32112. * Texture content is part of a multi render target process
  32113. */
  32114. MultiRenderTarget = 6,
  32115. /**
  32116. * Texture data comes from a cube data file
  32117. */
  32118. Cube = 7,
  32119. /**
  32120. * Texture data comes from a raw cube data
  32121. */
  32122. CubeRaw = 8,
  32123. /**
  32124. * Texture data come from a prefiltered cube data file
  32125. */
  32126. CubePrefiltered = 9,
  32127. /**
  32128. * Texture content is raw 3D data
  32129. */
  32130. Raw3D = 10,
  32131. /**
  32132. * Texture content is raw 2D array data
  32133. */
  32134. Raw2DArray = 11,
  32135. /**
  32136. * Texture content is a depth texture
  32137. */
  32138. Depth = 12,
  32139. /**
  32140. * Texture data comes from a raw cube data encoded with RGBD
  32141. */
  32142. CubeRawRGBD = 13
  32143. }
  32144. /**
  32145. * Class used to store data associated with WebGL texture data for the engine
  32146. * This class should not be used directly
  32147. */
  32148. export class InternalTexture {
  32149. /** @hidden */
  32150. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32151. /**
  32152. * Defines if the texture is ready
  32153. */
  32154. isReady: boolean;
  32155. /**
  32156. * Defines if the texture is a cube texture
  32157. */
  32158. isCube: boolean;
  32159. /**
  32160. * Defines if the texture contains 3D data
  32161. */
  32162. is3D: boolean;
  32163. /**
  32164. * Defines if the texture contains 2D array data
  32165. */
  32166. is2DArray: boolean;
  32167. /**
  32168. * Defines if the texture contains multiview data
  32169. */
  32170. isMultiview: boolean;
  32171. /**
  32172. * Gets the URL used to load this texture
  32173. */
  32174. url: string;
  32175. /**
  32176. * Gets the sampling mode of the texture
  32177. */
  32178. samplingMode: number;
  32179. /**
  32180. * Gets a boolean indicating if the texture needs mipmaps generation
  32181. */
  32182. generateMipMaps: boolean;
  32183. /**
  32184. * Gets the number of samples used by the texture (WebGL2+ only)
  32185. */
  32186. samples: number;
  32187. /**
  32188. * Gets the type of the texture (int, float...)
  32189. */
  32190. type: number;
  32191. /**
  32192. * Gets the format of the texture (RGB, RGBA...)
  32193. */
  32194. format: number;
  32195. /**
  32196. * Observable called when the texture is loaded
  32197. */
  32198. onLoadedObservable: Observable<InternalTexture>;
  32199. /**
  32200. * Gets the width of the texture
  32201. */
  32202. width: number;
  32203. /**
  32204. * Gets the height of the texture
  32205. */
  32206. height: number;
  32207. /**
  32208. * Gets the depth of the texture
  32209. */
  32210. depth: number;
  32211. /**
  32212. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32213. */
  32214. baseWidth: number;
  32215. /**
  32216. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32217. */
  32218. baseHeight: number;
  32219. /**
  32220. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32221. */
  32222. baseDepth: number;
  32223. /**
  32224. * Gets a boolean indicating if the texture is inverted on Y axis
  32225. */
  32226. invertY: boolean;
  32227. /** @hidden */
  32228. _invertVScale: boolean;
  32229. /** @hidden */
  32230. _associatedChannel: number;
  32231. /** @hidden */
  32232. _source: InternalTextureSource;
  32233. /** @hidden */
  32234. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32235. /** @hidden */
  32236. _bufferView: Nullable<ArrayBufferView>;
  32237. /** @hidden */
  32238. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32239. /** @hidden */
  32240. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32241. /** @hidden */
  32242. _size: number;
  32243. /** @hidden */
  32244. _extension: string;
  32245. /** @hidden */
  32246. _files: Nullable<string[]>;
  32247. /** @hidden */
  32248. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32249. /** @hidden */
  32250. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32251. /** @hidden */
  32252. _framebuffer: Nullable<WebGLFramebuffer>;
  32253. /** @hidden */
  32254. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32255. /** @hidden */
  32256. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32257. /** @hidden */
  32258. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32259. /** @hidden */
  32260. _attachments: Nullable<number[]>;
  32261. /** @hidden */
  32262. _cachedCoordinatesMode: Nullable<number>;
  32263. /** @hidden */
  32264. _cachedWrapU: Nullable<number>;
  32265. /** @hidden */
  32266. _cachedWrapV: Nullable<number>;
  32267. /** @hidden */
  32268. _cachedWrapR: Nullable<number>;
  32269. /** @hidden */
  32270. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32271. /** @hidden */
  32272. _isDisabled: boolean;
  32273. /** @hidden */
  32274. _compression: Nullable<string>;
  32275. /** @hidden */
  32276. _generateStencilBuffer: boolean;
  32277. /** @hidden */
  32278. _generateDepthBuffer: boolean;
  32279. /** @hidden */
  32280. _comparisonFunction: number;
  32281. /** @hidden */
  32282. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32283. /** @hidden */
  32284. _lodGenerationScale: number;
  32285. /** @hidden */
  32286. _lodGenerationOffset: number;
  32287. /** @hidden */
  32288. _depthStencilTexture: Nullable<InternalTexture>;
  32289. /** @hidden */
  32290. _colorTextureArray: Nullable<WebGLTexture>;
  32291. /** @hidden */
  32292. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32293. /** @hidden */
  32294. _lodTextureHigh: Nullable<BaseTexture>;
  32295. /** @hidden */
  32296. _lodTextureMid: Nullable<BaseTexture>;
  32297. /** @hidden */
  32298. _lodTextureLow: Nullable<BaseTexture>;
  32299. /** @hidden */
  32300. _isRGBD: boolean;
  32301. /** @hidden */
  32302. _linearSpecularLOD: boolean;
  32303. /** @hidden */
  32304. _irradianceTexture: Nullable<BaseTexture>;
  32305. /** @hidden */
  32306. _webGLTexture: Nullable<WebGLTexture>;
  32307. /** @hidden */
  32308. _references: number;
  32309. private _engine;
  32310. /**
  32311. * Gets the Engine the texture belongs to.
  32312. * @returns The babylon engine
  32313. */
  32314. getEngine(): ThinEngine;
  32315. /**
  32316. * Gets the data source type of the texture
  32317. */
  32318. get source(): InternalTextureSource;
  32319. /**
  32320. * Creates a new InternalTexture
  32321. * @param engine defines the engine to use
  32322. * @param source defines the type of data that will be used
  32323. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32324. */
  32325. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32326. /**
  32327. * Increments the number of references (ie. the number of Texture that point to it)
  32328. */
  32329. incrementReferences(): void;
  32330. /**
  32331. * Change the size of the texture (not the size of the content)
  32332. * @param width defines the new width
  32333. * @param height defines the new height
  32334. * @param depth defines the new depth (1 by default)
  32335. */
  32336. updateSize(width: int, height: int, depth?: int): void;
  32337. /** @hidden */
  32338. _rebuild(): void;
  32339. /** @hidden */
  32340. _swapAndDie(target: InternalTexture): void;
  32341. /**
  32342. * Dispose the current allocated resources
  32343. */
  32344. dispose(): void;
  32345. }
  32346. }
  32347. declare module BABYLON {
  32348. /**
  32349. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32351. */
  32352. export class Analyser {
  32353. /**
  32354. * Gets or sets the smoothing
  32355. * @ignorenaming
  32356. */
  32357. SMOOTHING: number;
  32358. /**
  32359. * Gets or sets the FFT table size
  32360. * @ignorenaming
  32361. */
  32362. FFT_SIZE: number;
  32363. /**
  32364. * Gets or sets the bar graph amplitude
  32365. * @ignorenaming
  32366. */
  32367. BARGRAPHAMPLITUDE: number;
  32368. /**
  32369. * Gets or sets the position of the debug canvas
  32370. * @ignorenaming
  32371. */
  32372. DEBUGCANVASPOS: {
  32373. x: number;
  32374. y: number;
  32375. };
  32376. /**
  32377. * Gets or sets the debug canvas size
  32378. * @ignorenaming
  32379. */
  32380. DEBUGCANVASSIZE: {
  32381. width: number;
  32382. height: number;
  32383. };
  32384. private _byteFreqs;
  32385. private _byteTime;
  32386. private _floatFreqs;
  32387. private _webAudioAnalyser;
  32388. private _debugCanvas;
  32389. private _debugCanvasContext;
  32390. private _scene;
  32391. private _registerFunc;
  32392. private _audioEngine;
  32393. /**
  32394. * Creates a new analyser
  32395. * @param scene defines hosting scene
  32396. */
  32397. constructor(scene: Scene);
  32398. /**
  32399. * Get the number of data values you will have to play with for the visualization
  32400. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32401. * @returns a number
  32402. */
  32403. getFrequencyBinCount(): number;
  32404. /**
  32405. * Gets the current frequency data as a byte array
  32406. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32407. * @returns a Uint8Array
  32408. */
  32409. getByteFrequencyData(): Uint8Array;
  32410. /**
  32411. * Gets the current waveform as a byte array
  32412. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32413. * @returns a Uint8Array
  32414. */
  32415. getByteTimeDomainData(): Uint8Array;
  32416. /**
  32417. * Gets the current frequency data as a float array
  32418. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32419. * @returns a Float32Array
  32420. */
  32421. getFloatFrequencyData(): Float32Array;
  32422. /**
  32423. * Renders the debug canvas
  32424. */
  32425. drawDebugCanvas(): void;
  32426. /**
  32427. * Stops rendering the debug canvas and removes it
  32428. */
  32429. stopDebugCanvas(): void;
  32430. /**
  32431. * Connects two audio nodes
  32432. * @param inputAudioNode defines first node to connect
  32433. * @param outputAudioNode defines second node to connect
  32434. */
  32435. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32436. /**
  32437. * Releases all associated resources
  32438. */
  32439. dispose(): void;
  32440. }
  32441. }
  32442. declare module BABYLON {
  32443. /**
  32444. * This represents an audio engine and it is responsible
  32445. * to play, synchronize and analyse sounds throughout the application.
  32446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32447. */
  32448. export interface IAudioEngine extends IDisposable {
  32449. /**
  32450. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32451. */
  32452. readonly canUseWebAudio: boolean;
  32453. /**
  32454. * Gets the current AudioContext if available.
  32455. */
  32456. readonly audioContext: Nullable<AudioContext>;
  32457. /**
  32458. * The master gain node defines the global audio volume of your audio engine.
  32459. */
  32460. readonly masterGain: GainNode;
  32461. /**
  32462. * Gets whether or not mp3 are supported by your browser.
  32463. */
  32464. readonly isMP3supported: boolean;
  32465. /**
  32466. * Gets whether or not ogg are supported by your browser.
  32467. */
  32468. readonly isOGGsupported: boolean;
  32469. /**
  32470. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32471. * @ignoreNaming
  32472. */
  32473. WarnedWebAudioUnsupported: boolean;
  32474. /**
  32475. * Defines if the audio engine relies on a custom unlocked button.
  32476. * In this case, the embedded button will not be displayed.
  32477. */
  32478. useCustomUnlockedButton: boolean;
  32479. /**
  32480. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32481. */
  32482. readonly unlocked: boolean;
  32483. /**
  32484. * Event raised when audio has been unlocked on the browser.
  32485. */
  32486. onAudioUnlockedObservable: Observable<AudioEngine>;
  32487. /**
  32488. * Event raised when audio has been locked on the browser.
  32489. */
  32490. onAudioLockedObservable: Observable<AudioEngine>;
  32491. /**
  32492. * Flags the audio engine in Locked state.
  32493. * This happens due to new browser policies preventing audio to autoplay.
  32494. */
  32495. lock(): void;
  32496. /**
  32497. * Unlocks the audio engine once a user action has been done on the dom.
  32498. * This is helpful to resume play once browser policies have been satisfied.
  32499. */
  32500. unlock(): void;
  32501. }
  32502. /**
  32503. * This represents the default audio engine used in babylon.
  32504. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32505. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32506. */
  32507. export class AudioEngine implements IAudioEngine {
  32508. private _audioContext;
  32509. private _audioContextInitialized;
  32510. private _muteButton;
  32511. private _hostElement;
  32512. /**
  32513. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32514. */
  32515. canUseWebAudio: boolean;
  32516. /**
  32517. * The master gain node defines the global audio volume of your audio engine.
  32518. */
  32519. masterGain: GainNode;
  32520. /**
  32521. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32522. * @ignoreNaming
  32523. */
  32524. WarnedWebAudioUnsupported: boolean;
  32525. /**
  32526. * Gets whether or not mp3 are supported by your browser.
  32527. */
  32528. isMP3supported: boolean;
  32529. /**
  32530. * Gets whether or not ogg are supported by your browser.
  32531. */
  32532. isOGGsupported: boolean;
  32533. /**
  32534. * Gets whether audio has been unlocked on the device.
  32535. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32536. * a user interaction has happened.
  32537. */
  32538. unlocked: boolean;
  32539. /**
  32540. * Defines if the audio engine relies on a custom unlocked button.
  32541. * In this case, the embedded button will not be displayed.
  32542. */
  32543. useCustomUnlockedButton: boolean;
  32544. /**
  32545. * Event raised when audio has been unlocked on the browser.
  32546. */
  32547. onAudioUnlockedObservable: Observable<AudioEngine>;
  32548. /**
  32549. * Event raised when audio has been locked on the browser.
  32550. */
  32551. onAudioLockedObservable: Observable<AudioEngine>;
  32552. /**
  32553. * Gets the current AudioContext if available.
  32554. */
  32555. get audioContext(): Nullable<AudioContext>;
  32556. private _connectedAnalyser;
  32557. /**
  32558. * Instantiates a new audio engine.
  32559. *
  32560. * There should be only one per page as some browsers restrict the number
  32561. * of audio contexts you can create.
  32562. * @param hostElement defines the host element where to display the mute icon if necessary
  32563. */
  32564. constructor(hostElement?: Nullable<HTMLElement>);
  32565. /**
  32566. * Flags the audio engine in Locked state.
  32567. * This happens due to new browser policies preventing audio to autoplay.
  32568. */
  32569. lock(): void;
  32570. /**
  32571. * Unlocks the audio engine once a user action has been done on the dom.
  32572. * This is helpful to resume play once browser policies have been satisfied.
  32573. */
  32574. unlock(): void;
  32575. private _resumeAudioContext;
  32576. private _initializeAudioContext;
  32577. private _tryToRun;
  32578. private _triggerRunningState;
  32579. private _triggerSuspendedState;
  32580. private _displayMuteButton;
  32581. private _moveButtonToTopLeft;
  32582. private _onResize;
  32583. private _hideMuteButton;
  32584. /**
  32585. * Destroy and release the resources associated with the audio ccontext.
  32586. */
  32587. dispose(): void;
  32588. /**
  32589. * Gets the global volume sets on the master gain.
  32590. * @returns the global volume if set or -1 otherwise
  32591. */
  32592. getGlobalVolume(): number;
  32593. /**
  32594. * Sets the global volume of your experience (sets on the master gain).
  32595. * @param newVolume Defines the new global volume of the application
  32596. */
  32597. setGlobalVolume(newVolume: number): void;
  32598. /**
  32599. * Connect the audio engine to an audio analyser allowing some amazing
  32600. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32602. * @param analyser The analyser to connect to the engine
  32603. */
  32604. connectToAnalyser(analyser: Analyser): void;
  32605. }
  32606. }
  32607. declare module BABYLON {
  32608. /**
  32609. * Interface used to present a loading screen while loading a scene
  32610. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32611. */
  32612. export interface ILoadingScreen {
  32613. /**
  32614. * Function called to display the loading screen
  32615. */
  32616. displayLoadingUI: () => void;
  32617. /**
  32618. * Function called to hide the loading screen
  32619. */
  32620. hideLoadingUI: () => void;
  32621. /**
  32622. * Gets or sets the color to use for the background
  32623. */
  32624. loadingUIBackgroundColor: string;
  32625. /**
  32626. * Gets or sets the text to display while loading
  32627. */
  32628. loadingUIText: string;
  32629. }
  32630. /**
  32631. * Class used for the default loading screen
  32632. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32633. */
  32634. export class DefaultLoadingScreen implements ILoadingScreen {
  32635. private _renderingCanvas;
  32636. private _loadingText;
  32637. private _loadingDivBackgroundColor;
  32638. private _loadingDiv;
  32639. private _loadingTextDiv;
  32640. /** Gets or sets the logo url to use for the default loading screen */
  32641. static DefaultLogoUrl: string;
  32642. /** Gets or sets the spinner url to use for the default loading screen */
  32643. static DefaultSpinnerUrl: string;
  32644. /**
  32645. * Creates a new default loading screen
  32646. * @param _renderingCanvas defines the canvas used to render the scene
  32647. * @param _loadingText defines the default text to display
  32648. * @param _loadingDivBackgroundColor defines the default background color
  32649. */
  32650. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32651. /**
  32652. * Function called to display the loading screen
  32653. */
  32654. displayLoadingUI(): void;
  32655. /**
  32656. * Function called to hide the loading screen
  32657. */
  32658. hideLoadingUI(): void;
  32659. /**
  32660. * Gets or sets the text to display while loading
  32661. */
  32662. set loadingUIText(text: string);
  32663. get loadingUIText(): string;
  32664. /**
  32665. * Gets or sets the color to use for the background
  32666. */
  32667. get loadingUIBackgroundColor(): string;
  32668. set loadingUIBackgroundColor(color: string);
  32669. private _resizeLoadingUI;
  32670. }
  32671. }
  32672. declare module BABYLON {
  32673. /**
  32674. * Interface for any object that can request an animation frame
  32675. */
  32676. export interface ICustomAnimationFrameRequester {
  32677. /**
  32678. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32679. */
  32680. renderFunction?: Function;
  32681. /**
  32682. * Called to request the next frame to render to
  32683. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32684. */
  32685. requestAnimationFrame: Function;
  32686. /**
  32687. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32688. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32689. */
  32690. requestID?: number;
  32691. }
  32692. }
  32693. declare module BABYLON {
  32694. /**
  32695. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32696. */
  32697. export class PerformanceMonitor {
  32698. private _enabled;
  32699. private _rollingFrameTime;
  32700. private _lastFrameTimeMs;
  32701. /**
  32702. * constructor
  32703. * @param frameSampleSize The number of samples required to saturate the sliding window
  32704. */
  32705. constructor(frameSampleSize?: number);
  32706. /**
  32707. * Samples current frame
  32708. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32709. */
  32710. sampleFrame(timeMs?: number): void;
  32711. /**
  32712. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32713. */
  32714. get averageFrameTime(): number;
  32715. /**
  32716. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32717. */
  32718. get averageFrameTimeVariance(): number;
  32719. /**
  32720. * Returns the frame time of the most recent frame
  32721. */
  32722. get instantaneousFrameTime(): number;
  32723. /**
  32724. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32725. */
  32726. get averageFPS(): number;
  32727. /**
  32728. * Returns the average framerate in frames per second using the most recent frame time
  32729. */
  32730. get instantaneousFPS(): number;
  32731. /**
  32732. * Returns true if enough samples have been taken to completely fill the sliding window
  32733. */
  32734. get isSaturated(): boolean;
  32735. /**
  32736. * Enables contributions to the sliding window sample set
  32737. */
  32738. enable(): void;
  32739. /**
  32740. * Disables contributions to the sliding window sample set
  32741. * Samples will not be interpolated over the disabled period
  32742. */
  32743. disable(): void;
  32744. /**
  32745. * Returns true if sampling is enabled
  32746. */
  32747. get isEnabled(): boolean;
  32748. /**
  32749. * Resets performance monitor
  32750. */
  32751. reset(): void;
  32752. }
  32753. /**
  32754. * RollingAverage
  32755. *
  32756. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32757. */
  32758. export class RollingAverage {
  32759. /**
  32760. * Current average
  32761. */
  32762. average: number;
  32763. /**
  32764. * Current variance
  32765. */
  32766. variance: number;
  32767. protected _samples: Array<number>;
  32768. protected _sampleCount: number;
  32769. protected _pos: number;
  32770. protected _m2: number;
  32771. /**
  32772. * constructor
  32773. * @param length The number of samples required to saturate the sliding window
  32774. */
  32775. constructor(length: number);
  32776. /**
  32777. * Adds a sample to the sample set
  32778. * @param v The sample value
  32779. */
  32780. add(v: number): void;
  32781. /**
  32782. * Returns previously added values or null if outside of history or outside the sliding window domain
  32783. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32784. * @return Value previously recorded with add() or null if outside of range
  32785. */
  32786. history(i: number): number;
  32787. /**
  32788. * Returns true if enough samples have been taken to completely fill the sliding window
  32789. * @return true if sample-set saturated
  32790. */
  32791. isSaturated(): boolean;
  32792. /**
  32793. * Resets the rolling average (equivalent to 0 samples taken so far)
  32794. */
  32795. reset(): void;
  32796. /**
  32797. * Wraps a value around the sample range boundaries
  32798. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32799. * @return Wrapped position in sample range
  32800. */
  32801. protected _wrapPosition(i: number): number;
  32802. }
  32803. }
  32804. declare module BABYLON {
  32805. /**
  32806. * This class is used to track a performance counter which is number based.
  32807. * The user has access to many properties which give statistics of different nature.
  32808. *
  32809. * The implementer can track two kinds of Performance Counter: time and count.
  32810. * 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.
  32811. * 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.
  32812. */
  32813. export class PerfCounter {
  32814. /**
  32815. * Gets or sets a global boolean to turn on and off all the counters
  32816. */
  32817. static Enabled: boolean;
  32818. /**
  32819. * Returns the smallest value ever
  32820. */
  32821. get min(): number;
  32822. /**
  32823. * Returns the biggest value ever
  32824. */
  32825. get max(): number;
  32826. /**
  32827. * Returns the average value since the performance counter is running
  32828. */
  32829. get average(): number;
  32830. /**
  32831. * Returns the average value of the last second the counter was monitored
  32832. */
  32833. get lastSecAverage(): number;
  32834. /**
  32835. * Returns the current value
  32836. */
  32837. get current(): number;
  32838. /**
  32839. * Gets the accumulated total
  32840. */
  32841. get total(): number;
  32842. /**
  32843. * Gets the total value count
  32844. */
  32845. get count(): number;
  32846. /**
  32847. * Creates a new counter
  32848. */
  32849. constructor();
  32850. /**
  32851. * Call this method to start monitoring a new frame.
  32852. * 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.
  32853. */
  32854. fetchNewFrame(): void;
  32855. /**
  32856. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32857. * @param newCount the count value to add to the monitored count
  32858. * @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.
  32859. */
  32860. addCount(newCount: number, fetchResult: boolean): void;
  32861. /**
  32862. * Start monitoring this performance counter
  32863. */
  32864. beginMonitoring(): void;
  32865. /**
  32866. * Compute the time lapsed since the previous beginMonitoring() call.
  32867. * @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
  32868. */
  32869. endMonitoring(newFrame?: boolean): void;
  32870. private _fetchResult;
  32871. private _startMonitoringTime;
  32872. private _min;
  32873. private _max;
  32874. private _average;
  32875. private _current;
  32876. private _totalValueCount;
  32877. private _totalAccumulated;
  32878. private _lastSecAverage;
  32879. private _lastSecAccumulated;
  32880. private _lastSecTime;
  32881. private _lastSecValueCount;
  32882. }
  32883. }
  32884. declare module BABYLON {
  32885. interface ThinEngine {
  32886. /**
  32887. * Sets alpha constants used by some alpha blending modes
  32888. * @param r defines the red component
  32889. * @param g defines the green component
  32890. * @param b defines the blue component
  32891. * @param a defines the alpha component
  32892. */
  32893. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32894. /**
  32895. * Sets the current alpha mode
  32896. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32897. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32898. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32899. */
  32900. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32901. /**
  32902. * Gets the current alpha mode
  32903. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32904. * @returns the current alpha mode
  32905. */
  32906. getAlphaMode(): number;
  32907. /**
  32908. * Sets the current alpha equation
  32909. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32910. */
  32911. setAlphaEquation(equation: number): void;
  32912. /**
  32913. * Gets the current alpha equation.
  32914. * @returns the current alpha equation
  32915. */
  32916. getAlphaEquation(): number;
  32917. }
  32918. }
  32919. declare module BABYLON {
  32920. /**
  32921. * Defines the interface used by display changed events
  32922. */
  32923. export interface IDisplayChangedEventArgs {
  32924. /** Gets the vrDisplay object (if any) */
  32925. vrDisplay: Nullable<any>;
  32926. /** Gets a boolean indicating if webVR is supported */
  32927. vrSupported: boolean;
  32928. }
  32929. /**
  32930. * Defines the interface used by objects containing a viewport (like a camera)
  32931. */
  32932. interface IViewportOwnerLike {
  32933. /**
  32934. * Gets or sets the viewport
  32935. */
  32936. viewport: IViewportLike;
  32937. }
  32938. /**
  32939. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32940. */
  32941. export class Engine extends ThinEngine {
  32942. /** Defines that alpha blending is disabled */
  32943. static readonly ALPHA_DISABLE: number;
  32944. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32945. static readonly ALPHA_ADD: number;
  32946. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32947. static readonly ALPHA_COMBINE: number;
  32948. /** Defines that alpha blending to DEST - SRC * DEST */
  32949. static readonly ALPHA_SUBTRACT: number;
  32950. /** Defines that alpha blending to SRC * DEST */
  32951. static readonly ALPHA_MULTIPLY: number;
  32952. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32953. static readonly ALPHA_MAXIMIZED: number;
  32954. /** Defines that alpha blending to SRC + DEST */
  32955. static readonly ALPHA_ONEONE: number;
  32956. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32957. static readonly ALPHA_PREMULTIPLIED: number;
  32958. /**
  32959. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32960. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32961. */
  32962. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32963. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32964. static readonly ALPHA_INTERPOLATE: number;
  32965. /**
  32966. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32967. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32968. */
  32969. static readonly ALPHA_SCREENMODE: number;
  32970. /** Defines that the ressource is not delayed*/
  32971. static readonly DELAYLOADSTATE_NONE: number;
  32972. /** Defines that the ressource was successfully delay loaded */
  32973. static readonly DELAYLOADSTATE_LOADED: number;
  32974. /** Defines that the ressource is currently delay loading */
  32975. static readonly DELAYLOADSTATE_LOADING: number;
  32976. /** Defines that the ressource is delayed and has not started loading */
  32977. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32978. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32979. static readonly NEVER: number;
  32980. /** 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 */
  32981. static readonly ALWAYS: number;
  32982. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32983. static readonly LESS: number;
  32984. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32985. static readonly EQUAL: number;
  32986. /** 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 */
  32987. static readonly LEQUAL: number;
  32988. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32989. static readonly GREATER: number;
  32990. /** 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 */
  32991. static readonly GEQUAL: number;
  32992. /** 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 */
  32993. static readonly NOTEQUAL: number;
  32994. /** Passed to stencilOperation to specify that stencil value must be kept */
  32995. static readonly KEEP: number;
  32996. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32997. static readonly REPLACE: number;
  32998. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32999. static readonly INCR: number;
  33000. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33001. static readonly DECR: number;
  33002. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33003. static readonly INVERT: number;
  33004. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33005. static readonly INCR_WRAP: number;
  33006. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33007. static readonly DECR_WRAP: number;
  33008. /** Texture is not repeating outside of 0..1 UVs */
  33009. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33010. /** Texture is repeating outside of 0..1 UVs */
  33011. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33012. /** Texture is repeating and mirrored */
  33013. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33014. /** ALPHA */
  33015. static readonly TEXTUREFORMAT_ALPHA: number;
  33016. /** LUMINANCE */
  33017. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33018. /** LUMINANCE_ALPHA */
  33019. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33020. /** RGB */
  33021. static readonly TEXTUREFORMAT_RGB: number;
  33022. /** RGBA */
  33023. static readonly TEXTUREFORMAT_RGBA: number;
  33024. /** RED */
  33025. static readonly TEXTUREFORMAT_RED: number;
  33026. /** RED (2nd reference) */
  33027. static readonly TEXTUREFORMAT_R: number;
  33028. /** RG */
  33029. static readonly TEXTUREFORMAT_RG: number;
  33030. /** RED_INTEGER */
  33031. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33032. /** RED_INTEGER (2nd reference) */
  33033. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33034. /** RG_INTEGER */
  33035. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33036. /** RGB_INTEGER */
  33037. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33038. /** RGBA_INTEGER */
  33039. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33040. /** UNSIGNED_BYTE */
  33041. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33042. /** UNSIGNED_BYTE (2nd reference) */
  33043. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33044. /** FLOAT */
  33045. static readonly TEXTURETYPE_FLOAT: number;
  33046. /** HALF_FLOAT */
  33047. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33048. /** BYTE */
  33049. static readonly TEXTURETYPE_BYTE: number;
  33050. /** SHORT */
  33051. static readonly TEXTURETYPE_SHORT: number;
  33052. /** UNSIGNED_SHORT */
  33053. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33054. /** INT */
  33055. static readonly TEXTURETYPE_INT: number;
  33056. /** UNSIGNED_INT */
  33057. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33058. /** UNSIGNED_SHORT_4_4_4_4 */
  33059. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33060. /** UNSIGNED_SHORT_5_5_5_1 */
  33061. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33062. /** UNSIGNED_SHORT_5_6_5 */
  33063. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33064. /** UNSIGNED_INT_2_10_10_10_REV */
  33065. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33066. /** UNSIGNED_INT_24_8 */
  33067. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33068. /** UNSIGNED_INT_10F_11F_11F_REV */
  33069. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33070. /** UNSIGNED_INT_5_9_9_9_REV */
  33071. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33072. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33073. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33074. /** nearest is mag = nearest and min = nearest and mip = linear */
  33075. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33077. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33078. /** Trilinear is mag = linear and min = linear and mip = linear */
  33079. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33080. /** nearest is mag = nearest and min = nearest and mip = linear */
  33081. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33082. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33083. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33084. /** Trilinear is mag = linear and min = linear and mip = linear */
  33085. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33086. /** mag = nearest and min = nearest and mip = nearest */
  33087. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33088. /** mag = nearest and min = linear and mip = nearest */
  33089. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33090. /** mag = nearest and min = linear and mip = linear */
  33091. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33092. /** mag = nearest and min = linear and mip = none */
  33093. static readonly TEXTURE_NEAREST_LINEAR: number;
  33094. /** mag = nearest and min = nearest and mip = none */
  33095. static readonly TEXTURE_NEAREST_NEAREST: number;
  33096. /** mag = linear and min = nearest and mip = nearest */
  33097. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33098. /** mag = linear and min = nearest and mip = linear */
  33099. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33100. /** mag = linear and min = linear and mip = none */
  33101. static readonly TEXTURE_LINEAR_LINEAR: number;
  33102. /** mag = linear and min = nearest and mip = none */
  33103. static readonly TEXTURE_LINEAR_NEAREST: number;
  33104. /** Explicit coordinates mode */
  33105. static readonly TEXTURE_EXPLICIT_MODE: number;
  33106. /** Spherical coordinates mode */
  33107. static readonly TEXTURE_SPHERICAL_MODE: number;
  33108. /** Planar coordinates mode */
  33109. static readonly TEXTURE_PLANAR_MODE: number;
  33110. /** Cubic coordinates mode */
  33111. static readonly TEXTURE_CUBIC_MODE: number;
  33112. /** Projection coordinates mode */
  33113. static readonly TEXTURE_PROJECTION_MODE: number;
  33114. /** Skybox coordinates mode */
  33115. static readonly TEXTURE_SKYBOX_MODE: number;
  33116. /** Inverse Cubic coordinates mode */
  33117. static readonly TEXTURE_INVCUBIC_MODE: number;
  33118. /** Equirectangular coordinates mode */
  33119. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33120. /** Equirectangular Fixed coordinates mode */
  33121. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33122. /** Equirectangular Fixed Mirrored coordinates mode */
  33123. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33124. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33125. static readonly SCALEMODE_FLOOR: number;
  33126. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33127. static readonly SCALEMODE_NEAREST: number;
  33128. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33129. static readonly SCALEMODE_CEILING: number;
  33130. /**
  33131. * Returns the current npm package of the sdk
  33132. */
  33133. static get NpmPackage(): string;
  33134. /**
  33135. * Returns the current version of the framework
  33136. */
  33137. static get Version(): string;
  33138. /** Gets the list of created engines */
  33139. static get Instances(): Engine[];
  33140. /**
  33141. * Gets the latest created engine
  33142. */
  33143. static get LastCreatedEngine(): Nullable<Engine>;
  33144. /**
  33145. * Gets the latest created scene
  33146. */
  33147. static get LastCreatedScene(): Nullable<Scene>;
  33148. /**
  33149. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33150. * @param flag defines which part of the materials must be marked as dirty
  33151. * @param predicate defines a predicate used to filter which materials should be affected
  33152. */
  33153. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33154. /**
  33155. * Method called to create the default loading screen.
  33156. * This can be overriden in your own app.
  33157. * @param canvas The rendering canvas element
  33158. * @returns The loading screen
  33159. */
  33160. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33161. /**
  33162. * Method called to create the default rescale post process on each engine.
  33163. */
  33164. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33165. /**
  33166. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33167. **/
  33168. enableOfflineSupport: boolean;
  33169. /**
  33170. * 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)
  33171. **/
  33172. disableManifestCheck: boolean;
  33173. /**
  33174. * Gets the list of created scenes
  33175. */
  33176. scenes: Scene[];
  33177. /**
  33178. * Event raised when a new scene is created
  33179. */
  33180. onNewSceneAddedObservable: Observable<Scene>;
  33181. /**
  33182. * Gets the list of created postprocesses
  33183. */
  33184. postProcesses: PostProcess[];
  33185. /**
  33186. * Gets a boolean indicating if the pointer is currently locked
  33187. */
  33188. isPointerLock: boolean;
  33189. /**
  33190. * Observable event triggered each time the rendering canvas is resized
  33191. */
  33192. onResizeObservable: Observable<Engine>;
  33193. /**
  33194. * Observable event triggered each time the canvas loses focus
  33195. */
  33196. onCanvasBlurObservable: Observable<Engine>;
  33197. /**
  33198. * Observable event triggered each time the canvas gains focus
  33199. */
  33200. onCanvasFocusObservable: Observable<Engine>;
  33201. /**
  33202. * Observable event triggered each time the canvas receives pointerout event
  33203. */
  33204. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33205. /**
  33206. * Observable raised when the engine begins a new frame
  33207. */
  33208. onBeginFrameObservable: Observable<Engine>;
  33209. /**
  33210. * If set, will be used to request the next animation frame for the render loop
  33211. */
  33212. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33213. /**
  33214. * Observable raised when the engine ends the current frame
  33215. */
  33216. onEndFrameObservable: Observable<Engine>;
  33217. /**
  33218. * Observable raised when the engine is about to compile a shader
  33219. */
  33220. onBeforeShaderCompilationObservable: Observable<Engine>;
  33221. /**
  33222. * Observable raised when the engine has jsut compiled a shader
  33223. */
  33224. onAfterShaderCompilationObservable: Observable<Engine>;
  33225. /**
  33226. * Gets the audio engine
  33227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33228. * @ignorenaming
  33229. */
  33230. static audioEngine: IAudioEngine;
  33231. /**
  33232. * Default AudioEngine factory responsible of creating the Audio Engine.
  33233. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33234. */
  33235. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33236. /**
  33237. * Default offline support factory responsible of creating a tool used to store data locally.
  33238. * By default, this will create a Database object if the workload has been embedded.
  33239. */
  33240. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33241. private _loadingScreen;
  33242. private _pointerLockRequested;
  33243. private _dummyFramebuffer;
  33244. private _rescalePostProcess;
  33245. private _deterministicLockstep;
  33246. private _lockstepMaxSteps;
  33247. private _timeStep;
  33248. protected get _supportsHardwareTextureRescaling(): boolean;
  33249. private _fps;
  33250. private _deltaTime;
  33251. /** @hidden */
  33252. _drawCalls: PerfCounter;
  33253. /** 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 */
  33254. canvasTabIndex: number;
  33255. /**
  33256. * Turn this value on if you want to pause FPS computation when in background
  33257. */
  33258. disablePerformanceMonitorInBackground: boolean;
  33259. private _performanceMonitor;
  33260. /**
  33261. * Gets the performance monitor attached to this engine
  33262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33263. */
  33264. get performanceMonitor(): PerformanceMonitor;
  33265. private _onFocus;
  33266. private _onBlur;
  33267. private _onCanvasPointerOut;
  33268. private _onCanvasBlur;
  33269. private _onCanvasFocus;
  33270. private _onFullscreenChange;
  33271. private _onPointerLockChange;
  33272. /**
  33273. * Gets the HTML element used to attach event listeners
  33274. * @returns a HTML element
  33275. */
  33276. getInputElement(): Nullable<HTMLElement>;
  33277. /**
  33278. * Creates a new engine
  33279. * @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
  33280. * @param antialias defines enable antialiasing (default: false)
  33281. * @param options defines further options to be sent to the getContext() function
  33282. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33283. */
  33284. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33285. /**
  33286. * Gets current aspect ratio
  33287. * @param viewportOwner defines the camera to use to get the aspect ratio
  33288. * @param useScreen defines if screen size must be used (or the current render target if any)
  33289. * @returns a number defining the aspect ratio
  33290. */
  33291. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33292. /**
  33293. * Gets current screen aspect ratio
  33294. * @returns a number defining the aspect ratio
  33295. */
  33296. getScreenAspectRatio(): number;
  33297. /**
  33298. * Gets the client rect of the HTML canvas attached with the current webGL context
  33299. * @returns a client rectanglee
  33300. */
  33301. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33302. /**
  33303. * Gets the client rect of the HTML element used for events
  33304. * @returns a client rectanglee
  33305. */
  33306. getInputElementClientRect(): Nullable<ClientRect>;
  33307. /**
  33308. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33309. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33310. * @returns true if engine is in deterministic lock step mode
  33311. */
  33312. isDeterministicLockStep(): boolean;
  33313. /**
  33314. * Gets the max steps when engine is running in deterministic lock step
  33315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33316. * @returns the max steps
  33317. */
  33318. getLockstepMaxSteps(): number;
  33319. /**
  33320. * Returns the time in ms between steps when using deterministic lock step.
  33321. * @returns time step in (ms)
  33322. */
  33323. getTimeStep(): number;
  33324. /**
  33325. * Force the mipmap generation for the given render target texture
  33326. * @param texture defines the render target texture to use
  33327. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33328. */
  33329. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33330. /** States */
  33331. /**
  33332. * Set various states to the webGL context
  33333. * @param culling defines backface culling state
  33334. * @param zOffset defines the value to apply to zOffset (0 by default)
  33335. * @param force defines if states must be applied even if cache is up to date
  33336. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33337. */
  33338. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33339. /**
  33340. * Set the z offset to apply to current rendering
  33341. * @param value defines the offset to apply
  33342. */
  33343. setZOffset(value: number): void;
  33344. /**
  33345. * Gets the current value of the zOffset
  33346. * @returns the current zOffset state
  33347. */
  33348. getZOffset(): number;
  33349. /**
  33350. * Enable or disable depth buffering
  33351. * @param enable defines the state to set
  33352. */
  33353. setDepthBuffer(enable: boolean): void;
  33354. /**
  33355. * Gets a boolean indicating if depth writing is enabled
  33356. * @returns the current depth writing state
  33357. */
  33358. getDepthWrite(): boolean;
  33359. /**
  33360. * Enable or disable depth writing
  33361. * @param enable defines the state to set
  33362. */
  33363. setDepthWrite(enable: boolean): void;
  33364. /**
  33365. * Gets a boolean indicating if stencil buffer is enabled
  33366. * @returns the current stencil buffer state
  33367. */
  33368. getStencilBuffer(): boolean;
  33369. /**
  33370. * Enable or disable the stencil buffer
  33371. * @param enable defines if the stencil buffer must be enabled or disabled
  33372. */
  33373. setStencilBuffer(enable: boolean): void;
  33374. /**
  33375. * Gets the current stencil mask
  33376. * @returns a number defining the new stencil mask to use
  33377. */
  33378. getStencilMask(): number;
  33379. /**
  33380. * Sets the current stencil mask
  33381. * @param mask defines the new stencil mask to use
  33382. */
  33383. setStencilMask(mask: number): void;
  33384. /**
  33385. * Gets the current stencil function
  33386. * @returns a number defining the stencil function to use
  33387. */
  33388. getStencilFunction(): number;
  33389. /**
  33390. * Gets the current stencil reference value
  33391. * @returns a number defining the stencil reference value to use
  33392. */
  33393. getStencilFunctionReference(): number;
  33394. /**
  33395. * Gets the current stencil mask
  33396. * @returns a number defining the stencil mask to use
  33397. */
  33398. getStencilFunctionMask(): number;
  33399. /**
  33400. * Sets the current stencil function
  33401. * @param stencilFunc defines the new stencil function to use
  33402. */
  33403. setStencilFunction(stencilFunc: number): void;
  33404. /**
  33405. * Sets the current stencil reference
  33406. * @param reference defines the new stencil reference to use
  33407. */
  33408. setStencilFunctionReference(reference: number): void;
  33409. /**
  33410. * Sets the current stencil mask
  33411. * @param mask defines the new stencil mask to use
  33412. */
  33413. setStencilFunctionMask(mask: number): void;
  33414. /**
  33415. * Gets the current stencil operation when stencil fails
  33416. * @returns a number defining stencil operation to use when stencil fails
  33417. */
  33418. getStencilOperationFail(): number;
  33419. /**
  33420. * Gets the current stencil operation when depth fails
  33421. * @returns a number defining stencil operation to use when depth fails
  33422. */
  33423. getStencilOperationDepthFail(): number;
  33424. /**
  33425. * Gets the current stencil operation when stencil passes
  33426. * @returns a number defining stencil operation to use when stencil passes
  33427. */
  33428. getStencilOperationPass(): number;
  33429. /**
  33430. * Sets the stencil operation to use when stencil fails
  33431. * @param operation defines the stencil operation to use when stencil fails
  33432. */
  33433. setStencilOperationFail(operation: number): void;
  33434. /**
  33435. * Sets the stencil operation to use when depth fails
  33436. * @param operation defines the stencil operation to use when depth fails
  33437. */
  33438. setStencilOperationDepthFail(operation: number): void;
  33439. /**
  33440. * Sets the stencil operation to use when stencil passes
  33441. * @param operation defines the stencil operation to use when stencil passes
  33442. */
  33443. setStencilOperationPass(operation: number): void;
  33444. /**
  33445. * Sets a boolean indicating if the dithering state is enabled or disabled
  33446. * @param value defines the dithering state
  33447. */
  33448. setDitheringState(value: boolean): void;
  33449. /**
  33450. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33451. * @param value defines the rasterizer state
  33452. */
  33453. setRasterizerState(value: boolean): void;
  33454. /**
  33455. * Gets the current depth function
  33456. * @returns a number defining the depth function
  33457. */
  33458. getDepthFunction(): Nullable<number>;
  33459. /**
  33460. * Sets the current depth function
  33461. * @param depthFunc defines the function to use
  33462. */
  33463. setDepthFunction(depthFunc: number): void;
  33464. /**
  33465. * Sets the current depth function to GREATER
  33466. */
  33467. setDepthFunctionToGreater(): void;
  33468. /**
  33469. * Sets the current depth function to GEQUAL
  33470. */
  33471. setDepthFunctionToGreaterOrEqual(): void;
  33472. /**
  33473. * Sets the current depth function to LESS
  33474. */
  33475. setDepthFunctionToLess(): void;
  33476. /**
  33477. * Sets the current depth function to LEQUAL
  33478. */
  33479. setDepthFunctionToLessOrEqual(): void;
  33480. private _cachedStencilBuffer;
  33481. private _cachedStencilFunction;
  33482. private _cachedStencilMask;
  33483. private _cachedStencilOperationPass;
  33484. private _cachedStencilOperationFail;
  33485. private _cachedStencilOperationDepthFail;
  33486. private _cachedStencilReference;
  33487. /**
  33488. * Caches the the state of the stencil buffer
  33489. */
  33490. cacheStencilState(): void;
  33491. /**
  33492. * Restores the state of the stencil buffer
  33493. */
  33494. restoreStencilState(): void;
  33495. /**
  33496. * Directly set the WebGL Viewport
  33497. * @param x defines the x coordinate of the viewport (in screen space)
  33498. * @param y defines the y coordinate of the viewport (in screen space)
  33499. * @param width defines the width of the viewport (in screen space)
  33500. * @param height defines the height of the viewport (in screen space)
  33501. * @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
  33502. */
  33503. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33504. /**
  33505. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33506. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33507. * @param y defines the y-coordinate of the corner of the clear rectangle
  33508. * @param width defines the width of the clear rectangle
  33509. * @param height defines the height of the clear rectangle
  33510. * @param clearColor defines the clear color
  33511. */
  33512. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33513. /**
  33514. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33515. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33516. * @param y defines the y-coordinate of the corner of the clear rectangle
  33517. * @param width defines the width of the clear rectangle
  33518. * @param height defines the height of the clear rectangle
  33519. */
  33520. enableScissor(x: number, y: number, width: number, height: number): void;
  33521. /**
  33522. * Disable previously set scissor test rectangle
  33523. */
  33524. disableScissor(): void;
  33525. protected _reportDrawCall(): void;
  33526. /**
  33527. * Initializes a webVR display and starts listening to display change events
  33528. * The onVRDisplayChangedObservable will be notified upon these changes
  33529. * @returns The onVRDisplayChangedObservable
  33530. */
  33531. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33532. /** @hidden */
  33533. _prepareVRComponent(): void;
  33534. /** @hidden */
  33535. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33536. /** @hidden */
  33537. _submitVRFrame(): void;
  33538. /**
  33539. * Call this function to leave webVR mode
  33540. * Will do nothing if webVR is not supported or if there is no webVR device
  33541. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33542. */
  33543. disableVR(): void;
  33544. /**
  33545. * Gets a boolean indicating that the system is in VR mode and is presenting
  33546. * @returns true if VR mode is engaged
  33547. */
  33548. isVRPresenting(): boolean;
  33549. /** @hidden */
  33550. _requestVRFrame(): void;
  33551. /** @hidden */
  33552. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33553. /**
  33554. * Gets the source code of the vertex shader associated with a specific webGL program
  33555. * @param program defines the program to use
  33556. * @returns a string containing the source code of the vertex shader associated with the program
  33557. */
  33558. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33559. /**
  33560. * Gets the source code of the fragment shader associated with a specific webGL program
  33561. * @param program defines the program to use
  33562. * @returns a string containing the source code of the fragment shader associated with the program
  33563. */
  33564. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33565. /**
  33566. * Sets a depth stencil texture from a render target to the according uniform.
  33567. * @param channel The texture channel
  33568. * @param uniform The uniform to set
  33569. * @param texture The render target texture containing the depth stencil texture to apply
  33570. */
  33571. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33572. /**
  33573. * Sets a texture to the webGL context from a postprocess
  33574. * @param channel defines the channel to use
  33575. * @param postProcess defines the source postprocess
  33576. */
  33577. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33578. /**
  33579. * Binds the output of the passed in post process to the texture channel specified
  33580. * @param channel The channel the texture should be bound to
  33581. * @param postProcess The post process which's output should be bound
  33582. */
  33583. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33584. /** @hidden */
  33585. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33586. protected _rebuildBuffers(): void;
  33587. /** @hidden */
  33588. _renderFrame(): void;
  33589. _renderLoop(): void;
  33590. /** @hidden */
  33591. _renderViews(): boolean;
  33592. /**
  33593. * Toggle full screen mode
  33594. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33595. */
  33596. switchFullscreen(requestPointerLock: boolean): void;
  33597. /**
  33598. * Enters full screen mode
  33599. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33600. */
  33601. enterFullscreen(requestPointerLock: boolean): void;
  33602. /**
  33603. * Exits full screen mode
  33604. */
  33605. exitFullscreen(): void;
  33606. /**
  33607. * Enters Pointerlock mode
  33608. */
  33609. enterPointerlock(): void;
  33610. /**
  33611. * Exits Pointerlock mode
  33612. */
  33613. exitPointerlock(): void;
  33614. /**
  33615. * Begin a new frame
  33616. */
  33617. beginFrame(): void;
  33618. /**
  33619. * Enf the current frame
  33620. */
  33621. endFrame(): void;
  33622. resize(): void;
  33623. /**
  33624. * Set the compressed texture format to use, based on the formats you have, and the formats
  33625. * supported by the hardware / browser.
  33626. *
  33627. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33628. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33629. * to API arguments needed to compressed textures. This puts the burden on the container
  33630. * generator to house the arcane code for determining these for current & future formats.
  33631. *
  33632. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33633. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33634. *
  33635. * Note: The result of this call is not taken into account when a texture is base64.
  33636. *
  33637. * @param formatsAvailable defines the list of those format families you have created
  33638. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33639. *
  33640. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33641. * @returns The extension selected.
  33642. */
  33643. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33644. /**
  33645. * Set the compressed texture extensions or file names to skip.
  33646. *
  33647. * @param skippedFiles defines the list of those texture files you want to skip
  33648. * Example: [".dds", ".env", "myfile.png"]
  33649. */
  33650. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33651. /**
  33652. * Force a specific size of the canvas
  33653. * @param width defines the new canvas' width
  33654. * @param height defines the new canvas' height
  33655. */
  33656. setSize(width: number, height: number): void;
  33657. /**
  33658. * Updates a dynamic vertex buffer.
  33659. * @param vertexBuffer the vertex buffer to update
  33660. * @param data the data used to update the vertex buffer
  33661. * @param byteOffset the byte offset of the data
  33662. * @param byteLength the byte length of the data
  33663. */
  33664. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33665. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33666. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33667. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33668. _releaseTexture(texture: InternalTexture): void;
  33669. /**
  33670. * @hidden
  33671. * Rescales a texture
  33672. * @param source input texutre
  33673. * @param destination destination texture
  33674. * @param scene scene to use to render the resize
  33675. * @param internalFormat format to use when resizing
  33676. * @param onComplete callback to be called when resize has completed
  33677. */
  33678. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33679. /**
  33680. * Gets the current framerate
  33681. * @returns a number representing the framerate
  33682. */
  33683. getFps(): number;
  33684. /**
  33685. * Gets the time spent between current and previous frame
  33686. * @returns a number representing the delta time in ms
  33687. */
  33688. getDeltaTime(): number;
  33689. private _measureFps;
  33690. /** @hidden */
  33691. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33692. /**
  33693. * Update a dynamic index buffer
  33694. * @param indexBuffer defines the target index buffer
  33695. * @param indices defines the data to update
  33696. * @param offset defines the offset in the target index buffer where update should start
  33697. */
  33698. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33699. /**
  33700. * Updates the sample count of a render target texture
  33701. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33702. * @param texture defines the texture to update
  33703. * @param samples defines the sample count to set
  33704. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33705. */
  33706. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33707. /**
  33708. * Updates a depth texture Comparison Mode and Function.
  33709. * If the comparison Function is equal to 0, the mode will be set to none.
  33710. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33711. * @param texture The texture to set the comparison function for
  33712. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33713. */
  33714. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33715. /**
  33716. * Creates a webGL buffer to use with instanciation
  33717. * @param capacity defines the size of the buffer
  33718. * @returns the webGL buffer
  33719. */
  33720. createInstancesBuffer(capacity: number): DataBuffer;
  33721. /**
  33722. * Delete a webGL buffer used with instanciation
  33723. * @param buffer defines the webGL buffer to delete
  33724. */
  33725. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33726. /** @hidden */
  33727. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33728. dispose(): void;
  33729. private _disableTouchAction;
  33730. /**
  33731. * Display the loading screen
  33732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33733. */
  33734. displayLoadingUI(): void;
  33735. /**
  33736. * Hide the loading screen
  33737. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33738. */
  33739. hideLoadingUI(): void;
  33740. /**
  33741. * Gets the current loading screen object
  33742. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33743. */
  33744. get loadingScreen(): ILoadingScreen;
  33745. /**
  33746. * Sets the current loading screen object
  33747. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33748. */
  33749. set loadingScreen(loadingScreen: ILoadingScreen);
  33750. /**
  33751. * Sets the current loading screen text
  33752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33753. */
  33754. set loadingUIText(text: string);
  33755. /**
  33756. * Sets the current loading screen background color
  33757. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33758. */
  33759. set loadingUIBackgroundColor(color: string);
  33760. /** Pointerlock and fullscreen */
  33761. /**
  33762. * Ask the browser to promote the current element to pointerlock mode
  33763. * @param element defines the DOM element to promote
  33764. */
  33765. static _RequestPointerlock(element: HTMLElement): void;
  33766. /**
  33767. * Asks the browser to exit pointerlock mode
  33768. */
  33769. static _ExitPointerlock(): void;
  33770. /**
  33771. * Ask the browser to promote the current element to fullscreen rendering mode
  33772. * @param element defines the DOM element to promote
  33773. */
  33774. static _RequestFullscreen(element: HTMLElement): void;
  33775. /**
  33776. * Asks the browser to exit fullscreen mode
  33777. */
  33778. static _ExitFullscreen(): void;
  33779. }
  33780. }
  33781. declare module BABYLON {
  33782. /**
  33783. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33784. * during the life time of the application.
  33785. */
  33786. export class EngineStore {
  33787. /** Gets the list of created engines */
  33788. static Instances: Engine[];
  33789. /** @hidden */
  33790. static _LastCreatedScene: Nullable<Scene>;
  33791. /**
  33792. * Gets the latest created engine
  33793. */
  33794. static get LastCreatedEngine(): Nullable<Engine>;
  33795. /**
  33796. * Gets the latest created scene
  33797. */
  33798. static get LastCreatedScene(): Nullable<Scene>;
  33799. /**
  33800. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33801. * @ignorenaming
  33802. */
  33803. static UseFallbackTexture: boolean;
  33804. /**
  33805. * Texture content used if a texture cannot loaded
  33806. * @ignorenaming
  33807. */
  33808. static FallbackTexture: string;
  33809. }
  33810. }
  33811. declare module BABYLON {
  33812. /**
  33813. * Helper class that provides a small promise polyfill
  33814. */
  33815. export class PromisePolyfill {
  33816. /**
  33817. * Static function used to check if the polyfill is required
  33818. * If this is the case then the function will inject the polyfill to window.Promise
  33819. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33820. */
  33821. static Apply(force?: boolean): void;
  33822. }
  33823. }
  33824. declare module BABYLON {
  33825. /**
  33826. * Interface for screenshot methods with describe argument called `size` as object with options
  33827. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33828. */
  33829. export interface IScreenshotSize {
  33830. /**
  33831. * number in pixels for canvas height
  33832. */
  33833. height?: number;
  33834. /**
  33835. * multiplier allowing render at a higher or lower resolution
  33836. * If value is defined then height and width will be ignored and taken from camera
  33837. */
  33838. precision?: number;
  33839. /**
  33840. * number in pixels for canvas width
  33841. */
  33842. width?: number;
  33843. }
  33844. }
  33845. declare module BABYLON {
  33846. interface IColor4Like {
  33847. r: float;
  33848. g: float;
  33849. b: float;
  33850. a: float;
  33851. }
  33852. /**
  33853. * Class containing a set of static utilities functions
  33854. */
  33855. export class Tools {
  33856. /**
  33857. * Gets or sets the base URL to use to load assets
  33858. */
  33859. static get BaseUrl(): string;
  33860. static set BaseUrl(value: string);
  33861. /**
  33862. * Enable/Disable Custom HTTP Request Headers globally.
  33863. * default = false
  33864. * @see CustomRequestHeaders
  33865. */
  33866. static UseCustomRequestHeaders: boolean;
  33867. /**
  33868. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33869. * i.e. when loading files, where the server/service expects an Authorization header
  33870. */
  33871. static CustomRequestHeaders: {
  33872. [key: string]: string;
  33873. };
  33874. /**
  33875. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33876. */
  33877. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33878. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33879. /**
  33880. * Default behaviour for cors in the application.
  33881. * It can be a string if the expected behavior is identical in the entire app.
  33882. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33883. */
  33884. static CorsBehavior: string | ((url: string | string[]) => string);
  33885. /**
  33886. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33887. * @ignorenaming
  33888. */
  33889. static get UseFallbackTexture(): boolean;
  33890. static set UseFallbackTexture(value: boolean);
  33891. /**
  33892. * Use this object to register external classes like custom textures or material
  33893. * to allow the laoders to instantiate them
  33894. */
  33895. static get RegisteredExternalClasses(): {
  33896. [key: string]: Object;
  33897. };
  33898. static set RegisteredExternalClasses(classes: {
  33899. [key: string]: Object;
  33900. });
  33901. /**
  33902. * Texture content used if a texture cannot loaded
  33903. * @ignorenaming
  33904. */
  33905. static get fallbackTexture(): string;
  33906. static set fallbackTexture(value: string);
  33907. /**
  33908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33909. * @param u defines the coordinate on X axis
  33910. * @param v defines the coordinate on Y axis
  33911. * @param width defines the width of the source data
  33912. * @param height defines the height of the source data
  33913. * @param pixels defines the source byte array
  33914. * @param color defines the output color
  33915. */
  33916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33917. /**
  33918. * Interpolates between a and b via alpha
  33919. * @param a The lower value (returned when alpha = 0)
  33920. * @param b The upper value (returned when alpha = 1)
  33921. * @param alpha The interpolation-factor
  33922. * @return The mixed value
  33923. */
  33924. static Mix(a: number, b: number, alpha: number): number;
  33925. /**
  33926. * Tries to instantiate a new object from a given class name
  33927. * @param className defines the class name to instantiate
  33928. * @returns the new object or null if the system was not able to do the instantiation
  33929. */
  33930. static Instantiate(className: string): any;
  33931. /**
  33932. * Provides a slice function that will work even on IE
  33933. * @param data defines the array to slice
  33934. * @param start defines the start of the data (optional)
  33935. * @param end defines the end of the data (optional)
  33936. * @returns the new sliced array
  33937. */
  33938. static Slice<T>(data: T, start?: number, end?: number): T;
  33939. /**
  33940. * Polyfill for setImmediate
  33941. * @param action defines the action to execute after the current execution block
  33942. */
  33943. static SetImmediate(action: () => void): void;
  33944. /**
  33945. * Function indicating if a number is an exponent of 2
  33946. * @param value defines the value to test
  33947. * @returns true if the value is an exponent of 2
  33948. */
  33949. static IsExponentOfTwo(value: number): boolean;
  33950. private static _tmpFloatArray;
  33951. /**
  33952. * Returns the nearest 32-bit single precision float representation of a Number
  33953. * @param value A Number. If the parameter is of a different type, it will get converted
  33954. * to a number or to NaN if it cannot be converted
  33955. * @returns number
  33956. */
  33957. static FloatRound(value: number): number;
  33958. /**
  33959. * Extracts the filename from a path
  33960. * @param path defines the path to use
  33961. * @returns the filename
  33962. */
  33963. static GetFilename(path: string): string;
  33964. /**
  33965. * Extracts the "folder" part of a path (everything before the filename).
  33966. * @param uri The URI to extract the info from
  33967. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33968. * @returns The "folder" part of the path
  33969. */
  33970. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33971. /**
  33972. * Extracts text content from a DOM element hierarchy
  33973. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33974. */
  33975. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33976. /**
  33977. * Convert an angle in radians to degrees
  33978. * @param angle defines the angle to convert
  33979. * @returns the angle in degrees
  33980. */
  33981. static ToDegrees(angle: number): number;
  33982. /**
  33983. * Convert an angle in degrees to radians
  33984. * @param angle defines the angle to convert
  33985. * @returns the angle in radians
  33986. */
  33987. static ToRadians(angle: number): number;
  33988. /**
  33989. * Returns an array if obj is not an array
  33990. * @param obj defines the object to evaluate as an array
  33991. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33992. * @returns either obj directly if obj is an array or a new array containing obj
  33993. */
  33994. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33995. /**
  33996. * Gets the pointer prefix to use
  33997. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33998. */
  33999. static GetPointerPrefix(): string;
  34000. /**
  34001. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34002. * @param url define the url we are trying
  34003. * @param element define the dom element where to configure the cors policy
  34004. */
  34005. static SetCorsBehavior(url: string | string[], element: {
  34006. crossOrigin: string | null;
  34007. }): void;
  34008. /**
  34009. * Removes unwanted characters from an url
  34010. * @param url defines the url to clean
  34011. * @returns the cleaned url
  34012. */
  34013. static CleanUrl(url: string): string;
  34014. /**
  34015. * Gets or sets a function used to pre-process url before using them to load assets
  34016. */
  34017. static get PreprocessUrl(): (url: string) => string;
  34018. static set PreprocessUrl(processor: (url: string) => string);
  34019. /**
  34020. * Loads an image as an HTMLImageElement.
  34021. * @param input url string, ArrayBuffer, or Blob to load
  34022. * @param onLoad callback called when the image successfully loads
  34023. * @param onError callback called when the image fails to load
  34024. * @param offlineProvider offline provider for caching
  34025. * @param mimeType optional mime type
  34026. * @returns the HTMLImageElement of the loaded image
  34027. */
  34028. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34029. /**
  34030. * Loads a file from a url
  34031. * @param url url string, ArrayBuffer, or Blob to load
  34032. * @param onSuccess callback called when the file successfully loads
  34033. * @param onProgress callback called while file is loading (if the server supports this mode)
  34034. * @param offlineProvider defines the offline provider for caching
  34035. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34036. * @param onError callback called when the file fails to load
  34037. * @returns a file request object
  34038. */
  34039. 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;
  34040. /**
  34041. * Loads a file from a url
  34042. * @param url the file url to load
  34043. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34044. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34045. */
  34046. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34047. /**
  34048. * Load a script (identified by an url). When the url returns, the
  34049. * content of this file is added into a new script element, attached to the DOM (body element)
  34050. * @param scriptUrl defines the url of the script to laod
  34051. * @param onSuccess defines the callback called when the script is loaded
  34052. * @param onError defines the callback to call if an error occurs
  34053. * @param scriptId defines the id of the script element
  34054. */
  34055. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34056. /**
  34057. * Load an asynchronous script (identified by an url). When the url returns, the
  34058. * content of this file is added into a new script element, attached to the DOM (body element)
  34059. * @param scriptUrl defines the url of the script to laod
  34060. * @param scriptId defines the id of the script element
  34061. * @returns a promise request object
  34062. */
  34063. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34064. /**
  34065. * Loads a file from a blob
  34066. * @param fileToLoad defines the blob to use
  34067. * @param callback defines the callback to call when data is loaded
  34068. * @param progressCallback defines the callback to call during loading process
  34069. * @returns a file request object
  34070. */
  34071. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34072. /**
  34073. * Reads a file from a File object
  34074. * @param file defines the file to load
  34075. * @param onSuccess defines the callback to call when data is loaded
  34076. * @param onProgress defines the callback to call during loading process
  34077. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34078. * @param onError defines the callback to call when an error occurs
  34079. * @returns a file request object
  34080. */
  34081. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34082. /**
  34083. * Creates a data url from a given string content
  34084. * @param content defines the content to convert
  34085. * @returns the new data url link
  34086. */
  34087. static FileAsURL(content: string): string;
  34088. /**
  34089. * Format the given number to a specific decimal format
  34090. * @param value defines the number to format
  34091. * @param decimals defines the number of decimals to use
  34092. * @returns the formatted string
  34093. */
  34094. static Format(value: number, decimals?: number): string;
  34095. /**
  34096. * Tries to copy an object by duplicating every property
  34097. * @param source defines the source object
  34098. * @param destination defines the target object
  34099. * @param doNotCopyList defines a list of properties to avoid
  34100. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34101. */
  34102. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34103. /**
  34104. * Gets a boolean indicating if the given object has no own property
  34105. * @param obj defines the object to test
  34106. * @returns true if object has no own property
  34107. */
  34108. static IsEmpty(obj: any): boolean;
  34109. /**
  34110. * Function used to register events at window level
  34111. * @param windowElement defines the Window object to use
  34112. * @param events defines the events to register
  34113. */
  34114. static RegisterTopRootEvents(windowElement: Window, events: {
  34115. name: string;
  34116. handler: Nullable<(e: FocusEvent) => any>;
  34117. }[]): void;
  34118. /**
  34119. * Function used to unregister events from window level
  34120. * @param windowElement defines the Window object to use
  34121. * @param events defines the events to unregister
  34122. */
  34123. static UnregisterTopRootEvents(windowElement: Window, events: {
  34124. name: string;
  34125. handler: Nullable<(e: FocusEvent) => any>;
  34126. }[]): void;
  34127. /**
  34128. * @ignore
  34129. */
  34130. static _ScreenshotCanvas: HTMLCanvasElement;
  34131. /**
  34132. * Dumps the current bound framebuffer
  34133. * @param width defines the rendering width
  34134. * @param height defines the rendering height
  34135. * @param engine defines the hosting engine
  34136. * @param successCallback defines the callback triggered once the data are available
  34137. * @param mimeType defines the mime type of the result
  34138. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34139. */
  34140. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34141. /**
  34142. * Converts the canvas data to blob.
  34143. * This acts as a polyfill for browsers not supporting the to blob function.
  34144. * @param canvas Defines the canvas to extract the data from
  34145. * @param successCallback Defines the callback triggered once the data are available
  34146. * @param mimeType Defines the mime type of the result
  34147. */
  34148. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34149. /**
  34150. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34151. * @param successCallback defines the callback triggered once the data are available
  34152. * @param mimeType defines the mime type of the result
  34153. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34154. */
  34155. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34156. /**
  34157. * Downloads a blob in the browser
  34158. * @param blob defines the blob to download
  34159. * @param fileName defines the name of the downloaded file
  34160. */
  34161. static Download(blob: Blob, fileName: string): void;
  34162. /**
  34163. * Captures a screenshot of the current rendering
  34164. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34165. * @param engine defines the rendering engine
  34166. * @param camera defines the source camera
  34167. * @param size This parameter can be set to a single number or to an object with the
  34168. * following (optional) properties: precision, width, height. If a single number is passed,
  34169. * it will be used for both width and height. If an object is passed, the screenshot size
  34170. * will be derived from the parameters. The precision property is a multiplier allowing
  34171. * rendering at a higher or lower resolution
  34172. * @param successCallback defines the callback receives a single parameter which contains the
  34173. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34174. * src parameter of an <img> to display it
  34175. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34176. * Check your browser for supported MIME types
  34177. */
  34178. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34179. /**
  34180. * Captures a screenshot of the current rendering
  34181. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34182. * @param engine defines the rendering engine
  34183. * @param camera defines the source camera
  34184. * @param size This parameter can be set to a single number or to an object with the
  34185. * following (optional) properties: precision, width, height. If a single number is passed,
  34186. * it will be used for both width and height. If an object is passed, the screenshot size
  34187. * will be derived from the parameters. The precision property is a multiplier allowing
  34188. * rendering at a higher or lower resolution
  34189. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34190. * Check your browser for supported MIME types
  34191. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34192. * to the src parameter of an <img> to display it
  34193. */
  34194. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34195. /**
  34196. * Generates an image screenshot from the specified camera.
  34197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34198. * @param engine The engine to use for rendering
  34199. * @param camera The camera to use for rendering
  34200. * @param size This parameter can be set to a single number or to an object with the
  34201. * following (optional) properties: precision, width, height. If a single number is passed,
  34202. * it will be used for both width and height. If an object is passed, the screenshot size
  34203. * will be derived from the parameters. The precision property is a multiplier allowing
  34204. * rendering at a higher or lower resolution
  34205. * @param successCallback The callback receives a single parameter which contains the
  34206. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34207. * src parameter of an <img> to display it
  34208. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34209. * Check your browser for supported MIME types
  34210. * @param samples Texture samples (default: 1)
  34211. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34212. * @param fileName A name for for the downloaded file.
  34213. */
  34214. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34215. /**
  34216. * Generates an image screenshot from the specified camera.
  34217. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34218. * @param engine The engine to use for rendering
  34219. * @param camera The camera to use for rendering
  34220. * @param size This parameter can be set to a single number or to an object with the
  34221. * following (optional) properties: precision, width, height. If a single number is passed,
  34222. * it will be used for both width and height. If an object is passed, the screenshot size
  34223. * will be derived from the parameters. The precision property is a multiplier allowing
  34224. * rendering at a higher or lower resolution
  34225. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34226. * Check your browser for supported MIME types
  34227. * @param samples Texture samples (default: 1)
  34228. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34229. * @param fileName A name for for the downloaded file.
  34230. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34231. * to the src parameter of an <img> to display it
  34232. */
  34233. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34234. /**
  34235. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34236. * Be aware Math.random() could cause collisions, but:
  34237. * "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"
  34238. * @returns a pseudo random id
  34239. */
  34240. static RandomId(): string;
  34241. /**
  34242. * Test if the given uri is a base64 string
  34243. * @param uri The uri to test
  34244. * @return True if the uri is a base64 string or false otherwise
  34245. */
  34246. static IsBase64(uri: string): boolean;
  34247. /**
  34248. * Decode the given base64 uri.
  34249. * @param uri The uri to decode
  34250. * @return The decoded base64 data.
  34251. */
  34252. static DecodeBase64(uri: string): ArrayBuffer;
  34253. /**
  34254. * Gets the absolute url.
  34255. * @param url the input url
  34256. * @return the absolute url
  34257. */
  34258. static GetAbsoluteUrl(url: string): string;
  34259. /**
  34260. * No log
  34261. */
  34262. static readonly NoneLogLevel: number;
  34263. /**
  34264. * Only message logs
  34265. */
  34266. static readonly MessageLogLevel: number;
  34267. /**
  34268. * Only warning logs
  34269. */
  34270. static readonly WarningLogLevel: number;
  34271. /**
  34272. * Only error logs
  34273. */
  34274. static readonly ErrorLogLevel: number;
  34275. /**
  34276. * All logs
  34277. */
  34278. static readonly AllLogLevel: number;
  34279. /**
  34280. * Gets a value indicating the number of loading errors
  34281. * @ignorenaming
  34282. */
  34283. static get errorsCount(): number;
  34284. /**
  34285. * Callback called when a new log is added
  34286. */
  34287. static OnNewCacheEntry: (entry: string) => void;
  34288. /**
  34289. * Log a message to the console
  34290. * @param message defines the message to log
  34291. */
  34292. static Log(message: string): void;
  34293. /**
  34294. * Write a warning message to the console
  34295. * @param message defines the message to log
  34296. */
  34297. static Warn(message: string): void;
  34298. /**
  34299. * Write an error message to the console
  34300. * @param message defines the message to log
  34301. */
  34302. static Error(message: string): void;
  34303. /**
  34304. * Gets current log cache (list of logs)
  34305. */
  34306. static get LogCache(): string;
  34307. /**
  34308. * Clears the log cache
  34309. */
  34310. static ClearLogCache(): void;
  34311. /**
  34312. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34313. */
  34314. static set LogLevels(level: number);
  34315. /**
  34316. * Checks if the window object exists
  34317. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34318. */
  34319. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34320. /**
  34321. * No performance log
  34322. */
  34323. static readonly PerformanceNoneLogLevel: number;
  34324. /**
  34325. * Use user marks to log performance
  34326. */
  34327. static readonly PerformanceUserMarkLogLevel: number;
  34328. /**
  34329. * Log performance to the console
  34330. */
  34331. static readonly PerformanceConsoleLogLevel: number;
  34332. private static _performance;
  34333. /**
  34334. * Sets the current performance log level
  34335. */
  34336. static set PerformanceLogLevel(level: number);
  34337. private static _StartPerformanceCounterDisabled;
  34338. private static _EndPerformanceCounterDisabled;
  34339. private static _StartUserMark;
  34340. private static _EndUserMark;
  34341. private static _StartPerformanceConsole;
  34342. private static _EndPerformanceConsole;
  34343. /**
  34344. * Starts a performance counter
  34345. */
  34346. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34347. /**
  34348. * Ends a specific performance coutner
  34349. */
  34350. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34351. /**
  34352. * Gets either window.performance.now() if supported or Date.now() else
  34353. */
  34354. static get Now(): number;
  34355. /**
  34356. * This method will return the name of the class used to create the instance of the given object.
  34357. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34358. * @param object the object to get the class name from
  34359. * @param isType defines if the object is actually a type
  34360. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34361. */
  34362. static GetClassName(object: any, isType?: boolean): string;
  34363. /**
  34364. * Gets the first element of an array satisfying a given predicate
  34365. * @param array defines the array to browse
  34366. * @param predicate defines the predicate to use
  34367. * @returns null if not found or the element
  34368. */
  34369. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34370. /**
  34371. * This method will return the name of the full name of the class, including its owning module (if any).
  34372. * 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).
  34373. * @param object the object to get the class name from
  34374. * @param isType defines if the object is actually a type
  34375. * @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.
  34376. * @ignorenaming
  34377. */
  34378. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34379. /**
  34380. * Returns a promise that resolves after the given amount of time.
  34381. * @param delay Number of milliseconds to delay
  34382. * @returns Promise that resolves after the given amount of time
  34383. */
  34384. static DelayAsync(delay: number): Promise<void>;
  34385. /**
  34386. * Utility function to detect if the current user agent is Safari
  34387. * @returns whether or not the current user agent is safari
  34388. */
  34389. static IsSafari(): boolean;
  34390. }
  34391. /**
  34392. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34393. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34394. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34395. * @param name The name of the class, case should be preserved
  34396. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34397. */
  34398. export function className(name: string, module?: string): (target: Object) => void;
  34399. /**
  34400. * An implementation of a loop for asynchronous functions.
  34401. */
  34402. export class AsyncLoop {
  34403. /**
  34404. * Defines the number of iterations for the loop
  34405. */
  34406. iterations: number;
  34407. /**
  34408. * Defines the current index of the loop.
  34409. */
  34410. index: number;
  34411. private _done;
  34412. private _fn;
  34413. private _successCallback;
  34414. /**
  34415. * Constructor.
  34416. * @param iterations the number of iterations.
  34417. * @param func the function to run each iteration
  34418. * @param successCallback the callback that will be called upon succesful execution
  34419. * @param offset starting offset.
  34420. */
  34421. constructor(
  34422. /**
  34423. * Defines the number of iterations for the loop
  34424. */
  34425. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34426. /**
  34427. * Execute the next iteration. Must be called after the last iteration was finished.
  34428. */
  34429. executeNext(): void;
  34430. /**
  34431. * Break the loop and run the success callback.
  34432. */
  34433. breakLoop(): void;
  34434. /**
  34435. * Create and run an async loop.
  34436. * @param iterations the number of iterations.
  34437. * @param fn the function to run each iteration
  34438. * @param successCallback the callback that will be called upon succesful execution
  34439. * @param offset starting offset.
  34440. * @returns the created async loop object
  34441. */
  34442. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34443. /**
  34444. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34445. * @param iterations total number of iterations
  34446. * @param syncedIterations number of synchronous iterations in each async iteration.
  34447. * @param fn the function to call each iteration.
  34448. * @param callback a success call back that will be called when iterating stops.
  34449. * @param breakFunction a break condition (optional)
  34450. * @param timeout timeout settings for the setTimeout function. default - 0.
  34451. * @returns the created async loop object
  34452. */
  34453. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34454. }
  34455. }
  34456. declare module BABYLON {
  34457. /**
  34458. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34459. * The underlying implementation relies on an associative array to ensure the best performances.
  34460. * The value can be anything including 'null' but except 'undefined'
  34461. */
  34462. export class StringDictionary<T> {
  34463. /**
  34464. * This will clear this dictionary and copy the content from the 'source' one.
  34465. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34466. * @param source the dictionary to take the content from and copy to this dictionary
  34467. */
  34468. copyFrom(source: StringDictionary<T>): void;
  34469. /**
  34470. * Get a value based from its key
  34471. * @param key the given key to get the matching value from
  34472. * @return the value if found, otherwise undefined is returned
  34473. */
  34474. get(key: string): T | undefined;
  34475. /**
  34476. * Get a value from its key or add it if it doesn't exist.
  34477. * This method will ensure you that a given key/data will be present in the dictionary.
  34478. * @param key the given key to get the matching value from
  34479. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34480. * The factory will only be invoked if there's no data for the given key.
  34481. * @return the value corresponding to the key.
  34482. */
  34483. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34484. /**
  34485. * Get a value from its key if present in the dictionary otherwise add it
  34486. * @param key the key to get the value from
  34487. * @param val if there's no such key/value pair in the dictionary add it with this value
  34488. * @return the value corresponding to the key
  34489. */
  34490. getOrAdd(key: string, val: T): T;
  34491. /**
  34492. * Check if there's a given key in the dictionary
  34493. * @param key the key to check for
  34494. * @return true if the key is present, false otherwise
  34495. */
  34496. contains(key: string): boolean;
  34497. /**
  34498. * Add a new key and its corresponding value
  34499. * @param key the key to add
  34500. * @param value the value corresponding to the key
  34501. * @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
  34502. */
  34503. add(key: string, value: T): boolean;
  34504. /**
  34505. * Update a specific value associated to a key
  34506. * @param key defines the key to use
  34507. * @param value defines the value to store
  34508. * @returns true if the value was updated (or false if the key was not found)
  34509. */
  34510. set(key: string, value: T): boolean;
  34511. /**
  34512. * Get the element of the given key and remove it from the dictionary
  34513. * @param key defines the key to search
  34514. * @returns the value associated with the key or null if not found
  34515. */
  34516. getAndRemove(key: string): Nullable<T>;
  34517. /**
  34518. * Remove a key/value from the dictionary.
  34519. * @param key the key to remove
  34520. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34521. */
  34522. remove(key: string): boolean;
  34523. /**
  34524. * Clear the whole content of the dictionary
  34525. */
  34526. clear(): void;
  34527. /**
  34528. * Gets the current count
  34529. */
  34530. get count(): number;
  34531. /**
  34532. * Execute a callback on each key/val of the dictionary.
  34533. * Note that you can remove any element in this dictionary in the callback implementation
  34534. * @param callback the callback to execute on a given key/value pair
  34535. */
  34536. forEach(callback: (key: string, val: T) => void): void;
  34537. /**
  34538. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34539. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34540. * Note that you can remove any element in this dictionary in the callback implementation
  34541. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34542. * @returns the first item
  34543. */
  34544. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34545. private _count;
  34546. private _data;
  34547. }
  34548. }
  34549. declare module BABYLON {
  34550. /** @hidden */
  34551. export interface ICollisionCoordinator {
  34552. createCollider(): Collider;
  34553. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34554. init(scene: Scene): void;
  34555. }
  34556. /** @hidden */
  34557. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34558. private _scene;
  34559. private _scaledPosition;
  34560. private _scaledVelocity;
  34561. private _finalPosition;
  34562. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34563. createCollider(): Collider;
  34564. init(scene: Scene): void;
  34565. private _collideWithWorld;
  34566. }
  34567. }
  34568. declare module BABYLON {
  34569. /**
  34570. * Class used to manage all inputs for the scene.
  34571. */
  34572. export class InputManager {
  34573. /** The distance in pixel that you have to move to prevent some events */
  34574. static DragMovementThreshold: number;
  34575. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34576. static LongPressDelay: number;
  34577. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34578. static DoubleClickDelay: number;
  34579. /** If you need to check double click without raising a single click at first click, enable this flag */
  34580. static ExclusiveDoubleClickMode: boolean;
  34581. private _wheelEventName;
  34582. private _onPointerMove;
  34583. private _onPointerDown;
  34584. private _onPointerUp;
  34585. private _initClickEvent;
  34586. private _initActionManager;
  34587. private _delayedSimpleClick;
  34588. private _delayedSimpleClickTimeout;
  34589. private _previousDelayedSimpleClickTimeout;
  34590. private _meshPickProceed;
  34591. private _previousButtonPressed;
  34592. private _currentPickResult;
  34593. private _previousPickResult;
  34594. private _totalPointersPressed;
  34595. private _doubleClickOccured;
  34596. private _pointerOverMesh;
  34597. private _pickedDownMesh;
  34598. private _pickedUpMesh;
  34599. private _pointerX;
  34600. private _pointerY;
  34601. private _unTranslatedPointerX;
  34602. private _unTranslatedPointerY;
  34603. private _startingPointerPosition;
  34604. private _previousStartingPointerPosition;
  34605. private _startingPointerTime;
  34606. private _previousStartingPointerTime;
  34607. private _pointerCaptures;
  34608. private _onKeyDown;
  34609. private _onKeyUp;
  34610. private _onCanvasFocusObserver;
  34611. private _onCanvasBlurObserver;
  34612. private _scene;
  34613. /**
  34614. * Creates a new InputManager
  34615. * @param scene defines the hosting scene
  34616. */
  34617. constructor(scene: Scene);
  34618. /**
  34619. * Gets the mesh that is currently under the pointer
  34620. */
  34621. get meshUnderPointer(): Nullable<AbstractMesh>;
  34622. /**
  34623. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34624. */
  34625. get unTranslatedPointer(): Vector2;
  34626. /**
  34627. * Gets or sets the current on-screen X position of the pointer
  34628. */
  34629. get pointerX(): number;
  34630. set pointerX(value: number);
  34631. /**
  34632. * Gets or sets the current on-screen Y position of the pointer
  34633. */
  34634. get pointerY(): number;
  34635. set pointerY(value: number);
  34636. private _updatePointerPosition;
  34637. private _processPointerMove;
  34638. private _setRayOnPointerInfo;
  34639. private _checkPrePointerObservable;
  34640. /**
  34641. * Use this method to simulate a pointer move on a mesh
  34642. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34643. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34644. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34645. */
  34646. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34647. /**
  34648. * Use this method to simulate a pointer down on a mesh
  34649. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34650. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34651. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34652. */
  34653. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34654. private _processPointerDown;
  34655. /** @hidden */
  34656. _isPointerSwiping(): boolean;
  34657. /**
  34658. * Use this method to simulate a pointer up on a mesh
  34659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34662. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34663. */
  34664. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34665. private _processPointerUp;
  34666. /**
  34667. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34668. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34669. * @returns true if the pointer was captured
  34670. */
  34671. isPointerCaptured(pointerId?: number): boolean;
  34672. /**
  34673. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34674. * @param attachUp defines if you want to attach events to pointerup
  34675. * @param attachDown defines if you want to attach events to pointerdown
  34676. * @param attachMove defines if you want to attach events to pointermove
  34677. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34678. */
  34679. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34680. /**
  34681. * Detaches all event handlers
  34682. */
  34683. detachControl(): void;
  34684. /**
  34685. * Force the value of meshUnderPointer
  34686. * @param mesh defines the mesh to use
  34687. */
  34688. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34689. /**
  34690. * Gets the mesh under the pointer
  34691. * @returns a Mesh or null if no mesh is under the pointer
  34692. */
  34693. getPointerOverMesh(): Nullable<AbstractMesh>;
  34694. }
  34695. }
  34696. declare module BABYLON {
  34697. /**
  34698. * Helper class used to generate session unique ID
  34699. */
  34700. export class UniqueIdGenerator {
  34701. private static _UniqueIdCounter;
  34702. /**
  34703. * Gets an unique (relatively to the current scene) Id
  34704. */
  34705. static get UniqueId(): number;
  34706. }
  34707. }
  34708. declare module BABYLON {
  34709. /**
  34710. * This class defines the direct association between an animation and a target
  34711. */
  34712. export class TargetedAnimation {
  34713. /**
  34714. * Animation to perform
  34715. */
  34716. animation: Animation;
  34717. /**
  34718. * Target to animate
  34719. */
  34720. target: any;
  34721. /**
  34722. * Serialize the object
  34723. * @returns the JSON object representing the current entity
  34724. */
  34725. serialize(): any;
  34726. }
  34727. /**
  34728. * Use this class to create coordinated animations on multiple targets
  34729. */
  34730. export class AnimationGroup implements IDisposable {
  34731. /** The name of the animation group */
  34732. name: string;
  34733. private _scene;
  34734. private _targetedAnimations;
  34735. private _animatables;
  34736. private _from;
  34737. private _to;
  34738. private _isStarted;
  34739. private _isPaused;
  34740. private _speedRatio;
  34741. private _loopAnimation;
  34742. /**
  34743. * Gets or sets the unique id of the node
  34744. */
  34745. uniqueId: number;
  34746. /**
  34747. * This observable will notify when one animation have ended
  34748. */
  34749. onAnimationEndObservable: Observable<TargetedAnimation>;
  34750. /**
  34751. * Observer raised when one animation loops
  34752. */
  34753. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34754. /**
  34755. * Observer raised when all animations have looped
  34756. */
  34757. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34758. /**
  34759. * This observable will notify when all animations have ended.
  34760. */
  34761. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34762. /**
  34763. * This observable will notify when all animations have paused.
  34764. */
  34765. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34766. /**
  34767. * This observable will notify when all animations are playing.
  34768. */
  34769. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34770. /**
  34771. * Gets the first frame
  34772. */
  34773. get from(): number;
  34774. /**
  34775. * Gets the last frame
  34776. */
  34777. get to(): number;
  34778. /**
  34779. * Define if the animations are started
  34780. */
  34781. get isStarted(): boolean;
  34782. /**
  34783. * Gets a value indicating that the current group is playing
  34784. */
  34785. get isPlaying(): boolean;
  34786. /**
  34787. * Gets or sets the speed ratio to use for all animations
  34788. */
  34789. get speedRatio(): number;
  34790. /**
  34791. * Gets or sets the speed ratio to use for all animations
  34792. */
  34793. set speedRatio(value: number);
  34794. /**
  34795. * Gets or sets if all animations should loop or not
  34796. */
  34797. get loopAnimation(): boolean;
  34798. set loopAnimation(value: boolean);
  34799. /**
  34800. * Gets the targeted animations for this animation group
  34801. */
  34802. get targetedAnimations(): Array<TargetedAnimation>;
  34803. /**
  34804. * returning the list of animatables controlled by this animation group.
  34805. */
  34806. get animatables(): Array<Animatable>;
  34807. /**
  34808. * Instantiates a new Animation Group.
  34809. * This helps managing several animations at once.
  34810. * @see http://doc.babylonjs.com/how_to/group
  34811. * @param name Defines the name of the group
  34812. * @param scene Defines the scene the group belongs to
  34813. */
  34814. constructor(
  34815. /** The name of the animation group */
  34816. name: string, scene?: Nullable<Scene>);
  34817. /**
  34818. * Add an animation (with its target) in the group
  34819. * @param animation defines the animation we want to add
  34820. * @param target defines the target of the animation
  34821. * @returns the TargetedAnimation object
  34822. */
  34823. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34824. /**
  34825. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34826. * It can add constant keys at begin or end
  34827. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34828. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34829. * @returns the animation group
  34830. */
  34831. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34832. private _animationLoopCount;
  34833. private _animationLoopFlags;
  34834. private _processLoop;
  34835. /**
  34836. * Start all animations on given targets
  34837. * @param loop defines if animations must loop
  34838. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34839. * @param from defines the from key (optional)
  34840. * @param to defines the to key (optional)
  34841. * @returns the current animation group
  34842. */
  34843. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34844. /**
  34845. * Pause all animations
  34846. * @returns the animation group
  34847. */
  34848. pause(): AnimationGroup;
  34849. /**
  34850. * Play all animations to initial state
  34851. * This function will start() the animations if they were not started or will restart() them if they were paused
  34852. * @param loop defines if animations must loop
  34853. * @returns the animation group
  34854. */
  34855. play(loop?: boolean): AnimationGroup;
  34856. /**
  34857. * Reset all animations to initial state
  34858. * @returns the animation group
  34859. */
  34860. reset(): AnimationGroup;
  34861. /**
  34862. * Restart animations from key 0
  34863. * @returns the animation group
  34864. */
  34865. restart(): AnimationGroup;
  34866. /**
  34867. * Stop all animations
  34868. * @returns the animation group
  34869. */
  34870. stop(): AnimationGroup;
  34871. /**
  34872. * Set animation weight for all animatables
  34873. * @param weight defines the weight to use
  34874. * @return the animationGroup
  34875. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34876. */
  34877. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34878. /**
  34879. * Synchronize and normalize all animatables with a source animatable
  34880. * @param root defines the root animatable to synchronize with
  34881. * @return the animationGroup
  34882. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34883. */
  34884. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34885. /**
  34886. * Goes to a specific frame in this animation group
  34887. * @param frame the frame number to go to
  34888. * @return the animationGroup
  34889. */
  34890. goToFrame(frame: number): AnimationGroup;
  34891. /**
  34892. * Dispose all associated resources
  34893. */
  34894. dispose(): void;
  34895. private _checkAnimationGroupEnded;
  34896. /**
  34897. * Clone the current animation group and returns a copy
  34898. * @param newName defines the name of the new group
  34899. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34900. * @returns the new aniamtion group
  34901. */
  34902. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34903. /**
  34904. * Serializes the animationGroup to an object
  34905. * @returns Serialized object
  34906. */
  34907. serialize(): any;
  34908. /**
  34909. * Returns a new AnimationGroup object parsed from the source provided.
  34910. * @param parsedAnimationGroup defines the source
  34911. * @param scene defines the scene that will receive the animationGroup
  34912. * @returns a new AnimationGroup
  34913. */
  34914. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34915. /**
  34916. * Returns the string "AnimationGroup"
  34917. * @returns "AnimationGroup"
  34918. */
  34919. getClassName(): string;
  34920. /**
  34921. * Creates a detailled string about the object
  34922. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34923. * @returns a string representing the object
  34924. */
  34925. toString(fullDetails?: boolean): string;
  34926. }
  34927. }
  34928. declare module BABYLON {
  34929. /**
  34930. * Define an interface for all classes that will hold resources
  34931. */
  34932. export interface IDisposable {
  34933. /**
  34934. * Releases all held resources
  34935. */
  34936. dispose(): void;
  34937. }
  34938. /** Interface defining initialization parameters for Scene class */
  34939. export interface SceneOptions {
  34940. /**
  34941. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34942. * It will improve performance when the number of geometries becomes important.
  34943. */
  34944. useGeometryUniqueIdsMap?: boolean;
  34945. /**
  34946. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34947. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34948. */
  34949. useMaterialMeshMap?: boolean;
  34950. /**
  34951. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34952. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34953. */
  34954. useClonedMeshMap?: boolean;
  34955. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34956. virtual?: boolean;
  34957. }
  34958. /**
  34959. * Represents a scene to be rendered by the engine.
  34960. * @see http://doc.babylonjs.com/features/scene
  34961. */
  34962. export class Scene extends AbstractScene implements IAnimatable {
  34963. /** The fog is deactivated */
  34964. static readonly FOGMODE_NONE: number;
  34965. /** The fog density is following an exponential function */
  34966. static readonly FOGMODE_EXP: number;
  34967. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34968. static readonly FOGMODE_EXP2: number;
  34969. /** The fog density is following a linear function. */
  34970. static readonly FOGMODE_LINEAR: number;
  34971. /**
  34972. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34973. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34974. */
  34975. static MinDeltaTime: number;
  34976. /**
  34977. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34978. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34979. */
  34980. static MaxDeltaTime: number;
  34981. /**
  34982. * Factory used to create the default material.
  34983. * @param name The name of the material to create
  34984. * @param scene The scene to create the material for
  34985. * @returns The default material
  34986. */
  34987. static DefaultMaterialFactory(scene: Scene): Material;
  34988. /**
  34989. * Factory used to create the a collision coordinator.
  34990. * @returns The collision coordinator
  34991. */
  34992. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34993. /** @hidden */
  34994. _inputManager: InputManager;
  34995. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34996. cameraToUseForPointers: Nullable<Camera>;
  34997. /** @hidden */
  34998. readonly _isScene: boolean;
  34999. /**
  35000. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35001. */
  35002. autoClear: boolean;
  35003. /**
  35004. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35005. */
  35006. autoClearDepthAndStencil: boolean;
  35007. /**
  35008. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35009. */
  35010. clearColor: Color4;
  35011. /**
  35012. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35013. */
  35014. ambientColor: Color3;
  35015. /**
  35016. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35017. * It should only be one of the following (if not the default embedded one):
  35018. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35019. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35020. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35021. * The material properties need to be setup according to the type of texture in use.
  35022. */
  35023. environmentBRDFTexture: BaseTexture;
  35024. /** @hidden */
  35025. protected _environmentTexture: Nullable<BaseTexture>;
  35026. /**
  35027. * Texture used in all pbr material as the reflection texture.
  35028. * As in the majority of the scene they are the same (exception for multi room and so on),
  35029. * this is easier to reference from here than from all the materials.
  35030. */
  35031. get environmentTexture(): Nullable<BaseTexture>;
  35032. /**
  35033. * Texture used in all pbr material as the reflection texture.
  35034. * As in the majority of the scene they are the same (exception for multi room and so on),
  35035. * this is easier to set here than in all the materials.
  35036. */
  35037. set environmentTexture(value: Nullable<BaseTexture>);
  35038. /** @hidden */
  35039. protected _environmentIntensity: number;
  35040. /**
  35041. * Intensity of the environment in all pbr material.
  35042. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35043. * As in the majority of the scene they are the same (exception for multi room and so on),
  35044. * this is easier to reference from here than from all the materials.
  35045. */
  35046. get environmentIntensity(): number;
  35047. /**
  35048. * Intensity of the environment in all pbr material.
  35049. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35050. * As in the majority of the scene they are the same (exception for multi room and so on),
  35051. * this is easier to set here than in all the materials.
  35052. */
  35053. set environmentIntensity(value: number);
  35054. /** @hidden */
  35055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35056. /**
  35057. * Default image processing configuration used either in the rendering
  35058. * Forward main pass or through the imageProcessingPostProcess if present.
  35059. * As in the majority of the scene they are the same (exception for multi camera),
  35060. * this is easier to reference from here than from all the materials and post process.
  35061. *
  35062. * No setter as we it is a shared configuration, you can set the values instead.
  35063. */
  35064. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35065. private _forceWireframe;
  35066. /**
  35067. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35068. */
  35069. set forceWireframe(value: boolean);
  35070. get forceWireframe(): boolean;
  35071. private _skipFrustumClipping;
  35072. /**
  35073. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35074. */
  35075. set skipFrustumClipping(value: boolean);
  35076. get skipFrustumClipping(): boolean;
  35077. private _forcePointsCloud;
  35078. /**
  35079. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35080. */
  35081. set forcePointsCloud(value: boolean);
  35082. get forcePointsCloud(): boolean;
  35083. /**
  35084. * Gets or sets the active clipplane 1
  35085. */
  35086. clipPlane: Nullable<Plane>;
  35087. /**
  35088. * Gets or sets the active clipplane 2
  35089. */
  35090. clipPlane2: Nullable<Plane>;
  35091. /**
  35092. * Gets or sets the active clipplane 3
  35093. */
  35094. clipPlane3: Nullable<Plane>;
  35095. /**
  35096. * Gets or sets the active clipplane 4
  35097. */
  35098. clipPlane4: Nullable<Plane>;
  35099. /**
  35100. * Gets or sets the active clipplane 5
  35101. */
  35102. clipPlane5: Nullable<Plane>;
  35103. /**
  35104. * Gets or sets the active clipplane 6
  35105. */
  35106. clipPlane6: Nullable<Plane>;
  35107. /**
  35108. * Gets or sets a boolean indicating if animations are enabled
  35109. */
  35110. animationsEnabled: boolean;
  35111. private _animationPropertiesOverride;
  35112. /**
  35113. * Gets or sets the animation properties override
  35114. */
  35115. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35116. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35117. /**
  35118. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35119. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35120. */
  35121. useConstantAnimationDeltaTime: boolean;
  35122. /**
  35123. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35124. * Please note that it requires to run a ray cast through the scene on every frame
  35125. */
  35126. constantlyUpdateMeshUnderPointer: boolean;
  35127. /**
  35128. * Defines the HTML cursor to use when hovering over interactive elements
  35129. */
  35130. hoverCursor: string;
  35131. /**
  35132. * Defines the HTML default cursor to use (empty by default)
  35133. */
  35134. defaultCursor: string;
  35135. /**
  35136. * Defines wether cursors are handled by the scene.
  35137. */
  35138. doNotHandleCursors: boolean;
  35139. /**
  35140. * This is used to call preventDefault() on pointer down
  35141. * in order to block unwanted artifacts like system double clicks
  35142. */
  35143. preventDefaultOnPointerDown: boolean;
  35144. /**
  35145. * This is used to call preventDefault() on pointer up
  35146. * in order to block unwanted artifacts like system double clicks
  35147. */
  35148. preventDefaultOnPointerUp: boolean;
  35149. /**
  35150. * Gets or sets user defined metadata
  35151. */
  35152. metadata: any;
  35153. /**
  35154. * For internal use only. Please do not use.
  35155. */
  35156. reservedDataStore: any;
  35157. /**
  35158. * Gets the name of the plugin used to load this scene (null by default)
  35159. */
  35160. loadingPluginName: string;
  35161. /**
  35162. * Use this array to add regular expressions used to disable offline support for specific urls
  35163. */
  35164. disableOfflineSupportExceptionRules: RegExp[];
  35165. /**
  35166. * An event triggered when the scene is disposed.
  35167. */
  35168. onDisposeObservable: Observable<Scene>;
  35169. private _onDisposeObserver;
  35170. /** Sets a function to be executed when this scene is disposed. */
  35171. set onDispose(callback: () => void);
  35172. /**
  35173. * An event triggered before rendering the scene (right after animations and physics)
  35174. */
  35175. onBeforeRenderObservable: Observable<Scene>;
  35176. private _onBeforeRenderObserver;
  35177. /** Sets a function to be executed before rendering this scene */
  35178. set beforeRender(callback: Nullable<() => void>);
  35179. /**
  35180. * An event triggered after rendering the scene
  35181. */
  35182. onAfterRenderObservable: Observable<Scene>;
  35183. /**
  35184. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35185. */
  35186. onAfterRenderCameraObservable: Observable<Camera>;
  35187. private _onAfterRenderObserver;
  35188. /** Sets a function to be executed after rendering this scene */
  35189. set afterRender(callback: Nullable<() => void>);
  35190. /**
  35191. * An event triggered before animating the scene
  35192. */
  35193. onBeforeAnimationsObservable: Observable<Scene>;
  35194. /**
  35195. * An event triggered after animations processing
  35196. */
  35197. onAfterAnimationsObservable: Observable<Scene>;
  35198. /**
  35199. * An event triggered before draw calls are ready to be sent
  35200. */
  35201. onBeforeDrawPhaseObservable: Observable<Scene>;
  35202. /**
  35203. * An event triggered after draw calls have been sent
  35204. */
  35205. onAfterDrawPhaseObservable: Observable<Scene>;
  35206. /**
  35207. * An event triggered when the scene is ready
  35208. */
  35209. onReadyObservable: Observable<Scene>;
  35210. /**
  35211. * An event triggered before rendering a camera
  35212. */
  35213. onBeforeCameraRenderObservable: Observable<Camera>;
  35214. private _onBeforeCameraRenderObserver;
  35215. /** Sets a function to be executed before rendering a camera*/
  35216. set beforeCameraRender(callback: () => void);
  35217. /**
  35218. * An event triggered after rendering a camera
  35219. */
  35220. onAfterCameraRenderObservable: Observable<Camera>;
  35221. private _onAfterCameraRenderObserver;
  35222. /** Sets a function to be executed after rendering a camera*/
  35223. set afterCameraRender(callback: () => void);
  35224. /**
  35225. * An event triggered when active meshes evaluation is about to start
  35226. */
  35227. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35228. /**
  35229. * An event triggered when active meshes evaluation is done
  35230. */
  35231. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35232. /**
  35233. * An event triggered when particles rendering is about to start
  35234. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35235. */
  35236. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35237. /**
  35238. * An event triggered when particles rendering is done
  35239. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35240. */
  35241. onAfterParticlesRenderingObservable: Observable<Scene>;
  35242. /**
  35243. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35244. */
  35245. onDataLoadedObservable: Observable<Scene>;
  35246. /**
  35247. * An event triggered when a camera is created
  35248. */
  35249. onNewCameraAddedObservable: Observable<Camera>;
  35250. /**
  35251. * An event triggered when a camera is removed
  35252. */
  35253. onCameraRemovedObservable: Observable<Camera>;
  35254. /**
  35255. * An event triggered when a light is created
  35256. */
  35257. onNewLightAddedObservable: Observable<Light>;
  35258. /**
  35259. * An event triggered when a light is removed
  35260. */
  35261. onLightRemovedObservable: Observable<Light>;
  35262. /**
  35263. * An event triggered when a geometry is created
  35264. */
  35265. onNewGeometryAddedObservable: Observable<Geometry>;
  35266. /**
  35267. * An event triggered when a geometry is removed
  35268. */
  35269. onGeometryRemovedObservable: Observable<Geometry>;
  35270. /**
  35271. * An event triggered when a transform node is created
  35272. */
  35273. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35274. /**
  35275. * An event triggered when a transform node is removed
  35276. */
  35277. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35278. /**
  35279. * An event triggered when a mesh is created
  35280. */
  35281. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35282. /**
  35283. * An event triggered when a mesh is removed
  35284. */
  35285. onMeshRemovedObservable: Observable<AbstractMesh>;
  35286. /**
  35287. * An event triggered when a skeleton is created
  35288. */
  35289. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35290. /**
  35291. * An event triggered when a skeleton is removed
  35292. */
  35293. onSkeletonRemovedObservable: Observable<Skeleton>;
  35294. /**
  35295. * An event triggered when a material is created
  35296. */
  35297. onNewMaterialAddedObservable: Observable<Material>;
  35298. /**
  35299. * An event triggered when a material is removed
  35300. */
  35301. onMaterialRemovedObservable: Observable<Material>;
  35302. /**
  35303. * An event triggered when a texture is created
  35304. */
  35305. onNewTextureAddedObservable: Observable<BaseTexture>;
  35306. /**
  35307. * An event triggered when a texture is removed
  35308. */
  35309. onTextureRemovedObservable: Observable<BaseTexture>;
  35310. /**
  35311. * An event triggered when render targets are about to be rendered
  35312. * Can happen multiple times per frame.
  35313. */
  35314. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35315. /**
  35316. * An event triggered when render targets were rendered.
  35317. * Can happen multiple times per frame.
  35318. */
  35319. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35320. /**
  35321. * An event triggered before calculating deterministic simulation step
  35322. */
  35323. onBeforeStepObservable: Observable<Scene>;
  35324. /**
  35325. * An event triggered after calculating deterministic simulation step
  35326. */
  35327. onAfterStepObservable: Observable<Scene>;
  35328. /**
  35329. * An event triggered when the activeCamera property is updated
  35330. */
  35331. onActiveCameraChanged: Observable<Scene>;
  35332. /**
  35333. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35334. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35335. * 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)
  35336. */
  35337. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35338. /**
  35339. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35340. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35341. * 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)
  35342. */
  35343. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35344. /**
  35345. * This Observable will when a mesh has been imported into the scene.
  35346. */
  35347. onMeshImportedObservable: Observable<AbstractMesh>;
  35348. /**
  35349. * This Observable will when an animation file has been imported into the scene.
  35350. */
  35351. onAnimationFileImportedObservable: Observable<Scene>;
  35352. /**
  35353. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35354. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35355. */
  35356. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35357. /** @hidden */
  35358. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35359. /**
  35360. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35361. */
  35362. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35363. /**
  35364. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35365. */
  35366. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35367. /**
  35368. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35369. */
  35370. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35371. /** Callback called when a pointer move is detected */
  35372. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35373. /** Callback called when a pointer down is detected */
  35374. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35375. /** Callback called when a pointer up is detected */
  35376. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35377. /** Callback called when a pointer pick is detected */
  35378. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35379. /**
  35380. * 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).
  35381. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35382. */
  35383. onPrePointerObservable: Observable<PointerInfoPre>;
  35384. /**
  35385. * Observable event triggered each time an input event is received from the rendering canvas
  35386. */
  35387. onPointerObservable: Observable<PointerInfo>;
  35388. /**
  35389. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35390. */
  35391. get unTranslatedPointer(): Vector2;
  35392. /**
  35393. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35394. */
  35395. static get DragMovementThreshold(): number;
  35396. static set DragMovementThreshold(value: number);
  35397. /**
  35398. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35399. */
  35400. static get LongPressDelay(): number;
  35401. static set LongPressDelay(value: number);
  35402. /**
  35403. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35404. */
  35405. static get DoubleClickDelay(): number;
  35406. static set DoubleClickDelay(value: number);
  35407. /** If you need to check double click without raising a single click at first click, enable this flag */
  35408. static get ExclusiveDoubleClickMode(): boolean;
  35409. static set ExclusiveDoubleClickMode(value: boolean);
  35410. /** @hidden */
  35411. _mirroredCameraPosition: Nullable<Vector3>;
  35412. /**
  35413. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35414. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35415. */
  35416. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35417. /**
  35418. * Observable event triggered each time an keyboard event is received from the hosting window
  35419. */
  35420. onKeyboardObservable: Observable<KeyboardInfo>;
  35421. private _useRightHandedSystem;
  35422. /**
  35423. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35424. */
  35425. set useRightHandedSystem(value: boolean);
  35426. get useRightHandedSystem(): boolean;
  35427. private _timeAccumulator;
  35428. private _currentStepId;
  35429. private _currentInternalStep;
  35430. /**
  35431. * Sets the step Id used by deterministic lock step
  35432. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35433. * @param newStepId defines the step Id
  35434. */
  35435. setStepId(newStepId: number): void;
  35436. /**
  35437. * Gets the step Id used by deterministic lock step
  35438. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35439. * @returns the step Id
  35440. */
  35441. getStepId(): number;
  35442. /**
  35443. * Gets the internal step used by deterministic lock step
  35444. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35445. * @returns the internal step
  35446. */
  35447. getInternalStep(): number;
  35448. private _fogEnabled;
  35449. /**
  35450. * Gets or sets a boolean indicating if fog is enabled on this scene
  35451. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35452. * (Default is true)
  35453. */
  35454. set fogEnabled(value: boolean);
  35455. get fogEnabled(): boolean;
  35456. private _fogMode;
  35457. /**
  35458. * Gets or sets the fog mode to use
  35459. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35460. * | mode | value |
  35461. * | --- | --- |
  35462. * | FOGMODE_NONE | 0 |
  35463. * | FOGMODE_EXP | 1 |
  35464. * | FOGMODE_EXP2 | 2 |
  35465. * | FOGMODE_LINEAR | 3 |
  35466. */
  35467. set fogMode(value: number);
  35468. get fogMode(): number;
  35469. /**
  35470. * Gets or sets the fog color to use
  35471. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35472. * (Default is Color3(0.2, 0.2, 0.3))
  35473. */
  35474. fogColor: Color3;
  35475. /**
  35476. * Gets or sets the fog density to use
  35477. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35478. * (Default is 0.1)
  35479. */
  35480. fogDensity: number;
  35481. /**
  35482. * Gets or sets the fog start distance to use
  35483. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35484. * (Default is 0)
  35485. */
  35486. fogStart: number;
  35487. /**
  35488. * Gets or sets the fog end distance to use
  35489. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35490. * (Default is 1000)
  35491. */
  35492. fogEnd: number;
  35493. private _shadowsEnabled;
  35494. /**
  35495. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35496. */
  35497. set shadowsEnabled(value: boolean);
  35498. get shadowsEnabled(): boolean;
  35499. private _lightsEnabled;
  35500. /**
  35501. * Gets or sets a boolean indicating if lights are enabled on this scene
  35502. */
  35503. set lightsEnabled(value: boolean);
  35504. get lightsEnabled(): boolean;
  35505. /** All of the active cameras added to this scene. */
  35506. activeCameras: Camera[];
  35507. /** @hidden */
  35508. _activeCamera: Nullable<Camera>;
  35509. /** Gets or sets the current active camera */
  35510. get activeCamera(): Nullable<Camera>;
  35511. set activeCamera(value: Nullable<Camera>);
  35512. private _defaultMaterial;
  35513. /** The default material used on meshes when no material is affected */
  35514. get defaultMaterial(): Material;
  35515. /** The default material used on meshes when no material is affected */
  35516. set defaultMaterial(value: Material);
  35517. private _texturesEnabled;
  35518. /**
  35519. * Gets or sets a boolean indicating if textures are enabled on this scene
  35520. */
  35521. set texturesEnabled(value: boolean);
  35522. get texturesEnabled(): boolean;
  35523. /**
  35524. * Gets or sets a boolean indicating if particles are enabled on this scene
  35525. */
  35526. particlesEnabled: boolean;
  35527. /**
  35528. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35529. */
  35530. spritesEnabled: boolean;
  35531. private _skeletonsEnabled;
  35532. /**
  35533. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35534. */
  35535. set skeletonsEnabled(value: boolean);
  35536. get skeletonsEnabled(): boolean;
  35537. /**
  35538. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35539. */
  35540. lensFlaresEnabled: boolean;
  35541. /**
  35542. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35544. */
  35545. collisionsEnabled: boolean;
  35546. private _collisionCoordinator;
  35547. /** @hidden */
  35548. get collisionCoordinator(): ICollisionCoordinator;
  35549. /**
  35550. * Defines the gravity applied to this scene (used only for collisions)
  35551. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35552. */
  35553. gravity: Vector3;
  35554. /**
  35555. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35556. */
  35557. postProcessesEnabled: boolean;
  35558. /**
  35559. * The list of postprocesses added to the scene
  35560. */
  35561. postProcesses: PostProcess[];
  35562. /**
  35563. * Gets the current postprocess manager
  35564. */
  35565. postProcessManager: PostProcessManager;
  35566. /**
  35567. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35568. */
  35569. renderTargetsEnabled: boolean;
  35570. /**
  35571. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35572. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35573. */
  35574. dumpNextRenderTargets: boolean;
  35575. /**
  35576. * The list of user defined render targets added to the scene
  35577. */
  35578. customRenderTargets: RenderTargetTexture[];
  35579. /**
  35580. * Defines if texture loading must be delayed
  35581. * If true, textures will only be loaded when they need to be rendered
  35582. */
  35583. useDelayedTextureLoading: boolean;
  35584. /**
  35585. * Gets the list of meshes imported to the scene through SceneLoader
  35586. */
  35587. importedMeshesFiles: String[];
  35588. /**
  35589. * Gets or sets a boolean indicating if probes are enabled on this scene
  35590. */
  35591. probesEnabled: boolean;
  35592. /**
  35593. * Gets or sets the current offline provider to use to store scene data
  35594. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35595. */
  35596. offlineProvider: IOfflineProvider;
  35597. /**
  35598. * Gets or sets the action manager associated with the scene
  35599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35600. */
  35601. actionManager: AbstractActionManager;
  35602. private _meshesForIntersections;
  35603. /**
  35604. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35605. */
  35606. proceduralTexturesEnabled: boolean;
  35607. private _engine;
  35608. private _totalVertices;
  35609. /** @hidden */
  35610. _activeIndices: PerfCounter;
  35611. /** @hidden */
  35612. _activeParticles: PerfCounter;
  35613. /** @hidden */
  35614. _activeBones: PerfCounter;
  35615. private _animationRatio;
  35616. /** @hidden */
  35617. _animationTimeLast: number;
  35618. /** @hidden */
  35619. _animationTime: number;
  35620. /**
  35621. * Gets or sets a general scale for animation speed
  35622. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35623. */
  35624. animationTimeScale: number;
  35625. /** @hidden */
  35626. _cachedMaterial: Nullable<Material>;
  35627. /** @hidden */
  35628. _cachedEffect: Nullable<Effect>;
  35629. /** @hidden */
  35630. _cachedVisibility: Nullable<number>;
  35631. private _renderId;
  35632. private _frameId;
  35633. private _executeWhenReadyTimeoutId;
  35634. private _intermediateRendering;
  35635. private _viewUpdateFlag;
  35636. private _projectionUpdateFlag;
  35637. /** @hidden */
  35638. _toBeDisposed: Nullable<IDisposable>[];
  35639. private _activeRequests;
  35640. /** @hidden */
  35641. _pendingData: any[];
  35642. private _isDisposed;
  35643. /**
  35644. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35645. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35646. */
  35647. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35648. private _activeMeshes;
  35649. private _processedMaterials;
  35650. private _renderTargets;
  35651. /** @hidden */
  35652. _activeParticleSystems: SmartArray<IParticleSystem>;
  35653. private _activeSkeletons;
  35654. private _softwareSkinnedMeshes;
  35655. private _renderingManager;
  35656. /** @hidden */
  35657. _activeAnimatables: Animatable[];
  35658. private _transformMatrix;
  35659. private _sceneUbo;
  35660. /** @hidden */
  35661. _viewMatrix: Matrix;
  35662. private _projectionMatrix;
  35663. /** @hidden */
  35664. _forcedViewPosition: Nullable<Vector3>;
  35665. /** @hidden */
  35666. _frustumPlanes: Plane[];
  35667. /**
  35668. * Gets the list of frustum planes (built from the active camera)
  35669. */
  35670. get frustumPlanes(): Plane[];
  35671. /**
  35672. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35673. * This is useful if there are more lights that the maximum simulteanous authorized
  35674. */
  35675. requireLightSorting: boolean;
  35676. /** @hidden */
  35677. readonly useMaterialMeshMap: boolean;
  35678. /** @hidden */
  35679. readonly useClonedMeshMap: boolean;
  35680. private _externalData;
  35681. private _uid;
  35682. /**
  35683. * @hidden
  35684. * Backing store of defined scene components.
  35685. */
  35686. _components: ISceneComponent[];
  35687. /**
  35688. * @hidden
  35689. * Backing store of defined scene components.
  35690. */
  35691. _serializableComponents: ISceneSerializableComponent[];
  35692. /**
  35693. * List of components to register on the next registration step.
  35694. */
  35695. private _transientComponents;
  35696. /**
  35697. * Registers the transient components if needed.
  35698. */
  35699. private _registerTransientComponents;
  35700. /**
  35701. * @hidden
  35702. * Add a component to the scene.
  35703. * Note that the ccomponent could be registered on th next frame if this is called after
  35704. * the register component stage.
  35705. * @param component Defines the component to add to the scene
  35706. */
  35707. _addComponent(component: ISceneComponent): void;
  35708. /**
  35709. * @hidden
  35710. * Gets a component from the scene.
  35711. * @param name defines the name of the component to retrieve
  35712. * @returns the component or null if not present
  35713. */
  35714. _getComponent(name: string): Nullable<ISceneComponent>;
  35715. /**
  35716. * @hidden
  35717. * Defines the actions happening before camera updates.
  35718. */
  35719. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35720. /**
  35721. * @hidden
  35722. * Defines the actions happening before clear the canvas.
  35723. */
  35724. _beforeClearStage: Stage<SimpleStageAction>;
  35725. /**
  35726. * @hidden
  35727. * Defines the actions when collecting render targets for the frame.
  35728. */
  35729. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35730. /**
  35731. * @hidden
  35732. * Defines the actions happening for one camera in the frame.
  35733. */
  35734. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35735. /**
  35736. * @hidden
  35737. * Defines the actions happening during the per mesh ready checks.
  35738. */
  35739. _isReadyForMeshStage: Stage<MeshStageAction>;
  35740. /**
  35741. * @hidden
  35742. * Defines the actions happening before evaluate active mesh checks.
  35743. */
  35744. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35745. /**
  35746. * @hidden
  35747. * Defines the actions happening during the evaluate sub mesh checks.
  35748. */
  35749. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35750. /**
  35751. * @hidden
  35752. * Defines the actions happening during the active mesh stage.
  35753. */
  35754. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35755. /**
  35756. * @hidden
  35757. * Defines the actions happening during the per camera render target step.
  35758. */
  35759. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35760. /**
  35761. * @hidden
  35762. * Defines the actions happening just before the active camera is drawing.
  35763. */
  35764. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35765. /**
  35766. * @hidden
  35767. * Defines the actions happening just before a render target is drawing.
  35768. */
  35769. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35770. /**
  35771. * @hidden
  35772. * Defines the actions happening just before a rendering group is drawing.
  35773. */
  35774. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35775. /**
  35776. * @hidden
  35777. * Defines the actions happening just before a mesh is drawing.
  35778. */
  35779. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35780. /**
  35781. * @hidden
  35782. * Defines the actions happening just after a mesh has been drawn.
  35783. */
  35784. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35785. /**
  35786. * @hidden
  35787. * Defines the actions happening just after a rendering group has been drawn.
  35788. */
  35789. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35790. /**
  35791. * @hidden
  35792. * Defines the actions happening just after the active camera has been drawn.
  35793. */
  35794. _afterCameraDrawStage: Stage<CameraStageAction>;
  35795. /**
  35796. * @hidden
  35797. * Defines the actions happening just after a render target has been drawn.
  35798. */
  35799. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35800. /**
  35801. * @hidden
  35802. * Defines the actions happening just after rendering all cameras and computing intersections.
  35803. */
  35804. _afterRenderStage: Stage<SimpleStageAction>;
  35805. /**
  35806. * @hidden
  35807. * Defines the actions happening when a pointer move event happens.
  35808. */
  35809. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35810. /**
  35811. * @hidden
  35812. * Defines the actions happening when a pointer down event happens.
  35813. */
  35814. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35815. /**
  35816. * @hidden
  35817. * Defines the actions happening when a pointer up event happens.
  35818. */
  35819. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35820. /**
  35821. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35822. */
  35823. private geometriesByUniqueId;
  35824. /**
  35825. * Creates a new Scene
  35826. * @param engine defines the engine to use to render this scene
  35827. * @param options defines the scene options
  35828. */
  35829. constructor(engine: Engine, options?: SceneOptions);
  35830. /**
  35831. * Gets a string idenfifying the name of the class
  35832. * @returns "Scene" string
  35833. */
  35834. getClassName(): string;
  35835. private _defaultMeshCandidates;
  35836. /**
  35837. * @hidden
  35838. */
  35839. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35840. private _defaultSubMeshCandidates;
  35841. /**
  35842. * @hidden
  35843. */
  35844. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35845. /**
  35846. * Sets the default candidate providers for the scene.
  35847. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35848. * and getCollidingSubMeshCandidates to their default function
  35849. */
  35850. setDefaultCandidateProviders(): void;
  35851. /**
  35852. * Gets the mesh that is currently under the pointer
  35853. */
  35854. get meshUnderPointer(): Nullable<AbstractMesh>;
  35855. /**
  35856. * Gets or sets the current on-screen X position of the pointer
  35857. */
  35858. get pointerX(): number;
  35859. set pointerX(value: number);
  35860. /**
  35861. * Gets or sets the current on-screen Y position of the pointer
  35862. */
  35863. get pointerY(): number;
  35864. set pointerY(value: number);
  35865. /**
  35866. * Gets the cached material (ie. the latest rendered one)
  35867. * @returns the cached material
  35868. */
  35869. getCachedMaterial(): Nullable<Material>;
  35870. /**
  35871. * Gets the cached effect (ie. the latest rendered one)
  35872. * @returns the cached effect
  35873. */
  35874. getCachedEffect(): Nullable<Effect>;
  35875. /**
  35876. * Gets the cached visibility state (ie. the latest rendered one)
  35877. * @returns the cached visibility state
  35878. */
  35879. getCachedVisibility(): Nullable<number>;
  35880. /**
  35881. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35882. * @param material defines the current material
  35883. * @param effect defines the current effect
  35884. * @param visibility defines the current visibility state
  35885. * @returns true if one parameter is not cached
  35886. */
  35887. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35888. /**
  35889. * Gets the engine associated with the scene
  35890. * @returns an Engine
  35891. */
  35892. getEngine(): Engine;
  35893. /**
  35894. * Gets the total number of vertices rendered per frame
  35895. * @returns the total number of vertices rendered per frame
  35896. */
  35897. getTotalVertices(): number;
  35898. /**
  35899. * Gets the performance counter for total vertices
  35900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35901. */
  35902. get totalVerticesPerfCounter(): PerfCounter;
  35903. /**
  35904. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35905. * @returns the total number of active indices rendered per frame
  35906. */
  35907. getActiveIndices(): number;
  35908. /**
  35909. * Gets the performance counter for active indices
  35910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35911. */
  35912. get totalActiveIndicesPerfCounter(): PerfCounter;
  35913. /**
  35914. * Gets the total number of active particles rendered per frame
  35915. * @returns the total number of active particles rendered per frame
  35916. */
  35917. getActiveParticles(): number;
  35918. /**
  35919. * Gets the performance counter for active particles
  35920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35921. */
  35922. get activeParticlesPerfCounter(): PerfCounter;
  35923. /**
  35924. * Gets the total number of active bones rendered per frame
  35925. * @returns the total number of active bones rendered per frame
  35926. */
  35927. getActiveBones(): number;
  35928. /**
  35929. * Gets the performance counter for active bones
  35930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35931. */
  35932. get activeBonesPerfCounter(): PerfCounter;
  35933. /**
  35934. * Gets the array of active meshes
  35935. * @returns an array of AbstractMesh
  35936. */
  35937. getActiveMeshes(): SmartArray<AbstractMesh>;
  35938. /**
  35939. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35940. * @returns a number
  35941. */
  35942. getAnimationRatio(): number;
  35943. /**
  35944. * Gets an unique Id for the current render phase
  35945. * @returns a number
  35946. */
  35947. getRenderId(): number;
  35948. /**
  35949. * Gets an unique Id for the current frame
  35950. * @returns a number
  35951. */
  35952. getFrameId(): number;
  35953. /** Call this function if you want to manually increment the render Id*/
  35954. incrementRenderId(): void;
  35955. private _createUbo;
  35956. /**
  35957. * Use this method to simulate a pointer move on a mesh
  35958. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35959. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35960. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35961. * @returns the current scene
  35962. */
  35963. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35964. /**
  35965. * Use this method to simulate a pointer down on a mesh
  35966. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35967. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35968. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35969. * @returns the current scene
  35970. */
  35971. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35972. /**
  35973. * Use this method to simulate a pointer up on a mesh
  35974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35977. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35978. * @returns the current scene
  35979. */
  35980. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35981. /**
  35982. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35983. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35984. * @returns true if the pointer was captured
  35985. */
  35986. isPointerCaptured(pointerId?: number): boolean;
  35987. /**
  35988. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35989. * @param attachUp defines if you want to attach events to pointerup
  35990. * @param attachDown defines if you want to attach events to pointerdown
  35991. * @param attachMove defines if you want to attach events to pointermove
  35992. */
  35993. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35994. /** Detaches all event handlers*/
  35995. detachControl(): void;
  35996. /**
  35997. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35998. * Delay loaded resources are not taking in account
  35999. * @return true if all required resources are ready
  36000. */
  36001. isReady(): boolean;
  36002. /** Resets all cached information relative to material (including effect and visibility) */
  36003. resetCachedMaterial(): void;
  36004. /**
  36005. * Registers a function to be called before every frame render
  36006. * @param func defines the function to register
  36007. */
  36008. registerBeforeRender(func: () => void): void;
  36009. /**
  36010. * Unregisters a function called before every frame render
  36011. * @param func defines the function to unregister
  36012. */
  36013. unregisterBeforeRender(func: () => void): void;
  36014. /**
  36015. * Registers a function to be called after every frame render
  36016. * @param func defines the function to register
  36017. */
  36018. registerAfterRender(func: () => void): void;
  36019. /**
  36020. * Unregisters a function called after every frame render
  36021. * @param func defines the function to unregister
  36022. */
  36023. unregisterAfterRender(func: () => void): void;
  36024. private _executeOnceBeforeRender;
  36025. /**
  36026. * The provided function will run before render once and will be disposed afterwards.
  36027. * A timeout delay can be provided so that the function will be executed in N ms.
  36028. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36029. * @param func The function to be executed.
  36030. * @param timeout optional delay in ms
  36031. */
  36032. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36033. /** @hidden */
  36034. _addPendingData(data: any): void;
  36035. /** @hidden */
  36036. _removePendingData(data: any): void;
  36037. /**
  36038. * Returns the number of items waiting to be loaded
  36039. * @returns the number of items waiting to be loaded
  36040. */
  36041. getWaitingItemsCount(): number;
  36042. /**
  36043. * Returns a boolean indicating if the scene is still loading data
  36044. */
  36045. get isLoading(): boolean;
  36046. /**
  36047. * Registers a function to be executed when the scene is ready
  36048. * @param {Function} func - the function to be executed
  36049. */
  36050. executeWhenReady(func: () => void): void;
  36051. /**
  36052. * Returns a promise that resolves when the scene is ready
  36053. * @returns A promise that resolves when the scene is ready
  36054. */
  36055. whenReadyAsync(): Promise<void>;
  36056. /** @hidden */
  36057. _checkIsReady(): void;
  36058. /**
  36059. * Gets all animatable attached to the scene
  36060. */
  36061. get animatables(): Animatable[];
  36062. /**
  36063. * Resets the last animation time frame.
  36064. * Useful to override when animations start running when loading a scene for the first time.
  36065. */
  36066. resetLastAnimationTimeFrame(): void;
  36067. /**
  36068. * Gets the current view matrix
  36069. * @returns a Matrix
  36070. */
  36071. getViewMatrix(): Matrix;
  36072. /**
  36073. * Gets the current projection matrix
  36074. * @returns a Matrix
  36075. */
  36076. getProjectionMatrix(): Matrix;
  36077. /**
  36078. * Gets the current transform matrix
  36079. * @returns a Matrix made of View * Projection
  36080. */
  36081. getTransformMatrix(): Matrix;
  36082. /**
  36083. * Sets the current transform matrix
  36084. * @param viewL defines the View matrix to use
  36085. * @param projectionL defines the Projection matrix to use
  36086. * @param viewR defines the right View matrix to use (if provided)
  36087. * @param projectionR defines the right Projection matrix to use (if provided)
  36088. */
  36089. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36090. /**
  36091. * Gets the uniform buffer used to store scene data
  36092. * @returns a UniformBuffer
  36093. */
  36094. getSceneUniformBuffer(): UniformBuffer;
  36095. /**
  36096. * Gets an unique (relatively to the current scene) Id
  36097. * @returns an unique number for the scene
  36098. */
  36099. getUniqueId(): number;
  36100. /**
  36101. * Add a mesh to the list of scene's meshes
  36102. * @param newMesh defines the mesh to add
  36103. * @param recursive if all child meshes should also be added to the scene
  36104. */
  36105. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36106. /**
  36107. * Remove a mesh for the list of scene's meshes
  36108. * @param toRemove defines the mesh to remove
  36109. * @param recursive if all child meshes should also be removed from the scene
  36110. * @returns the index where the mesh was in the mesh list
  36111. */
  36112. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36113. /**
  36114. * Add a transform node to the list of scene's transform nodes
  36115. * @param newTransformNode defines the transform node to add
  36116. */
  36117. addTransformNode(newTransformNode: TransformNode): void;
  36118. /**
  36119. * Remove a transform node for the list of scene's transform nodes
  36120. * @param toRemove defines the transform node to remove
  36121. * @returns the index where the transform node was in the transform node list
  36122. */
  36123. removeTransformNode(toRemove: TransformNode): number;
  36124. /**
  36125. * Remove a skeleton for the list of scene's skeletons
  36126. * @param toRemove defines the skeleton to remove
  36127. * @returns the index where the skeleton was in the skeleton list
  36128. */
  36129. removeSkeleton(toRemove: Skeleton): number;
  36130. /**
  36131. * Remove a morph target for the list of scene's morph targets
  36132. * @param toRemove defines the morph target to remove
  36133. * @returns the index where the morph target was in the morph target list
  36134. */
  36135. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36136. /**
  36137. * Remove a light for the list of scene's lights
  36138. * @param toRemove defines the light to remove
  36139. * @returns the index where the light was in the light list
  36140. */
  36141. removeLight(toRemove: Light): number;
  36142. /**
  36143. * Remove a camera for the list of scene's cameras
  36144. * @param toRemove defines the camera to remove
  36145. * @returns the index where the camera was in the camera list
  36146. */
  36147. removeCamera(toRemove: Camera): number;
  36148. /**
  36149. * Remove a particle system for the list of scene's particle systems
  36150. * @param toRemove defines the particle system to remove
  36151. * @returns the index where the particle system was in the particle system list
  36152. */
  36153. removeParticleSystem(toRemove: IParticleSystem): number;
  36154. /**
  36155. * Remove a animation for the list of scene's animations
  36156. * @param toRemove defines the animation to remove
  36157. * @returns the index where the animation was in the animation list
  36158. */
  36159. removeAnimation(toRemove: Animation): number;
  36160. /**
  36161. * Will stop the animation of the given target
  36162. * @param target - the target
  36163. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36164. * @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)
  36165. */
  36166. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36167. /**
  36168. * Removes the given animation group from this scene.
  36169. * @param toRemove The animation group to remove
  36170. * @returns The index of the removed animation group
  36171. */
  36172. removeAnimationGroup(toRemove: AnimationGroup): number;
  36173. /**
  36174. * Removes the given multi-material from this scene.
  36175. * @param toRemove The multi-material to remove
  36176. * @returns The index of the removed multi-material
  36177. */
  36178. removeMultiMaterial(toRemove: MultiMaterial): number;
  36179. /**
  36180. * Removes the given material from this scene.
  36181. * @param toRemove The material to remove
  36182. * @returns The index of the removed material
  36183. */
  36184. removeMaterial(toRemove: Material): number;
  36185. /**
  36186. * Removes the given action manager from this scene.
  36187. * @param toRemove The action manager to remove
  36188. * @returns The index of the removed action manager
  36189. */
  36190. removeActionManager(toRemove: AbstractActionManager): number;
  36191. /**
  36192. * Removes the given texture from this scene.
  36193. * @param toRemove The texture to remove
  36194. * @returns The index of the removed texture
  36195. */
  36196. removeTexture(toRemove: BaseTexture): number;
  36197. /**
  36198. * Adds the given light to this scene
  36199. * @param newLight The light to add
  36200. */
  36201. addLight(newLight: Light): void;
  36202. /**
  36203. * Sorts the list list based on light priorities
  36204. */
  36205. sortLightsByPriority(): void;
  36206. /**
  36207. * Adds the given camera to this scene
  36208. * @param newCamera The camera to add
  36209. */
  36210. addCamera(newCamera: Camera): void;
  36211. /**
  36212. * Adds the given skeleton to this scene
  36213. * @param newSkeleton The skeleton to add
  36214. */
  36215. addSkeleton(newSkeleton: Skeleton): void;
  36216. /**
  36217. * Adds the given particle system to this scene
  36218. * @param newParticleSystem The particle system to add
  36219. */
  36220. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36221. /**
  36222. * Adds the given animation to this scene
  36223. * @param newAnimation The animation to add
  36224. */
  36225. addAnimation(newAnimation: Animation): void;
  36226. /**
  36227. * Adds the given animation group to this scene.
  36228. * @param newAnimationGroup The animation group to add
  36229. */
  36230. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36231. /**
  36232. * Adds the given multi-material to this scene
  36233. * @param newMultiMaterial The multi-material to add
  36234. */
  36235. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36236. /**
  36237. * Adds the given material to this scene
  36238. * @param newMaterial The material to add
  36239. */
  36240. addMaterial(newMaterial: Material): void;
  36241. /**
  36242. * Adds the given morph target to this scene
  36243. * @param newMorphTargetManager The morph target to add
  36244. */
  36245. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36246. /**
  36247. * Adds the given geometry to this scene
  36248. * @param newGeometry The geometry to add
  36249. */
  36250. addGeometry(newGeometry: Geometry): void;
  36251. /**
  36252. * Adds the given action manager to this scene
  36253. * @param newActionManager The action manager to add
  36254. */
  36255. addActionManager(newActionManager: AbstractActionManager): void;
  36256. /**
  36257. * Adds the given texture to this scene.
  36258. * @param newTexture The texture to add
  36259. */
  36260. addTexture(newTexture: BaseTexture): void;
  36261. /**
  36262. * Switch active camera
  36263. * @param newCamera defines the new active camera
  36264. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36265. */
  36266. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36267. /**
  36268. * sets the active camera of the scene using its ID
  36269. * @param id defines the camera's ID
  36270. * @return the new active camera or null if none found.
  36271. */
  36272. setActiveCameraByID(id: string): Nullable<Camera>;
  36273. /**
  36274. * sets the active camera of the scene using its name
  36275. * @param name defines the camera's name
  36276. * @returns the new active camera or null if none found.
  36277. */
  36278. setActiveCameraByName(name: string): Nullable<Camera>;
  36279. /**
  36280. * get an animation group using its name
  36281. * @param name defines the material's name
  36282. * @return the animation group or null if none found.
  36283. */
  36284. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36285. /**
  36286. * Get a material using its unique id
  36287. * @param uniqueId defines the material's unique id
  36288. * @return the material or null if none found.
  36289. */
  36290. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36291. /**
  36292. * get a material using its id
  36293. * @param id defines the material's ID
  36294. * @return the material or null if none found.
  36295. */
  36296. getMaterialByID(id: string): Nullable<Material>;
  36297. /**
  36298. * Gets a the last added material using a given id
  36299. * @param id defines the material's ID
  36300. * @return the last material with the given id or null if none found.
  36301. */
  36302. getLastMaterialByID(id: string): Nullable<Material>;
  36303. /**
  36304. * Gets a material using its name
  36305. * @param name defines the material's name
  36306. * @return the material or null if none found.
  36307. */
  36308. getMaterialByName(name: string): Nullable<Material>;
  36309. /**
  36310. * Get a texture using its unique id
  36311. * @param uniqueId defines the texture's unique id
  36312. * @return the texture or null if none found.
  36313. */
  36314. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36315. /**
  36316. * Gets a camera using its id
  36317. * @param id defines the id to look for
  36318. * @returns the camera or null if not found
  36319. */
  36320. getCameraByID(id: string): Nullable<Camera>;
  36321. /**
  36322. * Gets a camera using its unique id
  36323. * @param uniqueId defines the unique id to look for
  36324. * @returns the camera or null if not found
  36325. */
  36326. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36327. /**
  36328. * Gets a camera using its name
  36329. * @param name defines the camera's name
  36330. * @return the camera or null if none found.
  36331. */
  36332. getCameraByName(name: string): Nullable<Camera>;
  36333. /**
  36334. * Gets a bone using its id
  36335. * @param id defines the bone's id
  36336. * @return the bone or null if not found
  36337. */
  36338. getBoneByID(id: string): Nullable<Bone>;
  36339. /**
  36340. * Gets a bone using its id
  36341. * @param name defines the bone's name
  36342. * @return the bone or null if not found
  36343. */
  36344. getBoneByName(name: string): Nullable<Bone>;
  36345. /**
  36346. * Gets a light node using its name
  36347. * @param name defines the the light's name
  36348. * @return the light or null if none found.
  36349. */
  36350. getLightByName(name: string): Nullable<Light>;
  36351. /**
  36352. * Gets a light node using its id
  36353. * @param id defines the light's id
  36354. * @return the light or null if none found.
  36355. */
  36356. getLightByID(id: string): Nullable<Light>;
  36357. /**
  36358. * Gets a light node using its scene-generated unique ID
  36359. * @param uniqueId defines the light's unique id
  36360. * @return the light or null if none found.
  36361. */
  36362. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36363. /**
  36364. * Gets a particle system by id
  36365. * @param id defines the particle system id
  36366. * @return the corresponding system or null if none found
  36367. */
  36368. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36369. /**
  36370. * Gets a geometry using its ID
  36371. * @param id defines the geometry's id
  36372. * @return the geometry or null if none found.
  36373. */
  36374. getGeometryByID(id: string): Nullable<Geometry>;
  36375. private _getGeometryByUniqueID;
  36376. /**
  36377. * Add a new geometry to this scene
  36378. * @param geometry defines the geometry to be added to the scene.
  36379. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36380. * @return a boolean defining if the geometry was added or not
  36381. */
  36382. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36383. /**
  36384. * Removes an existing geometry
  36385. * @param geometry defines the geometry to be removed from the scene
  36386. * @return a boolean defining if the geometry was removed or not
  36387. */
  36388. removeGeometry(geometry: Geometry): boolean;
  36389. /**
  36390. * Gets the list of geometries attached to the scene
  36391. * @returns an array of Geometry
  36392. */
  36393. getGeometries(): Geometry[];
  36394. /**
  36395. * Gets the first added mesh found of a given ID
  36396. * @param id defines the id to search for
  36397. * @return the mesh found or null if not found at all
  36398. */
  36399. getMeshByID(id: string): Nullable<AbstractMesh>;
  36400. /**
  36401. * Gets a list of meshes using their id
  36402. * @param id defines the id to search for
  36403. * @returns a list of meshes
  36404. */
  36405. getMeshesByID(id: string): Array<AbstractMesh>;
  36406. /**
  36407. * Gets the first added transform node found of a given ID
  36408. * @param id defines the id to search for
  36409. * @return the found transform node or null if not found at all.
  36410. */
  36411. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36412. /**
  36413. * Gets a transform node with its auto-generated unique id
  36414. * @param uniqueId efines the unique id to search for
  36415. * @return the found transform node or null if not found at all.
  36416. */
  36417. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36418. /**
  36419. * Gets a list of transform nodes using their id
  36420. * @param id defines the id to search for
  36421. * @returns a list of transform nodes
  36422. */
  36423. getTransformNodesByID(id: string): Array<TransformNode>;
  36424. /**
  36425. * Gets a mesh with its auto-generated unique id
  36426. * @param uniqueId defines the unique id to search for
  36427. * @return the found mesh or null if not found at all.
  36428. */
  36429. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36430. /**
  36431. * Gets a the last added mesh using a given id
  36432. * @param id defines the id to search for
  36433. * @return the found mesh or null if not found at all.
  36434. */
  36435. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36436. /**
  36437. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36438. * @param id defines the id to search for
  36439. * @return the found node or null if not found at all
  36440. */
  36441. getLastEntryByID(id: string): Nullable<Node>;
  36442. /**
  36443. * Gets a node (Mesh, Camera, Light) using a given id
  36444. * @param id defines the id to search for
  36445. * @return the found node or null if not found at all
  36446. */
  36447. getNodeByID(id: string): Nullable<Node>;
  36448. /**
  36449. * Gets a node (Mesh, Camera, Light) using a given name
  36450. * @param name defines the name to search for
  36451. * @return the found node or null if not found at all.
  36452. */
  36453. getNodeByName(name: string): Nullable<Node>;
  36454. /**
  36455. * Gets a mesh using a given name
  36456. * @param name defines the name to search for
  36457. * @return the found mesh or null if not found at all.
  36458. */
  36459. getMeshByName(name: string): Nullable<AbstractMesh>;
  36460. /**
  36461. * Gets a transform node using a given name
  36462. * @param name defines the name to search for
  36463. * @return the found transform node or null if not found at all.
  36464. */
  36465. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36466. /**
  36467. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36468. * @param id defines the id to search for
  36469. * @return the found skeleton or null if not found at all.
  36470. */
  36471. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36472. /**
  36473. * Gets a skeleton using a given auto generated unique id
  36474. * @param uniqueId defines the unique id to search for
  36475. * @return the found skeleton or null if not found at all.
  36476. */
  36477. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36478. /**
  36479. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36480. * @param id defines the id to search for
  36481. * @return the found skeleton or null if not found at all.
  36482. */
  36483. getSkeletonById(id: string): Nullable<Skeleton>;
  36484. /**
  36485. * Gets a skeleton using a given name
  36486. * @param name defines the name to search for
  36487. * @return the found skeleton or null if not found at all.
  36488. */
  36489. getSkeletonByName(name: string): Nullable<Skeleton>;
  36490. /**
  36491. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36492. * @param id defines the id to search for
  36493. * @return the found morph target manager or null if not found at all.
  36494. */
  36495. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36496. /**
  36497. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36498. * @param id defines the id to search for
  36499. * @return the found morph target or null if not found at all.
  36500. */
  36501. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36502. /**
  36503. * Gets a boolean indicating if the given mesh is active
  36504. * @param mesh defines the mesh to look for
  36505. * @returns true if the mesh is in the active list
  36506. */
  36507. isActiveMesh(mesh: AbstractMesh): boolean;
  36508. /**
  36509. * Return a unique id as a string which can serve as an identifier for the scene
  36510. */
  36511. get uid(): string;
  36512. /**
  36513. * Add an externaly attached data from its key.
  36514. * This method call will fail and return false, if such key already exists.
  36515. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36516. * @param key the unique key that identifies the data
  36517. * @param data the data object to associate to the key for this Engine instance
  36518. * @return true if no such key were already present and the data was added successfully, false otherwise
  36519. */
  36520. addExternalData<T>(key: string, data: T): boolean;
  36521. /**
  36522. * Get an externaly attached data from its key
  36523. * @param key the unique key that identifies the data
  36524. * @return the associated data, if present (can be null), or undefined if not present
  36525. */
  36526. getExternalData<T>(key: string): Nullable<T>;
  36527. /**
  36528. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36529. * @param key the unique key that identifies the data
  36530. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36531. * @return the associated data, can be null if the factory returned null.
  36532. */
  36533. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36534. /**
  36535. * Remove an externaly attached data from the Engine instance
  36536. * @param key the unique key that identifies the data
  36537. * @return true if the data was successfully removed, false if it doesn't exist
  36538. */
  36539. removeExternalData(key: string): boolean;
  36540. private _evaluateSubMesh;
  36541. /**
  36542. * Clear the processed materials smart array preventing retention point in material dispose.
  36543. */
  36544. freeProcessedMaterials(): void;
  36545. private _preventFreeActiveMeshesAndRenderingGroups;
  36546. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36547. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36548. * when disposing several meshes in a row or a hierarchy of meshes.
  36549. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36550. */
  36551. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36552. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36553. /**
  36554. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36555. */
  36556. freeActiveMeshes(): void;
  36557. /**
  36558. * Clear the info related to rendering groups preventing retention points during dispose.
  36559. */
  36560. freeRenderingGroups(): void;
  36561. /** @hidden */
  36562. _isInIntermediateRendering(): boolean;
  36563. /**
  36564. * Lambda returning the list of potentially active meshes.
  36565. */
  36566. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36567. /**
  36568. * Lambda returning the list of potentially active sub meshes.
  36569. */
  36570. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36571. /**
  36572. * Lambda returning the list of potentially intersecting sub meshes.
  36573. */
  36574. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36575. /**
  36576. * Lambda returning the list of potentially colliding sub meshes.
  36577. */
  36578. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36579. private _activeMeshesFrozen;
  36580. private _skipEvaluateActiveMeshesCompletely;
  36581. /**
  36582. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36583. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36584. * @returns the current scene
  36585. */
  36586. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36587. /**
  36588. * Use this function to restart evaluating active meshes on every frame
  36589. * @returns the current scene
  36590. */
  36591. unfreezeActiveMeshes(): Scene;
  36592. private _evaluateActiveMeshes;
  36593. private _activeMesh;
  36594. /**
  36595. * Update the transform matrix to update from the current active camera
  36596. * @param force defines a boolean used to force the update even if cache is up to date
  36597. */
  36598. updateTransformMatrix(force?: boolean): void;
  36599. private _bindFrameBuffer;
  36600. /** @hidden */
  36601. _allowPostProcessClearColor: boolean;
  36602. /** @hidden */
  36603. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36604. private _processSubCameras;
  36605. private _checkIntersections;
  36606. /** @hidden */
  36607. _advancePhysicsEngineStep(step: number): void;
  36608. /**
  36609. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36610. */
  36611. getDeterministicFrameTime: () => number;
  36612. /** @hidden */
  36613. _animate(): void;
  36614. /** Execute all animations (for a frame) */
  36615. animate(): void;
  36616. /**
  36617. * Render the scene
  36618. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36619. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36620. */
  36621. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36622. /**
  36623. * Freeze all materials
  36624. * A frozen material will not be updatable but should be faster to render
  36625. */
  36626. freezeMaterials(): void;
  36627. /**
  36628. * Unfreeze all materials
  36629. * A frozen material will not be updatable but should be faster to render
  36630. */
  36631. unfreezeMaterials(): void;
  36632. /**
  36633. * Releases all held ressources
  36634. */
  36635. dispose(): void;
  36636. /**
  36637. * Gets if the scene is already disposed
  36638. */
  36639. get isDisposed(): boolean;
  36640. /**
  36641. * Call this function to reduce memory footprint of the scene.
  36642. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36643. */
  36644. clearCachedVertexData(): void;
  36645. /**
  36646. * This function will remove the local cached buffer data from texture.
  36647. * It will save memory but will prevent the texture from being rebuilt
  36648. */
  36649. cleanCachedTextureBuffer(): void;
  36650. /**
  36651. * Get the world extend vectors with an optional filter
  36652. *
  36653. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36654. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36655. */
  36656. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36657. min: Vector3;
  36658. max: Vector3;
  36659. };
  36660. /**
  36661. * Creates a ray that can be used to pick in the scene
  36662. * @param x defines the x coordinate of the origin (on-screen)
  36663. * @param y defines the y coordinate of the origin (on-screen)
  36664. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36665. * @param camera defines the camera to use for the picking
  36666. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36667. * @returns a Ray
  36668. */
  36669. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36670. /**
  36671. * Creates a ray that can be used to pick in the scene
  36672. * @param x defines the x coordinate of the origin (on-screen)
  36673. * @param y defines the y coordinate of the origin (on-screen)
  36674. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36675. * @param result defines the ray where to store the picking ray
  36676. * @param camera defines the camera to use for the picking
  36677. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36678. * @returns the current scene
  36679. */
  36680. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36681. /**
  36682. * Creates a ray that can be used to pick in the scene
  36683. * @param x defines the x coordinate of the origin (on-screen)
  36684. * @param y defines the y coordinate of the origin (on-screen)
  36685. * @param camera defines the camera to use for the picking
  36686. * @returns a Ray
  36687. */
  36688. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36689. /**
  36690. * Creates a ray that can be used to pick in the scene
  36691. * @param x defines the x coordinate of the origin (on-screen)
  36692. * @param y defines the y coordinate of the origin (on-screen)
  36693. * @param result defines the ray where to store the picking ray
  36694. * @param camera defines the camera to use for the picking
  36695. * @returns the current scene
  36696. */
  36697. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36698. /** Launch a ray to try to pick a mesh in the scene
  36699. * @param x position on screen
  36700. * @param y position on screen
  36701. * @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
  36702. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36703. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36704. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36705. * @returns a PickingInfo
  36706. */
  36707. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36708. /** Use the given ray to pick a mesh in the scene
  36709. * @param ray The ray to use to pick meshes
  36710. * @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
  36711. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36713. * @returns a PickingInfo
  36714. */
  36715. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36716. /**
  36717. * Launch a ray to try to pick a mesh in the scene
  36718. * @param x X position on screen
  36719. * @param y Y position on screen
  36720. * @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
  36721. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36722. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36723. * @returns an array of PickingInfo
  36724. */
  36725. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36726. /**
  36727. * Launch a ray to try to pick a mesh in the scene
  36728. * @param ray Ray to use
  36729. * @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
  36730. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36731. * @returns an array of PickingInfo
  36732. */
  36733. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36734. /**
  36735. * Force the value of meshUnderPointer
  36736. * @param mesh defines the mesh to use
  36737. */
  36738. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36739. /**
  36740. * Gets the mesh under the pointer
  36741. * @returns a Mesh or null if no mesh is under the pointer
  36742. */
  36743. getPointerOverMesh(): Nullable<AbstractMesh>;
  36744. /** @hidden */
  36745. _rebuildGeometries(): void;
  36746. /** @hidden */
  36747. _rebuildTextures(): void;
  36748. private _getByTags;
  36749. /**
  36750. * Get a list of meshes by tags
  36751. * @param tagsQuery defines the tags query to use
  36752. * @param forEach defines a predicate used to filter results
  36753. * @returns an array of Mesh
  36754. */
  36755. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36756. /**
  36757. * Get a list of cameras by tags
  36758. * @param tagsQuery defines the tags query to use
  36759. * @param forEach defines a predicate used to filter results
  36760. * @returns an array of Camera
  36761. */
  36762. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36763. /**
  36764. * Get a list of lights by tags
  36765. * @param tagsQuery defines the tags query to use
  36766. * @param forEach defines a predicate used to filter results
  36767. * @returns an array of Light
  36768. */
  36769. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36770. /**
  36771. * Get a list of materials by tags
  36772. * @param tagsQuery defines the tags query to use
  36773. * @param forEach defines a predicate used to filter results
  36774. * @returns an array of Material
  36775. */
  36776. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36777. /**
  36778. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36779. * This allowed control for front to back rendering or reversly depending of the special needs.
  36780. *
  36781. * @param renderingGroupId The rendering group id corresponding to its index
  36782. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36783. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36784. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36785. */
  36786. 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;
  36787. /**
  36788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36789. *
  36790. * @param renderingGroupId The rendering group id corresponding to its index
  36791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36792. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36793. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36794. */
  36795. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36796. /**
  36797. * Gets the current auto clear configuration for one rendering group of the rendering
  36798. * manager.
  36799. * @param index the rendering group index to get the information for
  36800. * @returns The auto clear setup for the requested rendering group
  36801. */
  36802. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36803. private _blockMaterialDirtyMechanism;
  36804. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36805. get blockMaterialDirtyMechanism(): boolean;
  36806. set blockMaterialDirtyMechanism(value: boolean);
  36807. /**
  36808. * Will flag all materials as dirty to trigger new shader compilation
  36809. * @param flag defines the flag used to specify which material part must be marked as dirty
  36810. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36811. */
  36812. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36813. /** @hidden */
  36814. _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;
  36815. /** @hidden */
  36816. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36817. /** @hidden */
  36818. _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;
  36819. /** @hidden */
  36820. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36821. /** @hidden */
  36822. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36823. /** @hidden */
  36824. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36825. }
  36826. }
  36827. declare module BABYLON {
  36828. /**
  36829. * Set of assets to keep when moving a scene into an asset container.
  36830. */
  36831. export class KeepAssets extends AbstractScene {
  36832. }
  36833. /**
  36834. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36835. */
  36836. export class InstantiatedEntries {
  36837. /**
  36838. * List of new root nodes (eg. nodes with no parent)
  36839. */
  36840. rootNodes: TransformNode[];
  36841. /**
  36842. * List of new skeletons
  36843. */
  36844. skeletons: Skeleton[];
  36845. /**
  36846. * List of new animation groups
  36847. */
  36848. animationGroups: AnimationGroup[];
  36849. }
  36850. /**
  36851. * Container with a set of assets that can be added or removed from a scene.
  36852. */
  36853. export class AssetContainer extends AbstractScene {
  36854. /**
  36855. * The scene the AssetContainer belongs to.
  36856. */
  36857. scene: Scene;
  36858. /**
  36859. * Instantiates an AssetContainer.
  36860. * @param scene The scene the AssetContainer belongs to.
  36861. */
  36862. constructor(scene: Scene);
  36863. /**
  36864. * Instantiate or clone all meshes and add the new ones to the scene.
  36865. * Skeletons and animation groups will all be cloned
  36866. * @param nameFunction defines an optional function used to get new names for clones
  36867. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36868. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36869. */
  36870. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36871. /**
  36872. * Adds all the assets from the container to the scene.
  36873. */
  36874. addAllToScene(): void;
  36875. /**
  36876. * Removes all the assets in the container from the scene
  36877. */
  36878. removeAllFromScene(): void;
  36879. /**
  36880. * Disposes all the assets in the container
  36881. */
  36882. dispose(): void;
  36883. private _moveAssets;
  36884. /**
  36885. * Removes all the assets contained in the scene and adds them to the container.
  36886. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36887. */
  36888. moveAllFromScene(keepAssets?: KeepAssets): void;
  36889. /**
  36890. * 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.
  36891. * @returns the root mesh
  36892. */
  36893. createRootMesh(): Mesh;
  36894. /**
  36895. * Merge animations from this asset container into a scene
  36896. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36897. * @param animatables set of animatables to retarget to a node from the scene
  36898. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36899. */
  36900. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36901. }
  36902. }
  36903. declare module BABYLON {
  36904. /**
  36905. * Defines how the parser contract is defined.
  36906. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36907. */
  36908. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36909. /**
  36910. * Defines how the individual parser contract is defined.
  36911. * These parser can parse an individual asset
  36912. */
  36913. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36914. /**
  36915. * Base class of the scene acting as a container for the different elements composing a scene.
  36916. * This class is dynamically extended by the different components of the scene increasing
  36917. * flexibility and reducing coupling
  36918. */
  36919. export abstract class AbstractScene {
  36920. /**
  36921. * Stores the list of available parsers in the application.
  36922. */
  36923. private static _BabylonFileParsers;
  36924. /**
  36925. * Stores the list of available individual parsers in the application.
  36926. */
  36927. private static _IndividualBabylonFileParsers;
  36928. /**
  36929. * Adds a parser in the list of available ones
  36930. * @param name Defines the name of the parser
  36931. * @param parser Defines the parser to add
  36932. */
  36933. static AddParser(name: string, parser: BabylonFileParser): void;
  36934. /**
  36935. * Gets a general parser from the list of avaialble ones
  36936. * @param name Defines the name of the parser
  36937. * @returns the requested parser or null
  36938. */
  36939. static GetParser(name: string): Nullable<BabylonFileParser>;
  36940. /**
  36941. * Adds n individual parser in the list of available ones
  36942. * @param name Defines the name of the parser
  36943. * @param parser Defines the parser to add
  36944. */
  36945. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36946. /**
  36947. * Gets an individual parser from the list of avaialble ones
  36948. * @param name Defines the name of the parser
  36949. * @returns the requested parser or null
  36950. */
  36951. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36952. /**
  36953. * Parser json data and populate both a scene and its associated container object
  36954. * @param jsonData Defines the data to parse
  36955. * @param scene Defines the scene to parse the data for
  36956. * @param container Defines the container attached to the parsing sequence
  36957. * @param rootUrl Defines the root url of the data
  36958. */
  36959. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36960. /**
  36961. * Gets the list of root nodes (ie. nodes with no parent)
  36962. */
  36963. rootNodes: Node[];
  36964. /** All of the cameras added to this scene
  36965. * @see http://doc.babylonjs.com/babylon101/cameras
  36966. */
  36967. cameras: Camera[];
  36968. /**
  36969. * All of the lights added to this scene
  36970. * @see http://doc.babylonjs.com/babylon101/lights
  36971. */
  36972. lights: Light[];
  36973. /**
  36974. * All of the (abstract) meshes added to this scene
  36975. */
  36976. meshes: AbstractMesh[];
  36977. /**
  36978. * The list of skeletons added to the scene
  36979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36980. */
  36981. skeletons: Skeleton[];
  36982. /**
  36983. * All of the particle systems added to this scene
  36984. * @see http://doc.babylonjs.com/babylon101/particles
  36985. */
  36986. particleSystems: IParticleSystem[];
  36987. /**
  36988. * Gets a list of Animations associated with the scene
  36989. */
  36990. animations: Animation[];
  36991. /**
  36992. * All of the animation groups added to this scene
  36993. * @see http://doc.babylonjs.com/how_to/group
  36994. */
  36995. animationGroups: AnimationGroup[];
  36996. /**
  36997. * All of the multi-materials added to this scene
  36998. * @see http://doc.babylonjs.com/how_to/multi_materials
  36999. */
  37000. multiMaterials: MultiMaterial[];
  37001. /**
  37002. * All of the materials added to this scene
  37003. * In the context of a Scene, it is not supposed to be modified manually.
  37004. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37005. * Note also that the order of the Material within the array is not significant and might change.
  37006. * @see http://doc.babylonjs.com/babylon101/materials
  37007. */
  37008. materials: Material[];
  37009. /**
  37010. * The list of morph target managers added to the scene
  37011. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37012. */
  37013. morphTargetManagers: MorphTargetManager[];
  37014. /**
  37015. * The list of geometries used in the scene.
  37016. */
  37017. geometries: Geometry[];
  37018. /**
  37019. * All of the tranform nodes added to this scene
  37020. * In the context of a Scene, it is not supposed to be modified manually.
  37021. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37022. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37023. * @see http://doc.babylonjs.com/how_to/transformnode
  37024. */
  37025. transformNodes: TransformNode[];
  37026. /**
  37027. * ActionManagers available on the scene.
  37028. */
  37029. actionManagers: AbstractActionManager[];
  37030. /**
  37031. * Textures to keep.
  37032. */
  37033. textures: BaseTexture[];
  37034. /**
  37035. * Environment texture for the scene
  37036. */
  37037. environmentTexture: Nullable<BaseTexture>;
  37038. /**
  37039. * @returns all meshes, lights, cameras, transformNodes and bones
  37040. */
  37041. getNodes(): Array<Node>;
  37042. }
  37043. }
  37044. declare module BABYLON {
  37045. /**
  37046. * Interface used to define options for Sound class
  37047. */
  37048. export interface ISoundOptions {
  37049. /**
  37050. * Does the sound autoplay once loaded.
  37051. */
  37052. autoplay?: boolean;
  37053. /**
  37054. * Does the sound loop after it finishes playing once.
  37055. */
  37056. loop?: boolean;
  37057. /**
  37058. * Sound's volume
  37059. */
  37060. volume?: number;
  37061. /**
  37062. * Is it a spatial sound?
  37063. */
  37064. spatialSound?: boolean;
  37065. /**
  37066. * Maximum distance to hear that sound
  37067. */
  37068. maxDistance?: number;
  37069. /**
  37070. * Uses user defined attenuation function
  37071. */
  37072. useCustomAttenuation?: boolean;
  37073. /**
  37074. * Define the roll off factor of spatial sounds.
  37075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37076. */
  37077. rolloffFactor?: number;
  37078. /**
  37079. * Define the reference distance the sound should be heard perfectly.
  37080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37081. */
  37082. refDistance?: number;
  37083. /**
  37084. * Define the distance attenuation model the sound will follow.
  37085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37086. */
  37087. distanceModel?: string;
  37088. /**
  37089. * Defines the playback speed (1 by default)
  37090. */
  37091. playbackRate?: number;
  37092. /**
  37093. * Defines if the sound is from a streaming source
  37094. */
  37095. streaming?: boolean;
  37096. /**
  37097. * Defines an optional length (in seconds) inside the sound file
  37098. */
  37099. length?: number;
  37100. /**
  37101. * Defines an optional offset (in seconds) inside the sound file
  37102. */
  37103. offset?: number;
  37104. /**
  37105. * If true, URLs will not be required to state the audio file codec to use.
  37106. */
  37107. skipCodecCheck?: boolean;
  37108. }
  37109. /**
  37110. * Defines a sound that can be played in the application.
  37111. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37113. */
  37114. export class Sound {
  37115. /**
  37116. * The name of the sound in the scene.
  37117. */
  37118. name: string;
  37119. /**
  37120. * Does the sound autoplay once loaded.
  37121. */
  37122. autoplay: boolean;
  37123. /**
  37124. * Does the sound loop after it finishes playing once.
  37125. */
  37126. loop: boolean;
  37127. /**
  37128. * Does the sound use a custom attenuation curve to simulate the falloff
  37129. * happening when the source gets further away from the camera.
  37130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37131. */
  37132. useCustomAttenuation: boolean;
  37133. /**
  37134. * The sound track id this sound belongs to.
  37135. */
  37136. soundTrackId: number;
  37137. /**
  37138. * Is this sound currently played.
  37139. */
  37140. isPlaying: boolean;
  37141. /**
  37142. * Is this sound currently paused.
  37143. */
  37144. isPaused: boolean;
  37145. /**
  37146. * Does this sound enables spatial sound.
  37147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37148. */
  37149. spatialSound: boolean;
  37150. /**
  37151. * Define the reference distance the sound should be heard perfectly.
  37152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37153. */
  37154. refDistance: number;
  37155. /**
  37156. * Define the roll off factor of spatial sounds.
  37157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37158. */
  37159. rolloffFactor: number;
  37160. /**
  37161. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37163. */
  37164. maxDistance: number;
  37165. /**
  37166. * Define the distance attenuation model the sound will follow.
  37167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37168. */
  37169. distanceModel: string;
  37170. /**
  37171. * @hidden
  37172. * Back Compat
  37173. **/
  37174. onended: () => any;
  37175. /**
  37176. * Observable event when the current playing sound finishes.
  37177. */
  37178. onEndedObservable: Observable<Sound>;
  37179. private _panningModel;
  37180. private _playbackRate;
  37181. private _streaming;
  37182. private _startTime;
  37183. private _startOffset;
  37184. private _position;
  37185. /** @hidden */
  37186. _positionInEmitterSpace: boolean;
  37187. private _localDirection;
  37188. private _volume;
  37189. private _isReadyToPlay;
  37190. private _isDirectional;
  37191. private _readyToPlayCallback;
  37192. private _audioBuffer;
  37193. private _soundSource;
  37194. private _streamingSource;
  37195. private _soundPanner;
  37196. private _soundGain;
  37197. private _inputAudioNode;
  37198. private _outputAudioNode;
  37199. private _coneInnerAngle;
  37200. private _coneOuterAngle;
  37201. private _coneOuterGain;
  37202. private _scene;
  37203. private _connectedTransformNode;
  37204. private _customAttenuationFunction;
  37205. private _registerFunc;
  37206. private _isOutputConnected;
  37207. private _htmlAudioElement;
  37208. private _urlType;
  37209. private _length?;
  37210. private _offset?;
  37211. /** @hidden */
  37212. static _SceneComponentInitialization: (scene: Scene) => void;
  37213. /**
  37214. * Create a sound and attach it to a scene
  37215. * @param name Name of your sound
  37216. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37217. * @param scene defines the scene the sound belongs to
  37218. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37219. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37220. */
  37221. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37222. /**
  37223. * Release the sound and its associated resources
  37224. */
  37225. dispose(): void;
  37226. /**
  37227. * Gets if the sounds is ready to be played or not.
  37228. * @returns true if ready, otherwise false
  37229. */
  37230. isReady(): boolean;
  37231. private _soundLoaded;
  37232. /**
  37233. * Sets the data of the sound from an audiobuffer
  37234. * @param audioBuffer The audioBuffer containing the data
  37235. */
  37236. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37237. /**
  37238. * Updates the current sounds options such as maxdistance, loop...
  37239. * @param options A JSON object containing values named as the object properties
  37240. */
  37241. updateOptions(options: ISoundOptions): void;
  37242. private _createSpatialParameters;
  37243. private _updateSpatialParameters;
  37244. /**
  37245. * Switch the panning model to HRTF:
  37246. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37248. */
  37249. switchPanningModelToHRTF(): void;
  37250. /**
  37251. * Switch the panning model to Equal Power:
  37252. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37254. */
  37255. switchPanningModelToEqualPower(): void;
  37256. private _switchPanningModel;
  37257. /**
  37258. * Connect this sound to a sound track audio node like gain...
  37259. * @param soundTrackAudioNode the sound track audio node to connect to
  37260. */
  37261. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37262. /**
  37263. * Transform this sound into a directional source
  37264. * @param coneInnerAngle Size of the inner cone in degree
  37265. * @param coneOuterAngle Size of the outer cone in degree
  37266. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37267. */
  37268. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37269. /**
  37270. * Gets or sets the inner angle for the directional cone.
  37271. */
  37272. get directionalConeInnerAngle(): number;
  37273. /**
  37274. * Gets or sets the inner angle for the directional cone.
  37275. */
  37276. set directionalConeInnerAngle(value: number);
  37277. /**
  37278. * Gets or sets the outer angle for the directional cone.
  37279. */
  37280. get directionalConeOuterAngle(): number;
  37281. /**
  37282. * Gets or sets the outer angle for the directional cone.
  37283. */
  37284. set directionalConeOuterAngle(value: number);
  37285. /**
  37286. * Sets the position of the emitter if spatial sound is enabled
  37287. * @param newPosition Defines the new posisiton
  37288. */
  37289. setPosition(newPosition: Vector3): void;
  37290. /**
  37291. * Sets the local direction of the emitter if spatial sound is enabled
  37292. * @param newLocalDirection Defines the new local direction
  37293. */
  37294. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37295. private _updateDirection;
  37296. /** @hidden */
  37297. updateDistanceFromListener(): void;
  37298. /**
  37299. * Sets a new custom attenuation function for the sound.
  37300. * @param callback Defines the function used for the attenuation
  37301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37302. */
  37303. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37304. /**
  37305. * Play the sound
  37306. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37307. * @param offset (optional) Start the sound at a specific time in seconds
  37308. * @param length (optional) Sound duration (in seconds)
  37309. */
  37310. play(time?: number, offset?: number, length?: number): void;
  37311. private _onended;
  37312. /**
  37313. * Stop the sound
  37314. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37315. */
  37316. stop(time?: number): void;
  37317. /**
  37318. * Put the sound in pause
  37319. */
  37320. pause(): void;
  37321. /**
  37322. * Sets a dedicated volume for this sounds
  37323. * @param newVolume Define the new volume of the sound
  37324. * @param time Define time for gradual change to new volume
  37325. */
  37326. setVolume(newVolume: number, time?: number): void;
  37327. /**
  37328. * Set the sound play back rate
  37329. * @param newPlaybackRate Define the playback rate the sound should be played at
  37330. */
  37331. setPlaybackRate(newPlaybackRate: number): void;
  37332. /**
  37333. * Gets the volume of the sound.
  37334. * @returns the volume of the sound
  37335. */
  37336. getVolume(): number;
  37337. /**
  37338. * Attach the sound to a dedicated mesh
  37339. * @param transformNode The transform node to connect the sound with
  37340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37341. */
  37342. attachToMesh(transformNode: TransformNode): void;
  37343. /**
  37344. * Detach the sound from the previously attached mesh
  37345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37346. */
  37347. detachFromMesh(): void;
  37348. private _onRegisterAfterWorldMatrixUpdate;
  37349. /**
  37350. * Clone the current sound in the scene.
  37351. * @returns the new sound clone
  37352. */
  37353. clone(): Nullable<Sound>;
  37354. /**
  37355. * Gets the current underlying audio buffer containing the data
  37356. * @returns the audio buffer
  37357. */
  37358. getAudioBuffer(): Nullable<AudioBuffer>;
  37359. /**
  37360. * Serializes the Sound in a JSON representation
  37361. * @returns the JSON representation of the sound
  37362. */
  37363. serialize(): any;
  37364. /**
  37365. * Parse a JSON representation of a sound to innstantiate in a given scene
  37366. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37367. * @param scene Define the scene the new parsed sound should be created in
  37368. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37369. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37370. * @returns the newly parsed sound
  37371. */
  37372. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * This defines an action helpful to play a defined sound on a triggered action.
  37378. */
  37379. export class PlaySoundAction extends Action {
  37380. private _sound;
  37381. /**
  37382. * Instantiate the action
  37383. * @param triggerOptions defines the trigger options
  37384. * @param sound defines the sound to play
  37385. * @param condition defines the trigger related conditions
  37386. */
  37387. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37388. /** @hidden */
  37389. _prepare(): void;
  37390. /**
  37391. * Execute the action and play the sound.
  37392. */
  37393. execute(): void;
  37394. /**
  37395. * Serializes the actions and its related information.
  37396. * @param parent defines the object to serialize in
  37397. * @returns the serialized object
  37398. */
  37399. serialize(parent: any): any;
  37400. }
  37401. /**
  37402. * This defines an action helpful to stop a defined sound on a triggered action.
  37403. */
  37404. export class StopSoundAction extends Action {
  37405. private _sound;
  37406. /**
  37407. * Instantiate the action
  37408. * @param triggerOptions defines the trigger options
  37409. * @param sound defines the sound to stop
  37410. * @param condition defines the trigger related conditions
  37411. */
  37412. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37413. /** @hidden */
  37414. _prepare(): void;
  37415. /**
  37416. * Execute the action and stop the sound.
  37417. */
  37418. execute(): void;
  37419. /**
  37420. * Serializes the actions and its related information.
  37421. * @param parent defines the object to serialize in
  37422. * @returns the serialized object
  37423. */
  37424. serialize(parent: any): any;
  37425. }
  37426. }
  37427. declare module BABYLON {
  37428. /**
  37429. * This defines an action responsible to change the value of a property
  37430. * by interpolating between its current value and the newly set one once triggered.
  37431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37432. */
  37433. export class InterpolateValueAction extends Action {
  37434. /**
  37435. * Defines the path of the property where the value should be interpolated
  37436. */
  37437. propertyPath: string;
  37438. /**
  37439. * Defines the target value at the end of the interpolation.
  37440. */
  37441. value: any;
  37442. /**
  37443. * Defines the time it will take for the property to interpolate to the value.
  37444. */
  37445. duration: number;
  37446. /**
  37447. * Defines if the other scene animations should be stopped when the action has been triggered
  37448. */
  37449. stopOtherAnimations?: boolean;
  37450. /**
  37451. * Defines a callback raised once the interpolation animation has been done.
  37452. */
  37453. onInterpolationDone?: () => void;
  37454. /**
  37455. * Observable triggered once the interpolation animation has been done.
  37456. */
  37457. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37458. private _target;
  37459. private _effectiveTarget;
  37460. private _property;
  37461. /**
  37462. * Instantiate the action
  37463. * @param triggerOptions defines the trigger options
  37464. * @param target defines the object containing the value to interpolate
  37465. * @param propertyPath defines the path to the property in the target object
  37466. * @param value defines the target value at the end of the interpolation
  37467. * @param duration deines the time it will take for the property to interpolate to the value.
  37468. * @param condition defines the trigger related conditions
  37469. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37470. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37471. */
  37472. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37473. /** @hidden */
  37474. _prepare(): void;
  37475. /**
  37476. * Execute the action starts the value interpolation.
  37477. */
  37478. execute(): void;
  37479. /**
  37480. * Serializes the actions and its related information.
  37481. * @param parent defines the object to serialize in
  37482. * @returns the serialized object
  37483. */
  37484. serialize(parent: any): any;
  37485. }
  37486. }
  37487. declare module BABYLON {
  37488. /**
  37489. * Options allowed during the creation of a sound track.
  37490. */
  37491. export interface ISoundTrackOptions {
  37492. /**
  37493. * The volume the sound track should take during creation
  37494. */
  37495. volume?: number;
  37496. /**
  37497. * Define if the sound track is the main sound track of the scene
  37498. */
  37499. mainTrack?: boolean;
  37500. }
  37501. /**
  37502. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37503. * It will be also used in a future release to apply effects on a specific track.
  37504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37505. */
  37506. export class SoundTrack {
  37507. /**
  37508. * The unique identifier of the sound track in the scene.
  37509. */
  37510. id: number;
  37511. /**
  37512. * The list of sounds included in the sound track.
  37513. */
  37514. soundCollection: Array<Sound>;
  37515. private _outputAudioNode;
  37516. private _scene;
  37517. private _connectedAnalyser;
  37518. private _options;
  37519. private _isInitialized;
  37520. /**
  37521. * Creates a new sound track.
  37522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37523. * @param scene Define the scene the sound track belongs to
  37524. * @param options
  37525. */
  37526. constructor(scene: Scene, options?: ISoundTrackOptions);
  37527. private _initializeSoundTrackAudioGraph;
  37528. /**
  37529. * Release the sound track and its associated resources
  37530. */
  37531. dispose(): void;
  37532. /**
  37533. * Adds a sound to this sound track
  37534. * @param sound define the cound to add
  37535. * @ignoreNaming
  37536. */
  37537. AddSound(sound: Sound): void;
  37538. /**
  37539. * Removes a sound to this sound track
  37540. * @param sound define the cound to remove
  37541. * @ignoreNaming
  37542. */
  37543. RemoveSound(sound: Sound): void;
  37544. /**
  37545. * Set a global volume for the full sound track.
  37546. * @param newVolume Define the new volume of the sound track
  37547. */
  37548. setVolume(newVolume: number): void;
  37549. /**
  37550. * Switch the panning model to HRTF:
  37551. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37553. */
  37554. switchPanningModelToHRTF(): void;
  37555. /**
  37556. * Switch the panning model to Equal Power:
  37557. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37559. */
  37560. switchPanningModelToEqualPower(): void;
  37561. /**
  37562. * Connect the sound track to an audio analyser allowing some amazing
  37563. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37565. * @param analyser The analyser to connect to the engine
  37566. */
  37567. connectToAnalyser(analyser: Analyser): void;
  37568. }
  37569. }
  37570. declare module BABYLON {
  37571. interface AbstractScene {
  37572. /**
  37573. * The list of sounds used in the scene.
  37574. */
  37575. sounds: Nullable<Array<Sound>>;
  37576. }
  37577. interface Scene {
  37578. /**
  37579. * @hidden
  37580. * Backing field
  37581. */
  37582. _mainSoundTrack: SoundTrack;
  37583. /**
  37584. * The main sound track played by the scene.
  37585. * It cotains your primary collection of sounds.
  37586. */
  37587. mainSoundTrack: SoundTrack;
  37588. /**
  37589. * The list of sound tracks added to the scene
  37590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37591. */
  37592. soundTracks: Nullable<Array<SoundTrack>>;
  37593. /**
  37594. * Gets a sound using a given name
  37595. * @param name defines the name to search for
  37596. * @return the found sound or null if not found at all.
  37597. */
  37598. getSoundByName(name: string): Nullable<Sound>;
  37599. /**
  37600. * Gets or sets if audio support is enabled
  37601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37602. */
  37603. audioEnabled: boolean;
  37604. /**
  37605. * Gets or sets if audio will be output to headphones
  37606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37607. */
  37608. headphone: boolean;
  37609. /**
  37610. * Gets or sets custom audio listener position provider
  37611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37612. */
  37613. audioListenerPositionProvider: Nullable<() => Vector3>;
  37614. /**
  37615. * Gets or sets a refresh rate when using 3D audio positioning
  37616. */
  37617. audioPositioningRefreshRate: number;
  37618. }
  37619. /**
  37620. * Defines the sound scene component responsible to manage any sounds
  37621. * in a given scene.
  37622. */
  37623. export class AudioSceneComponent implements ISceneSerializableComponent {
  37624. /**
  37625. * The component name helpfull to identify the component in the list of scene components.
  37626. */
  37627. readonly name: string;
  37628. /**
  37629. * The scene the component belongs to.
  37630. */
  37631. scene: Scene;
  37632. private _audioEnabled;
  37633. /**
  37634. * Gets whether audio is enabled or not.
  37635. * Please use related enable/disable method to switch state.
  37636. */
  37637. get audioEnabled(): boolean;
  37638. private _headphone;
  37639. /**
  37640. * Gets whether audio is outputing to headphone or not.
  37641. * Please use the according Switch methods to change output.
  37642. */
  37643. get headphone(): boolean;
  37644. /**
  37645. * Gets or sets a refresh rate when using 3D audio positioning
  37646. */
  37647. audioPositioningRefreshRate: number;
  37648. private _audioListenerPositionProvider;
  37649. /**
  37650. * Gets the current audio listener position provider
  37651. */
  37652. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37653. /**
  37654. * Sets a custom listener position for all sounds in the scene
  37655. * By default, this is the position of the first active camera
  37656. */
  37657. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37658. /**
  37659. * Creates a new instance of the component for the given scene
  37660. * @param scene Defines the scene to register the component in
  37661. */
  37662. constructor(scene: Scene);
  37663. /**
  37664. * Registers the component in a given scene
  37665. */
  37666. register(): void;
  37667. /**
  37668. * Rebuilds the elements related to this component in case of
  37669. * context lost for instance.
  37670. */
  37671. rebuild(): void;
  37672. /**
  37673. * Serializes the component data to the specified json object
  37674. * @param serializationObject The object to serialize to
  37675. */
  37676. serialize(serializationObject: any): void;
  37677. /**
  37678. * Adds all the elements from the container to the scene
  37679. * @param container the container holding the elements
  37680. */
  37681. addFromContainer(container: AbstractScene): void;
  37682. /**
  37683. * Removes all the elements in the container from the scene
  37684. * @param container contains the elements to remove
  37685. * @param dispose if the removed element should be disposed (default: false)
  37686. */
  37687. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37688. /**
  37689. * Disposes the component and the associated ressources.
  37690. */
  37691. dispose(): void;
  37692. /**
  37693. * Disables audio in the associated scene.
  37694. */
  37695. disableAudio(): void;
  37696. /**
  37697. * Enables audio in the associated scene.
  37698. */
  37699. enableAudio(): void;
  37700. /**
  37701. * Switch audio to headphone output.
  37702. */
  37703. switchAudioModeForHeadphones(): void;
  37704. /**
  37705. * Switch audio to normal speakers.
  37706. */
  37707. switchAudioModeForNormalSpeakers(): void;
  37708. private _cachedCameraDirection;
  37709. private _cachedCameraPosition;
  37710. private _lastCheck;
  37711. private _afterRender;
  37712. }
  37713. }
  37714. declare module BABYLON {
  37715. /**
  37716. * Wraps one or more Sound objects and selects one with random weight for playback.
  37717. */
  37718. export class WeightedSound {
  37719. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37720. loop: boolean;
  37721. private _coneInnerAngle;
  37722. private _coneOuterAngle;
  37723. private _volume;
  37724. /** A Sound is currently playing. */
  37725. isPlaying: boolean;
  37726. /** A Sound is currently paused. */
  37727. isPaused: boolean;
  37728. private _sounds;
  37729. private _weights;
  37730. private _currentIndex?;
  37731. /**
  37732. * Creates a new WeightedSound from the list of sounds given.
  37733. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37734. * @param sounds Array of Sounds that will be selected from.
  37735. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37736. */
  37737. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37738. /**
  37739. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37740. */
  37741. get directionalConeInnerAngle(): number;
  37742. /**
  37743. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37744. */
  37745. set directionalConeInnerAngle(value: number);
  37746. /**
  37747. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37748. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37749. */
  37750. get directionalConeOuterAngle(): number;
  37751. /**
  37752. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37753. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37754. */
  37755. set directionalConeOuterAngle(value: number);
  37756. /**
  37757. * Playback volume.
  37758. */
  37759. get volume(): number;
  37760. /**
  37761. * Playback volume.
  37762. */
  37763. set volume(value: number);
  37764. private _onended;
  37765. /**
  37766. * Suspend playback
  37767. */
  37768. pause(): void;
  37769. /**
  37770. * Stop playback
  37771. */
  37772. stop(): void;
  37773. /**
  37774. * Start playback.
  37775. * @param startOffset Position the clip head at a specific time in seconds.
  37776. */
  37777. play(startOffset?: number): void;
  37778. }
  37779. }
  37780. declare module BABYLON {
  37781. /**
  37782. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37783. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37784. */
  37785. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37786. /**
  37787. * Gets the name of the behavior.
  37788. */
  37789. get name(): string;
  37790. /**
  37791. * The easing function used by animations
  37792. */
  37793. static EasingFunction: BackEase;
  37794. /**
  37795. * The easing mode used by animations
  37796. */
  37797. static EasingMode: number;
  37798. /**
  37799. * The duration of the animation, in milliseconds
  37800. */
  37801. transitionDuration: number;
  37802. /**
  37803. * Length of the distance animated by the transition when lower radius is reached
  37804. */
  37805. lowerRadiusTransitionRange: number;
  37806. /**
  37807. * Length of the distance animated by the transition when upper radius is reached
  37808. */
  37809. upperRadiusTransitionRange: number;
  37810. private _autoTransitionRange;
  37811. /**
  37812. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37813. */
  37814. get autoTransitionRange(): boolean;
  37815. /**
  37816. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37817. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37818. */
  37819. set autoTransitionRange(value: boolean);
  37820. private _attachedCamera;
  37821. private _onAfterCheckInputsObserver;
  37822. private _onMeshTargetChangedObserver;
  37823. /**
  37824. * Initializes the behavior.
  37825. */
  37826. init(): void;
  37827. /**
  37828. * Attaches the behavior to its arc rotate camera.
  37829. * @param camera Defines the camera to attach the behavior to
  37830. */
  37831. attach(camera: ArcRotateCamera): void;
  37832. /**
  37833. * Detaches the behavior from its current arc rotate camera.
  37834. */
  37835. detach(): void;
  37836. private _radiusIsAnimating;
  37837. private _radiusBounceTransition;
  37838. private _animatables;
  37839. private _cachedWheelPrecision;
  37840. /**
  37841. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37842. * @param radiusLimit The limit to check against.
  37843. * @return Bool to indicate if at limit.
  37844. */
  37845. private _isRadiusAtLimit;
  37846. /**
  37847. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37848. * @param radiusDelta The delta by which to animate to. Can be negative.
  37849. */
  37850. private _applyBoundRadiusAnimation;
  37851. /**
  37852. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37853. */
  37854. protected _clearAnimationLocks(): void;
  37855. /**
  37856. * Stops and removes all animations that have been applied to the camera
  37857. */
  37858. stopAllAnimations(): void;
  37859. }
  37860. }
  37861. declare module BABYLON {
  37862. /**
  37863. * 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.
  37864. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37865. */
  37866. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37867. /**
  37868. * Gets the name of the behavior.
  37869. */
  37870. get name(): string;
  37871. private _mode;
  37872. private _radiusScale;
  37873. private _positionScale;
  37874. private _defaultElevation;
  37875. private _elevationReturnTime;
  37876. private _elevationReturnWaitTime;
  37877. private _zoomStopsAnimation;
  37878. private _framingTime;
  37879. /**
  37880. * The easing function used by animations
  37881. */
  37882. static EasingFunction: ExponentialEase;
  37883. /**
  37884. * The easing mode used by animations
  37885. */
  37886. static EasingMode: number;
  37887. /**
  37888. * Sets the current mode used by the behavior
  37889. */
  37890. set mode(mode: number);
  37891. /**
  37892. * Gets current mode used by the behavior.
  37893. */
  37894. get mode(): number;
  37895. /**
  37896. * Sets the scale applied to the radius (1 by default)
  37897. */
  37898. set radiusScale(radius: number);
  37899. /**
  37900. * Gets the scale applied to the radius
  37901. */
  37902. get radiusScale(): number;
  37903. /**
  37904. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37905. */
  37906. set positionScale(scale: number);
  37907. /**
  37908. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37909. */
  37910. get positionScale(): number;
  37911. /**
  37912. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37913. * behaviour is triggered, in radians.
  37914. */
  37915. set defaultElevation(elevation: number);
  37916. /**
  37917. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37918. * behaviour is triggered, in radians.
  37919. */
  37920. get defaultElevation(): number;
  37921. /**
  37922. * Sets the time (in milliseconds) taken to return to the default beta position.
  37923. * Negative value indicates camera should not return to default.
  37924. */
  37925. set elevationReturnTime(speed: number);
  37926. /**
  37927. * Gets the time (in milliseconds) taken to return to the default beta position.
  37928. * Negative value indicates camera should not return to default.
  37929. */
  37930. get elevationReturnTime(): number;
  37931. /**
  37932. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37933. */
  37934. set elevationReturnWaitTime(time: number);
  37935. /**
  37936. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37937. */
  37938. get elevationReturnWaitTime(): number;
  37939. /**
  37940. * Sets the flag that indicates if user zooming should stop animation.
  37941. */
  37942. set zoomStopsAnimation(flag: boolean);
  37943. /**
  37944. * Gets the flag that indicates if user zooming should stop animation.
  37945. */
  37946. get zoomStopsAnimation(): boolean;
  37947. /**
  37948. * Sets the transition time when framing the mesh, in milliseconds
  37949. */
  37950. set framingTime(time: number);
  37951. /**
  37952. * Gets the transition time when framing the mesh, in milliseconds
  37953. */
  37954. get framingTime(): number;
  37955. /**
  37956. * Define if the behavior should automatically change the configured
  37957. * camera limits and sensibilities.
  37958. */
  37959. autoCorrectCameraLimitsAndSensibility: boolean;
  37960. private _onPrePointerObservableObserver;
  37961. private _onAfterCheckInputsObserver;
  37962. private _onMeshTargetChangedObserver;
  37963. private _attachedCamera;
  37964. private _isPointerDown;
  37965. private _lastInteractionTime;
  37966. /**
  37967. * Initializes the behavior.
  37968. */
  37969. init(): void;
  37970. /**
  37971. * Attaches the behavior to its arc rotate camera.
  37972. * @param camera Defines the camera to attach the behavior to
  37973. */
  37974. attach(camera: ArcRotateCamera): void;
  37975. /**
  37976. * Detaches the behavior from its current arc rotate camera.
  37977. */
  37978. detach(): void;
  37979. private _animatables;
  37980. private _betaIsAnimating;
  37981. private _betaTransition;
  37982. private _radiusTransition;
  37983. private _vectorTransition;
  37984. /**
  37985. * Targets the given mesh and updates zoom level accordingly.
  37986. * @param mesh The mesh to target.
  37987. * @param radius Optional. If a cached radius position already exists, overrides default.
  37988. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37989. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37990. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37991. */
  37992. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37993. /**
  37994. * Targets the given mesh with its children and updates zoom level accordingly.
  37995. * @param mesh The mesh to target.
  37996. * @param radius Optional. If a cached radius position already exists, overrides default.
  37997. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37998. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37999. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38000. */
  38001. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38002. /**
  38003. * Targets the given meshes with their children and updates zoom level accordingly.
  38004. * @param meshes The mesh to target.
  38005. * @param radius Optional. If a cached radius position already exists, overrides default.
  38006. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38007. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38008. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38009. */
  38010. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38011. /**
  38012. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38013. * @param minimumWorld Determines the smaller position of the bounding box extend
  38014. * @param maximumWorld Determines the bigger position of the bounding box extend
  38015. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38016. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38017. */
  38018. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38019. /**
  38020. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38021. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38022. * frustum width.
  38023. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38024. * to fully enclose the mesh in the viewing frustum.
  38025. */
  38026. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38027. /**
  38028. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38029. * is automatically returned to its default position (expected to be above ground plane).
  38030. */
  38031. private _maintainCameraAboveGround;
  38032. /**
  38033. * Returns the frustum slope based on the canvas ratio and camera FOV
  38034. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38035. */
  38036. private _getFrustumSlope;
  38037. /**
  38038. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38039. */
  38040. private _clearAnimationLocks;
  38041. /**
  38042. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38043. */
  38044. private _applyUserInteraction;
  38045. /**
  38046. * Stops and removes all animations that have been applied to the camera
  38047. */
  38048. stopAllAnimations(): void;
  38049. /**
  38050. * Gets a value indicating if the user is moving the camera
  38051. */
  38052. get isUserIsMoving(): boolean;
  38053. /**
  38054. * The camera can move all the way towards the mesh.
  38055. */
  38056. static IgnoreBoundsSizeMode: number;
  38057. /**
  38058. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38059. */
  38060. static FitFrustumSidesMode: number;
  38061. }
  38062. }
  38063. declare module BABYLON {
  38064. /**
  38065. * Base class for Camera Pointer Inputs.
  38066. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38067. * for example usage.
  38068. */
  38069. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38070. /**
  38071. * Defines the camera the input is attached to.
  38072. */
  38073. abstract camera: Camera;
  38074. /**
  38075. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38076. */
  38077. protected _altKey: boolean;
  38078. protected _ctrlKey: boolean;
  38079. protected _metaKey: boolean;
  38080. protected _shiftKey: boolean;
  38081. /**
  38082. * Which mouse buttons were pressed at time of last mouse event.
  38083. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38084. */
  38085. protected _buttonsPressed: number;
  38086. /**
  38087. * Defines the buttons associated with the input to handle camera move.
  38088. */
  38089. buttons: number[];
  38090. /**
  38091. * Attach the input controls to a specific dom element to get the input from.
  38092. * @param element Defines the element the controls should be listened from
  38093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38094. */
  38095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38096. /**
  38097. * Detach the current controls from the specified dom element.
  38098. * @param element Defines the element to stop listening the inputs from
  38099. */
  38100. detachControl(element: Nullable<HTMLElement>): void;
  38101. /**
  38102. * Gets the class name of the current input.
  38103. * @returns the class name
  38104. */
  38105. getClassName(): string;
  38106. /**
  38107. * Get the friendly name associated with the input class.
  38108. * @returns the input friendly name
  38109. */
  38110. getSimpleName(): string;
  38111. /**
  38112. * Called on pointer POINTERDOUBLETAP event.
  38113. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38114. */
  38115. protected onDoubleTap(type: string): void;
  38116. /**
  38117. * Called on pointer POINTERMOVE event if only a single touch is active.
  38118. * Override this method to provide functionality.
  38119. */
  38120. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38121. /**
  38122. * Called on pointer POINTERMOVE event if multiple touches are active.
  38123. * Override this method to provide functionality.
  38124. */
  38125. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38126. /**
  38127. * Called on JS contextmenu event.
  38128. * Override this method to provide functionality.
  38129. */
  38130. protected onContextMenu(evt: PointerEvent): void;
  38131. /**
  38132. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38133. * press.
  38134. * Override this method to provide functionality.
  38135. */
  38136. protected onButtonDown(evt: PointerEvent): void;
  38137. /**
  38138. * Called each time a new POINTERUP event occurs. Ie, for each button
  38139. * release.
  38140. * Override this method to provide functionality.
  38141. */
  38142. protected onButtonUp(evt: PointerEvent): void;
  38143. /**
  38144. * Called when window becomes inactive.
  38145. * Override this method to provide functionality.
  38146. */
  38147. protected onLostFocus(): void;
  38148. private _pointerInput;
  38149. private _observer;
  38150. private _onLostFocus;
  38151. private pointA;
  38152. private pointB;
  38153. }
  38154. }
  38155. declare module BABYLON {
  38156. /**
  38157. * Manage the pointers inputs to control an arc rotate camera.
  38158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38159. */
  38160. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38161. /**
  38162. * Defines the camera the input is attached to.
  38163. */
  38164. camera: ArcRotateCamera;
  38165. /**
  38166. * Gets the class name of the current input.
  38167. * @returns the class name
  38168. */
  38169. getClassName(): string;
  38170. /**
  38171. * Defines the buttons associated with the input to handle camera move.
  38172. */
  38173. buttons: number[];
  38174. /**
  38175. * Defines the pointer angular sensibility along the X axis or how fast is
  38176. * the camera rotating.
  38177. */
  38178. angularSensibilityX: number;
  38179. /**
  38180. * Defines the pointer angular sensibility along the Y axis or how fast is
  38181. * the camera rotating.
  38182. */
  38183. angularSensibilityY: number;
  38184. /**
  38185. * Defines the pointer pinch precision or how fast is the camera zooming.
  38186. */
  38187. pinchPrecision: number;
  38188. /**
  38189. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38190. * from 0.
  38191. * It defines the percentage of current camera.radius to use as delta when
  38192. * pinch zoom is used.
  38193. */
  38194. pinchDeltaPercentage: number;
  38195. /**
  38196. * Defines the pointer panning sensibility or how fast is the camera moving.
  38197. */
  38198. panningSensibility: number;
  38199. /**
  38200. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38201. */
  38202. multiTouchPanning: boolean;
  38203. /**
  38204. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38205. * zoom (pinch) through multitouch.
  38206. */
  38207. multiTouchPanAndZoom: boolean;
  38208. /**
  38209. * Revers pinch action direction.
  38210. */
  38211. pinchInwards: boolean;
  38212. private _isPanClick;
  38213. private _twoFingerActivityCount;
  38214. private _isPinching;
  38215. /**
  38216. * Called on pointer POINTERMOVE event if only a single touch is active.
  38217. */
  38218. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38219. /**
  38220. * Called on pointer POINTERDOUBLETAP event.
  38221. */
  38222. protected onDoubleTap(type: string): void;
  38223. /**
  38224. * Called on pointer POINTERMOVE event if multiple touches are active.
  38225. */
  38226. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38227. /**
  38228. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38229. * press.
  38230. */
  38231. protected onButtonDown(evt: PointerEvent): void;
  38232. /**
  38233. * Called each time a new POINTERUP event occurs. Ie, for each button
  38234. * release.
  38235. */
  38236. protected onButtonUp(evt: PointerEvent): void;
  38237. /**
  38238. * Called when window becomes inactive.
  38239. */
  38240. protected onLostFocus(): void;
  38241. }
  38242. }
  38243. declare module BABYLON {
  38244. /**
  38245. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38247. */
  38248. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38249. /**
  38250. * Defines the camera the input is attached to.
  38251. */
  38252. camera: ArcRotateCamera;
  38253. /**
  38254. * Defines the list of key codes associated with the up action (increase alpha)
  38255. */
  38256. keysUp: number[];
  38257. /**
  38258. * Defines the list of key codes associated with the down action (decrease alpha)
  38259. */
  38260. keysDown: number[];
  38261. /**
  38262. * Defines the list of key codes associated with the left action (increase beta)
  38263. */
  38264. keysLeft: number[];
  38265. /**
  38266. * Defines the list of key codes associated with the right action (decrease beta)
  38267. */
  38268. keysRight: number[];
  38269. /**
  38270. * Defines the list of key codes associated with the reset action.
  38271. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38272. */
  38273. keysReset: number[];
  38274. /**
  38275. * Defines the panning sensibility of the inputs.
  38276. * (How fast is the camera paning)
  38277. */
  38278. panningSensibility: number;
  38279. /**
  38280. * Defines the zooming sensibility of the inputs.
  38281. * (How fast is the camera zooming)
  38282. */
  38283. zoomingSensibility: number;
  38284. /**
  38285. * Defines wether maintaining the alt key down switch the movement mode from
  38286. * orientation to zoom.
  38287. */
  38288. useAltToZoom: boolean;
  38289. /**
  38290. * Rotation speed of the camera
  38291. */
  38292. angularSpeed: number;
  38293. private _keys;
  38294. private _ctrlPressed;
  38295. private _altPressed;
  38296. private _onCanvasBlurObserver;
  38297. private _onKeyboardObserver;
  38298. private _engine;
  38299. private _scene;
  38300. /**
  38301. * Attach the input controls to a specific dom element to get the input from.
  38302. * @param element Defines the element the controls should be listened from
  38303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38304. */
  38305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38306. /**
  38307. * Detach the current controls from the specified dom element.
  38308. * @param element Defines the element to stop listening the inputs from
  38309. */
  38310. detachControl(element: Nullable<HTMLElement>): void;
  38311. /**
  38312. * Update the current camera state depending on the inputs that have been used this frame.
  38313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38314. */
  38315. checkInputs(): void;
  38316. /**
  38317. * Gets the class name of the current intput.
  38318. * @returns the class name
  38319. */
  38320. getClassName(): string;
  38321. /**
  38322. * Get the friendly name associated with the input class.
  38323. * @returns the input friendly name
  38324. */
  38325. getSimpleName(): string;
  38326. }
  38327. }
  38328. declare module BABYLON {
  38329. /**
  38330. * Manage the mouse wheel inputs to control an arc rotate camera.
  38331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38332. */
  38333. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38334. /**
  38335. * Defines the camera the input is attached to.
  38336. */
  38337. camera: ArcRotateCamera;
  38338. /**
  38339. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38340. */
  38341. wheelPrecision: number;
  38342. /**
  38343. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38344. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38345. */
  38346. wheelDeltaPercentage: number;
  38347. private _wheel;
  38348. private _observer;
  38349. private computeDeltaFromMouseWheelLegacyEvent;
  38350. /**
  38351. * Attach the input controls to a specific dom element to get the input from.
  38352. * @param element Defines the element the controls should be listened from
  38353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38354. */
  38355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38356. /**
  38357. * Detach the current controls from the specified dom element.
  38358. * @param element Defines the element to stop listening the inputs from
  38359. */
  38360. detachControl(element: Nullable<HTMLElement>): void;
  38361. /**
  38362. * Gets the class name of the current intput.
  38363. * @returns the class name
  38364. */
  38365. getClassName(): string;
  38366. /**
  38367. * Get the friendly name associated with the input class.
  38368. * @returns the input friendly name
  38369. */
  38370. getSimpleName(): string;
  38371. }
  38372. }
  38373. declare module BABYLON {
  38374. /**
  38375. * Default Inputs manager for the ArcRotateCamera.
  38376. * It groups all the default supported inputs for ease of use.
  38377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38378. */
  38379. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38380. /**
  38381. * Instantiates a new ArcRotateCameraInputsManager.
  38382. * @param camera Defines the camera the inputs belong to
  38383. */
  38384. constructor(camera: ArcRotateCamera);
  38385. /**
  38386. * Add mouse wheel input support to the input manager.
  38387. * @returns the current input manager
  38388. */
  38389. addMouseWheel(): ArcRotateCameraInputsManager;
  38390. /**
  38391. * Add pointers input support to the input manager.
  38392. * @returns the current input manager
  38393. */
  38394. addPointers(): ArcRotateCameraInputsManager;
  38395. /**
  38396. * Add keyboard input support to the input manager.
  38397. * @returns the current input manager
  38398. */
  38399. addKeyboard(): ArcRotateCameraInputsManager;
  38400. }
  38401. }
  38402. declare module BABYLON {
  38403. /**
  38404. * This represents an orbital type of camera.
  38405. *
  38406. * 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.
  38407. * 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.
  38408. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38409. */
  38410. export class ArcRotateCamera extends TargetCamera {
  38411. /**
  38412. * Defines the rotation angle of the camera along the longitudinal axis.
  38413. */
  38414. alpha: number;
  38415. /**
  38416. * Defines the rotation angle of the camera along the latitudinal axis.
  38417. */
  38418. beta: number;
  38419. /**
  38420. * Defines the radius of the camera from it s target point.
  38421. */
  38422. radius: number;
  38423. protected _target: Vector3;
  38424. protected _targetHost: Nullable<AbstractMesh>;
  38425. /**
  38426. * Defines the target point of the camera.
  38427. * The camera looks towards it form the radius distance.
  38428. */
  38429. get target(): Vector3;
  38430. set target(value: Vector3);
  38431. /**
  38432. * Define the current local position of the camera in the scene
  38433. */
  38434. get position(): Vector3;
  38435. set position(newPosition: Vector3);
  38436. protected _upVector: Vector3;
  38437. protected _upToYMatrix: Matrix;
  38438. protected _YToUpMatrix: Matrix;
  38439. /**
  38440. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38441. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38442. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38443. */
  38444. set upVector(vec: Vector3);
  38445. get upVector(): Vector3;
  38446. /**
  38447. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38448. */
  38449. setMatUp(): void;
  38450. /**
  38451. * Current inertia value on the longitudinal axis.
  38452. * The bigger this number the longer it will take for the camera to stop.
  38453. */
  38454. inertialAlphaOffset: number;
  38455. /**
  38456. * Current inertia value on the latitudinal axis.
  38457. * The bigger this number the longer it will take for the camera to stop.
  38458. */
  38459. inertialBetaOffset: number;
  38460. /**
  38461. * Current inertia value on the radius axis.
  38462. * The bigger this number the longer it will take for the camera to stop.
  38463. */
  38464. inertialRadiusOffset: number;
  38465. /**
  38466. * Minimum allowed angle on the longitudinal axis.
  38467. * This can help limiting how the Camera is able to move in the scene.
  38468. */
  38469. lowerAlphaLimit: Nullable<number>;
  38470. /**
  38471. * Maximum allowed angle on the longitudinal axis.
  38472. * This can help limiting how the Camera is able to move in the scene.
  38473. */
  38474. upperAlphaLimit: Nullable<number>;
  38475. /**
  38476. * Minimum allowed angle on the latitudinal axis.
  38477. * This can help limiting how the Camera is able to move in the scene.
  38478. */
  38479. lowerBetaLimit: number;
  38480. /**
  38481. * Maximum allowed angle on the latitudinal axis.
  38482. * This can help limiting how the Camera is able to move in the scene.
  38483. */
  38484. upperBetaLimit: number;
  38485. /**
  38486. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38487. * This can help limiting how the Camera is able to move in the scene.
  38488. */
  38489. lowerRadiusLimit: Nullable<number>;
  38490. /**
  38491. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38492. * This can help limiting how the Camera is able to move in the scene.
  38493. */
  38494. upperRadiusLimit: Nullable<number>;
  38495. /**
  38496. * Defines the current inertia value used during panning of the camera along the X axis.
  38497. */
  38498. inertialPanningX: number;
  38499. /**
  38500. * Defines the current inertia value used during panning of the camera along the Y axis.
  38501. */
  38502. inertialPanningY: number;
  38503. /**
  38504. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38505. * Basically if your fingers moves away from more than this distance you will be considered
  38506. * in pinch mode.
  38507. */
  38508. pinchToPanMaxDistance: number;
  38509. /**
  38510. * Defines the maximum distance the camera can pan.
  38511. * This could help keeping the cammera always in your scene.
  38512. */
  38513. panningDistanceLimit: Nullable<number>;
  38514. /**
  38515. * Defines the target of the camera before paning.
  38516. */
  38517. panningOriginTarget: Vector3;
  38518. /**
  38519. * Defines the value of the inertia used during panning.
  38520. * 0 would mean stop inertia and one would mean no decelleration at all.
  38521. */
  38522. panningInertia: number;
  38523. /**
  38524. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38525. */
  38526. get angularSensibilityX(): number;
  38527. set angularSensibilityX(value: number);
  38528. /**
  38529. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38530. */
  38531. get angularSensibilityY(): number;
  38532. set angularSensibilityY(value: number);
  38533. /**
  38534. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38535. */
  38536. get pinchPrecision(): number;
  38537. set pinchPrecision(value: number);
  38538. /**
  38539. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38540. * It will be used instead of pinchDeltaPrecision if different from 0.
  38541. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38542. */
  38543. get pinchDeltaPercentage(): number;
  38544. set pinchDeltaPercentage(value: number);
  38545. /**
  38546. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38547. */
  38548. get panningSensibility(): number;
  38549. set panningSensibility(value: number);
  38550. /**
  38551. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38552. */
  38553. get keysUp(): number[];
  38554. set keysUp(value: number[]);
  38555. /**
  38556. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38557. */
  38558. get keysDown(): number[];
  38559. set keysDown(value: number[]);
  38560. /**
  38561. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38562. */
  38563. get keysLeft(): number[];
  38564. set keysLeft(value: number[]);
  38565. /**
  38566. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38567. */
  38568. get keysRight(): number[];
  38569. set keysRight(value: number[]);
  38570. /**
  38571. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38572. */
  38573. get wheelPrecision(): number;
  38574. set wheelPrecision(value: number);
  38575. /**
  38576. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38577. * It will be used instead of pinchDeltaPrecision if different from 0.
  38578. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38579. */
  38580. get wheelDeltaPercentage(): number;
  38581. set wheelDeltaPercentage(value: number);
  38582. /**
  38583. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38584. */
  38585. zoomOnFactor: number;
  38586. /**
  38587. * Defines a screen offset for the camera position.
  38588. */
  38589. targetScreenOffset: Vector2;
  38590. /**
  38591. * Allows the camera to be completely reversed.
  38592. * If false the camera can not arrive upside down.
  38593. */
  38594. allowUpsideDown: boolean;
  38595. /**
  38596. * Define if double tap/click is used to restore the previously saved state of the camera.
  38597. */
  38598. useInputToRestoreState: boolean;
  38599. /** @hidden */
  38600. _viewMatrix: Matrix;
  38601. /** @hidden */
  38602. _useCtrlForPanning: boolean;
  38603. /** @hidden */
  38604. _panningMouseButton: number;
  38605. /**
  38606. * Defines the input associated to the camera.
  38607. */
  38608. inputs: ArcRotateCameraInputsManager;
  38609. /** @hidden */
  38610. _reset: () => void;
  38611. /**
  38612. * Defines the allowed panning axis.
  38613. */
  38614. panningAxis: Vector3;
  38615. protected _localDirection: Vector3;
  38616. protected _transformedDirection: Vector3;
  38617. private _bouncingBehavior;
  38618. /**
  38619. * Gets the bouncing behavior of the camera if it has been enabled.
  38620. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38621. */
  38622. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38623. /**
  38624. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38625. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38626. */
  38627. get useBouncingBehavior(): boolean;
  38628. set useBouncingBehavior(value: boolean);
  38629. private _framingBehavior;
  38630. /**
  38631. * Gets the framing behavior of the camera if it has been enabled.
  38632. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38633. */
  38634. get framingBehavior(): Nullable<FramingBehavior>;
  38635. /**
  38636. * Defines if the framing behavior of the camera is enabled on the camera.
  38637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38638. */
  38639. get useFramingBehavior(): boolean;
  38640. set useFramingBehavior(value: boolean);
  38641. private _autoRotationBehavior;
  38642. /**
  38643. * Gets the auto rotation behavior of the camera if it has been enabled.
  38644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38645. */
  38646. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38647. /**
  38648. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38650. */
  38651. get useAutoRotationBehavior(): boolean;
  38652. set useAutoRotationBehavior(value: boolean);
  38653. /**
  38654. * Observable triggered when the mesh target has been changed on the camera.
  38655. */
  38656. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38657. /**
  38658. * Event raised when the camera is colliding with a mesh.
  38659. */
  38660. onCollide: (collidedMesh: AbstractMesh) => void;
  38661. /**
  38662. * Defines whether the camera should check collision with the objects oh the scene.
  38663. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38664. */
  38665. checkCollisions: boolean;
  38666. /**
  38667. * Defines the collision radius of the camera.
  38668. * This simulates a sphere around the camera.
  38669. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38670. */
  38671. collisionRadius: Vector3;
  38672. protected _collider: Collider;
  38673. protected _previousPosition: Vector3;
  38674. protected _collisionVelocity: Vector3;
  38675. protected _newPosition: Vector3;
  38676. protected _previousAlpha: number;
  38677. protected _previousBeta: number;
  38678. protected _previousRadius: number;
  38679. protected _collisionTriggered: boolean;
  38680. protected _targetBoundingCenter: Nullable<Vector3>;
  38681. private _computationVector;
  38682. /**
  38683. * Instantiates a new ArcRotateCamera in a given scene
  38684. * @param name Defines the name of the camera
  38685. * @param alpha Defines the camera rotation along the logitudinal axis
  38686. * @param beta Defines the camera rotation along the latitudinal axis
  38687. * @param radius Defines the camera distance from its target
  38688. * @param target Defines the camera target
  38689. * @param scene Defines the scene the camera belongs to
  38690. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38691. */
  38692. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38693. /** @hidden */
  38694. _initCache(): void;
  38695. /** @hidden */
  38696. _updateCache(ignoreParentClass?: boolean): void;
  38697. protected _getTargetPosition(): Vector3;
  38698. private _storedAlpha;
  38699. private _storedBeta;
  38700. private _storedRadius;
  38701. private _storedTarget;
  38702. private _storedTargetScreenOffset;
  38703. /**
  38704. * Stores the current state of the camera (alpha, beta, radius and target)
  38705. * @returns the camera itself
  38706. */
  38707. storeState(): Camera;
  38708. /**
  38709. * @hidden
  38710. * Restored camera state. You must call storeState() first
  38711. */
  38712. _restoreStateValues(): boolean;
  38713. /** @hidden */
  38714. _isSynchronizedViewMatrix(): boolean;
  38715. /**
  38716. * Attached controls to the current camera.
  38717. * @param element Defines the element the controls should be listened from
  38718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38719. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38720. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38721. */
  38722. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38723. /**
  38724. * Detach the current controls from the camera.
  38725. * The camera will stop reacting to inputs.
  38726. * @param element Defines the element to stop listening the inputs from
  38727. */
  38728. detachControl(element: HTMLElement): void;
  38729. /** @hidden */
  38730. _checkInputs(): void;
  38731. protected _checkLimits(): void;
  38732. /**
  38733. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38734. */
  38735. rebuildAnglesAndRadius(): void;
  38736. /**
  38737. * Use a position to define the current camera related information like alpha, beta and radius
  38738. * @param position Defines the position to set the camera at
  38739. */
  38740. setPosition(position: Vector3): void;
  38741. /**
  38742. * Defines the target the camera should look at.
  38743. * This will automatically adapt alpha beta and radius to fit within the new target.
  38744. * @param target Defines the new target as a Vector or a mesh
  38745. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38746. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38747. */
  38748. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38749. /** @hidden */
  38750. _getViewMatrix(): Matrix;
  38751. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38752. /**
  38753. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38754. * @param meshes Defines the mesh to zoom on
  38755. * @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)
  38756. */
  38757. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38758. /**
  38759. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38760. * The target will be changed but the radius
  38761. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38762. * @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)
  38763. */
  38764. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38765. min: Vector3;
  38766. max: Vector3;
  38767. distance: number;
  38768. }, doNotUpdateMaxZ?: boolean): void;
  38769. /**
  38770. * @override
  38771. * Override Camera.createRigCamera
  38772. */
  38773. createRigCamera(name: string, cameraIndex: number): Camera;
  38774. /**
  38775. * @hidden
  38776. * @override
  38777. * Override Camera._updateRigCameras
  38778. */
  38779. _updateRigCameras(): void;
  38780. /**
  38781. * Destroy the camera and release the current resources hold by it.
  38782. */
  38783. dispose(): void;
  38784. /**
  38785. * Gets the current object class name.
  38786. * @return the class name
  38787. */
  38788. getClassName(): string;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38794. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38795. */
  38796. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38797. /**
  38798. * Gets the name of the behavior.
  38799. */
  38800. get name(): string;
  38801. private _zoomStopsAnimation;
  38802. private _idleRotationSpeed;
  38803. private _idleRotationWaitTime;
  38804. private _idleRotationSpinupTime;
  38805. /**
  38806. * Sets the flag that indicates if user zooming should stop animation.
  38807. */
  38808. set zoomStopsAnimation(flag: boolean);
  38809. /**
  38810. * Gets the flag that indicates if user zooming should stop animation.
  38811. */
  38812. get zoomStopsAnimation(): boolean;
  38813. /**
  38814. * Sets the default speed at which the camera rotates around the model.
  38815. */
  38816. set idleRotationSpeed(speed: number);
  38817. /**
  38818. * Gets the default speed at which the camera rotates around the model.
  38819. */
  38820. get idleRotationSpeed(): number;
  38821. /**
  38822. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38823. */
  38824. set idleRotationWaitTime(time: number);
  38825. /**
  38826. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38827. */
  38828. get idleRotationWaitTime(): number;
  38829. /**
  38830. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38831. */
  38832. set idleRotationSpinupTime(time: number);
  38833. /**
  38834. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38835. */
  38836. get idleRotationSpinupTime(): number;
  38837. /**
  38838. * Gets a value indicating if the camera is currently rotating because of this behavior
  38839. */
  38840. get rotationInProgress(): boolean;
  38841. private _onPrePointerObservableObserver;
  38842. private _onAfterCheckInputsObserver;
  38843. private _attachedCamera;
  38844. private _isPointerDown;
  38845. private _lastFrameTime;
  38846. private _lastInteractionTime;
  38847. private _cameraRotationSpeed;
  38848. /**
  38849. * Initializes the behavior.
  38850. */
  38851. init(): void;
  38852. /**
  38853. * Attaches the behavior to its arc rotate camera.
  38854. * @param camera Defines the camera to attach the behavior to
  38855. */
  38856. attach(camera: ArcRotateCamera): void;
  38857. /**
  38858. * Detaches the behavior from its current arc rotate camera.
  38859. */
  38860. detach(): void;
  38861. /**
  38862. * Returns true if user is scrolling.
  38863. * @return true if user is scrolling.
  38864. */
  38865. private _userIsZooming;
  38866. private _lastFrameRadius;
  38867. private _shouldAnimationStopForInteraction;
  38868. /**
  38869. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38870. */
  38871. private _applyUserInteraction;
  38872. private _userIsMoving;
  38873. }
  38874. }
  38875. declare module BABYLON {
  38876. /**
  38877. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38878. */
  38879. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38880. private ui;
  38881. /**
  38882. * The name of the behavior
  38883. */
  38884. name: string;
  38885. /**
  38886. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38887. */
  38888. distanceAwayFromFace: number;
  38889. /**
  38890. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38891. */
  38892. distanceAwayFromBottomOfFace: number;
  38893. private _faceVectors;
  38894. private _target;
  38895. private _scene;
  38896. private _onRenderObserver;
  38897. private _tmpMatrix;
  38898. private _tmpVector;
  38899. /**
  38900. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38901. * @param ui The transform node that should be attched to the mesh
  38902. */
  38903. constructor(ui: TransformNode);
  38904. /**
  38905. * Initializes the behavior
  38906. */
  38907. init(): void;
  38908. private _closestFace;
  38909. private _zeroVector;
  38910. private _lookAtTmpMatrix;
  38911. private _lookAtToRef;
  38912. /**
  38913. * Attaches the AttachToBoxBehavior to the passed in mesh
  38914. * @param target The mesh that the specified node will be attached to
  38915. */
  38916. attach(target: Mesh): void;
  38917. /**
  38918. * Detaches the behavior from the mesh
  38919. */
  38920. detach(): void;
  38921. }
  38922. }
  38923. declare module BABYLON {
  38924. /**
  38925. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38926. */
  38927. export class FadeInOutBehavior implements Behavior<Mesh> {
  38928. /**
  38929. * Time in milliseconds to delay before fading in (Default: 0)
  38930. */
  38931. delay: number;
  38932. /**
  38933. * Time in milliseconds for the mesh to fade in (Default: 300)
  38934. */
  38935. fadeInTime: number;
  38936. private _millisecondsPerFrame;
  38937. private _hovered;
  38938. private _hoverValue;
  38939. private _ownerNode;
  38940. /**
  38941. * Instatiates the FadeInOutBehavior
  38942. */
  38943. constructor();
  38944. /**
  38945. * The name of the behavior
  38946. */
  38947. get name(): string;
  38948. /**
  38949. * Initializes the behavior
  38950. */
  38951. init(): void;
  38952. /**
  38953. * Attaches the fade behavior on the passed in mesh
  38954. * @param ownerNode The mesh that will be faded in/out once attached
  38955. */
  38956. attach(ownerNode: Mesh): void;
  38957. /**
  38958. * Detaches the behavior from the mesh
  38959. */
  38960. detach(): void;
  38961. /**
  38962. * Triggers the mesh to begin fading in or out
  38963. * @param value if the object should fade in or out (true to fade in)
  38964. */
  38965. fadeIn(value: boolean): void;
  38966. private _update;
  38967. private _setAllVisibility;
  38968. }
  38969. }
  38970. declare module BABYLON {
  38971. /**
  38972. * Class containing a set of static utilities functions for managing Pivots
  38973. * @hidden
  38974. */
  38975. export class PivotTools {
  38976. private static _PivotCached;
  38977. private static _OldPivotPoint;
  38978. private static _PivotTranslation;
  38979. private static _PivotTmpVector;
  38980. /** @hidden */
  38981. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38982. /** @hidden */
  38983. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38984. }
  38985. }
  38986. declare module BABYLON {
  38987. /**
  38988. * Class containing static functions to help procedurally build meshes
  38989. */
  38990. export class PlaneBuilder {
  38991. /**
  38992. * Creates a plane mesh
  38993. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38994. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38995. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38997. * * 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
  38998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38999. * @param name defines the name of the mesh
  39000. * @param options defines the options used to create the mesh
  39001. * @param scene defines the hosting scene
  39002. * @returns the plane mesh
  39003. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39004. */
  39005. static CreatePlane(name: string, options: {
  39006. size?: number;
  39007. width?: number;
  39008. height?: number;
  39009. sideOrientation?: number;
  39010. frontUVs?: Vector4;
  39011. backUVs?: Vector4;
  39012. updatable?: boolean;
  39013. sourcePlane?: Plane;
  39014. }, scene?: Nullable<Scene>): Mesh;
  39015. }
  39016. }
  39017. declare module BABYLON {
  39018. /**
  39019. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39020. */
  39021. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39022. private static _AnyMouseID;
  39023. /**
  39024. * Abstract mesh the behavior is set on
  39025. */
  39026. attachedNode: AbstractMesh;
  39027. private _dragPlane;
  39028. private _scene;
  39029. private _pointerObserver;
  39030. private _beforeRenderObserver;
  39031. private static _planeScene;
  39032. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39033. /**
  39034. * 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)
  39035. */
  39036. maxDragAngle: number;
  39037. /**
  39038. * @hidden
  39039. */
  39040. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39041. /**
  39042. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39043. */
  39044. currentDraggingPointerID: number;
  39045. /**
  39046. * The last position where the pointer hit the drag plane in world space
  39047. */
  39048. lastDragPosition: Vector3;
  39049. /**
  39050. * If the behavior is currently in a dragging state
  39051. */
  39052. dragging: boolean;
  39053. /**
  39054. * 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)
  39055. */
  39056. dragDeltaRatio: number;
  39057. /**
  39058. * If the drag plane orientation should be updated during the dragging (Default: true)
  39059. */
  39060. updateDragPlane: boolean;
  39061. private _debugMode;
  39062. private _moving;
  39063. /**
  39064. * Fires each time the attached mesh is dragged with the pointer
  39065. * * delta between last drag position and current drag position in world space
  39066. * * dragDistance along the drag axis
  39067. * * dragPlaneNormal normal of the current drag plane used during the drag
  39068. * * dragPlanePoint in world space where the drag intersects the drag plane
  39069. */
  39070. onDragObservable: Observable<{
  39071. delta: Vector3;
  39072. dragPlanePoint: Vector3;
  39073. dragPlaneNormal: Vector3;
  39074. dragDistance: number;
  39075. pointerId: number;
  39076. }>;
  39077. /**
  39078. * Fires each time a drag begins (eg. mouse down on mesh)
  39079. */
  39080. onDragStartObservable: Observable<{
  39081. dragPlanePoint: Vector3;
  39082. pointerId: number;
  39083. }>;
  39084. /**
  39085. * Fires each time a drag ends (eg. mouse release after drag)
  39086. */
  39087. onDragEndObservable: Observable<{
  39088. dragPlanePoint: Vector3;
  39089. pointerId: number;
  39090. }>;
  39091. /**
  39092. * If the attached mesh should be moved when dragged
  39093. */
  39094. moveAttached: boolean;
  39095. /**
  39096. * If the drag behavior will react to drag events (Default: true)
  39097. */
  39098. enabled: boolean;
  39099. /**
  39100. * If pointer events should start and release the drag (Default: true)
  39101. */
  39102. startAndReleaseDragOnPointerEvents: boolean;
  39103. /**
  39104. * If camera controls should be detached during the drag
  39105. */
  39106. detachCameraControls: boolean;
  39107. /**
  39108. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39109. */
  39110. useObjectOrientationForDragging: boolean;
  39111. private _options;
  39112. /**
  39113. * Gets the options used by the behavior
  39114. */
  39115. get options(): {
  39116. dragAxis?: Vector3;
  39117. dragPlaneNormal?: Vector3;
  39118. };
  39119. /**
  39120. * Sets the options used by the behavior
  39121. */
  39122. set options(options: {
  39123. dragAxis?: Vector3;
  39124. dragPlaneNormal?: Vector3;
  39125. });
  39126. /**
  39127. * Creates a pointer drag behavior that can be attached to a mesh
  39128. * @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)
  39129. */
  39130. constructor(options?: {
  39131. dragAxis?: Vector3;
  39132. dragPlaneNormal?: Vector3;
  39133. });
  39134. /**
  39135. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39136. */
  39137. validateDrag: (targetPosition: Vector3) => boolean;
  39138. /**
  39139. * The name of the behavior
  39140. */
  39141. get name(): string;
  39142. /**
  39143. * Initializes the behavior
  39144. */
  39145. init(): void;
  39146. private _tmpVector;
  39147. private _alternatePickedPoint;
  39148. private _worldDragAxis;
  39149. private _targetPosition;
  39150. private _attachedElement;
  39151. /**
  39152. * Attaches the drag behavior the passed in mesh
  39153. * @param ownerNode The mesh that will be dragged around once attached
  39154. * @param predicate Predicate to use for pick filtering
  39155. */
  39156. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39157. /**
  39158. * Force relase the drag action by code.
  39159. */
  39160. releaseDrag(): void;
  39161. private _startDragRay;
  39162. private _lastPointerRay;
  39163. /**
  39164. * Simulates the start of a pointer drag event on the behavior
  39165. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39166. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39167. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39168. */
  39169. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39170. private _startDrag;
  39171. private _dragDelta;
  39172. private _moveDrag;
  39173. private _pickWithRayOnDragPlane;
  39174. private _pointA;
  39175. private _pointB;
  39176. private _pointC;
  39177. private _lineA;
  39178. private _lineB;
  39179. private _localAxis;
  39180. private _lookAt;
  39181. private _updateDragPlanePosition;
  39182. /**
  39183. * Detaches the behavior from the mesh
  39184. */
  39185. detach(): void;
  39186. }
  39187. }
  39188. declare module BABYLON {
  39189. /**
  39190. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39191. */
  39192. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39193. private _dragBehaviorA;
  39194. private _dragBehaviorB;
  39195. private _startDistance;
  39196. private _initialScale;
  39197. private _targetScale;
  39198. private _ownerNode;
  39199. private _sceneRenderObserver;
  39200. /**
  39201. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39202. */
  39203. constructor();
  39204. /**
  39205. * The name of the behavior
  39206. */
  39207. get name(): string;
  39208. /**
  39209. * Initializes the behavior
  39210. */
  39211. init(): void;
  39212. private _getCurrentDistance;
  39213. /**
  39214. * Attaches the scale behavior the passed in mesh
  39215. * @param ownerNode The mesh that will be scaled around once attached
  39216. */
  39217. attach(ownerNode: Mesh): void;
  39218. /**
  39219. * Detaches the behavior from the mesh
  39220. */
  39221. detach(): void;
  39222. }
  39223. }
  39224. declare module BABYLON {
  39225. /**
  39226. * 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
  39227. */
  39228. export class SixDofDragBehavior implements Behavior<Mesh> {
  39229. private static _virtualScene;
  39230. private _ownerNode;
  39231. private _sceneRenderObserver;
  39232. private _scene;
  39233. private _targetPosition;
  39234. private _virtualOriginMesh;
  39235. private _virtualDragMesh;
  39236. private _pointerObserver;
  39237. private _moving;
  39238. private _startingOrientation;
  39239. /**
  39240. * 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)
  39241. */
  39242. private zDragFactor;
  39243. /**
  39244. * If the object should rotate to face the drag origin
  39245. */
  39246. rotateDraggedObject: boolean;
  39247. /**
  39248. * If the behavior is currently in a dragging state
  39249. */
  39250. dragging: boolean;
  39251. /**
  39252. * 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)
  39253. */
  39254. dragDeltaRatio: number;
  39255. /**
  39256. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39257. */
  39258. currentDraggingPointerID: number;
  39259. /**
  39260. * If camera controls should be detached during the drag
  39261. */
  39262. detachCameraControls: boolean;
  39263. /**
  39264. * Fires each time a drag starts
  39265. */
  39266. onDragStartObservable: Observable<{}>;
  39267. /**
  39268. * Fires each time a drag ends (eg. mouse release after drag)
  39269. */
  39270. onDragEndObservable: Observable<{}>;
  39271. /**
  39272. * 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
  39273. */
  39274. constructor();
  39275. /**
  39276. * The name of the behavior
  39277. */
  39278. get name(): string;
  39279. /**
  39280. * Initializes the behavior
  39281. */
  39282. init(): void;
  39283. /**
  39284. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39285. */
  39286. private get _pointerCamera();
  39287. /**
  39288. * Attaches the scale behavior the passed in mesh
  39289. * @param ownerNode The mesh that will be scaled around once attached
  39290. */
  39291. attach(ownerNode: Mesh): void;
  39292. /**
  39293. * Detaches the behavior from the mesh
  39294. */
  39295. detach(): void;
  39296. }
  39297. }
  39298. declare module BABYLON {
  39299. /**
  39300. * Class used to apply inverse kinematics to bones
  39301. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39302. */
  39303. export class BoneIKController {
  39304. private static _tmpVecs;
  39305. private static _tmpQuat;
  39306. private static _tmpMats;
  39307. /**
  39308. * Gets or sets the target mesh
  39309. */
  39310. targetMesh: AbstractMesh;
  39311. /** Gets or sets the mesh used as pole */
  39312. poleTargetMesh: AbstractMesh;
  39313. /**
  39314. * Gets or sets the bone used as pole
  39315. */
  39316. poleTargetBone: Nullable<Bone>;
  39317. /**
  39318. * Gets or sets the target position
  39319. */
  39320. targetPosition: Vector3;
  39321. /**
  39322. * Gets or sets the pole target position
  39323. */
  39324. poleTargetPosition: Vector3;
  39325. /**
  39326. * Gets or sets the pole target local offset
  39327. */
  39328. poleTargetLocalOffset: Vector3;
  39329. /**
  39330. * Gets or sets the pole angle
  39331. */
  39332. poleAngle: number;
  39333. /**
  39334. * Gets or sets the mesh associated with the controller
  39335. */
  39336. mesh: AbstractMesh;
  39337. /**
  39338. * 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)
  39339. */
  39340. slerpAmount: number;
  39341. private _bone1Quat;
  39342. private _bone1Mat;
  39343. private _bone2Ang;
  39344. private _bone1;
  39345. private _bone2;
  39346. private _bone1Length;
  39347. private _bone2Length;
  39348. private _maxAngle;
  39349. private _maxReach;
  39350. private _rightHandedSystem;
  39351. private _bendAxis;
  39352. private _slerping;
  39353. private _adjustRoll;
  39354. /**
  39355. * Gets or sets maximum allowed angle
  39356. */
  39357. get maxAngle(): number;
  39358. set maxAngle(value: number);
  39359. /**
  39360. * Creates a new BoneIKController
  39361. * @param mesh defines the mesh to control
  39362. * @param bone defines the bone to control
  39363. * @param options defines options to set up the controller
  39364. */
  39365. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39366. targetMesh?: AbstractMesh;
  39367. poleTargetMesh?: AbstractMesh;
  39368. poleTargetBone?: Bone;
  39369. poleTargetLocalOffset?: Vector3;
  39370. poleAngle?: number;
  39371. bendAxis?: Vector3;
  39372. maxAngle?: number;
  39373. slerpAmount?: number;
  39374. });
  39375. private _setMaxAngle;
  39376. /**
  39377. * Force the controller to update the bones
  39378. */
  39379. update(): void;
  39380. }
  39381. }
  39382. declare module BABYLON {
  39383. /**
  39384. * Class used to make a bone look toward a point in space
  39385. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39386. */
  39387. export class BoneLookController {
  39388. private static _tmpVecs;
  39389. private static _tmpQuat;
  39390. private static _tmpMats;
  39391. /**
  39392. * The target Vector3 that the bone will look at
  39393. */
  39394. target: Vector3;
  39395. /**
  39396. * The mesh that the bone is attached to
  39397. */
  39398. mesh: AbstractMesh;
  39399. /**
  39400. * The bone that will be looking to the target
  39401. */
  39402. bone: Bone;
  39403. /**
  39404. * The up axis of the coordinate system that is used when the bone is rotated
  39405. */
  39406. upAxis: Vector3;
  39407. /**
  39408. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39409. */
  39410. upAxisSpace: Space;
  39411. /**
  39412. * Used to make an adjustment to the yaw of the bone
  39413. */
  39414. adjustYaw: number;
  39415. /**
  39416. * Used to make an adjustment to the pitch of the bone
  39417. */
  39418. adjustPitch: number;
  39419. /**
  39420. * Used to make an adjustment to the roll of the bone
  39421. */
  39422. adjustRoll: number;
  39423. /**
  39424. * 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)
  39425. */
  39426. slerpAmount: number;
  39427. private _minYaw;
  39428. private _maxYaw;
  39429. private _minPitch;
  39430. private _maxPitch;
  39431. private _minYawSin;
  39432. private _minYawCos;
  39433. private _maxYawSin;
  39434. private _maxYawCos;
  39435. private _midYawConstraint;
  39436. private _minPitchTan;
  39437. private _maxPitchTan;
  39438. private _boneQuat;
  39439. private _slerping;
  39440. private _transformYawPitch;
  39441. private _transformYawPitchInv;
  39442. private _firstFrameSkipped;
  39443. private _yawRange;
  39444. private _fowardAxis;
  39445. /**
  39446. * Gets or sets the minimum yaw angle that the bone can look to
  39447. */
  39448. get minYaw(): number;
  39449. set minYaw(value: number);
  39450. /**
  39451. * Gets or sets the maximum yaw angle that the bone can look to
  39452. */
  39453. get maxYaw(): number;
  39454. set maxYaw(value: number);
  39455. /**
  39456. * Gets or sets the minimum pitch angle that the bone can look to
  39457. */
  39458. get minPitch(): number;
  39459. set minPitch(value: number);
  39460. /**
  39461. * Gets or sets the maximum pitch angle that the bone can look to
  39462. */
  39463. get maxPitch(): number;
  39464. set maxPitch(value: number);
  39465. /**
  39466. * Create a BoneLookController
  39467. * @param mesh the mesh that the bone belongs to
  39468. * @param bone the bone that will be looking to the target
  39469. * @param target the target Vector3 to look at
  39470. * @param options optional settings:
  39471. * * maxYaw: the maximum angle the bone will yaw to
  39472. * * minYaw: the minimum angle the bone will yaw to
  39473. * * maxPitch: the maximum angle the bone will pitch to
  39474. * * minPitch: the minimum angle the bone will yaw to
  39475. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39476. * * upAxis: the up axis of the coordinate system
  39477. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39478. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39479. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39480. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39481. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39482. * * adjustRoll: used to make an adjustment to the roll of the bone
  39483. **/
  39484. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39485. maxYaw?: number;
  39486. minYaw?: number;
  39487. maxPitch?: number;
  39488. minPitch?: number;
  39489. slerpAmount?: number;
  39490. upAxis?: Vector3;
  39491. upAxisSpace?: Space;
  39492. yawAxis?: Vector3;
  39493. pitchAxis?: Vector3;
  39494. adjustYaw?: number;
  39495. adjustPitch?: number;
  39496. adjustRoll?: number;
  39497. });
  39498. /**
  39499. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39500. */
  39501. update(): void;
  39502. private _getAngleDiff;
  39503. private _getAngleBetween;
  39504. private _isAngleBetween;
  39505. }
  39506. }
  39507. declare module BABYLON {
  39508. /**
  39509. * Manage the gamepad inputs to control an arc rotate camera.
  39510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39511. */
  39512. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39513. /**
  39514. * Defines the camera the input is attached to.
  39515. */
  39516. camera: ArcRotateCamera;
  39517. /**
  39518. * Defines the gamepad the input is gathering event from.
  39519. */
  39520. gamepad: Nullable<Gamepad>;
  39521. /**
  39522. * Defines the gamepad rotation sensiblity.
  39523. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39524. */
  39525. gamepadRotationSensibility: number;
  39526. /**
  39527. * Defines the gamepad move sensiblity.
  39528. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39529. */
  39530. gamepadMoveSensibility: number;
  39531. private _yAxisScale;
  39532. /**
  39533. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39534. */
  39535. get invertYAxis(): boolean;
  39536. set invertYAxis(value: boolean);
  39537. private _onGamepadConnectedObserver;
  39538. private _onGamepadDisconnectedObserver;
  39539. /**
  39540. * Attach the input controls to a specific dom element to get the input from.
  39541. * @param element Defines the element the controls should be listened from
  39542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39543. */
  39544. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39545. /**
  39546. * Detach the current controls from the specified dom element.
  39547. * @param element Defines the element to stop listening the inputs from
  39548. */
  39549. detachControl(element: Nullable<HTMLElement>): void;
  39550. /**
  39551. * Update the current camera state depending on the inputs that have been used this frame.
  39552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39553. */
  39554. checkInputs(): void;
  39555. /**
  39556. * Gets the class name of the current intput.
  39557. * @returns the class name
  39558. */
  39559. getClassName(): string;
  39560. /**
  39561. * Get the friendly name associated with the input class.
  39562. * @returns the input friendly name
  39563. */
  39564. getSimpleName(): string;
  39565. }
  39566. }
  39567. declare module BABYLON {
  39568. interface ArcRotateCameraInputsManager {
  39569. /**
  39570. * Add orientation input support to the input manager.
  39571. * @returns the current input manager
  39572. */
  39573. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39574. }
  39575. /**
  39576. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39578. */
  39579. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39580. /**
  39581. * Defines the camera the input is attached to.
  39582. */
  39583. camera: ArcRotateCamera;
  39584. /**
  39585. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39586. */
  39587. alphaCorrection: number;
  39588. /**
  39589. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39590. */
  39591. gammaCorrection: number;
  39592. private _alpha;
  39593. private _gamma;
  39594. private _dirty;
  39595. private _deviceOrientationHandler;
  39596. /**
  39597. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39598. */
  39599. constructor();
  39600. /**
  39601. * Attach the input controls to a specific dom element to get the input from.
  39602. * @param element Defines the element the controls should be listened from
  39603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39604. */
  39605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39606. /** @hidden */
  39607. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39608. /**
  39609. * Update the current camera state depending on the inputs that have been used this frame.
  39610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39611. */
  39612. checkInputs(): void;
  39613. /**
  39614. * Detach the current controls from the specified dom element.
  39615. * @param element Defines the element to stop listening the inputs from
  39616. */
  39617. detachControl(element: Nullable<HTMLElement>): void;
  39618. /**
  39619. * Gets the class name of the current intput.
  39620. * @returns the class name
  39621. */
  39622. getClassName(): string;
  39623. /**
  39624. * Get the friendly name associated with the input class.
  39625. * @returns the input friendly name
  39626. */
  39627. getSimpleName(): string;
  39628. }
  39629. }
  39630. declare module BABYLON {
  39631. /**
  39632. * Listen to mouse events to control the camera.
  39633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39634. */
  39635. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39636. /**
  39637. * Defines the camera the input is attached to.
  39638. */
  39639. camera: FlyCamera;
  39640. /**
  39641. * Defines if touch is enabled. (Default is true.)
  39642. */
  39643. touchEnabled: boolean;
  39644. /**
  39645. * Defines the buttons associated with the input to handle camera rotation.
  39646. */
  39647. buttons: number[];
  39648. /**
  39649. * Assign buttons for Yaw control.
  39650. */
  39651. buttonsYaw: number[];
  39652. /**
  39653. * Assign buttons for Pitch control.
  39654. */
  39655. buttonsPitch: number[];
  39656. /**
  39657. * Assign buttons for Roll control.
  39658. */
  39659. buttonsRoll: number[];
  39660. /**
  39661. * Detect if any button is being pressed while mouse is moved.
  39662. * -1 = Mouse locked.
  39663. * 0 = Left button.
  39664. * 1 = Middle Button.
  39665. * 2 = Right Button.
  39666. */
  39667. activeButton: number;
  39668. /**
  39669. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39670. * Higher values reduce its sensitivity.
  39671. */
  39672. angularSensibility: number;
  39673. private _mousemoveCallback;
  39674. private _observer;
  39675. private _rollObserver;
  39676. private previousPosition;
  39677. private noPreventDefault;
  39678. private element;
  39679. /**
  39680. * Listen to mouse events to control the camera.
  39681. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39683. */
  39684. constructor(touchEnabled?: boolean);
  39685. /**
  39686. * Attach the mouse control to the HTML DOM element.
  39687. * @param element Defines the element that listens to the input events.
  39688. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39689. */
  39690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39691. /**
  39692. * Detach the current controls from the specified dom element.
  39693. * @param element Defines the element to stop listening the inputs from
  39694. */
  39695. detachControl(element: Nullable<HTMLElement>): void;
  39696. /**
  39697. * Gets the class name of the current input.
  39698. * @returns the class name.
  39699. */
  39700. getClassName(): string;
  39701. /**
  39702. * Get the friendly name associated with the input class.
  39703. * @returns the input's friendly name.
  39704. */
  39705. getSimpleName(): string;
  39706. private _pointerInput;
  39707. private _onMouseMove;
  39708. /**
  39709. * Rotate camera by mouse offset.
  39710. */
  39711. private rotateCamera;
  39712. }
  39713. }
  39714. declare module BABYLON {
  39715. /**
  39716. * Default Inputs manager for the FlyCamera.
  39717. * It groups all the default supported inputs for ease of use.
  39718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39719. */
  39720. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39721. /**
  39722. * Instantiates a new FlyCameraInputsManager.
  39723. * @param camera Defines the camera the inputs belong to.
  39724. */
  39725. constructor(camera: FlyCamera);
  39726. /**
  39727. * Add keyboard input support to the input manager.
  39728. * @returns the new FlyCameraKeyboardMoveInput().
  39729. */
  39730. addKeyboard(): FlyCameraInputsManager;
  39731. /**
  39732. * Add mouse input support to the input manager.
  39733. * @param touchEnabled Enable touch screen support.
  39734. * @returns the new FlyCameraMouseInput().
  39735. */
  39736. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39737. }
  39738. }
  39739. declare module BABYLON {
  39740. /**
  39741. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39742. * such as in a 3D Space Shooter or a Flight Simulator.
  39743. */
  39744. export class FlyCamera extends TargetCamera {
  39745. /**
  39746. * Define the collision ellipsoid of the camera.
  39747. * This is helpful for simulating a camera body, like a player's body.
  39748. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39749. */
  39750. ellipsoid: Vector3;
  39751. /**
  39752. * Define an offset for the position of the ellipsoid around the camera.
  39753. * This can be helpful if the camera is attached away from the player's body center,
  39754. * such as at its head.
  39755. */
  39756. ellipsoidOffset: Vector3;
  39757. /**
  39758. * Enable or disable collisions of the camera with the rest of the scene objects.
  39759. */
  39760. checkCollisions: boolean;
  39761. /**
  39762. * Enable or disable gravity on the camera.
  39763. */
  39764. applyGravity: boolean;
  39765. /**
  39766. * Define the current direction the camera is moving to.
  39767. */
  39768. cameraDirection: Vector3;
  39769. /**
  39770. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39771. * This overrides and empties cameraRotation.
  39772. */
  39773. rotationQuaternion: Quaternion;
  39774. /**
  39775. * Track Roll to maintain the wanted Rolling when looking around.
  39776. */
  39777. _trackRoll: number;
  39778. /**
  39779. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39780. */
  39781. rollCorrect: number;
  39782. /**
  39783. * Mimic a banked turn, Rolling the camera when Yawing.
  39784. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39785. */
  39786. bankedTurn: boolean;
  39787. /**
  39788. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39789. */
  39790. bankedTurnLimit: number;
  39791. /**
  39792. * Value of 0 disables the banked Roll.
  39793. * Value of 1 is equal to the Yaw angle in radians.
  39794. */
  39795. bankedTurnMultiplier: number;
  39796. /**
  39797. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39798. */
  39799. inputs: FlyCameraInputsManager;
  39800. /**
  39801. * Gets the input sensibility for mouse input.
  39802. * Higher values reduce sensitivity.
  39803. */
  39804. get angularSensibility(): number;
  39805. /**
  39806. * Sets the input sensibility for a mouse input.
  39807. * Higher values reduce sensitivity.
  39808. */
  39809. set angularSensibility(value: number);
  39810. /**
  39811. * Get the keys for camera movement forward.
  39812. */
  39813. get keysForward(): number[];
  39814. /**
  39815. * Set the keys for camera movement forward.
  39816. */
  39817. set keysForward(value: number[]);
  39818. /**
  39819. * Get the keys for camera movement backward.
  39820. */
  39821. get keysBackward(): number[];
  39822. set keysBackward(value: number[]);
  39823. /**
  39824. * Get the keys for camera movement up.
  39825. */
  39826. get keysUp(): number[];
  39827. /**
  39828. * Set the keys for camera movement up.
  39829. */
  39830. set keysUp(value: number[]);
  39831. /**
  39832. * Get the keys for camera movement down.
  39833. */
  39834. get keysDown(): number[];
  39835. /**
  39836. * Set the keys for camera movement down.
  39837. */
  39838. set keysDown(value: number[]);
  39839. /**
  39840. * Get the keys for camera movement left.
  39841. */
  39842. get keysLeft(): number[];
  39843. /**
  39844. * Set the keys for camera movement left.
  39845. */
  39846. set keysLeft(value: number[]);
  39847. /**
  39848. * Set the keys for camera movement right.
  39849. */
  39850. get keysRight(): number[];
  39851. /**
  39852. * Set the keys for camera movement right.
  39853. */
  39854. set keysRight(value: number[]);
  39855. /**
  39856. * Event raised when the camera collides with a mesh in the scene.
  39857. */
  39858. onCollide: (collidedMesh: AbstractMesh) => void;
  39859. private _collider;
  39860. private _needMoveForGravity;
  39861. private _oldPosition;
  39862. private _diffPosition;
  39863. private _newPosition;
  39864. /** @hidden */
  39865. _localDirection: Vector3;
  39866. /** @hidden */
  39867. _transformedDirection: Vector3;
  39868. /**
  39869. * Instantiates a FlyCamera.
  39870. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39871. * such as in a 3D Space Shooter or a Flight Simulator.
  39872. * @param name Define the name of the camera in the scene.
  39873. * @param position Define the starting position of the camera in the scene.
  39874. * @param scene Define the scene the camera belongs to.
  39875. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39876. */
  39877. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39878. /**
  39879. * Attach a control to the HTML DOM element.
  39880. * @param element Defines the element that listens to the input events.
  39881. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39882. */
  39883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39884. /**
  39885. * Detach a control from the HTML DOM element.
  39886. * The camera will stop reacting to that input.
  39887. * @param element Defines the element that listens to the input events.
  39888. */
  39889. detachControl(element: HTMLElement): void;
  39890. private _collisionMask;
  39891. /**
  39892. * Get the mask that the camera ignores in collision events.
  39893. */
  39894. get collisionMask(): number;
  39895. /**
  39896. * Set the mask that the camera ignores in collision events.
  39897. */
  39898. set collisionMask(mask: number);
  39899. /** @hidden */
  39900. _collideWithWorld(displacement: Vector3): void;
  39901. /** @hidden */
  39902. private _onCollisionPositionChange;
  39903. /** @hidden */
  39904. _checkInputs(): void;
  39905. /** @hidden */
  39906. _decideIfNeedsToMove(): boolean;
  39907. /** @hidden */
  39908. _updatePosition(): void;
  39909. /**
  39910. * Restore the Roll to its target value at the rate specified.
  39911. * @param rate - Higher means slower restoring.
  39912. * @hidden
  39913. */
  39914. restoreRoll(rate: number): void;
  39915. /**
  39916. * Destroy the camera and release the current resources held by it.
  39917. */
  39918. dispose(): void;
  39919. /**
  39920. * Get the current object class name.
  39921. * @returns the class name.
  39922. */
  39923. getClassName(): string;
  39924. }
  39925. }
  39926. declare module BABYLON {
  39927. /**
  39928. * Listen to keyboard events to control the camera.
  39929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39930. */
  39931. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39932. /**
  39933. * Defines the camera the input is attached to.
  39934. */
  39935. camera: FlyCamera;
  39936. /**
  39937. * The list of keyboard keys used to control the forward move of the camera.
  39938. */
  39939. keysForward: number[];
  39940. /**
  39941. * The list of keyboard keys used to control the backward move of the camera.
  39942. */
  39943. keysBackward: number[];
  39944. /**
  39945. * The list of keyboard keys used to control the forward move of the camera.
  39946. */
  39947. keysUp: number[];
  39948. /**
  39949. * The list of keyboard keys used to control the backward move of the camera.
  39950. */
  39951. keysDown: number[];
  39952. /**
  39953. * The list of keyboard keys used to control the right strafe move of the camera.
  39954. */
  39955. keysRight: number[];
  39956. /**
  39957. * The list of keyboard keys used to control the left strafe move of the camera.
  39958. */
  39959. keysLeft: number[];
  39960. private _keys;
  39961. private _onCanvasBlurObserver;
  39962. private _onKeyboardObserver;
  39963. private _engine;
  39964. private _scene;
  39965. /**
  39966. * Attach the input controls to a specific dom element to get the input from.
  39967. * @param element Defines the element the controls should be listened from
  39968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39969. */
  39970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39971. /**
  39972. * Detach the current controls from the specified dom element.
  39973. * @param element Defines the element to stop listening the inputs from
  39974. */
  39975. detachControl(element: Nullable<HTMLElement>): void;
  39976. /**
  39977. * Gets the class name of the current intput.
  39978. * @returns the class name
  39979. */
  39980. getClassName(): string;
  39981. /** @hidden */
  39982. _onLostFocus(e: FocusEvent): void;
  39983. /**
  39984. * Get the friendly name associated with the input class.
  39985. * @returns the input friendly name
  39986. */
  39987. getSimpleName(): string;
  39988. /**
  39989. * Update the current camera state depending on the inputs that have been used this frame.
  39990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39991. */
  39992. checkInputs(): void;
  39993. }
  39994. }
  39995. declare module BABYLON {
  39996. /**
  39997. * Manage the mouse wheel inputs to control a follow camera.
  39998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39999. */
  40000. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40001. /**
  40002. * Defines the camera the input is attached to.
  40003. */
  40004. camera: FollowCamera;
  40005. /**
  40006. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40007. */
  40008. axisControlRadius: boolean;
  40009. /**
  40010. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40011. */
  40012. axisControlHeight: boolean;
  40013. /**
  40014. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40015. */
  40016. axisControlRotation: boolean;
  40017. /**
  40018. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40019. * relation to mouseWheel events.
  40020. */
  40021. wheelPrecision: number;
  40022. /**
  40023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40025. */
  40026. wheelDeltaPercentage: number;
  40027. private _wheel;
  40028. private _observer;
  40029. /**
  40030. * Attach the input controls to a specific dom element to get the input from.
  40031. * @param element Defines the element the controls should be listened from
  40032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40033. */
  40034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40035. /**
  40036. * Detach the current controls from the specified dom element.
  40037. * @param element Defines the element to stop listening the inputs from
  40038. */
  40039. detachControl(element: Nullable<HTMLElement>): void;
  40040. /**
  40041. * Gets the class name of the current intput.
  40042. * @returns the class name
  40043. */
  40044. getClassName(): string;
  40045. /**
  40046. * Get the friendly name associated with the input class.
  40047. * @returns the input friendly name
  40048. */
  40049. getSimpleName(): string;
  40050. }
  40051. }
  40052. declare module BABYLON {
  40053. /**
  40054. * Manage the pointers inputs to control an follow camera.
  40055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40056. */
  40057. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40058. /**
  40059. * Defines the camera the input is attached to.
  40060. */
  40061. camera: FollowCamera;
  40062. /**
  40063. * Gets the class name of the current input.
  40064. * @returns the class name
  40065. */
  40066. getClassName(): string;
  40067. /**
  40068. * Defines the pointer angular sensibility along the X axis or how fast is
  40069. * the camera rotating.
  40070. * A negative number will reverse the axis direction.
  40071. */
  40072. angularSensibilityX: number;
  40073. /**
  40074. * Defines the pointer angular sensibility along the Y axis or how fast is
  40075. * the camera rotating.
  40076. * A negative number will reverse the axis direction.
  40077. */
  40078. angularSensibilityY: number;
  40079. /**
  40080. * Defines the pointer pinch precision or how fast is the camera zooming.
  40081. * A negative number will reverse the axis direction.
  40082. */
  40083. pinchPrecision: number;
  40084. /**
  40085. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40086. * from 0.
  40087. * It defines the percentage of current camera.radius to use as delta when
  40088. * pinch zoom is used.
  40089. */
  40090. pinchDeltaPercentage: number;
  40091. /**
  40092. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40093. */
  40094. axisXControlRadius: boolean;
  40095. /**
  40096. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40097. */
  40098. axisXControlHeight: boolean;
  40099. /**
  40100. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40101. */
  40102. axisXControlRotation: boolean;
  40103. /**
  40104. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40105. */
  40106. axisYControlRadius: boolean;
  40107. /**
  40108. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40109. */
  40110. axisYControlHeight: boolean;
  40111. /**
  40112. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40113. */
  40114. axisYControlRotation: boolean;
  40115. /**
  40116. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40117. */
  40118. axisPinchControlRadius: boolean;
  40119. /**
  40120. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40121. */
  40122. axisPinchControlHeight: boolean;
  40123. /**
  40124. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40125. */
  40126. axisPinchControlRotation: boolean;
  40127. /**
  40128. * Log error messages if basic misconfiguration has occurred.
  40129. */
  40130. warningEnable: boolean;
  40131. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40132. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40133. private _warningCounter;
  40134. private _warning;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. /**
  40139. * Default Inputs manager for the FollowCamera.
  40140. * It groups all the default supported inputs for ease of use.
  40141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40142. */
  40143. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40144. /**
  40145. * Instantiates a new FollowCameraInputsManager.
  40146. * @param camera Defines the camera the inputs belong to
  40147. */
  40148. constructor(camera: FollowCamera);
  40149. /**
  40150. * Add keyboard input support to the input manager.
  40151. * @returns the current input manager
  40152. */
  40153. addKeyboard(): FollowCameraInputsManager;
  40154. /**
  40155. * Add mouse wheel input support to the input manager.
  40156. * @returns the current input manager
  40157. */
  40158. addMouseWheel(): FollowCameraInputsManager;
  40159. /**
  40160. * Add pointers input support to the input manager.
  40161. * @returns the current input manager
  40162. */
  40163. addPointers(): FollowCameraInputsManager;
  40164. /**
  40165. * Add orientation input support to the input manager.
  40166. * @returns the current input manager
  40167. */
  40168. addVRDeviceOrientation(): FollowCameraInputsManager;
  40169. }
  40170. }
  40171. declare module BABYLON {
  40172. /**
  40173. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40174. * an arc rotate version arcFollowCamera are available.
  40175. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40176. */
  40177. export class FollowCamera extends TargetCamera {
  40178. /**
  40179. * Distance the follow camera should follow an object at
  40180. */
  40181. radius: number;
  40182. /**
  40183. * Minimum allowed distance of the camera to the axis of rotation
  40184. * (The camera can not get closer).
  40185. * This can help limiting how the Camera is able to move in the scene.
  40186. */
  40187. lowerRadiusLimit: Nullable<number>;
  40188. /**
  40189. * Maximum allowed distance of the camera to the axis of rotation
  40190. * (The camera can not get further).
  40191. * This can help limiting how the Camera is able to move in the scene.
  40192. */
  40193. upperRadiusLimit: Nullable<number>;
  40194. /**
  40195. * Define a rotation offset between the camera and the object it follows
  40196. */
  40197. rotationOffset: number;
  40198. /**
  40199. * Minimum allowed angle to camera position relative to target object.
  40200. * This can help limiting how the Camera is able to move in the scene.
  40201. */
  40202. lowerRotationOffsetLimit: Nullable<number>;
  40203. /**
  40204. * Maximum allowed angle to camera position relative to target object.
  40205. * This can help limiting how the Camera is able to move in the scene.
  40206. */
  40207. upperRotationOffsetLimit: Nullable<number>;
  40208. /**
  40209. * Define a height offset between the camera and the object it follows.
  40210. * It can help following an object from the top (like a car chaing a plane)
  40211. */
  40212. heightOffset: number;
  40213. /**
  40214. * Minimum allowed height of camera position relative to target object.
  40215. * This can help limiting how the Camera is able to move in the scene.
  40216. */
  40217. lowerHeightOffsetLimit: Nullable<number>;
  40218. /**
  40219. * Maximum allowed height of camera position relative to target object.
  40220. * This can help limiting how the Camera is able to move in the scene.
  40221. */
  40222. upperHeightOffsetLimit: Nullable<number>;
  40223. /**
  40224. * Define how fast the camera can accelerate to follow it s target.
  40225. */
  40226. cameraAcceleration: number;
  40227. /**
  40228. * Define the speed limit of the camera following an object.
  40229. */
  40230. maxCameraSpeed: number;
  40231. /**
  40232. * Define the target of the camera.
  40233. */
  40234. lockedTarget: Nullable<AbstractMesh>;
  40235. /**
  40236. * Defines the input associated with the camera.
  40237. */
  40238. inputs: FollowCameraInputsManager;
  40239. /**
  40240. * Instantiates the follow camera.
  40241. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40242. * @param name Define the name of the camera in the scene
  40243. * @param position Define the position of the camera
  40244. * @param scene Define the scene the camera belong to
  40245. * @param lockedTarget Define the target of the camera
  40246. */
  40247. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40248. private _follow;
  40249. /**
  40250. * Attached controls to the current camera.
  40251. * @param element Defines the element the controls should be listened from
  40252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40253. */
  40254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40255. /**
  40256. * Detach the current controls from the camera.
  40257. * The camera will stop reacting to inputs.
  40258. * @param element Defines the element to stop listening the inputs from
  40259. */
  40260. detachControl(element: HTMLElement): void;
  40261. /** @hidden */
  40262. _checkInputs(): void;
  40263. private _checkLimits;
  40264. /**
  40265. * Gets the camera class name.
  40266. * @returns the class name
  40267. */
  40268. getClassName(): string;
  40269. }
  40270. /**
  40271. * Arc Rotate version of the follow camera.
  40272. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40273. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40274. */
  40275. export class ArcFollowCamera extends TargetCamera {
  40276. /** The longitudinal angle of the camera */
  40277. alpha: number;
  40278. /** The latitudinal angle of the camera */
  40279. beta: number;
  40280. /** The radius of the camera from its target */
  40281. radius: number;
  40282. /** Define the camera target (the messh it should follow) */
  40283. target: Nullable<AbstractMesh>;
  40284. private _cartesianCoordinates;
  40285. /**
  40286. * Instantiates a new ArcFollowCamera
  40287. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40288. * @param name Define the name of the camera
  40289. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40290. * @param beta Define the rotation angle of the camera around the elevation axis
  40291. * @param radius Define the radius of the camera from its target point
  40292. * @param target Define the target of the camera
  40293. * @param scene Define the scene the camera belongs to
  40294. */
  40295. constructor(name: string,
  40296. /** The longitudinal angle of the camera */
  40297. alpha: number,
  40298. /** The latitudinal angle of the camera */
  40299. beta: number,
  40300. /** The radius of the camera from its target */
  40301. radius: number,
  40302. /** Define the camera target (the messh it should follow) */
  40303. target: Nullable<AbstractMesh>, scene: Scene);
  40304. private _follow;
  40305. /** @hidden */
  40306. _checkInputs(): void;
  40307. /**
  40308. * Returns the class name of the object.
  40309. * It is mostly used internally for serialization purposes.
  40310. */
  40311. getClassName(): string;
  40312. }
  40313. }
  40314. declare module BABYLON {
  40315. /**
  40316. * Manage the keyboard inputs to control the movement of a follow camera.
  40317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40318. */
  40319. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40320. /**
  40321. * Defines the camera the input is attached to.
  40322. */
  40323. camera: FollowCamera;
  40324. /**
  40325. * Defines the list of key codes associated with the up action (increase heightOffset)
  40326. */
  40327. keysHeightOffsetIncr: number[];
  40328. /**
  40329. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40330. */
  40331. keysHeightOffsetDecr: number[];
  40332. /**
  40333. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40334. */
  40335. keysHeightOffsetModifierAlt: boolean;
  40336. /**
  40337. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40338. */
  40339. keysHeightOffsetModifierCtrl: boolean;
  40340. /**
  40341. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40342. */
  40343. keysHeightOffsetModifierShift: boolean;
  40344. /**
  40345. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40346. */
  40347. keysRotationOffsetIncr: number[];
  40348. /**
  40349. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40350. */
  40351. keysRotationOffsetDecr: number[];
  40352. /**
  40353. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40354. */
  40355. keysRotationOffsetModifierAlt: boolean;
  40356. /**
  40357. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40358. */
  40359. keysRotationOffsetModifierCtrl: boolean;
  40360. /**
  40361. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40362. */
  40363. keysRotationOffsetModifierShift: boolean;
  40364. /**
  40365. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40366. */
  40367. keysRadiusIncr: number[];
  40368. /**
  40369. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40370. */
  40371. keysRadiusDecr: number[];
  40372. /**
  40373. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40374. */
  40375. keysRadiusModifierAlt: boolean;
  40376. /**
  40377. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40378. */
  40379. keysRadiusModifierCtrl: boolean;
  40380. /**
  40381. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40382. */
  40383. keysRadiusModifierShift: boolean;
  40384. /**
  40385. * Defines the rate of change of heightOffset.
  40386. */
  40387. heightSensibility: number;
  40388. /**
  40389. * Defines the rate of change of rotationOffset.
  40390. */
  40391. rotationSensibility: number;
  40392. /**
  40393. * Defines the rate of change of radius.
  40394. */
  40395. radiusSensibility: number;
  40396. private _keys;
  40397. private _ctrlPressed;
  40398. private _altPressed;
  40399. private _shiftPressed;
  40400. private _onCanvasBlurObserver;
  40401. private _onKeyboardObserver;
  40402. private _engine;
  40403. private _scene;
  40404. /**
  40405. * Attach the input controls to a specific dom element to get the input from.
  40406. * @param element Defines the element the controls should be listened from
  40407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40408. */
  40409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40410. /**
  40411. * Detach the current controls from the specified dom element.
  40412. * @param element Defines the element to stop listening the inputs from
  40413. */
  40414. detachControl(element: Nullable<HTMLElement>): void;
  40415. /**
  40416. * Update the current camera state depending on the inputs that have been used this frame.
  40417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40418. */
  40419. checkInputs(): void;
  40420. /**
  40421. * Gets the class name of the current input.
  40422. * @returns the class name
  40423. */
  40424. getClassName(): string;
  40425. /**
  40426. * Get the friendly name associated with the input class.
  40427. * @returns the input friendly name
  40428. */
  40429. getSimpleName(): string;
  40430. /**
  40431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40432. * allow modification of the heightOffset value.
  40433. */
  40434. private _modifierHeightOffset;
  40435. /**
  40436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40437. * allow modification of the rotationOffset value.
  40438. */
  40439. private _modifierRotationOffset;
  40440. /**
  40441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40442. * allow modification of the radius value.
  40443. */
  40444. private _modifierRadius;
  40445. }
  40446. }
  40447. declare module BABYLON {
  40448. interface FreeCameraInputsManager {
  40449. /**
  40450. * @hidden
  40451. */
  40452. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40453. /**
  40454. * Add orientation input support to the input manager.
  40455. * @returns the current input manager
  40456. */
  40457. addDeviceOrientation(): FreeCameraInputsManager;
  40458. }
  40459. /**
  40460. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40461. * Screen rotation is taken into account.
  40462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40463. */
  40464. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40465. private _camera;
  40466. private _screenOrientationAngle;
  40467. private _constantTranform;
  40468. private _screenQuaternion;
  40469. private _alpha;
  40470. private _beta;
  40471. private _gamma;
  40472. /**
  40473. * Can be used to detect if a device orientation sensor is available on a device
  40474. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40475. * @returns a promise that will resolve on orientation change
  40476. */
  40477. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40478. /**
  40479. * @hidden
  40480. */
  40481. _onDeviceOrientationChangedObservable: Observable<void>;
  40482. /**
  40483. * Instantiates a new input
  40484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40485. */
  40486. constructor();
  40487. /**
  40488. * Define the camera controlled by the input.
  40489. */
  40490. get camera(): FreeCamera;
  40491. set camera(camera: FreeCamera);
  40492. /**
  40493. * Attach the input controls to a specific dom element to get the input from.
  40494. * @param element Defines the element the controls should be listened from
  40495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40496. */
  40497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40498. private _orientationChanged;
  40499. private _deviceOrientation;
  40500. /**
  40501. * Detach the current controls from the specified dom element.
  40502. * @param element Defines the element to stop listening the inputs from
  40503. */
  40504. detachControl(element: Nullable<HTMLElement>): void;
  40505. /**
  40506. * Update the current camera state depending on the inputs that have been used this frame.
  40507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40508. */
  40509. checkInputs(): void;
  40510. /**
  40511. * Gets the class name of the current intput.
  40512. * @returns the class name
  40513. */
  40514. getClassName(): string;
  40515. /**
  40516. * Get the friendly name associated with the input class.
  40517. * @returns the input friendly name
  40518. */
  40519. getSimpleName(): string;
  40520. }
  40521. }
  40522. declare module BABYLON {
  40523. /**
  40524. * Manage the gamepad inputs to control a free camera.
  40525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40526. */
  40527. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40528. /**
  40529. * Define the camera the input is attached to.
  40530. */
  40531. camera: FreeCamera;
  40532. /**
  40533. * Define the Gamepad controlling the input
  40534. */
  40535. gamepad: Nullable<Gamepad>;
  40536. /**
  40537. * Defines the gamepad rotation sensiblity.
  40538. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40539. */
  40540. gamepadAngularSensibility: number;
  40541. /**
  40542. * Defines the gamepad move sensiblity.
  40543. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40544. */
  40545. gamepadMoveSensibility: number;
  40546. private _yAxisScale;
  40547. /**
  40548. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40549. */
  40550. get invertYAxis(): boolean;
  40551. set invertYAxis(value: boolean);
  40552. private _onGamepadConnectedObserver;
  40553. private _onGamepadDisconnectedObserver;
  40554. private _cameraTransform;
  40555. private _deltaTransform;
  40556. private _vector3;
  40557. private _vector2;
  40558. /**
  40559. * Attach the input controls to a specific dom element to get the input from.
  40560. * @param element Defines the element the controls should be listened from
  40561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40562. */
  40563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40564. /**
  40565. * Detach the current controls from the specified dom element.
  40566. * @param element Defines the element to stop listening the inputs from
  40567. */
  40568. detachControl(element: Nullable<HTMLElement>): void;
  40569. /**
  40570. * Update the current camera state depending on the inputs that have been used this frame.
  40571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40572. */
  40573. checkInputs(): void;
  40574. /**
  40575. * Gets the class name of the current intput.
  40576. * @returns the class name
  40577. */
  40578. getClassName(): string;
  40579. /**
  40580. * Get the friendly name associated with the input class.
  40581. * @returns the input friendly name
  40582. */
  40583. getSimpleName(): string;
  40584. }
  40585. }
  40586. declare module BABYLON {
  40587. /**
  40588. * Defines the potential axis of a Joystick
  40589. */
  40590. export enum JoystickAxis {
  40591. /** X axis */
  40592. X = 0,
  40593. /** Y axis */
  40594. Y = 1,
  40595. /** Z axis */
  40596. Z = 2
  40597. }
  40598. /**
  40599. * Class used to define virtual joystick (used in touch mode)
  40600. */
  40601. export class VirtualJoystick {
  40602. /**
  40603. * Gets or sets a boolean indicating that left and right values must be inverted
  40604. */
  40605. reverseLeftRight: boolean;
  40606. /**
  40607. * Gets or sets a boolean indicating that up and down values must be inverted
  40608. */
  40609. reverseUpDown: boolean;
  40610. /**
  40611. * Gets the offset value for the position (ie. the change of the position value)
  40612. */
  40613. deltaPosition: Vector3;
  40614. /**
  40615. * Gets a boolean indicating if the virtual joystick was pressed
  40616. */
  40617. pressed: boolean;
  40618. /**
  40619. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40620. */
  40621. static Canvas: Nullable<HTMLCanvasElement>;
  40622. private static _globalJoystickIndex;
  40623. private static vjCanvasContext;
  40624. private static vjCanvasWidth;
  40625. private static vjCanvasHeight;
  40626. private static halfWidth;
  40627. private _action;
  40628. private _axisTargetedByLeftAndRight;
  40629. private _axisTargetedByUpAndDown;
  40630. private _joystickSensibility;
  40631. private _inversedSensibility;
  40632. private _joystickPointerID;
  40633. private _joystickColor;
  40634. private _joystickPointerPos;
  40635. private _joystickPreviousPointerPos;
  40636. private _joystickPointerStartPos;
  40637. private _deltaJoystickVector;
  40638. private _leftJoystick;
  40639. private _touches;
  40640. private _onPointerDownHandlerRef;
  40641. private _onPointerMoveHandlerRef;
  40642. private _onPointerUpHandlerRef;
  40643. private _onResize;
  40644. /**
  40645. * Creates a new virtual joystick
  40646. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40647. */
  40648. constructor(leftJoystick?: boolean);
  40649. /**
  40650. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40651. * @param newJoystickSensibility defines the new sensibility
  40652. */
  40653. setJoystickSensibility(newJoystickSensibility: number): void;
  40654. private _onPointerDown;
  40655. private _onPointerMove;
  40656. private _onPointerUp;
  40657. /**
  40658. * Change the color of the virtual joystick
  40659. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40660. */
  40661. setJoystickColor(newColor: string): void;
  40662. /**
  40663. * Defines a callback to call when the joystick is touched
  40664. * @param action defines the callback
  40665. */
  40666. setActionOnTouch(action: () => any): void;
  40667. /**
  40668. * Defines which axis you'd like to control for left & right
  40669. * @param axis defines the axis to use
  40670. */
  40671. setAxisForLeftRight(axis: JoystickAxis): void;
  40672. /**
  40673. * Defines which axis you'd like to control for up & down
  40674. * @param axis defines the axis to use
  40675. */
  40676. setAxisForUpDown(axis: JoystickAxis): void;
  40677. private _drawVirtualJoystick;
  40678. /**
  40679. * Release internal HTML canvas
  40680. */
  40681. releaseCanvas(): void;
  40682. }
  40683. }
  40684. declare module BABYLON {
  40685. interface FreeCameraInputsManager {
  40686. /**
  40687. * Add virtual joystick input support to the input manager.
  40688. * @returns the current input manager
  40689. */
  40690. addVirtualJoystick(): FreeCameraInputsManager;
  40691. }
  40692. /**
  40693. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40695. */
  40696. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40697. /**
  40698. * Defines the camera the input is attached to.
  40699. */
  40700. camera: FreeCamera;
  40701. private _leftjoystick;
  40702. private _rightjoystick;
  40703. /**
  40704. * Gets the left stick of the virtual joystick.
  40705. * @returns The virtual Joystick
  40706. */
  40707. getLeftJoystick(): VirtualJoystick;
  40708. /**
  40709. * Gets the right stick of the virtual joystick.
  40710. * @returns The virtual Joystick
  40711. */
  40712. getRightJoystick(): VirtualJoystick;
  40713. /**
  40714. * Update the current camera state depending on the inputs that have been used this frame.
  40715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40716. */
  40717. checkInputs(): void;
  40718. /**
  40719. * Attach the input controls to a specific dom element to get the input from.
  40720. * @param element Defines the element the controls should be listened from
  40721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40722. */
  40723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40724. /**
  40725. * Detach the current controls from the specified dom element.
  40726. * @param element Defines the element to stop listening the inputs from
  40727. */
  40728. detachControl(element: Nullable<HTMLElement>): void;
  40729. /**
  40730. * Gets the class name of the current intput.
  40731. * @returns the class name
  40732. */
  40733. getClassName(): string;
  40734. /**
  40735. * Get the friendly name associated with the input class.
  40736. * @returns the input friendly name
  40737. */
  40738. getSimpleName(): string;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * This represents a FPS type of camera controlled by touch.
  40744. * This is like a universal camera minus the Gamepad controls.
  40745. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40746. */
  40747. export class TouchCamera extends FreeCamera {
  40748. /**
  40749. * Defines the touch sensibility for rotation.
  40750. * The higher the faster.
  40751. */
  40752. get touchAngularSensibility(): number;
  40753. set touchAngularSensibility(value: number);
  40754. /**
  40755. * Defines the touch sensibility for move.
  40756. * The higher the faster.
  40757. */
  40758. get touchMoveSensibility(): number;
  40759. set touchMoveSensibility(value: number);
  40760. /**
  40761. * Instantiates a new touch camera.
  40762. * This represents a FPS type of camera controlled by touch.
  40763. * This is like a universal camera minus the Gamepad controls.
  40764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40765. * @param name Define the name of the camera in the scene
  40766. * @param position Define the start position of the camera in the scene
  40767. * @param scene Define the scene the camera belongs to
  40768. */
  40769. constructor(name: string, position: Vector3, scene: Scene);
  40770. /**
  40771. * Gets the current object class name.
  40772. * @return the class name
  40773. */
  40774. getClassName(): string;
  40775. /** @hidden */
  40776. _setupInputs(): void;
  40777. }
  40778. }
  40779. declare module BABYLON {
  40780. /**
  40781. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40782. * being tilted forward or back and left or right.
  40783. */
  40784. export class DeviceOrientationCamera extends FreeCamera {
  40785. private _initialQuaternion;
  40786. private _quaternionCache;
  40787. private _tmpDragQuaternion;
  40788. private _disablePointerInputWhenUsingDeviceOrientation;
  40789. /**
  40790. * Creates a new device orientation camera
  40791. * @param name The name of the camera
  40792. * @param position The start position camera
  40793. * @param scene The scene the camera belongs to
  40794. */
  40795. constructor(name: string, position: Vector3, scene: Scene);
  40796. /**
  40797. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40798. */
  40799. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40800. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40801. private _dragFactor;
  40802. /**
  40803. * Enabled turning on the y axis when the orientation sensor is active
  40804. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40805. */
  40806. enableHorizontalDragging(dragFactor?: number): void;
  40807. /**
  40808. * Gets the current instance class name ("DeviceOrientationCamera").
  40809. * This helps avoiding instanceof at run time.
  40810. * @returns the class name
  40811. */
  40812. getClassName(): string;
  40813. /**
  40814. * @hidden
  40815. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40816. */
  40817. _checkInputs(): void;
  40818. /**
  40819. * Reset the camera to its default orientation on the specified axis only.
  40820. * @param axis The axis to reset
  40821. */
  40822. resetToCurrentRotation(axis?: Axis): void;
  40823. }
  40824. }
  40825. declare module BABYLON {
  40826. /**
  40827. * Defines supported buttons for XBox360 compatible gamepads
  40828. */
  40829. export enum Xbox360Button {
  40830. /** A */
  40831. A = 0,
  40832. /** B */
  40833. B = 1,
  40834. /** X */
  40835. X = 2,
  40836. /** Y */
  40837. Y = 3,
  40838. /** Start */
  40839. Start = 4,
  40840. /** Back */
  40841. Back = 5,
  40842. /** Left button */
  40843. LB = 6,
  40844. /** Right button */
  40845. RB = 7,
  40846. /** Left stick */
  40847. LeftStick = 8,
  40848. /** Right stick */
  40849. RightStick = 9
  40850. }
  40851. /** Defines values for XBox360 DPad */
  40852. export enum Xbox360Dpad {
  40853. /** Up */
  40854. Up = 0,
  40855. /** Down */
  40856. Down = 1,
  40857. /** Left */
  40858. Left = 2,
  40859. /** Right */
  40860. Right = 3
  40861. }
  40862. /**
  40863. * Defines a XBox360 gamepad
  40864. */
  40865. export class Xbox360Pad extends Gamepad {
  40866. private _leftTrigger;
  40867. private _rightTrigger;
  40868. private _onlefttriggerchanged;
  40869. private _onrighttriggerchanged;
  40870. private _onbuttondown;
  40871. private _onbuttonup;
  40872. private _ondpaddown;
  40873. private _ondpadup;
  40874. /** Observable raised when a button is pressed */
  40875. onButtonDownObservable: Observable<Xbox360Button>;
  40876. /** Observable raised when a button is released */
  40877. onButtonUpObservable: Observable<Xbox360Button>;
  40878. /** Observable raised when a pad is pressed */
  40879. onPadDownObservable: Observable<Xbox360Dpad>;
  40880. /** Observable raised when a pad is released */
  40881. onPadUpObservable: Observable<Xbox360Dpad>;
  40882. private _buttonA;
  40883. private _buttonB;
  40884. private _buttonX;
  40885. private _buttonY;
  40886. private _buttonBack;
  40887. private _buttonStart;
  40888. private _buttonLB;
  40889. private _buttonRB;
  40890. private _buttonLeftStick;
  40891. private _buttonRightStick;
  40892. private _dPadUp;
  40893. private _dPadDown;
  40894. private _dPadLeft;
  40895. private _dPadRight;
  40896. private _isXboxOnePad;
  40897. /**
  40898. * Creates a new XBox360 gamepad object
  40899. * @param id defines the id of this gamepad
  40900. * @param index defines its index
  40901. * @param gamepad defines the internal HTML gamepad object
  40902. * @param xboxOne defines if it is a XBox One gamepad
  40903. */
  40904. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40905. /**
  40906. * Defines the callback to call when left trigger is pressed
  40907. * @param callback defines the callback to use
  40908. */
  40909. onlefttriggerchanged(callback: (value: number) => void): void;
  40910. /**
  40911. * Defines the callback to call when right trigger is pressed
  40912. * @param callback defines the callback to use
  40913. */
  40914. onrighttriggerchanged(callback: (value: number) => void): void;
  40915. /**
  40916. * Gets the left trigger value
  40917. */
  40918. get leftTrigger(): number;
  40919. /**
  40920. * Sets the left trigger value
  40921. */
  40922. set leftTrigger(newValue: number);
  40923. /**
  40924. * Gets the right trigger value
  40925. */
  40926. get rightTrigger(): number;
  40927. /**
  40928. * Sets the right trigger value
  40929. */
  40930. set rightTrigger(newValue: number);
  40931. /**
  40932. * Defines the callback to call when a button is pressed
  40933. * @param callback defines the callback to use
  40934. */
  40935. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40936. /**
  40937. * Defines the callback to call when a button is released
  40938. * @param callback defines the callback to use
  40939. */
  40940. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40941. /**
  40942. * Defines the callback to call when a pad is pressed
  40943. * @param callback defines the callback to use
  40944. */
  40945. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40946. /**
  40947. * Defines the callback to call when a pad is released
  40948. * @param callback defines the callback to use
  40949. */
  40950. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40951. private _setButtonValue;
  40952. private _setDPadValue;
  40953. /**
  40954. * Gets the value of the `A` button
  40955. */
  40956. get buttonA(): number;
  40957. /**
  40958. * Sets the value of the `A` button
  40959. */
  40960. set buttonA(value: number);
  40961. /**
  40962. * Gets the value of the `B` button
  40963. */
  40964. get buttonB(): number;
  40965. /**
  40966. * Sets the value of the `B` button
  40967. */
  40968. set buttonB(value: number);
  40969. /**
  40970. * Gets the value of the `X` button
  40971. */
  40972. get buttonX(): number;
  40973. /**
  40974. * Sets the value of the `X` button
  40975. */
  40976. set buttonX(value: number);
  40977. /**
  40978. * Gets the value of the `Y` button
  40979. */
  40980. get buttonY(): number;
  40981. /**
  40982. * Sets the value of the `Y` button
  40983. */
  40984. set buttonY(value: number);
  40985. /**
  40986. * Gets the value of the `Start` button
  40987. */
  40988. get buttonStart(): number;
  40989. /**
  40990. * Sets the value of the `Start` button
  40991. */
  40992. set buttonStart(value: number);
  40993. /**
  40994. * Gets the value of the `Back` button
  40995. */
  40996. get buttonBack(): number;
  40997. /**
  40998. * Sets the value of the `Back` button
  40999. */
  41000. set buttonBack(value: number);
  41001. /**
  41002. * Gets the value of the `Left` button
  41003. */
  41004. get buttonLB(): number;
  41005. /**
  41006. * Sets the value of the `Left` button
  41007. */
  41008. set buttonLB(value: number);
  41009. /**
  41010. * Gets the value of the `Right` button
  41011. */
  41012. get buttonRB(): number;
  41013. /**
  41014. * Sets the value of the `Right` button
  41015. */
  41016. set buttonRB(value: number);
  41017. /**
  41018. * Gets the value of the Left joystick
  41019. */
  41020. get buttonLeftStick(): number;
  41021. /**
  41022. * Sets the value of the Left joystick
  41023. */
  41024. set buttonLeftStick(value: number);
  41025. /**
  41026. * Gets the value of the Right joystick
  41027. */
  41028. get buttonRightStick(): number;
  41029. /**
  41030. * Sets the value of the Right joystick
  41031. */
  41032. set buttonRightStick(value: number);
  41033. /**
  41034. * Gets the value of D-pad up
  41035. */
  41036. get dPadUp(): number;
  41037. /**
  41038. * Sets the value of D-pad up
  41039. */
  41040. set dPadUp(value: number);
  41041. /**
  41042. * Gets the value of D-pad down
  41043. */
  41044. get dPadDown(): number;
  41045. /**
  41046. * Sets the value of D-pad down
  41047. */
  41048. set dPadDown(value: number);
  41049. /**
  41050. * Gets the value of D-pad left
  41051. */
  41052. get dPadLeft(): number;
  41053. /**
  41054. * Sets the value of D-pad left
  41055. */
  41056. set dPadLeft(value: number);
  41057. /**
  41058. * Gets the value of D-pad right
  41059. */
  41060. get dPadRight(): number;
  41061. /**
  41062. * Sets the value of D-pad right
  41063. */
  41064. set dPadRight(value: number);
  41065. /**
  41066. * Force the gamepad to synchronize with device values
  41067. */
  41068. update(): void;
  41069. /**
  41070. * Disposes the gamepad
  41071. */
  41072. dispose(): void;
  41073. }
  41074. }
  41075. declare module BABYLON {
  41076. /**
  41077. * Defines supported buttons for DualShock compatible gamepads
  41078. */
  41079. export enum DualShockButton {
  41080. /** Cross */
  41081. Cross = 0,
  41082. /** Circle */
  41083. Circle = 1,
  41084. /** Square */
  41085. Square = 2,
  41086. /** Triangle */
  41087. Triangle = 3,
  41088. /** Options */
  41089. Options = 4,
  41090. /** Share */
  41091. Share = 5,
  41092. /** L1 */
  41093. L1 = 6,
  41094. /** R1 */
  41095. R1 = 7,
  41096. /** Left stick */
  41097. LeftStick = 8,
  41098. /** Right stick */
  41099. RightStick = 9
  41100. }
  41101. /** Defines values for DualShock DPad */
  41102. export enum DualShockDpad {
  41103. /** Up */
  41104. Up = 0,
  41105. /** Down */
  41106. Down = 1,
  41107. /** Left */
  41108. Left = 2,
  41109. /** Right */
  41110. Right = 3
  41111. }
  41112. /**
  41113. * Defines a DualShock gamepad
  41114. */
  41115. export class DualShockPad extends Gamepad {
  41116. private _leftTrigger;
  41117. private _rightTrigger;
  41118. private _onlefttriggerchanged;
  41119. private _onrighttriggerchanged;
  41120. private _onbuttondown;
  41121. private _onbuttonup;
  41122. private _ondpaddown;
  41123. private _ondpadup;
  41124. /** Observable raised when a button is pressed */
  41125. onButtonDownObservable: Observable<DualShockButton>;
  41126. /** Observable raised when a button is released */
  41127. onButtonUpObservable: Observable<DualShockButton>;
  41128. /** Observable raised when a pad is pressed */
  41129. onPadDownObservable: Observable<DualShockDpad>;
  41130. /** Observable raised when a pad is released */
  41131. onPadUpObservable: Observable<DualShockDpad>;
  41132. private _buttonCross;
  41133. private _buttonCircle;
  41134. private _buttonSquare;
  41135. private _buttonTriangle;
  41136. private _buttonShare;
  41137. private _buttonOptions;
  41138. private _buttonL1;
  41139. private _buttonR1;
  41140. private _buttonLeftStick;
  41141. private _buttonRightStick;
  41142. private _dPadUp;
  41143. private _dPadDown;
  41144. private _dPadLeft;
  41145. private _dPadRight;
  41146. /**
  41147. * Creates a new DualShock gamepad object
  41148. * @param id defines the id of this gamepad
  41149. * @param index defines its index
  41150. * @param gamepad defines the internal HTML gamepad object
  41151. */
  41152. constructor(id: string, index: number, gamepad: any);
  41153. /**
  41154. * Defines the callback to call when left trigger is pressed
  41155. * @param callback defines the callback to use
  41156. */
  41157. onlefttriggerchanged(callback: (value: number) => void): void;
  41158. /**
  41159. * Defines the callback to call when right trigger is pressed
  41160. * @param callback defines the callback to use
  41161. */
  41162. onrighttriggerchanged(callback: (value: number) => void): void;
  41163. /**
  41164. * Gets the left trigger value
  41165. */
  41166. get leftTrigger(): number;
  41167. /**
  41168. * Sets the left trigger value
  41169. */
  41170. set leftTrigger(newValue: number);
  41171. /**
  41172. * Gets the right trigger value
  41173. */
  41174. get rightTrigger(): number;
  41175. /**
  41176. * Sets the right trigger value
  41177. */
  41178. set rightTrigger(newValue: number);
  41179. /**
  41180. * Defines the callback to call when a button is pressed
  41181. * @param callback defines the callback to use
  41182. */
  41183. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41184. /**
  41185. * Defines the callback to call when a button is released
  41186. * @param callback defines the callback to use
  41187. */
  41188. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41189. /**
  41190. * Defines the callback to call when a pad is pressed
  41191. * @param callback defines the callback to use
  41192. */
  41193. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41194. /**
  41195. * Defines the callback to call when a pad is released
  41196. * @param callback defines the callback to use
  41197. */
  41198. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41199. private _setButtonValue;
  41200. private _setDPadValue;
  41201. /**
  41202. * Gets the value of the `Cross` button
  41203. */
  41204. get buttonCross(): number;
  41205. /**
  41206. * Sets the value of the `Cross` button
  41207. */
  41208. set buttonCross(value: number);
  41209. /**
  41210. * Gets the value of the `Circle` button
  41211. */
  41212. get buttonCircle(): number;
  41213. /**
  41214. * Sets the value of the `Circle` button
  41215. */
  41216. set buttonCircle(value: number);
  41217. /**
  41218. * Gets the value of the `Square` button
  41219. */
  41220. get buttonSquare(): number;
  41221. /**
  41222. * Sets the value of the `Square` button
  41223. */
  41224. set buttonSquare(value: number);
  41225. /**
  41226. * Gets the value of the `Triangle` button
  41227. */
  41228. get buttonTriangle(): number;
  41229. /**
  41230. * Sets the value of the `Triangle` button
  41231. */
  41232. set buttonTriangle(value: number);
  41233. /**
  41234. * Gets the value of the `Options` button
  41235. */
  41236. get buttonOptions(): number;
  41237. /**
  41238. * Sets the value of the `Options` button
  41239. */
  41240. set buttonOptions(value: number);
  41241. /**
  41242. * Gets the value of the `Share` button
  41243. */
  41244. get buttonShare(): number;
  41245. /**
  41246. * Sets the value of the `Share` button
  41247. */
  41248. set buttonShare(value: number);
  41249. /**
  41250. * Gets the value of the `L1` button
  41251. */
  41252. get buttonL1(): number;
  41253. /**
  41254. * Sets the value of the `L1` button
  41255. */
  41256. set buttonL1(value: number);
  41257. /**
  41258. * Gets the value of the `R1` button
  41259. */
  41260. get buttonR1(): number;
  41261. /**
  41262. * Sets the value of the `R1` button
  41263. */
  41264. set buttonR1(value: number);
  41265. /**
  41266. * Gets the value of the Left joystick
  41267. */
  41268. get buttonLeftStick(): number;
  41269. /**
  41270. * Sets the value of the Left joystick
  41271. */
  41272. set buttonLeftStick(value: number);
  41273. /**
  41274. * Gets the value of the Right joystick
  41275. */
  41276. get buttonRightStick(): number;
  41277. /**
  41278. * Sets the value of the Right joystick
  41279. */
  41280. set buttonRightStick(value: number);
  41281. /**
  41282. * Gets the value of D-pad up
  41283. */
  41284. get dPadUp(): number;
  41285. /**
  41286. * Sets the value of D-pad up
  41287. */
  41288. set dPadUp(value: number);
  41289. /**
  41290. * Gets the value of D-pad down
  41291. */
  41292. get dPadDown(): number;
  41293. /**
  41294. * Sets the value of D-pad down
  41295. */
  41296. set dPadDown(value: number);
  41297. /**
  41298. * Gets the value of D-pad left
  41299. */
  41300. get dPadLeft(): number;
  41301. /**
  41302. * Sets the value of D-pad left
  41303. */
  41304. set dPadLeft(value: number);
  41305. /**
  41306. * Gets the value of D-pad right
  41307. */
  41308. get dPadRight(): number;
  41309. /**
  41310. * Sets the value of D-pad right
  41311. */
  41312. set dPadRight(value: number);
  41313. /**
  41314. * Force the gamepad to synchronize with device values
  41315. */
  41316. update(): void;
  41317. /**
  41318. * Disposes the gamepad
  41319. */
  41320. dispose(): void;
  41321. }
  41322. }
  41323. declare module BABYLON {
  41324. /**
  41325. * Manager for handling gamepads
  41326. */
  41327. export class GamepadManager {
  41328. private _scene?;
  41329. private _babylonGamepads;
  41330. private _oneGamepadConnected;
  41331. /** @hidden */
  41332. _isMonitoring: boolean;
  41333. private _gamepadEventSupported;
  41334. private _gamepadSupport?;
  41335. /**
  41336. * observable to be triggered when the gamepad controller has been connected
  41337. */
  41338. onGamepadConnectedObservable: Observable<Gamepad>;
  41339. /**
  41340. * observable to be triggered when the gamepad controller has been disconnected
  41341. */
  41342. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41343. private _onGamepadConnectedEvent;
  41344. private _onGamepadDisconnectedEvent;
  41345. /**
  41346. * Initializes the gamepad manager
  41347. * @param _scene BabylonJS scene
  41348. */
  41349. constructor(_scene?: Scene | undefined);
  41350. /**
  41351. * The gamepads in the game pad manager
  41352. */
  41353. get gamepads(): Gamepad[];
  41354. /**
  41355. * Get the gamepad controllers based on type
  41356. * @param type The type of gamepad controller
  41357. * @returns Nullable gamepad
  41358. */
  41359. getGamepadByType(type?: number): Nullable<Gamepad>;
  41360. /**
  41361. * Disposes the gamepad manager
  41362. */
  41363. dispose(): void;
  41364. private _addNewGamepad;
  41365. private _startMonitoringGamepads;
  41366. private _stopMonitoringGamepads;
  41367. /** @hidden */
  41368. _checkGamepadsStatus(): void;
  41369. private _updateGamepadObjects;
  41370. }
  41371. }
  41372. declare module BABYLON {
  41373. interface Scene {
  41374. /** @hidden */
  41375. _gamepadManager: Nullable<GamepadManager>;
  41376. /**
  41377. * Gets the gamepad manager associated with the scene
  41378. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41379. */
  41380. gamepadManager: GamepadManager;
  41381. }
  41382. /**
  41383. * Interface representing a free camera inputs manager
  41384. */
  41385. interface FreeCameraInputsManager {
  41386. /**
  41387. * Adds gamepad input support to the FreeCameraInputsManager.
  41388. * @returns the FreeCameraInputsManager
  41389. */
  41390. addGamepad(): FreeCameraInputsManager;
  41391. }
  41392. /**
  41393. * Interface representing an arc rotate camera inputs manager
  41394. */
  41395. interface ArcRotateCameraInputsManager {
  41396. /**
  41397. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41398. * @returns the camera inputs manager
  41399. */
  41400. addGamepad(): ArcRotateCameraInputsManager;
  41401. }
  41402. /**
  41403. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41404. */
  41405. export class GamepadSystemSceneComponent implements ISceneComponent {
  41406. /**
  41407. * The component name helpfull to identify the component in the list of scene components.
  41408. */
  41409. readonly name: string;
  41410. /**
  41411. * The scene the component belongs to.
  41412. */
  41413. scene: Scene;
  41414. /**
  41415. * Creates a new instance of the component for the given scene
  41416. * @param scene Defines the scene to register the component in
  41417. */
  41418. constructor(scene: Scene);
  41419. /**
  41420. * Registers the component in a given scene
  41421. */
  41422. register(): void;
  41423. /**
  41424. * Rebuilds the elements related to this component in case of
  41425. * context lost for instance.
  41426. */
  41427. rebuild(): void;
  41428. /**
  41429. * Disposes the component and the associated ressources
  41430. */
  41431. dispose(): void;
  41432. private _beforeCameraUpdate;
  41433. }
  41434. }
  41435. declare module BABYLON {
  41436. /**
  41437. * 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,
  41438. * which still works and will still be found in many Playgrounds.
  41439. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41440. */
  41441. export class UniversalCamera extends TouchCamera {
  41442. /**
  41443. * Defines the gamepad rotation sensiblity.
  41444. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41445. */
  41446. get gamepadAngularSensibility(): number;
  41447. set gamepadAngularSensibility(value: number);
  41448. /**
  41449. * Defines the gamepad move sensiblity.
  41450. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41451. */
  41452. get gamepadMoveSensibility(): number;
  41453. set gamepadMoveSensibility(value: number);
  41454. /**
  41455. * 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,
  41456. * which still works and will still be found in many Playgrounds.
  41457. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41458. * @param name Define the name of the camera in the scene
  41459. * @param position Define the start position of the camera in the scene
  41460. * @param scene Define the scene the camera belongs to
  41461. */
  41462. constructor(name: string, position: Vector3, scene: Scene);
  41463. /**
  41464. * Gets the current object class name.
  41465. * @return the class name
  41466. */
  41467. getClassName(): string;
  41468. }
  41469. }
  41470. declare module BABYLON {
  41471. /**
  41472. * This represents a FPS type of camera. This is only here for back compat purpose.
  41473. * Please use the UniversalCamera instead as both are identical.
  41474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41475. */
  41476. export class GamepadCamera extends UniversalCamera {
  41477. /**
  41478. * Instantiates a new Gamepad Camera
  41479. * This represents a FPS type of camera. This is only here for back compat purpose.
  41480. * Please use the UniversalCamera instead as both are identical.
  41481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41482. * @param name Define the name of the camera in the scene
  41483. * @param position Define the start position of the camera in the scene
  41484. * @param scene Define the scene the camera belongs to
  41485. */
  41486. constructor(name: string, position: Vector3, scene: Scene);
  41487. /**
  41488. * Gets the current object class name.
  41489. * @return the class name
  41490. */
  41491. getClassName(): string;
  41492. }
  41493. }
  41494. declare module BABYLON {
  41495. /** @hidden */
  41496. export var passPixelShader: {
  41497. name: string;
  41498. shader: string;
  41499. };
  41500. }
  41501. declare module BABYLON {
  41502. /** @hidden */
  41503. export var passCubePixelShader: {
  41504. name: string;
  41505. shader: string;
  41506. };
  41507. }
  41508. declare module BABYLON {
  41509. /**
  41510. * PassPostProcess which produces an output the same as it's input
  41511. */
  41512. export class PassPostProcess extends PostProcess {
  41513. /**
  41514. * Creates the PassPostProcess
  41515. * @param name The name of the effect.
  41516. * @param options The required width/height ratio to downsize to before computing the render pass.
  41517. * @param camera The camera to apply the render pass to.
  41518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41519. * @param engine The engine which the post process will be applied. (default: current engine)
  41520. * @param reusable If the post process can be reused on the same frame. (default: false)
  41521. * @param textureType The type of texture to be used when performing the post processing.
  41522. * @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)
  41523. */
  41524. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41525. }
  41526. /**
  41527. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41528. */
  41529. export class PassCubePostProcess extends PostProcess {
  41530. private _face;
  41531. /**
  41532. * Gets or sets the cube face to display.
  41533. * * 0 is +X
  41534. * * 1 is -X
  41535. * * 2 is +Y
  41536. * * 3 is -Y
  41537. * * 4 is +Z
  41538. * * 5 is -Z
  41539. */
  41540. get face(): number;
  41541. set face(value: number);
  41542. /**
  41543. * Creates the PassCubePostProcess
  41544. * @param name The name of the effect.
  41545. * @param options The required width/height ratio to downsize to before computing the render pass.
  41546. * @param camera The camera to apply the render pass to.
  41547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41548. * @param engine The engine which the post process will be applied. (default: current engine)
  41549. * @param reusable If the post process can be reused on the same frame. (default: false)
  41550. * @param textureType The type of texture to be used when performing the post processing.
  41551. * @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)
  41552. */
  41553. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /** @hidden */
  41558. export var anaglyphPixelShader: {
  41559. name: string;
  41560. shader: string;
  41561. };
  41562. }
  41563. declare module BABYLON {
  41564. /**
  41565. * Postprocess used to generate anaglyphic rendering
  41566. */
  41567. export class AnaglyphPostProcess extends PostProcess {
  41568. private _passedProcess;
  41569. /**
  41570. * Creates a new AnaglyphPostProcess
  41571. * @param name defines postprocess name
  41572. * @param options defines creation options or target ratio scale
  41573. * @param rigCameras defines cameras using this postprocess
  41574. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41575. * @param engine defines hosting engine
  41576. * @param reusable defines if the postprocess will be reused multiple times per frame
  41577. */
  41578. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41579. }
  41580. }
  41581. declare module BABYLON {
  41582. /**
  41583. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41584. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41585. */
  41586. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41587. /**
  41588. * Creates a new AnaglyphArcRotateCamera
  41589. * @param name defines camera name
  41590. * @param alpha defines alpha angle (in radians)
  41591. * @param beta defines beta angle (in radians)
  41592. * @param radius defines radius
  41593. * @param target defines camera target
  41594. * @param interaxialDistance defines distance between each color axis
  41595. * @param scene defines the hosting scene
  41596. */
  41597. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41598. /**
  41599. * Gets camera class name
  41600. * @returns AnaglyphArcRotateCamera
  41601. */
  41602. getClassName(): string;
  41603. }
  41604. }
  41605. declare module BABYLON {
  41606. /**
  41607. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41608. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41609. */
  41610. export class AnaglyphFreeCamera extends FreeCamera {
  41611. /**
  41612. * Creates a new AnaglyphFreeCamera
  41613. * @param name defines camera name
  41614. * @param position defines initial position
  41615. * @param interaxialDistance defines distance between each color axis
  41616. * @param scene defines the hosting scene
  41617. */
  41618. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41619. /**
  41620. * Gets camera class name
  41621. * @returns AnaglyphFreeCamera
  41622. */
  41623. getClassName(): string;
  41624. }
  41625. }
  41626. declare module BABYLON {
  41627. /**
  41628. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41629. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41630. */
  41631. export class AnaglyphGamepadCamera extends GamepadCamera {
  41632. /**
  41633. * Creates a new AnaglyphGamepadCamera
  41634. * @param name defines camera name
  41635. * @param position defines initial position
  41636. * @param interaxialDistance defines distance between each color axis
  41637. * @param scene defines the hosting scene
  41638. */
  41639. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41640. /**
  41641. * Gets camera class name
  41642. * @returns AnaglyphGamepadCamera
  41643. */
  41644. getClassName(): string;
  41645. }
  41646. }
  41647. declare module BABYLON {
  41648. /**
  41649. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41650. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41651. */
  41652. export class AnaglyphUniversalCamera extends UniversalCamera {
  41653. /**
  41654. * Creates a new AnaglyphUniversalCamera
  41655. * @param name defines camera name
  41656. * @param position defines initial position
  41657. * @param interaxialDistance defines distance between each color axis
  41658. * @param scene defines the hosting scene
  41659. */
  41660. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41661. /**
  41662. * Gets camera class name
  41663. * @returns AnaglyphUniversalCamera
  41664. */
  41665. getClassName(): string;
  41666. }
  41667. }
  41668. declare module BABYLON {
  41669. /** @hidden */
  41670. export var stereoscopicInterlacePixelShader: {
  41671. name: string;
  41672. shader: string;
  41673. };
  41674. }
  41675. declare module BABYLON {
  41676. /**
  41677. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41678. */
  41679. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41680. private _stepSize;
  41681. private _passedProcess;
  41682. /**
  41683. * Initializes a StereoscopicInterlacePostProcessI
  41684. * @param name The name of the effect.
  41685. * @param rigCameras The rig cameras to be appled to the post process
  41686. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41687. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41689. * @param engine The engine which the post process will be applied. (default: current engine)
  41690. * @param reusable If the post process can be reused on the same frame. (default: false)
  41691. */
  41692. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41693. }
  41694. /**
  41695. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41696. */
  41697. export class StereoscopicInterlacePostProcess extends PostProcess {
  41698. private _stepSize;
  41699. private _passedProcess;
  41700. /**
  41701. * Initializes a StereoscopicInterlacePostProcess
  41702. * @param name The name of the effect.
  41703. * @param rigCameras The rig cameras to be appled to the post process
  41704. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41706. * @param engine The engine which the post process will be applied. (default: current engine)
  41707. * @param reusable If the post process can be reused on the same frame. (default: false)
  41708. */
  41709. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41710. }
  41711. }
  41712. declare module BABYLON {
  41713. /**
  41714. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41715. * @see http://doc.babylonjs.com/features/cameras
  41716. */
  41717. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41718. /**
  41719. * Creates a new StereoscopicArcRotateCamera
  41720. * @param name defines camera name
  41721. * @param alpha defines alpha angle (in radians)
  41722. * @param beta defines beta angle (in radians)
  41723. * @param radius defines radius
  41724. * @param target defines camera target
  41725. * @param interaxialDistance defines distance between each color axis
  41726. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41727. * @param scene defines the hosting scene
  41728. */
  41729. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41730. /**
  41731. * Gets camera class name
  41732. * @returns StereoscopicArcRotateCamera
  41733. */
  41734. getClassName(): string;
  41735. }
  41736. }
  41737. declare module BABYLON {
  41738. /**
  41739. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41740. * @see http://doc.babylonjs.com/features/cameras
  41741. */
  41742. export class StereoscopicFreeCamera extends FreeCamera {
  41743. /**
  41744. * Creates a new StereoscopicFreeCamera
  41745. * @param name defines camera name
  41746. * @param position defines initial position
  41747. * @param interaxialDistance defines distance between each color axis
  41748. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41749. * @param scene defines the hosting scene
  41750. */
  41751. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41752. /**
  41753. * Gets camera class name
  41754. * @returns StereoscopicFreeCamera
  41755. */
  41756. getClassName(): string;
  41757. }
  41758. }
  41759. declare module BABYLON {
  41760. /**
  41761. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41762. * @see http://doc.babylonjs.com/features/cameras
  41763. */
  41764. export class StereoscopicGamepadCamera extends GamepadCamera {
  41765. /**
  41766. * Creates a new StereoscopicGamepadCamera
  41767. * @param name defines camera name
  41768. * @param position defines initial position
  41769. * @param interaxialDistance defines distance between each color axis
  41770. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41771. * @param scene defines the hosting scene
  41772. */
  41773. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41774. /**
  41775. * Gets camera class name
  41776. * @returns StereoscopicGamepadCamera
  41777. */
  41778. getClassName(): string;
  41779. }
  41780. }
  41781. declare module BABYLON {
  41782. /**
  41783. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41784. * @see http://doc.babylonjs.com/features/cameras
  41785. */
  41786. export class StereoscopicUniversalCamera extends UniversalCamera {
  41787. /**
  41788. * Creates a new StereoscopicUniversalCamera
  41789. * @param name defines camera name
  41790. * @param position defines initial position
  41791. * @param interaxialDistance defines distance between each color axis
  41792. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41793. * @param scene defines the hosting scene
  41794. */
  41795. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41796. /**
  41797. * Gets camera class name
  41798. * @returns StereoscopicUniversalCamera
  41799. */
  41800. getClassName(): string;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41806. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41807. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41808. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41809. */
  41810. export class VirtualJoysticksCamera extends FreeCamera {
  41811. /**
  41812. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41813. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41814. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41815. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41816. * @param name Define the name of the camera in the scene
  41817. * @param position Define the start position of the camera in the scene
  41818. * @param scene Define the scene the camera belongs to
  41819. */
  41820. constructor(name: string, position: Vector3, scene: Scene);
  41821. /**
  41822. * Gets the current object class name.
  41823. * @return the class name
  41824. */
  41825. getClassName(): string;
  41826. }
  41827. }
  41828. declare module BABYLON {
  41829. /**
  41830. * This represents all the required metrics to create a VR camera.
  41831. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41832. */
  41833. export class VRCameraMetrics {
  41834. /**
  41835. * Define the horizontal resolution off the screen.
  41836. */
  41837. hResolution: number;
  41838. /**
  41839. * Define the vertical resolution off the screen.
  41840. */
  41841. vResolution: number;
  41842. /**
  41843. * Define the horizontal screen size.
  41844. */
  41845. hScreenSize: number;
  41846. /**
  41847. * Define the vertical screen size.
  41848. */
  41849. vScreenSize: number;
  41850. /**
  41851. * Define the vertical screen center position.
  41852. */
  41853. vScreenCenter: number;
  41854. /**
  41855. * Define the distance of the eyes to the screen.
  41856. */
  41857. eyeToScreenDistance: number;
  41858. /**
  41859. * Define the distance between both lenses
  41860. */
  41861. lensSeparationDistance: number;
  41862. /**
  41863. * Define the distance between both viewer's eyes.
  41864. */
  41865. interpupillaryDistance: number;
  41866. /**
  41867. * Define the distortion factor of the VR postprocess.
  41868. * Please, touch with care.
  41869. */
  41870. distortionK: number[];
  41871. /**
  41872. * Define the chromatic aberration correction factors for the VR post process.
  41873. */
  41874. chromaAbCorrection: number[];
  41875. /**
  41876. * Define the scale factor of the post process.
  41877. * The smaller the better but the slower.
  41878. */
  41879. postProcessScaleFactor: number;
  41880. /**
  41881. * Define an offset for the lens center.
  41882. */
  41883. lensCenterOffset: number;
  41884. /**
  41885. * Define if the current vr camera should compensate the distortion of the lense or not.
  41886. */
  41887. compensateDistortion: boolean;
  41888. /**
  41889. * Defines if multiview should be enabled when rendering (Default: false)
  41890. */
  41891. multiviewEnabled: boolean;
  41892. /**
  41893. * Gets the rendering aspect ratio based on the provided resolutions.
  41894. */
  41895. get aspectRatio(): number;
  41896. /**
  41897. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41898. */
  41899. get aspectRatioFov(): number;
  41900. /**
  41901. * @hidden
  41902. */
  41903. get leftHMatrix(): Matrix;
  41904. /**
  41905. * @hidden
  41906. */
  41907. get rightHMatrix(): Matrix;
  41908. /**
  41909. * @hidden
  41910. */
  41911. get leftPreViewMatrix(): Matrix;
  41912. /**
  41913. * @hidden
  41914. */
  41915. get rightPreViewMatrix(): Matrix;
  41916. /**
  41917. * Get the default VRMetrics based on the most generic setup.
  41918. * @returns the default vr metrics
  41919. */
  41920. static GetDefault(): VRCameraMetrics;
  41921. }
  41922. }
  41923. declare module BABYLON {
  41924. /** @hidden */
  41925. export var vrDistortionCorrectionPixelShader: {
  41926. name: string;
  41927. shader: string;
  41928. };
  41929. }
  41930. declare module BABYLON {
  41931. /**
  41932. * VRDistortionCorrectionPostProcess used for mobile VR
  41933. */
  41934. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41935. private _isRightEye;
  41936. private _distortionFactors;
  41937. private _postProcessScaleFactor;
  41938. private _lensCenterOffset;
  41939. private _scaleIn;
  41940. private _scaleFactor;
  41941. private _lensCenter;
  41942. /**
  41943. * Initializes the VRDistortionCorrectionPostProcess
  41944. * @param name The name of the effect.
  41945. * @param camera The camera to apply the render pass to.
  41946. * @param isRightEye If this is for the right eye distortion
  41947. * @param vrMetrics All the required metrics for the VR camera
  41948. */
  41949. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41950. }
  41951. }
  41952. declare module BABYLON {
  41953. /**
  41954. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41955. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41956. */
  41957. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41958. /**
  41959. * Creates a new VRDeviceOrientationArcRotateCamera
  41960. * @param name defines camera name
  41961. * @param alpha defines the camera rotation along the logitudinal axis
  41962. * @param beta defines the camera rotation along the latitudinal axis
  41963. * @param radius defines the camera distance from its target
  41964. * @param target defines the camera target
  41965. * @param scene defines the scene the camera belongs to
  41966. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41967. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41968. */
  41969. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41970. /**
  41971. * Gets camera class name
  41972. * @returns VRDeviceOrientationArcRotateCamera
  41973. */
  41974. getClassName(): string;
  41975. }
  41976. }
  41977. declare module BABYLON {
  41978. /**
  41979. * Camera used to simulate VR rendering (based on FreeCamera)
  41980. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41981. */
  41982. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41983. /**
  41984. * Creates a new VRDeviceOrientationFreeCamera
  41985. * @param name defines camera name
  41986. * @param position defines the start position of the camera
  41987. * @param scene defines the scene the camera belongs to
  41988. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41989. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41990. */
  41991. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41992. /**
  41993. * Gets camera class name
  41994. * @returns VRDeviceOrientationFreeCamera
  41995. */
  41996. getClassName(): string;
  41997. }
  41998. }
  41999. declare module BABYLON {
  42000. /**
  42001. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42002. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42003. */
  42004. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42005. /**
  42006. * Creates a new VRDeviceOrientationGamepadCamera
  42007. * @param name defines camera name
  42008. * @param position defines the start position of the camera
  42009. * @param scene defines the scene the camera belongs to
  42010. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42011. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42012. */
  42013. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42014. /**
  42015. * Gets camera class name
  42016. * @returns VRDeviceOrientationGamepadCamera
  42017. */
  42018. getClassName(): string;
  42019. }
  42020. }
  42021. declare module BABYLON {
  42022. /** @hidden */
  42023. export var imageProcessingPixelShader: {
  42024. name: string;
  42025. shader: string;
  42026. };
  42027. }
  42028. declare module BABYLON {
  42029. /**
  42030. * ImageProcessingPostProcess
  42031. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42032. */
  42033. export class ImageProcessingPostProcess extends PostProcess {
  42034. /**
  42035. * Default configuration related to image processing available in the PBR Material.
  42036. */
  42037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42038. /**
  42039. * Gets the image processing configuration used either in this material.
  42040. */
  42041. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42042. /**
  42043. * Sets the Default image processing configuration used either in the this material.
  42044. *
  42045. * If sets to null, the scene one is in use.
  42046. */
  42047. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42048. /**
  42049. * Keep track of the image processing observer to allow dispose and replace.
  42050. */
  42051. private _imageProcessingObserver;
  42052. /**
  42053. * Attaches a new image processing configuration to the PBR Material.
  42054. * @param configuration
  42055. */
  42056. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42057. /**
  42058. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42059. */
  42060. get colorCurves(): Nullable<ColorCurves>;
  42061. /**
  42062. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42063. */
  42064. set colorCurves(value: Nullable<ColorCurves>);
  42065. /**
  42066. * Gets wether the color curves effect is enabled.
  42067. */
  42068. get colorCurvesEnabled(): boolean;
  42069. /**
  42070. * Sets wether the color curves effect is enabled.
  42071. */
  42072. set colorCurvesEnabled(value: boolean);
  42073. /**
  42074. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42075. */
  42076. get colorGradingTexture(): Nullable<BaseTexture>;
  42077. /**
  42078. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42079. */
  42080. set colorGradingTexture(value: Nullable<BaseTexture>);
  42081. /**
  42082. * Gets wether the color grading effect is enabled.
  42083. */
  42084. get colorGradingEnabled(): boolean;
  42085. /**
  42086. * Gets wether the color grading effect is enabled.
  42087. */
  42088. set colorGradingEnabled(value: boolean);
  42089. /**
  42090. * Gets exposure used in the effect.
  42091. */
  42092. get exposure(): number;
  42093. /**
  42094. * Sets exposure used in the effect.
  42095. */
  42096. set exposure(value: number);
  42097. /**
  42098. * Gets wether tonemapping is enabled or not.
  42099. */
  42100. get toneMappingEnabled(): boolean;
  42101. /**
  42102. * Sets wether tonemapping is enabled or not
  42103. */
  42104. set toneMappingEnabled(value: boolean);
  42105. /**
  42106. * Gets the type of tone mapping effect.
  42107. */
  42108. get toneMappingType(): number;
  42109. /**
  42110. * Sets the type of tone mapping effect.
  42111. */
  42112. set toneMappingType(value: number);
  42113. /**
  42114. * Gets contrast used in the effect.
  42115. */
  42116. get contrast(): number;
  42117. /**
  42118. * Sets contrast used in the effect.
  42119. */
  42120. set contrast(value: number);
  42121. /**
  42122. * Gets Vignette stretch size.
  42123. */
  42124. get vignetteStretch(): number;
  42125. /**
  42126. * Sets Vignette stretch size.
  42127. */
  42128. set vignetteStretch(value: number);
  42129. /**
  42130. * Gets Vignette centre X Offset.
  42131. */
  42132. get vignetteCentreX(): number;
  42133. /**
  42134. * Sets Vignette centre X Offset.
  42135. */
  42136. set vignetteCentreX(value: number);
  42137. /**
  42138. * Gets Vignette centre Y Offset.
  42139. */
  42140. get vignetteCentreY(): number;
  42141. /**
  42142. * Sets Vignette centre Y Offset.
  42143. */
  42144. set vignetteCentreY(value: number);
  42145. /**
  42146. * Gets Vignette weight or intensity of the vignette effect.
  42147. */
  42148. get vignetteWeight(): number;
  42149. /**
  42150. * Sets Vignette weight or intensity of the vignette effect.
  42151. */
  42152. set vignetteWeight(value: number);
  42153. /**
  42154. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42155. * if vignetteEnabled is set to true.
  42156. */
  42157. get vignetteColor(): Color4;
  42158. /**
  42159. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42160. * if vignetteEnabled is set to true.
  42161. */
  42162. set vignetteColor(value: Color4);
  42163. /**
  42164. * Gets Camera field of view used by the Vignette effect.
  42165. */
  42166. get vignetteCameraFov(): number;
  42167. /**
  42168. * Sets Camera field of view used by the Vignette effect.
  42169. */
  42170. set vignetteCameraFov(value: number);
  42171. /**
  42172. * Gets the vignette blend mode allowing different kind of effect.
  42173. */
  42174. get vignetteBlendMode(): number;
  42175. /**
  42176. * Sets the vignette blend mode allowing different kind of effect.
  42177. */
  42178. set vignetteBlendMode(value: number);
  42179. /**
  42180. * Gets wether the vignette effect is enabled.
  42181. */
  42182. get vignetteEnabled(): boolean;
  42183. /**
  42184. * Sets wether the vignette effect is enabled.
  42185. */
  42186. set vignetteEnabled(value: boolean);
  42187. private _fromLinearSpace;
  42188. /**
  42189. * Gets wether the input of the processing is in Gamma or Linear Space.
  42190. */
  42191. get fromLinearSpace(): boolean;
  42192. /**
  42193. * Sets wether the input of the processing is in Gamma or Linear Space.
  42194. */
  42195. set fromLinearSpace(value: boolean);
  42196. /**
  42197. * Defines cache preventing GC.
  42198. */
  42199. private _defines;
  42200. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42201. /**
  42202. * "ImageProcessingPostProcess"
  42203. * @returns "ImageProcessingPostProcess"
  42204. */
  42205. getClassName(): string;
  42206. protected _updateParameters(): void;
  42207. dispose(camera?: Camera): void;
  42208. }
  42209. }
  42210. declare module BABYLON {
  42211. /**
  42212. * Class containing static functions to help procedurally build meshes
  42213. */
  42214. export class GroundBuilder {
  42215. /**
  42216. * Creates a ground mesh
  42217. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42218. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42220. * @param name defines the name of the mesh
  42221. * @param options defines the options used to create the mesh
  42222. * @param scene defines the hosting scene
  42223. * @returns the ground mesh
  42224. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42225. */
  42226. static CreateGround(name: string, options: {
  42227. width?: number;
  42228. height?: number;
  42229. subdivisions?: number;
  42230. subdivisionsX?: number;
  42231. subdivisionsY?: number;
  42232. updatable?: boolean;
  42233. }, scene: any): Mesh;
  42234. /**
  42235. * Creates a tiled ground mesh
  42236. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42237. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42238. * * 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
  42239. * * 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
  42240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42241. * @param name defines the name of the mesh
  42242. * @param options defines the options used to create the mesh
  42243. * @param scene defines the hosting scene
  42244. * @returns the tiled ground mesh
  42245. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42246. */
  42247. static CreateTiledGround(name: string, options: {
  42248. xmin: number;
  42249. zmin: number;
  42250. xmax: number;
  42251. zmax: number;
  42252. subdivisions?: {
  42253. w: number;
  42254. h: number;
  42255. };
  42256. precision?: {
  42257. w: number;
  42258. h: number;
  42259. };
  42260. updatable?: boolean;
  42261. }, scene?: Nullable<Scene>): Mesh;
  42262. /**
  42263. * Creates a ground mesh from a height map
  42264. * * The parameter `url` sets the URL of the height map image resource.
  42265. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42266. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42267. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42268. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42269. * * 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.
  42270. * * 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).
  42271. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42273. * @param name defines the name of the mesh
  42274. * @param url defines the url to the height map
  42275. * @param options defines the options used to create the mesh
  42276. * @param scene defines the hosting scene
  42277. * @returns the ground mesh
  42278. * @see https://doc.babylonjs.com/babylon101/height_map
  42279. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42280. */
  42281. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42282. width?: number;
  42283. height?: number;
  42284. subdivisions?: number;
  42285. minHeight?: number;
  42286. maxHeight?: number;
  42287. colorFilter?: Color3;
  42288. alphaFilter?: number;
  42289. updatable?: boolean;
  42290. onReady?: (mesh: GroundMesh) => void;
  42291. }, scene?: Nullable<Scene>): GroundMesh;
  42292. }
  42293. }
  42294. declare module BABYLON {
  42295. /**
  42296. * Class containing static functions to help procedurally build meshes
  42297. */
  42298. export class TorusBuilder {
  42299. /**
  42300. * Creates a torus mesh
  42301. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42302. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42303. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42305. * * 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
  42306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42307. * @param name defines the name of the mesh
  42308. * @param options defines the options used to create the mesh
  42309. * @param scene defines the hosting scene
  42310. * @returns the torus mesh
  42311. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42312. */
  42313. static CreateTorus(name: string, options: {
  42314. diameter?: number;
  42315. thickness?: number;
  42316. tessellation?: number;
  42317. updatable?: boolean;
  42318. sideOrientation?: number;
  42319. frontUVs?: Vector4;
  42320. backUVs?: Vector4;
  42321. }, scene: any): Mesh;
  42322. }
  42323. }
  42324. declare module BABYLON {
  42325. /**
  42326. * Class containing static functions to help procedurally build meshes
  42327. */
  42328. export class CylinderBuilder {
  42329. /**
  42330. * Creates a cylinder or a cone mesh
  42331. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42332. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42333. * * 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.
  42334. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42335. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42336. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42337. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42338. * * 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).
  42339. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42340. * * 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).
  42341. * * 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
  42342. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42343. * * 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
  42344. * * 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.
  42345. * * If `enclose` is false, a ring surface is one element.
  42346. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42347. * * 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
  42348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42349. * * 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
  42350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42351. * @param name defines the name of the mesh
  42352. * @param options defines the options used to create the mesh
  42353. * @param scene defines the hosting scene
  42354. * @returns the cylinder mesh
  42355. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42356. */
  42357. static CreateCylinder(name: string, options: {
  42358. height?: number;
  42359. diameterTop?: number;
  42360. diameterBottom?: number;
  42361. diameter?: number;
  42362. tessellation?: number;
  42363. subdivisions?: number;
  42364. arc?: number;
  42365. faceColors?: Color4[];
  42366. faceUV?: Vector4[];
  42367. updatable?: boolean;
  42368. hasRings?: boolean;
  42369. enclose?: boolean;
  42370. cap?: number;
  42371. sideOrientation?: number;
  42372. frontUVs?: Vector4;
  42373. backUVs?: Vector4;
  42374. }, scene: any): Mesh;
  42375. }
  42376. }
  42377. declare module BABYLON {
  42378. /**
  42379. * States of the webXR experience
  42380. */
  42381. export enum WebXRState {
  42382. /**
  42383. * Transitioning to being in XR mode
  42384. */
  42385. ENTERING_XR = 0,
  42386. /**
  42387. * Transitioning to non XR mode
  42388. */
  42389. EXITING_XR = 1,
  42390. /**
  42391. * In XR mode and presenting
  42392. */
  42393. IN_XR = 2,
  42394. /**
  42395. * Not entered XR mode
  42396. */
  42397. NOT_IN_XR = 3
  42398. }
  42399. /**
  42400. * Abstraction of the XR render target
  42401. */
  42402. export interface WebXRRenderTarget extends IDisposable {
  42403. /**
  42404. * xrpresent context of the canvas which can be used to display/mirror xr content
  42405. */
  42406. canvasContext: WebGLRenderingContext;
  42407. /**
  42408. * xr layer for the canvas
  42409. */
  42410. xrLayer: Nullable<XRWebGLLayer>;
  42411. /**
  42412. * Initializes the xr layer for the session
  42413. * @param xrSession xr session
  42414. * @returns a promise that will resolve once the XR Layer has been created
  42415. */
  42416. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42417. }
  42418. }
  42419. declare module BABYLON {
  42420. /**
  42421. * COnfiguration object for WebXR output canvas
  42422. */
  42423. export class WebXRManagedOutputCanvasOptions {
  42424. /**
  42425. * Options for this XR Layer output
  42426. */
  42427. canvasOptions?: XRWebGLLayerOptions;
  42428. /**
  42429. * CSS styling for a newly created canvas (if not provided)
  42430. */
  42431. newCanvasCssStyle?: string;
  42432. /**
  42433. * An optional canvas in case you wish to create it yourself and provide it here.
  42434. * If not provided, a new canvas will be created
  42435. */
  42436. canvasElement?: HTMLCanvasElement;
  42437. /**
  42438. * Get the default values of the configuration object
  42439. * @returns default values of this configuration object
  42440. */
  42441. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42442. }
  42443. /**
  42444. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42445. */
  42446. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42447. private _options;
  42448. private _engine;
  42449. private _canvas;
  42450. /**
  42451. * Rendering context of the canvas which can be used to display/mirror xr content
  42452. */
  42453. canvasContext: WebGLRenderingContext;
  42454. /**
  42455. * xr layer for the canvas
  42456. */
  42457. xrLayer: Nullable<XRWebGLLayer>;
  42458. /**
  42459. * Initializes the xr layer for the session
  42460. * @param xrSession xr session
  42461. * @returns a promise that will resolve once the XR Layer has been created
  42462. */
  42463. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42464. /**
  42465. * Initializes the canvas to be added/removed upon entering/exiting xr
  42466. * @param _xrSessionManager The XR Session manager
  42467. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42468. */
  42469. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42470. /**
  42471. * Disposes of the object
  42472. */
  42473. dispose(): void;
  42474. private _setManagedOutputCanvas;
  42475. private _addCanvas;
  42476. private _removeCanvas;
  42477. }
  42478. }
  42479. declare module BABYLON {
  42480. /**
  42481. * Manages an XRSession to work with Babylon's engine
  42482. * @see https://doc.babylonjs.com/how_to/webxr
  42483. */
  42484. export class WebXRSessionManager implements IDisposable {
  42485. /** The scene which the session should be created for */
  42486. scene: Scene;
  42487. /**
  42488. * Fires every time a new xrFrame arrives which can be used to update the camera
  42489. */
  42490. onXRFrameObservable: Observable<XRFrame>;
  42491. /**
  42492. * Fires when the xr session is ended either by the device or manually done
  42493. */
  42494. onXRSessionEnded: Observable<any>;
  42495. /**
  42496. * Fires when the xr session is ended either by the device or manually done
  42497. */
  42498. onXRSessionInit: Observable<XRSession>;
  42499. /**
  42500. * Fires when the reference space changed
  42501. */
  42502. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42503. /**
  42504. * Underlying xr session
  42505. */
  42506. session: XRSession;
  42507. /**
  42508. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42509. * or get the offset the player is currently at.
  42510. */
  42511. viewerReferenceSpace: XRReferenceSpace;
  42512. private _referenceSpace;
  42513. /**
  42514. * The current reference space used in this session. This reference space can constantly change!
  42515. * It is mainly used to offset the camera's position.
  42516. */
  42517. get referenceSpace(): XRReferenceSpace;
  42518. /**
  42519. * Set a new reference space and triggers the observable
  42520. */
  42521. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42522. /**
  42523. * The base reference space from which the session started. good if you want to reset your
  42524. * reference space
  42525. */
  42526. baseReferenceSpace: XRReferenceSpace;
  42527. /**
  42528. * Used just in case of a failure to initialize an immersive session.
  42529. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42530. */
  42531. defaultHeightCompensation: number;
  42532. /**
  42533. * Current XR frame
  42534. */
  42535. currentFrame: Nullable<XRFrame>;
  42536. /** WebXR timestamp updated every frame */
  42537. currentTimestamp: number;
  42538. private _xrNavigator;
  42539. private baseLayer;
  42540. private _rttProvider;
  42541. private _sessionEnded;
  42542. /**
  42543. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42544. * @param scene The scene which the session should be created for
  42545. */
  42546. constructor(
  42547. /** The scene which the session should be created for */
  42548. scene: Scene);
  42549. /**
  42550. * Initializes the manager
  42551. * After initialization enterXR can be called to start an XR session
  42552. * @returns Promise which resolves after it is initialized
  42553. */
  42554. initializeAsync(): Promise<void>;
  42555. /**
  42556. * Initializes an xr session
  42557. * @param xrSessionMode mode to initialize
  42558. * @param xrSessionInit defines optional and required values to pass to the session builder
  42559. * @returns a promise which will resolve once the session has been initialized
  42560. */
  42561. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42562. /**
  42563. * Sets the reference space on the xr session
  42564. * @param referenceSpaceType space to set
  42565. * @returns a promise that will resolve once the reference space has been set
  42566. */
  42567. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42568. /**
  42569. * Resets the reference space to the one started the session
  42570. */
  42571. resetReferenceSpace(): void;
  42572. /**
  42573. * Updates the render state of the session
  42574. * @param state state to set
  42575. * @returns a promise that resolves once the render state has been updated
  42576. */
  42577. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42578. /**
  42579. * Starts rendering to the xr layer
  42580. */
  42581. runXRRenderLoop(): void;
  42582. /**
  42583. * Gets the correct render target texture to be rendered this frame for this eye
  42584. * @param eye the eye for which to get the render target
  42585. * @returns the render target for the specified eye
  42586. */
  42587. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42588. /**
  42589. * Stops the xrSession and restores the renderloop
  42590. * @returns Promise which resolves after it exits XR
  42591. */
  42592. exitXRAsync(): Promise<void>;
  42593. /**
  42594. * Checks if a session would be supported for the creation options specified
  42595. * @param sessionMode session mode to check if supported eg. immersive-vr
  42596. * @returns A Promise that resolves to true if supported and false if not
  42597. */
  42598. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42599. /**
  42600. * Creates a WebXRRenderTarget object for the XR session
  42601. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42602. * @param options optional options to provide when creating a new render target
  42603. * @returns a WebXR render target to which the session can render
  42604. */
  42605. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42606. /**
  42607. * @hidden
  42608. * Converts the render layer of xrSession to a render target
  42609. * @param session session to create render target for
  42610. * @param scene scene the new render target should be created for
  42611. * @param baseLayer the webgl layer to create the render target for
  42612. */
  42613. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42614. /**
  42615. * Disposes of the session manager
  42616. */
  42617. dispose(): void;
  42618. /**
  42619. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42620. * @param sessionMode defines the session to test
  42621. * @returns a promise with boolean as final value
  42622. */
  42623. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42624. }
  42625. }
  42626. declare module BABYLON {
  42627. /**
  42628. * WebXR Camera which holds the views for the xrSession
  42629. * @see https://doc.babylonjs.com/how_to/webxr
  42630. */
  42631. export class WebXRCamera extends FreeCamera {
  42632. private _xrSessionManager;
  42633. /**
  42634. * Should position compensation execute on first frame.
  42635. * This is used when copying the position from a native (non XR) camera
  42636. */
  42637. compensateOnFirstFrame: boolean;
  42638. private _firstFrame;
  42639. private _referencedPosition;
  42640. private _referenceQuaternion;
  42641. private _xrInvPositionCache;
  42642. private _xrInvQuaternionCache;
  42643. /**
  42644. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42645. * @param name the name of the camera
  42646. * @param scene the scene to add the camera to
  42647. */
  42648. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42649. private _updateNumberOfRigCameras;
  42650. /**
  42651. * Sets this camera's transformation based on a non-vr camera
  42652. * @param otherCamera the non-vr camera to copy the transformation from
  42653. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42654. */
  42655. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42656. /** @hidden */
  42657. _updateForDualEyeDebugging(): void;
  42658. private _updateReferenceSpace;
  42659. private _updateReferenceSpaceOffset;
  42660. private _updateFromXRSession;
  42661. }
  42662. }
  42663. declare module BABYLON {
  42664. /**
  42665. * Defining the interface required for a (webxr) feature
  42666. */
  42667. export interface IWebXRFeature extends IDisposable {
  42668. /**
  42669. * Is this feature attached
  42670. */
  42671. attached: boolean;
  42672. /**
  42673. * Should auto-attach be disabled?
  42674. */
  42675. disableAutoAttach: boolean;
  42676. /**
  42677. * Attach the feature to the session
  42678. * Will usually be called by the features manager
  42679. *
  42680. * @param force should attachment be forced (even when already attached)
  42681. * @returns true if successful.
  42682. */
  42683. attach(force?: boolean): boolean;
  42684. /**
  42685. * Detach the feature from the session
  42686. * Will usually be called by the features manager
  42687. *
  42688. * @returns true if successful.
  42689. */
  42690. detach(): boolean;
  42691. }
  42692. /**
  42693. * A list of the currently available features without referencing them
  42694. */
  42695. export class WebXRFeatureName {
  42696. /**
  42697. * The name of the hit test feature
  42698. */
  42699. static HIT_TEST: string;
  42700. /**
  42701. * The name of the anchor system feature
  42702. */
  42703. static ANCHOR_SYSTEM: string;
  42704. /**
  42705. * The name of the background remover feature
  42706. */
  42707. static BACKGROUND_REMOVER: string;
  42708. /**
  42709. * The name of the pointer selection feature
  42710. */
  42711. static POINTER_SELECTION: string;
  42712. /**
  42713. * The name of the teleportation feature
  42714. */
  42715. static TELEPORTATION: string;
  42716. /**
  42717. * The name of the plane detection feature
  42718. */
  42719. static PLANE_DETECTION: string;
  42720. }
  42721. /**
  42722. * Defining the constructor of a feature. Used to register the modules.
  42723. */
  42724. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42725. /**
  42726. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42727. * It is mainly used in AR sessions.
  42728. *
  42729. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42730. */
  42731. export class WebXRFeaturesManager implements IDisposable {
  42732. private _xrSessionManager;
  42733. private static readonly _AvailableFeatures;
  42734. /**
  42735. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42736. * Mainly used internally.
  42737. *
  42738. * @param featureName the name of the feature to register
  42739. * @param constructorFunction the function used to construct the module
  42740. * @param version the (babylon) version of the module
  42741. * @param stable is that a stable version of this module
  42742. */
  42743. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42744. /**
  42745. * Returns a constructor of a specific feature.
  42746. *
  42747. * @param featureName the name of the feature to construct
  42748. * @param version the version of the feature to load
  42749. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42750. * @param options optional options provided to the module.
  42751. * @returns a function that, when called, will return a new instance of this feature
  42752. */
  42753. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42754. /**
  42755. * Return the latest unstable version of this feature
  42756. * @param featureName the name of the feature to search
  42757. * @returns the version number. if not found will return -1
  42758. */
  42759. static GetLatestVersionOfFeature(featureName: string): number;
  42760. /**
  42761. * Return the latest stable version of this feature
  42762. * @param featureName the name of the feature to search
  42763. * @returns the version number. if not found will return -1
  42764. */
  42765. static GetStableVersionOfFeature(featureName: string): number;
  42766. /**
  42767. * Can be used to return the list of features currently registered
  42768. *
  42769. * @returns an Array of available features
  42770. */
  42771. static GetAvailableFeatures(): string[];
  42772. /**
  42773. * Gets the versions available for a specific feature
  42774. * @param featureName the name of the feature
  42775. * @returns an array with the available versions
  42776. */
  42777. static GetAvailableVersions(featureName: string): string[];
  42778. private _features;
  42779. /**
  42780. * constructs a new features manages.
  42781. *
  42782. * @param _xrSessionManager an instance of WebXRSessionManager
  42783. */
  42784. constructor(_xrSessionManager: WebXRSessionManager);
  42785. /**
  42786. * 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.
  42787. * 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.
  42788. *
  42789. * @param featureName the name of the feature to load or the class of the feature
  42790. * @param version optional version to load. if not provided the latest version will be enabled
  42791. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42792. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42793. * @returns a new constructed feature or throws an error if feature not found.
  42794. */
  42795. enableFeature(featureName: string | {
  42796. Name: string;
  42797. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42798. /**
  42799. * Used to disable an already-enabled feature
  42800. * The feature will be disposed and will be recreated once enabled.
  42801. * @param featureName the feature to disable
  42802. * @returns true if disable was successful
  42803. */
  42804. disableFeature(featureName: string | {
  42805. Name: string;
  42806. }): boolean;
  42807. /**
  42808. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42809. * Can be used during a session to start a feature
  42810. * @param featureName the name of feature to attach
  42811. */
  42812. attachFeature(featureName: string): void;
  42813. /**
  42814. * Can be used inside a session or when the session ends to detach a specific feature
  42815. * @param featureName the name of the feature to detach
  42816. */
  42817. detachFeature(featureName: string): void;
  42818. /**
  42819. * Get the list of enabled features
  42820. * @returns an array of enabled features
  42821. */
  42822. getEnabledFeatures(): string[];
  42823. /**
  42824. * get the implementation of an enabled feature.
  42825. * @param featureName the name of the feature to load
  42826. * @returns the feature class, if found
  42827. */
  42828. getEnabledFeature(featureName: string): IWebXRFeature;
  42829. /**
  42830. * dispose this features manager
  42831. */
  42832. dispose(): void;
  42833. }
  42834. }
  42835. declare module BABYLON {
  42836. /**
  42837. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42838. * @see https://doc.babylonjs.com/how_to/webxr
  42839. */
  42840. export class WebXRExperienceHelper implements IDisposable {
  42841. private scene;
  42842. /**
  42843. * Camera used to render xr content
  42844. */
  42845. camera: WebXRCamera;
  42846. /**
  42847. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42848. */
  42849. state: WebXRState;
  42850. private _setState;
  42851. /**
  42852. * Fires when the state of the experience helper has changed
  42853. */
  42854. onStateChangedObservable: Observable<WebXRState>;
  42855. /**
  42856. * Observers registered here will be triggered after the camera's initial transformation is set
  42857. * This can be used to set a different ground level or an extra rotation.
  42858. *
  42859. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42860. * to the position set after this observable is done executing.
  42861. */
  42862. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42863. /** Session manager used to keep track of xr session */
  42864. sessionManager: WebXRSessionManager;
  42865. /** A features manager for this xr session */
  42866. featuresManager: WebXRFeaturesManager;
  42867. private _nonVRCamera;
  42868. private _originalSceneAutoClear;
  42869. private _supported;
  42870. /**
  42871. * Creates the experience helper
  42872. * @param scene the scene to attach the experience helper to
  42873. * @returns a promise for the experience helper
  42874. */
  42875. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42876. /**
  42877. * Creates a WebXRExperienceHelper
  42878. * @param scene The scene the helper should be created in
  42879. */
  42880. private constructor();
  42881. /**
  42882. * Exits XR mode and returns the scene to its original state
  42883. * @returns promise that resolves after xr mode has exited
  42884. */
  42885. exitXRAsync(): Promise<void>;
  42886. /**
  42887. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42888. * @param sessionMode options for the XR session
  42889. * @param referenceSpaceType frame of reference of the XR session
  42890. * @param renderTarget the output canvas that will be used to enter XR mode
  42891. * @returns promise that resolves after xr mode has entered
  42892. */
  42893. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42894. /**
  42895. * Disposes of the experience helper
  42896. */
  42897. dispose(): void;
  42898. private _nonXRToXRCamera;
  42899. }
  42900. }
  42901. declare module BABYLON {
  42902. /**
  42903. * X-Y values for axes in WebXR
  42904. */
  42905. export interface IWebXRMotionControllerAxesValue {
  42906. /**
  42907. * The value of the x axis
  42908. */
  42909. x: number;
  42910. /**
  42911. * The value of the y-axis
  42912. */
  42913. y: number;
  42914. }
  42915. /**
  42916. * changed / previous values for the values of this component
  42917. */
  42918. export interface IWebXRMotionControllerComponentChangesValues<T> {
  42919. /**
  42920. * current (this frame) value
  42921. */
  42922. current: T;
  42923. /**
  42924. * previous (last change) value
  42925. */
  42926. previous: T;
  42927. }
  42928. /**
  42929. * Represents changes in the component between current frame and last values recorded
  42930. */
  42931. export interface IWebXRMotionControllerComponentChanges {
  42932. /**
  42933. * will be populated with previous and current values if touched changed
  42934. */
  42935. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42936. /**
  42937. * will be populated with previous and current values if pressed changed
  42938. */
  42939. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42940. /**
  42941. * will be populated with previous and current values if value changed
  42942. */
  42943. value?: IWebXRMotionControllerComponentChangesValues<number>;
  42944. /**
  42945. * will be populated with previous and current values if axes changed
  42946. */
  42947. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  42948. }
  42949. /**
  42950. * This class represents a single component (for example button or thumbstick) of a motion controller
  42951. */
  42952. export class WebXRControllerComponent implements IDisposable {
  42953. /**
  42954. * the id of this component
  42955. */
  42956. id: string;
  42957. /**
  42958. * the type of the component
  42959. */
  42960. type: MotionControllerComponentType;
  42961. private _buttonIndex;
  42962. private _axesIndices;
  42963. /**
  42964. * Thumbstick component type
  42965. */
  42966. static THUMBSTICK: MotionControllerComponentType;
  42967. /**
  42968. * Touchpad component type
  42969. */
  42970. static TOUCHPAD: MotionControllerComponentType;
  42971. /**
  42972. * trigger component type
  42973. */
  42974. static TRIGGER: MotionControllerComponentType;
  42975. /**
  42976. * squeeze component type
  42977. */
  42978. static SQUEEZE: MotionControllerComponentType;
  42979. /**
  42980. * button component type
  42981. */
  42982. static BUTTON: MotionControllerComponentType;
  42983. /**
  42984. * Observers registered here will be triggered when the state of a button changes
  42985. * State change is either pressed / touched / value
  42986. */
  42987. onButtonStateChanged: Observable<WebXRControllerComponent>;
  42988. /**
  42989. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  42990. * the axes data changes
  42991. */
  42992. onAxisValueChanged: Observable<{
  42993. x: number;
  42994. y: number;
  42995. }>;
  42996. private _currentValue;
  42997. private _touched;
  42998. private _pressed;
  42999. private _axes;
  43000. private _changes;
  43001. private _hasChanges;
  43002. /**
  43003. * Return whether or not the component changed the last frame
  43004. */
  43005. get hasChanges(): boolean;
  43006. /**
  43007. * Creates a new component for a motion controller.
  43008. * It is created by the motion controller itself
  43009. *
  43010. * @param id the id of this component
  43011. * @param type the type of the component
  43012. * @param _buttonIndex index in the buttons array of the gamepad
  43013. * @param _axesIndices indices of the values in the axes array of the gamepad
  43014. */
  43015. constructor(
  43016. /**
  43017. * the id of this component
  43018. */
  43019. id: string,
  43020. /**
  43021. * the type of the component
  43022. */
  43023. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43024. /**
  43025. * Get the current value of this component
  43026. */
  43027. get value(): number;
  43028. /**
  43029. * is the button currently pressed
  43030. */
  43031. get pressed(): boolean;
  43032. /**
  43033. * is the button currently touched
  43034. */
  43035. get touched(): boolean;
  43036. /**
  43037. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43038. */
  43039. get axes(): IWebXRMotionControllerAxesValue;
  43040. /**
  43041. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43042. */
  43043. get changes(): IWebXRMotionControllerComponentChanges;
  43044. /**
  43045. * Is this component a button (hence - pressable)
  43046. * @returns true if can be pressed
  43047. */
  43048. isButton(): boolean;
  43049. /**
  43050. * Are there axes correlating to this component
  43051. * @return true is axes data is available
  43052. */
  43053. isAxes(): boolean;
  43054. /**
  43055. * update this component using the gamepad object it is in. Called on every frame
  43056. * @param nativeController the native gamepad controller object
  43057. */
  43058. update(nativeController: IMinimalMotionControllerObject): void;
  43059. /**
  43060. * Dispose this component
  43061. */
  43062. dispose(): void;
  43063. }
  43064. }
  43065. declare module BABYLON {
  43066. /**
  43067. * Class used to represent data loading progression
  43068. */
  43069. export class SceneLoaderProgressEvent {
  43070. /** defines if data length to load can be evaluated */
  43071. readonly lengthComputable: boolean;
  43072. /** defines the loaded data length */
  43073. readonly loaded: number;
  43074. /** defines the data length to load */
  43075. readonly total: number;
  43076. /**
  43077. * Create a new progress event
  43078. * @param lengthComputable defines if data length to load can be evaluated
  43079. * @param loaded defines the loaded data length
  43080. * @param total defines the data length to load
  43081. */
  43082. constructor(
  43083. /** defines if data length to load can be evaluated */
  43084. lengthComputable: boolean,
  43085. /** defines the loaded data length */
  43086. loaded: number,
  43087. /** defines the data length to load */
  43088. total: number);
  43089. /**
  43090. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43091. * @param event defines the source event
  43092. * @returns a new SceneLoaderProgressEvent
  43093. */
  43094. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43095. }
  43096. /**
  43097. * Interface used by SceneLoader plugins to define supported file extensions
  43098. */
  43099. export interface ISceneLoaderPluginExtensions {
  43100. /**
  43101. * Defines the list of supported extensions
  43102. */
  43103. [extension: string]: {
  43104. isBinary: boolean;
  43105. };
  43106. }
  43107. /**
  43108. * Interface used by SceneLoader plugin factory
  43109. */
  43110. export interface ISceneLoaderPluginFactory {
  43111. /**
  43112. * Defines the name of the factory
  43113. */
  43114. name: string;
  43115. /**
  43116. * Function called to create a new plugin
  43117. * @return the new plugin
  43118. */
  43119. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43120. /**
  43121. * The callback that returns true if the data can be directly loaded.
  43122. * @param data string containing the file data
  43123. * @returns if the data can be loaded directly
  43124. */
  43125. canDirectLoad?(data: string): boolean;
  43126. }
  43127. /**
  43128. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43129. */
  43130. export interface ISceneLoaderPluginBase {
  43131. /**
  43132. * The friendly name of this plugin.
  43133. */
  43134. name: string;
  43135. /**
  43136. * The file extensions supported by this plugin.
  43137. */
  43138. extensions: string | ISceneLoaderPluginExtensions;
  43139. /**
  43140. * The callback called when loading from a url.
  43141. * @param scene scene loading this url
  43142. * @param url url to load
  43143. * @param onSuccess callback called when the file successfully loads
  43144. * @param onProgress callback called while file is loading (if the server supports this mode)
  43145. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43146. * @param onError callback called when the file fails to load
  43147. * @returns a file request object
  43148. */
  43149. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43150. /**
  43151. * The callback called when loading from a file object.
  43152. * @param scene scene loading this file
  43153. * @param file defines the file to load
  43154. * @param onSuccess defines the callback to call when data is loaded
  43155. * @param onProgress defines the callback to call during loading process
  43156. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43157. * @param onError defines the callback to call when an error occurs
  43158. * @returns a file request object
  43159. */
  43160. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43161. /**
  43162. * The callback that returns true if the data can be directly loaded.
  43163. * @param data string containing the file data
  43164. * @returns if the data can be loaded directly
  43165. */
  43166. canDirectLoad?(data: string): boolean;
  43167. /**
  43168. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43169. * @param scene scene loading this data
  43170. * @param data string containing the data
  43171. * @returns data to pass to the plugin
  43172. */
  43173. directLoad?(scene: Scene, data: string): any;
  43174. /**
  43175. * The callback that allows custom handling of the root url based on the response url.
  43176. * @param rootUrl the original root url
  43177. * @param responseURL the response url if available
  43178. * @returns the new root url
  43179. */
  43180. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43181. }
  43182. /**
  43183. * Interface used to define a SceneLoader plugin
  43184. */
  43185. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43186. /**
  43187. * Import meshes into a scene.
  43188. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43189. * @param scene The scene to import into
  43190. * @param data The data to import
  43191. * @param rootUrl The root url for scene and resources
  43192. * @param meshes The meshes array to import into
  43193. * @param particleSystems The particle systems array to import into
  43194. * @param skeletons The skeletons array to import into
  43195. * @param onError The callback when import fails
  43196. * @returns True if successful or false otherwise
  43197. */
  43198. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43199. /**
  43200. * Load into a scene.
  43201. * @param scene The scene to load into
  43202. * @param data The data to import
  43203. * @param rootUrl The root url for scene and resources
  43204. * @param onError The callback when import fails
  43205. * @returns True if successful or false otherwise
  43206. */
  43207. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43208. /**
  43209. * Load into an asset container.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns The loaded asset container
  43215. */
  43216. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43217. }
  43218. /**
  43219. * Interface used to define an async SceneLoader plugin
  43220. */
  43221. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43222. /**
  43223. * Import meshes into a scene.
  43224. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43225. * @param scene The scene to import into
  43226. * @param data The data to import
  43227. * @param rootUrl The root url for scene and resources
  43228. * @param onProgress The callback when the load progresses
  43229. * @param fileName Defines the name of the file to load
  43230. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43231. */
  43232. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43233. meshes: AbstractMesh[];
  43234. particleSystems: IParticleSystem[];
  43235. skeletons: Skeleton[];
  43236. animationGroups: AnimationGroup[];
  43237. }>;
  43238. /**
  43239. * Load into a scene.
  43240. * @param scene The scene to load into
  43241. * @param data The data to import
  43242. * @param rootUrl The root url for scene and resources
  43243. * @param onProgress The callback when the load progresses
  43244. * @param fileName Defines the name of the file to load
  43245. * @returns Nothing
  43246. */
  43247. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43248. /**
  43249. * Load into an asset container.
  43250. * @param scene The scene to load into
  43251. * @param data The data to import
  43252. * @param rootUrl The root url for scene and resources
  43253. * @param onProgress The callback when the load progresses
  43254. * @param fileName Defines the name of the file to load
  43255. * @returns The loaded asset container
  43256. */
  43257. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43258. }
  43259. /**
  43260. * Mode that determines how to handle old animation groups before loading new ones.
  43261. */
  43262. export enum SceneLoaderAnimationGroupLoadingMode {
  43263. /**
  43264. * Reset all old animations to initial state then dispose them.
  43265. */
  43266. Clean = 0,
  43267. /**
  43268. * Stop all old animations.
  43269. */
  43270. Stop = 1,
  43271. /**
  43272. * Restart old animations from first frame.
  43273. */
  43274. Sync = 2,
  43275. /**
  43276. * Old animations remains untouched.
  43277. */
  43278. NoSync = 3
  43279. }
  43280. /**
  43281. * Class used to load scene from various file formats using registered plugins
  43282. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43283. */
  43284. export class SceneLoader {
  43285. /**
  43286. * No logging while loading
  43287. */
  43288. static readonly NO_LOGGING: number;
  43289. /**
  43290. * Minimal logging while loading
  43291. */
  43292. static readonly MINIMAL_LOGGING: number;
  43293. /**
  43294. * Summary logging while loading
  43295. */
  43296. static readonly SUMMARY_LOGGING: number;
  43297. /**
  43298. * Detailled logging while loading
  43299. */
  43300. static readonly DETAILED_LOGGING: number;
  43301. /**
  43302. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43303. */
  43304. static get ForceFullSceneLoadingForIncremental(): boolean;
  43305. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43306. /**
  43307. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43308. */
  43309. static get ShowLoadingScreen(): boolean;
  43310. static set ShowLoadingScreen(value: boolean);
  43311. /**
  43312. * Defines the current logging level (while loading the scene)
  43313. * @ignorenaming
  43314. */
  43315. static get loggingLevel(): number;
  43316. static set loggingLevel(value: number);
  43317. /**
  43318. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43319. */
  43320. static get CleanBoneMatrixWeights(): boolean;
  43321. static set CleanBoneMatrixWeights(value: boolean);
  43322. /**
  43323. * Event raised when a plugin is used to load a scene
  43324. */
  43325. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43326. private static _registeredPlugins;
  43327. private static _getDefaultPlugin;
  43328. private static _getPluginForExtension;
  43329. private static _getPluginForDirectLoad;
  43330. private static _getPluginForFilename;
  43331. private static _getDirectLoad;
  43332. private static _loadData;
  43333. private static _getFileInfo;
  43334. /**
  43335. * Gets a plugin that can load the given extension
  43336. * @param extension defines the extension to load
  43337. * @returns a plugin or null if none works
  43338. */
  43339. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43340. /**
  43341. * Gets a boolean indicating that the given extension can be loaded
  43342. * @param extension defines the extension to load
  43343. * @returns true if the extension is supported
  43344. */
  43345. static IsPluginForExtensionAvailable(extension: string): boolean;
  43346. /**
  43347. * Adds a new plugin to the list of registered plugins
  43348. * @param plugin defines the plugin to add
  43349. */
  43350. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43351. /**
  43352. * Import meshes into a scene
  43353. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43354. * @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)
  43355. * @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)
  43356. * @param scene the instance of BABYLON.Scene to append to
  43357. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43358. * @param onProgress a callback with a progress event for each file being loaded
  43359. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43360. * @param pluginExtension the extension used to determine the plugin
  43361. * @returns The loaded plugin
  43362. */
  43363. 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>;
  43364. /**
  43365. * Import meshes into a scene
  43366. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43367. * @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)
  43368. * @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)
  43369. * @param scene the instance of BABYLON.Scene to append to
  43370. * @param onProgress a callback with a progress event for each file being loaded
  43371. * @param pluginExtension the extension used to determine the plugin
  43372. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43373. */
  43374. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43375. meshes: AbstractMesh[];
  43376. particleSystems: IParticleSystem[];
  43377. skeletons: Skeleton[];
  43378. animationGroups: AnimationGroup[];
  43379. }>;
  43380. /**
  43381. * Load a scene
  43382. * @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)
  43383. * @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)
  43384. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43385. * @param onSuccess a callback with the scene when import succeeds
  43386. * @param onProgress a callback with a progress event for each file being loaded
  43387. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43388. * @param pluginExtension the extension used to determine the plugin
  43389. * @returns The loaded plugin
  43390. */
  43391. 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>;
  43392. /**
  43393. * Load a scene
  43394. * @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)
  43395. * @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)
  43396. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43397. * @param onProgress a callback with a progress event for each file being loaded
  43398. * @param pluginExtension the extension used to determine the plugin
  43399. * @returns The loaded scene
  43400. */
  43401. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43402. /**
  43403. * Append a scene
  43404. * @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)
  43405. * @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)
  43406. * @param scene is the instance of BABYLON.Scene to append to
  43407. * @param onSuccess a callback with the scene when import succeeds
  43408. * @param onProgress a callback with a progress event for each file being loaded
  43409. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43410. * @param pluginExtension the extension used to determine the plugin
  43411. * @returns The loaded plugin
  43412. */
  43413. 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>;
  43414. /**
  43415. * Append a scene
  43416. * @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)
  43417. * @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)
  43418. * @param scene is the instance of BABYLON.Scene to append to
  43419. * @param onProgress a callback with a progress event for each file being loaded
  43420. * @param pluginExtension the extension used to determine the plugin
  43421. * @returns The given scene
  43422. */
  43423. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43424. /**
  43425. * Load a scene into an asset container
  43426. * @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)
  43427. * @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)
  43428. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43429. * @param onSuccess a callback with the scene when import succeeds
  43430. * @param onProgress a callback with a progress event for each file being loaded
  43431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43432. * @param pluginExtension the extension used to determine the plugin
  43433. * @returns The loaded plugin
  43434. */
  43435. 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>;
  43436. /**
  43437. * Load a scene into an asset container
  43438. * @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)
  43439. * @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)
  43440. * @param scene is the instance of Scene to append to
  43441. * @param onProgress a callback with a progress event for each file being loaded
  43442. * @param pluginExtension the extension used to determine the plugin
  43443. * @returns The loaded asset container
  43444. */
  43445. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43446. /**
  43447. * Import animations from a file into a scene
  43448. * @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)
  43449. * @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)
  43450. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43451. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43452. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43453. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43454. * @param onSuccess a callback with the scene when import succeeds
  43455. * @param onProgress a callback with a progress event for each file being loaded
  43456. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43457. */
  43458. 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;
  43459. /**
  43460. * Import animations from a file into a scene
  43461. * @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)
  43462. * @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)
  43463. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43464. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43465. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43466. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43467. * @param onSuccess a callback with the scene when import succeeds
  43468. * @param onProgress a callback with a progress event for each file being loaded
  43469. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43470. * @returns the updated scene with imported animations
  43471. */
  43472. 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>;
  43473. }
  43474. }
  43475. declare module BABYLON {
  43476. /**
  43477. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43478. */
  43479. export type MotionControllerHandness = "none" | "left" | "right";
  43480. /**
  43481. * The type of components available in motion controllers.
  43482. * This is not the name of the component.
  43483. */
  43484. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43485. /**
  43486. * The state of a controller component
  43487. */
  43488. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43489. /**
  43490. * The schema of motion controller layout.
  43491. * No object will be initialized using this interface
  43492. * This is used just to define the profile.
  43493. */
  43494. export interface IMotionControllerLayout {
  43495. /**
  43496. * Defines the main button component id
  43497. */
  43498. selectComponentId: string;
  43499. /**
  43500. * Available components (unsorted)
  43501. */
  43502. components: {
  43503. /**
  43504. * A map of component Ids
  43505. */
  43506. [componentId: string]: {
  43507. /**
  43508. * The type of input the component outputs
  43509. */
  43510. type: MotionControllerComponentType;
  43511. /**
  43512. * The indices of this component in the gamepad object
  43513. */
  43514. gamepadIndices: {
  43515. /**
  43516. * Index of button
  43517. */
  43518. button?: number;
  43519. /**
  43520. * If available, index of x-axis
  43521. */
  43522. xAxis?: number;
  43523. /**
  43524. * If available, index of y-axis
  43525. */
  43526. yAxis?: number;
  43527. };
  43528. /**
  43529. * The mesh's root node name
  43530. */
  43531. rootNodeName: string;
  43532. /**
  43533. * Animation definitions for this model
  43534. */
  43535. visualResponses: {
  43536. [stateKey: string]: {
  43537. /**
  43538. * What property will be animated
  43539. */
  43540. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43541. /**
  43542. * What states influence this visual reponse
  43543. */
  43544. states: MotionControllerComponentStateType[];
  43545. /**
  43546. * Type of animation - movement or visibility
  43547. */
  43548. valueNodeProperty: "transform" | "visibility";
  43549. /**
  43550. * Base node name to move. Its position will be calculated according to the min and max nodes
  43551. */
  43552. valueNodeName?: string;
  43553. /**
  43554. * Minimum movement node
  43555. */
  43556. minNodeName?: string;
  43557. /**
  43558. * Max movement node
  43559. */
  43560. maxNodeName?: string;
  43561. };
  43562. };
  43563. /**
  43564. * If touch enabled, what is the name of node to display user feedback
  43565. */
  43566. touchPointNodeName?: string;
  43567. };
  43568. };
  43569. /**
  43570. * Is it xr standard mapping or not
  43571. */
  43572. gamepadMapping: "" | "xr-standard";
  43573. /**
  43574. * Base root node of this entire model
  43575. */
  43576. rootNodeName: string;
  43577. /**
  43578. * Path to load the assets. Usually relative to the base path
  43579. */
  43580. assetPath: string;
  43581. }
  43582. /**
  43583. * A definition for the layout map in the input profile
  43584. */
  43585. export interface IMotionControllerLayoutMap {
  43586. /**
  43587. * Layouts with handness type as a key
  43588. */
  43589. [handness: string]: IMotionControllerLayout;
  43590. }
  43591. /**
  43592. * The XR Input profile schema
  43593. * Profiles can be found here:
  43594. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43595. */
  43596. export interface IMotionControllerProfile {
  43597. /**
  43598. * The id of this profile
  43599. * correlates to the profile(s) in the xrInput.profiles array
  43600. */
  43601. profileId: string;
  43602. /**
  43603. * fallback profiles for this profileId
  43604. */
  43605. fallbackProfileIds: string[];
  43606. /**
  43607. * The layout map, with handness as key
  43608. */
  43609. layouts: IMotionControllerLayoutMap;
  43610. }
  43611. /**
  43612. * A helper-interface for the 3 meshes needed for controller button animation
  43613. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43614. */
  43615. export interface IMotionControllerButtonMeshMap {
  43616. /**
  43617. * The mesh that will be changed when value changes
  43618. */
  43619. valueMesh: AbstractMesh;
  43620. /**
  43621. * the mesh that defines the pressed value mesh position.
  43622. * This is used to find the max-position of this button
  43623. */
  43624. pressedMesh: AbstractMesh;
  43625. /**
  43626. * the mesh that defines the unpressed value mesh position.
  43627. * This is used to find the min (or initial) position of this button
  43628. */
  43629. unpressedMesh: AbstractMesh;
  43630. }
  43631. /**
  43632. * A helper-interface for the 3 meshes needed for controller axis animation.
  43633. * This will be expanded when touchpad animations are fully supported
  43634. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43635. */
  43636. export interface IMotionControllerMeshMap {
  43637. /**
  43638. * The mesh that will be changed when axis value changes
  43639. */
  43640. valueMesh: AbstractMesh;
  43641. /**
  43642. * the mesh that defines the minimum value mesh position.
  43643. */
  43644. minMesh?: AbstractMesh;
  43645. /**
  43646. * the mesh that defines the maximum value mesh position.
  43647. */
  43648. maxMesh?: AbstractMesh;
  43649. }
  43650. /**
  43651. * The elements needed for change-detection of the gamepad objects in motion controllers
  43652. */
  43653. export interface IMinimalMotionControllerObject {
  43654. /**
  43655. * An array of available buttons
  43656. */
  43657. buttons: Array<{
  43658. /**
  43659. * Value of the button/trigger
  43660. */
  43661. value: number;
  43662. /**
  43663. * If the button/trigger is currently touched
  43664. */
  43665. touched: boolean;
  43666. /**
  43667. * If the button/trigger is currently pressed
  43668. */
  43669. pressed: boolean;
  43670. }>;
  43671. /**
  43672. * Available axes of this controller
  43673. */
  43674. axes: number[];
  43675. }
  43676. /**
  43677. * An Abstract Motion controller
  43678. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43679. * Each component has an observable to check for changes in value and state
  43680. */
  43681. export abstract class WebXRAbstractMotionController implements IDisposable {
  43682. protected scene: Scene;
  43683. protected layout: IMotionControllerLayout;
  43684. /**
  43685. * The gamepad object correlating to this controller
  43686. */
  43687. gamepadObject: IMinimalMotionControllerObject;
  43688. /**
  43689. * handness (left/right/none) of this controller
  43690. */
  43691. handness: MotionControllerHandness;
  43692. /**
  43693. * The profile id of this motion controller
  43694. */
  43695. abstract profileId: string;
  43696. /**
  43697. * A map of components (WebXRControllerComponent) in this motion controller
  43698. * Components have a ComponentType and can also have both button and axis definitions
  43699. */
  43700. readonly components: {
  43701. [id: string]: WebXRControllerComponent;
  43702. };
  43703. /**
  43704. * Observers registered here will be triggered when the model of this controller is done loading
  43705. */
  43706. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43707. /**
  43708. * The root mesh of the model. It is null if the model was not yet initialized
  43709. */
  43710. rootMesh: Nullable<AbstractMesh>;
  43711. /**
  43712. * Disable the model's animation. Can be set at any time.
  43713. */
  43714. disableAnimation: boolean;
  43715. private _modelReady;
  43716. /**
  43717. * constructs a new abstract motion controller
  43718. * @param scene the scene to which the model of the controller will be added
  43719. * @param layout The profile layout to load
  43720. * @param gamepadObject The gamepad object correlating to this controller
  43721. * @param handness handness (left/right/none) of this controller
  43722. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43723. */
  43724. constructor(scene: Scene, layout: IMotionControllerLayout,
  43725. /**
  43726. * The gamepad object correlating to this controller
  43727. */
  43728. gamepadObject: IMinimalMotionControllerObject,
  43729. /**
  43730. * handness (left/right/none) of this controller
  43731. */
  43732. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43733. private _initComponent;
  43734. /**
  43735. * Update this model using the current XRFrame
  43736. * @param xrFrame the current xr frame to use and update the model
  43737. */
  43738. updateFromXRFrame(xrFrame: XRFrame): void;
  43739. /**
  43740. * Get the list of components available in this motion controller
  43741. * @returns an array of strings correlating to available components
  43742. */
  43743. getComponentIds(): string[];
  43744. /**
  43745. * Get the main (Select) component of this controller as defined in the layout
  43746. * @returns the main component of this controller
  43747. */
  43748. getMainComponent(): WebXRControllerComponent;
  43749. /**
  43750. * get a component based an its component id as defined in layout.components
  43751. * @param id the id of the component
  43752. * @returns the component correlates to the id or undefined if not found
  43753. */
  43754. getComponent(id: string): WebXRControllerComponent;
  43755. /**
  43756. * Get the first component of specific type
  43757. * @param type type of component to find
  43758. * @return a controller component or null if not found
  43759. */
  43760. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43761. /**
  43762. * Returns all components of specific type
  43763. * @param type the type to search for
  43764. * @return an array of components with this type
  43765. */
  43766. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43767. /**
  43768. * Loads the model correlating to this controller
  43769. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43770. * @returns A promise fulfilled with the result of the model loading
  43771. */
  43772. loadModel(): Promise<boolean>;
  43773. /**
  43774. * Update the model itself with the current frame data
  43775. * @param xrFrame the frame to use for updating the model mesh
  43776. */
  43777. protected updateModel(xrFrame: XRFrame): void;
  43778. /**
  43779. * Moves the axis on the controller mesh based on its current state
  43780. * @param axis the index of the axis
  43781. * @param axisValue the value of the axis which determines the meshes new position
  43782. * @hidden
  43783. */
  43784. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43785. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43786. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43787. private _getGenericFilenameAndPath;
  43788. private _getGenericParentMesh;
  43789. /**
  43790. * Get the filename and path for this controller's model
  43791. * @returns a map of filename and path
  43792. */
  43793. protected abstract _getFilenameAndPath(): {
  43794. filename: string;
  43795. path: string;
  43796. };
  43797. /**
  43798. * This function will be called after the model was successfully loaded and can be used
  43799. * for mesh transformations before it is available for the user
  43800. * @param meshes the loaded meshes
  43801. */
  43802. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43803. /**
  43804. * Set the root mesh for this controller. Important for the WebXR controller class
  43805. * @param meshes the loaded meshes
  43806. */
  43807. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43808. /**
  43809. * A function executed each frame that updates the mesh (if needed)
  43810. * @param xrFrame the current xrFrame
  43811. */
  43812. protected abstract _updateModel(xrFrame: XRFrame): void;
  43813. /**
  43814. * This function is called before the mesh is loaded. It checks for loading constraints.
  43815. * For example, this function can check if the GLB loader is available
  43816. * If this function returns false, the generic controller will be loaded instead
  43817. * @returns Is the client ready to load the mesh
  43818. */
  43819. protected abstract _getModelLoadingConstraints(): boolean;
  43820. /**
  43821. * Dispose this controller, the model mesh and all its components
  43822. */
  43823. dispose(): void;
  43824. }
  43825. }
  43826. declare module BABYLON {
  43827. /**
  43828. * A generic trigger-only motion controller for WebXR
  43829. */
  43830. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43831. /**
  43832. * Static version of the profile id of this controller
  43833. */
  43834. static ProfileId: string;
  43835. profileId: string;
  43836. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43837. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43838. protected _updateModel(): void;
  43839. protected _getFilenameAndPath(): {
  43840. filename: string;
  43841. path: string;
  43842. };
  43843. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43844. protected _getModelLoadingConstraints(): boolean;
  43845. }
  43846. }
  43847. declare module BABYLON {
  43848. /**
  43849. * Class containing static functions to help procedurally build meshes
  43850. */
  43851. export class SphereBuilder {
  43852. /**
  43853. * Creates a sphere mesh
  43854. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43855. * * 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`)
  43856. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43857. * * 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
  43858. * * 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)
  43859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43860. * * 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
  43861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43862. * @param name defines the name of the mesh
  43863. * @param options defines the options used to create the mesh
  43864. * @param scene defines the hosting scene
  43865. * @returns the sphere mesh
  43866. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43867. */
  43868. static CreateSphere(name: string, options: {
  43869. segments?: number;
  43870. diameter?: number;
  43871. diameterX?: number;
  43872. diameterY?: number;
  43873. diameterZ?: number;
  43874. arc?: number;
  43875. slice?: number;
  43876. sideOrientation?: number;
  43877. frontUVs?: Vector4;
  43878. backUVs?: Vector4;
  43879. updatable?: boolean;
  43880. }, scene?: Nullable<Scene>): Mesh;
  43881. }
  43882. }
  43883. declare module BABYLON {
  43884. /**
  43885. * A profiled motion controller has its profile loaded from an online repository.
  43886. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  43887. */
  43888. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  43889. private _repositoryUrl;
  43890. /**
  43891. * The profile ID of this controller. Will be populated when the controller initializes.
  43892. */
  43893. profileId: string;
  43894. private _buttonMeshMapping;
  43895. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  43896. protected _getFilenameAndPath(): {
  43897. filename: string;
  43898. path: string;
  43899. };
  43900. private _touchDots;
  43901. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  43902. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43903. protected _updateModel(_xrFrame: XRFrame): void;
  43904. protected _getModelLoadingConstraints(): boolean;
  43905. dispose(): void;
  43906. }
  43907. }
  43908. declare module BABYLON {
  43909. /**
  43910. * A construction function type to create a new controller based on an xrInput object
  43911. */
  43912. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  43913. /**
  43914. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  43915. *
  43916. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  43917. * it should be replaced with auto-loaded controllers.
  43918. *
  43919. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  43920. */
  43921. export class WebXRMotionControllerManager {
  43922. /**
  43923. * The base URL of the online controller repository. Can be changed at any time.
  43924. */
  43925. static BaseRepositoryUrl: string;
  43926. /**
  43927. * Use the online repository, or use only locally-defined controllers
  43928. */
  43929. static UseOnlineRepository: boolean;
  43930. /**
  43931. * Which repository gets priority - local or online
  43932. */
  43933. static PrioritizeOnlineRepository: boolean;
  43934. private static _AvailableControllers;
  43935. private static _Fallbacks;
  43936. /**
  43937. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  43938. *
  43939. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  43940. *
  43941. * @param type the profile type to register
  43942. * @param constructFunction the function to be called when loading this profile
  43943. */
  43944. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  43945. /**
  43946. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  43947. * The order of search:
  43948. *
  43949. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  43950. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  43951. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  43952. * 4) return the generic trigger controller if none were found
  43953. *
  43954. * @param xrInput the xrInput to which a new controller is initialized
  43955. * @param scene the scene to which the model will be added
  43956. * @param forceProfile force a certain profile for this controller
  43957. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  43958. */
  43959. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  43960. private static _LoadProfilesFromAvailableControllers;
  43961. private static _ProfilesList;
  43962. private static _ProfileLoadingPromises;
  43963. private static _LoadProfileFromRepository;
  43964. /**
  43965. * Clear the cache used for profile loading and reload when requested again
  43966. */
  43967. static ClearProfilesCache(): void;
  43968. /**
  43969. * Will update the list of profiles available in the repository
  43970. * @return a promise that resolves to a map of profiles available online
  43971. */
  43972. static UpdateProfilesList(): Promise<{
  43973. [profile: string]: string;
  43974. }>;
  43975. /**
  43976. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  43977. * @param profileId the profile to which a fallback needs to be found
  43978. * @return an array with corresponding fallback profiles
  43979. */
  43980. static FindFallbackWithProfileId(profileId: string): string[];
  43981. /**
  43982. * Register a fallback to a specific profile.
  43983. * @param profileId the profileId that will receive the fallbacks
  43984. * @param fallbacks A list of fallback profiles
  43985. */
  43986. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  43987. /**
  43988. * Register the default fallbacks.
  43989. * This function is called automatically when this file is imported.
  43990. */
  43991. static DefaultFallbacks(): void;
  43992. }
  43993. }
  43994. declare module BABYLON {
  43995. /**
  43996. * Configuration options for the WebXR controller creation
  43997. */
  43998. export interface IWebXRControllerOptions {
  43999. /**
  44000. * Force a specific controller type for this controller.
  44001. * This can be used when creating your own profile or when testing different controllers
  44002. */
  44003. forceControllerProfile?: string;
  44004. /**
  44005. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44006. */
  44007. doNotLoadControllerMesh?: boolean;
  44008. /**
  44009. * Should the controller mesh be animated when a user interacts with it
  44010. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44011. */
  44012. disableMotionControllerAnimation?: boolean;
  44013. }
  44014. /**
  44015. * Represents an XR controller
  44016. */
  44017. export class WebXRController {
  44018. private _scene;
  44019. /** The underlying input source for the controller */
  44020. inputSource: XRInputSource;
  44021. private _options;
  44022. /**
  44023. * 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
  44024. */
  44025. grip?: AbstractMesh;
  44026. /**
  44027. * Pointer which can be used to select objects or attach a visible laser to
  44028. */
  44029. pointer: AbstractMesh;
  44030. /**
  44031. * If available, this is the gamepad object related to this controller.
  44032. * Using this object it is possible to get click events and trackpad changes of the
  44033. * webxr controller that is currently being used.
  44034. */
  44035. motionController?: WebXRAbstractMotionController;
  44036. /**
  44037. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44038. */
  44039. onMotionControllerProfileLoaded: Observable<WebXRAbstractMotionController>;
  44040. /**
  44041. * Event that fires when the controller is removed/disposed
  44042. */
  44043. onDisposeObservable: Observable<{}>;
  44044. private _tmpQuaternion;
  44045. private _tmpVector;
  44046. private _uniqueId;
  44047. /**
  44048. * Creates the controller
  44049. * @see https://doc.babylonjs.com/how_to/webxr
  44050. * @param _scene the scene which the controller should be associated to
  44051. * @param inputSource the underlying input source for the controller
  44052. * @param _options options for this controller creation
  44053. */
  44054. constructor(_scene: Scene,
  44055. /** The underlying input source for the controller */
  44056. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44057. /**
  44058. * Get this controllers unique id
  44059. */
  44060. get uniqueId(): string;
  44061. /**
  44062. * Updates the controller pose based on the given XRFrame
  44063. * @param xrFrame xr frame to update the pose with
  44064. * @param referenceSpace reference space to use
  44065. */
  44066. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44067. /**
  44068. * Gets a world space ray coming from the controller
  44069. * @param result the resulting ray
  44070. */
  44071. getWorldPointerRayToRef(result: Ray): void;
  44072. /**
  44073. * Disposes of the object
  44074. */
  44075. dispose(): void;
  44076. }
  44077. }
  44078. declare module BABYLON {
  44079. /**
  44080. * The schema for initialization options of the XR Input class
  44081. */
  44082. export interface IWebXRInputOptions {
  44083. /**
  44084. * If set to true no model will be automatically loaded
  44085. */
  44086. doNotLoadControllerMeshes?: boolean;
  44087. /**
  44088. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44089. * If not found, the xr input profile data will be used.
  44090. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44091. */
  44092. forceInputProfile?: string;
  44093. /**
  44094. * Do not send a request to the controlle repository to load the profile.
  44095. *
  44096. * Instead, use the controllers available in babylon itself.
  44097. */
  44098. disableOnlineControllerRepository?: boolean;
  44099. /**
  44100. * A custom URL for the controllers repository
  44101. */
  44102. customControllersRepositoryURL?: string;
  44103. /**
  44104. * Should the controller model's components not move according to the user input
  44105. */
  44106. disableControllerAnimation?: boolean;
  44107. }
  44108. /**
  44109. * XR input used to track XR inputs such as controllers/rays
  44110. */
  44111. export class WebXRInput implements IDisposable {
  44112. /**
  44113. * the xr session manager for this session
  44114. */
  44115. xrSessionManager: WebXRSessionManager;
  44116. /**
  44117. * the WebXR camera for this session. Mainly used for teleportation
  44118. */
  44119. xrCamera: WebXRCamera;
  44120. private readonly options;
  44121. /**
  44122. * XR controllers being tracked
  44123. */
  44124. controllers: Array<WebXRController>;
  44125. private _frameObserver;
  44126. private _sessionEndedObserver;
  44127. private _sessionInitObserver;
  44128. /**
  44129. * Event when a controller has been connected/added
  44130. */
  44131. onControllerAddedObservable: Observable<WebXRController>;
  44132. /**
  44133. * Event when a controller has been removed/disconnected
  44134. */
  44135. onControllerRemovedObservable: Observable<WebXRController>;
  44136. /**
  44137. * Initializes the WebXRInput
  44138. * @param xrSessionManager the xr session manager for this session
  44139. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44140. * @param options = initialization options for this xr input
  44141. */
  44142. constructor(
  44143. /**
  44144. * the xr session manager for this session
  44145. */
  44146. xrSessionManager: WebXRSessionManager,
  44147. /**
  44148. * the WebXR camera for this session. Mainly used for teleportation
  44149. */
  44150. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44151. private _onInputSourcesChange;
  44152. private _addAndRemoveControllers;
  44153. /**
  44154. * Disposes of the object
  44155. */
  44156. dispose(): void;
  44157. }
  44158. }
  44159. declare module BABYLON {
  44160. /**
  44161. * This is the base class for all WebXR features.
  44162. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44163. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44164. */
  44165. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44166. protected _xrSessionManager: WebXRSessionManager;
  44167. /**
  44168. * Construct a new (abstract) webxr feature
  44169. * @param _xrSessionManager the xr session manager for this feature
  44170. */
  44171. constructor(_xrSessionManager: WebXRSessionManager);
  44172. private _attached;
  44173. private _removeOnDetach;
  44174. /**
  44175. * Is this feature attached
  44176. */
  44177. get attached(): boolean;
  44178. /**
  44179. * Should auto-attach be disabled?
  44180. */
  44181. disableAutoAttach: boolean;
  44182. /**
  44183. * attach this feature
  44184. *
  44185. * @param force should attachment be forced (even when already attached)
  44186. * @returns true if successful, false is failed or already attached
  44187. */
  44188. attach(force?: boolean): boolean;
  44189. /**
  44190. * detach this feature.
  44191. *
  44192. * @returns true if successful, false if failed or already detached
  44193. */
  44194. detach(): boolean;
  44195. /**
  44196. * Dispose this feature and all of the resources attached
  44197. */
  44198. dispose(): void;
  44199. /**
  44200. * Code in this function will be executed on each xrFrame received from the browser.
  44201. * This function will not execute after the feature is detached.
  44202. * @param _xrFrame the current frame
  44203. */
  44204. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44205. /**
  44206. * This is used to register callbacks that will automatically be removed when detach is called.
  44207. * @param observable the observable to which the observer will be attached
  44208. * @param callback the callback to register
  44209. */
  44210. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44211. }
  44212. }
  44213. declare module BABYLON {
  44214. /**
  44215. * Options interface for the pointer selection module
  44216. */
  44217. export interface IWebXRControllerPointerSelectionOptions {
  44218. /**
  44219. * the xr input to use with this pointer selection
  44220. */
  44221. xrInput: WebXRInput;
  44222. /**
  44223. * Different button type to use instead of the main component
  44224. */
  44225. overrideButtonId?: string;
  44226. /**
  44227. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44228. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44229. * 3000 means 3 seconds between pointing at something and selecting it
  44230. */
  44231. timeToSelect?: number;
  44232. /**
  44233. * 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)
  44234. * If not disabled, the last picked point will be used to execute a pointer up event
  44235. * If disabled, pointer up event will be triggered right after the pointer down event.
  44236. * Used in screen and gaze target ray mode only
  44237. */
  44238. disablePointerUpOnTouchOut: boolean;
  44239. /**
  44240. * For gaze mode (time to select instead of press)
  44241. */
  44242. forceGazeMode: boolean;
  44243. /**
  44244. * 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
  44245. * to start a new countdown to the pointer down event.
  44246. * Defaults to 1.
  44247. */
  44248. gazeModePointerMovedFactor?: number;
  44249. }
  44250. /**
  44251. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44252. */
  44253. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44254. private readonly _options;
  44255. /**
  44256. * The module's name
  44257. */
  44258. static readonly Name: string;
  44259. /**
  44260. * The (Babylon) version of this module.
  44261. * This is an integer representing the implementation version.
  44262. * This number does not correspond to the webxr specs version
  44263. */
  44264. static readonly Version: number;
  44265. /**
  44266. * This color will be set to the laser pointer when selection is triggered
  44267. */
  44268. laserPointerPickedColor: Color3;
  44269. /**
  44270. * This color will be applied to the selection ring when selection is triggered
  44271. */
  44272. selectionMeshPickedColor: Color3;
  44273. /**
  44274. * default color of the selection ring
  44275. */
  44276. selectionMeshDefaultColor: Color3;
  44277. /**
  44278. * Default color of the laser pointer
  44279. */
  44280. lasterPointerDefaultColor: Color3;
  44281. /**
  44282. * Should the laser pointer be displayed
  44283. */
  44284. displayLaserPointer: boolean;
  44285. /**
  44286. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44287. */
  44288. displaySelectionMesh: boolean;
  44289. /**
  44290. * Disable lighting on the laser pointer (so it will always be visible)
  44291. */
  44292. disablePointerLighting: boolean;
  44293. /**
  44294. * Disable lighting on the selection mesh (so it will always be visible)
  44295. */
  44296. disableSelectionMeshLighting: boolean;
  44297. private static _idCounter;
  44298. private _tmpRay;
  44299. private _controllers;
  44300. private _scene;
  44301. /**
  44302. * constructs a new background remover module
  44303. * @param _xrSessionManager the session manager for this module
  44304. * @param _options read-only options to be used in this module
  44305. */
  44306. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44307. /**
  44308. * attach this feature
  44309. * Will usually be called by the features manager
  44310. *
  44311. * @returns true if successful.
  44312. */
  44313. attach(): boolean;
  44314. /**
  44315. * detach this feature.
  44316. * Will usually be called by the features manager
  44317. *
  44318. * @returns true if successful.
  44319. */
  44320. detach(): boolean;
  44321. /**
  44322. * Get the xr controller that correlates to the pointer id in the pointer event
  44323. *
  44324. * @param id the pointer id to search for
  44325. * @returns the controller that correlates to this id or null if not found
  44326. */
  44327. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  44328. protected _onXRFrame(_xrFrame: XRFrame): void;
  44329. private _attachController;
  44330. private _attachScreenRayMode;
  44331. private _attachGazeMode;
  44332. private _tmpVectorForPickCompare;
  44333. private _pickingMoved;
  44334. private _attachTrackedPointerRayMode;
  44335. private _detachController;
  44336. private _generateNewMeshPair;
  44337. private _convertNormalToDirectionOfRay;
  44338. private _updatePointerDistance;
  44339. }
  44340. }
  44341. declare module BABYLON {
  44342. /**
  44343. * Button which can be used to enter a different mode of XR
  44344. */
  44345. export class WebXREnterExitUIButton {
  44346. /** button element */
  44347. element: HTMLElement;
  44348. /** XR initialization options for the button */
  44349. sessionMode: XRSessionMode;
  44350. /** Reference space type */
  44351. referenceSpaceType: XRReferenceSpaceType;
  44352. /**
  44353. * Creates a WebXREnterExitUIButton
  44354. * @param element button element
  44355. * @param sessionMode XR initialization session mode
  44356. * @param referenceSpaceType the type of reference space to be used
  44357. */
  44358. constructor(
  44359. /** button element */
  44360. element: HTMLElement,
  44361. /** XR initialization options for the button */
  44362. sessionMode: XRSessionMode,
  44363. /** Reference space type */
  44364. referenceSpaceType: XRReferenceSpaceType);
  44365. /**
  44366. * Overwritable function which can be used to update the button's visuals when the state changes
  44367. * @param activeButton the current active button in the UI
  44368. */
  44369. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44370. }
  44371. /**
  44372. * Options to create the webXR UI
  44373. */
  44374. export class WebXREnterExitUIOptions {
  44375. /**
  44376. * Context to enter xr with
  44377. */
  44378. renderTarget?: Nullable<WebXRRenderTarget>;
  44379. /**
  44380. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44381. */
  44382. customButtons?: Array<WebXREnterExitUIButton>;
  44383. /**
  44384. * A session mode to use when creating the default button.
  44385. * Default is immersive-vr
  44386. */
  44387. sessionMode?: XRSessionMode;
  44388. /**
  44389. * A reference space type to use when creating the default button.
  44390. * Default is local-floor
  44391. */
  44392. referenceSpaceType?: XRReferenceSpaceType;
  44393. }
  44394. /**
  44395. * UI to allow the user to enter/exit XR mode
  44396. */
  44397. export class WebXREnterExitUI implements IDisposable {
  44398. private scene;
  44399. /** version of the options passed to this UI */
  44400. options: WebXREnterExitUIOptions;
  44401. private _overlay;
  44402. private _buttons;
  44403. private _activeButton;
  44404. /**
  44405. * Fired every time the active button is changed.
  44406. *
  44407. * When xr is entered via a button that launches xr that button will be the callback parameter
  44408. *
  44409. * When exiting xr the callback parameter will be null)
  44410. */
  44411. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44412. /**
  44413. * Creates UI to allow the user to enter/exit XR mode
  44414. * @param scene the scene to add the ui to
  44415. * @param helper the xr experience helper to enter/exit xr with
  44416. * @param options options to configure the UI
  44417. * @returns the created ui
  44418. */
  44419. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44420. /**
  44421. *
  44422. * @param scene babylon scene object to use
  44423. * @param options (read-only) version of the options passed to this UI
  44424. */
  44425. private constructor();
  44426. private _updateButtons;
  44427. /**
  44428. * Disposes of the object
  44429. */
  44430. dispose(): void;
  44431. }
  44432. }
  44433. declare module BABYLON {
  44434. /**
  44435. * Class containing static functions to help procedurally build meshes
  44436. */
  44437. export class LinesBuilder {
  44438. /**
  44439. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44440. * * 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
  44441. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44442. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44443. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44444. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44445. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44446. * * 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
  44447. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44450. * @param name defines the name of the new line system
  44451. * @param options defines the options used to create the line system
  44452. * @param scene defines the hosting scene
  44453. * @returns a new line system mesh
  44454. */
  44455. static CreateLineSystem(name: string, options: {
  44456. lines: Vector3[][];
  44457. updatable?: boolean;
  44458. instance?: Nullable<LinesMesh>;
  44459. colors?: Nullable<Color4[][]>;
  44460. useVertexAlpha?: boolean;
  44461. }, scene: Nullable<Scene>): LinesMesh;
  44462. /**
  44463. * Creates a line mesh
  44464. * 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
  44465. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44466. * * The parameter `points` is an array successive Vector3
  44467. * * 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
  44468. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44469. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44470. * * When updating an instance, remember that only point positions can change, not the number of points
  44471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44473. * @param name defines the name of the new line system
  44474. * @param options defines the options used to create the line system
  44475. * @param scene defines the hosting scene
  44476. * @returns a new line mesh
  44477. */
  44478. static CreateLines(name: string, options: {
  44479. points: Vector3[];
  44480. updatable?: boolean;
  44481. instance?: Nullable<LinesMesh>;
  44482. colors?: Color4[];
  44483. useVertexAlpha?: boolean;
  44484. }, scene?: Nullable<Scene>): LinesMesh;
  44485. /**
  44486. * Creates a dashed line mesh
  44487. * * 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
  44488. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44489. * * The parameter `points` is an array successive Vector3
  44490. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44491. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44492. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44493. * * 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
  44494. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44495. * * When updating an instance, remember that only point positions can change, not the number of points
  44496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44497. * @param name defines the name of the mesh
  44498. * @param options defines the options used to create the mesh
  44499. * @param scene defines the hosting scene
  44500. * @returns the dashed line mesh
  44501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44502. */
  44503. static CreateDashedLines(name: string, options: {
  44504. points: Vector3[];
  44505. dashSize?: number;
  44506. gapSize?: number;
  44507. dashNb?: number;
  44508. updatable?: boolean;
  44509. instance?: LinesMesh;
  44510. useVertexAlpha?: boolean;
  44511. }, scene?: Nullable<Scene>): LinesMesh;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * The options container for the teleportation module
  44517. */
  44518. export interface IWebXRTeleportationOptions {
  44519. /**
  44520. * Babylon XR Input class for controller
  44521. */
  44522. xrInput: WebXRInput;
  44523. /**
  44524. * A list of meshes to use as floor meshes.
  44525. * Meshes can be added and removed after initializing the feature using the
  44526. * addFloorMesh and removeFloorMesh functions
  44527. * If empty, rotation will still work
  44528. */
  44529. floorMeshes?: AbstractMesh[];
  44530. /**
  44531. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44532. * If you want to support rotation, make sure your mesh has a direction indicator.
  44533. *
  44534. * When left untouched, the default mesh will be initialized.
  44535. */
  44536. teleportationTargetMesh?: AbstractMesh;
  44537. /**
  44538. * Values to configure the default target mesh
  44539. */
  44540. defaultTargetMeshOptions?: {
  44541. /**
  44542. * Fill color of the teleportation area
  44543. */
  44544. teleportationFillColor?: string;
  44545. /**
  44546. * Border color for the teleportation area
  44547. */
  44548. teleportationBorderColor?: string;
  44549. /**
  44550. * Disable the mesh's animation sequence
  44551. */
  44552. disableAnimation?: boolean;
  44553. /**
  44554. * Disable lighting on the material or the ring and arrow
  44555. */
  44556. disableLighting?: boolean;
  44557. /**
  44558. * Override the default material of the torus and arrow
  44559. */
  44560. torusArrowMaterial?: Material;
  44561. };
  44562. /**
  44563. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44564. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44565. */
  44566. useMainComponentOnly?: boolean;
  44567. /**
  44568. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44569. */
  44570. timeToTeleport?: number;
  44571. }
  44572. /**
  44573. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44574. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44575. * the input of the attached controllers.
  44576. */
  44577. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44578. private _options;
  44579. /**
  44580. * The module's name
  44581. */
  44582. static readonly Name: string;
  44583. /**
  44584. * The (Babylon) version of this module.
  44585. * This is an integer representing the implementation version.
  44586. * This number does not correspond to the webxr specs version
  44587. */
  44588. static readonly Version: number;
  44589. /**
  44590. * Is rotation enabled when moving forward?
  44591. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44592. */
  44593. rotationEnabled: boolean;
  44594. /**
  44595. * Should the module support parabolic ray on top of direct ray
  44596. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44597. * Very helpful when moving between floors / different heights
  44598. */
  44599. parabolicRayEnabled: boolean;
  44600. /**
  44601. * The distance from the user to the inspection point in the direction of the controller
  44602. * A higher number will allow the user to move further
  44603. * defaults to 5 (meters, in xr units)
  44604. */
  44605. parabolicCheckRadius: number;
  44606. /**
  44607. * How much rotation should be applied when rotating right and left
  44608. */
  44609. rotationAngle: number;
  44610. /**
  44611. * Is movement backwards enabled
  44612. */
  44613. backwardsMovementEnabled: boolean;
  44614. /**
  44615. * Distance to travel when moving backwards
  44616. */
  44617. backwardsTeleportationDistance: number;
  44618. /**
  44619. * Add a new mesh to the floor meshes array
  44620. * @param mesh the mesh to use as floor mesh
  44621. */
  44622. addFloorMesh(mesh: AbstractMesh): void;
  44623. /**
  44624. * Remove a mesh from the floor meshes array
  44625. * @param mesh the mesh to remove
  44626. */
  44627. removeFloorMesh(mesh: AbstractMesh): void;
  44628. /**
  44629. * Remove a mesh from the floor meshes array using its name
  44630. * @param name the mesh name to remove
  44631. */
  44632. removeFloorMeshByName(name: string): void;
  44633. private _tmpRay;
  44634. private _tmpVector;
  44635. private _floorMeshes;
  44636. private _controllers;
  44637. /**
  44638. * constructs a new anchor system
  44639. * @param _xrSessionManager an instance of WebXRSessionManager
  44640. * @param _options configuration object for this feature
  44641. */
  44642. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44643. private _selectionFeature;
  44644. /**
  44645. * This function sets a selection feature that will be disabled when
  44646. * the forward ray is shown and will be reattached when hidden.
  44647. * This is used to remove the selection rays when moving.
  44648. * @param selectionFeature the feature to disable when forward movement is enabled
  44649. */
  44650. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44651. attach(): boolean;
  44652. detach(): boolean;
  44653. dispose(): void;
  44654. protected _onXRFrame(_xrFrame: XRFrame): void;
  44655. private _currentTeleportationControllerId;
  44656. private _attachController;
  44657. private _teleportForward;
  44658. private _detachController;
  44659. private createDefaultTargetMesh;
  44660. private setTargetMeshVisibility;
  44661. private setTargetMeshPosition;
  44662. private _quadraticBezierCurve;
  44663. private showParabolicPath;
  44664. }
  44665. }
  44666. declare module BABYLON {
  44667. /**
  44668. * Options for the default xr helper
  44669. */
  44670. export class WebXRDefaultExperienceOptions {
  44671. /**
  44672. * Floor meshes that will be used for teleporting
  44673. */
  44674. floorMeshes?: Array<AbstractMesh>;
  44675. /**
  44676. * Enable or disable default UI to enter XR
  44677. */
  44678. disableDefaultUI?: boolean;
  44679. /**
  44680. * optional configuration for the output canvas
  44681. */
  44682. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44683. /**
  44684. * optional UI options. This can be used among other to change session mode and reference space type
  44685. */
  44686. uiOptions?: WebXREnterExitUIOptions;
  44687. /**
  44688. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44689. */
  44690. inputOptions?: IWebXRInputOptions;
  44691. /**
  44692. * Should teleportation not initialize. defaults to false.
  44693. */
  44694. disableTeleportation?: boolean;
  44695. /**
  44696. * If set to true, the first frame will not be used to reset position
  44697. * The first frame is mainly used when copying transformation from the old camera
  44698. * Mainly used in AR
  44699. */
  44700. ignoreNativeCameraTransformation?: boolean;
  44701. }
  44702. /**
  44703. * Default experience which provides a similar setup to the previous webVRExperience
  44704. */
  44705. export class WebXRDefaultExperience {
  44706. /**
  44707. * Base experience
  44708. */
  44709. baseExperience: WebXRExperienceHelper;
  44710. /**
  44711. * Input experience extension
  44712. */
  44713. input: WebXRInput;
  44714. /**
  44715. * Enables laser pointer and selection
  44716. */
  44717. pointerSelection: WebXRControllerPointerSelection;
  44718. /**
  44719. * Enables teleportation
  44720. */
  44721. teleportation: WebXRMotionControllerTeleportation;
  44722. /**
  44723. * Enables ui for entering/exiting xr
  44724. */
  44725. enterExitUI: WebXREnterExitUI;
  44726. /**
  44727. * Default target xr should render to
  44728. */
  44729. renderTarget: WebXRRenderTarget;
  44730. /**
  44731. * Creates the default xr experience
  44732. * @param scene scene
  44733. * @param options options for basic configuration
  44734. * @returns resulting WebXRDefaultExperience
  44735. */
  44736. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44737. private constructor();
  44738. /**
  44739. * DIsposes of the experience helper
  44740. */
  44741. dispose(): void;
  44742. }
  44743. }
  44744. declare module BABYLON {
  44745. /**
  44746. * Options to modify the vr teleportation behavior.
  44747. */
  44748. export interface VRTeleportationOptions {
  44749. /**
  44750. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44751. */
  44752. floorMeshName?: string;
  44753. /**
  44754. * A list of meshes to be used as the teleportation floor. (default: empty)
  44755. */
  44756. floorMeshes?: Mesh[];
  44757. /**
  44758. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44759. */
  44760. teleportationMode?: number;
  44761. /**
  44762. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44763. */
  44764. teleportationTime?: number;
  44765. /**
  44766. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44767. */
  44768. teleportationSpeed?: number;
  44769. /**
  44770. * The easing function used in the animation or null for Linear. (default CircleEase)
  44771. */
  44772. easingFunction?: EasingFunction;
  44773. }
  44774. /**
  44775. * Options to modify the vr experience helper's behavior.
  44776. */
  44777. export interface VRExperienceHelperOptions extends WebVROptions {
  44778. /**
  44779. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44780. */
  44781. createDeviceOrientationCamera?: boolean;
  44782. /**
  44783. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44784. */
  44785. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44786. /**
  44787. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44788. */
  44789. laserToggle?: boolean;
  44790. /**
  44791. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44792. */
  44793. floorMeshes?: Mesh[];
  44794. /**
  44795. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44796. */
  44797. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44798. /**
  44799. * Defines if WebXR should be used instead of WebVR (if available)
  44800. */
  44801. useXR?: boolean;
  44802. }
  44803. /**
  44804. * Event containing information after VR has been entered
  44805. */
  44806. export class OnAfterEnteringVRObservableEvent {
  44807. /**
  44808. * If entering vr was successful
  44809. */
  44810. success: boolean;
  44811. }
  44812. /**
  44813. * Helps to quickly add VR support to an existing scene.
  44814. * See http://doc.babylonjs.com/how_to/webvr_helper
  44815. */
  44816. export class VRExperienceHelper {
  44817. /** Options to modify the vr experience helper's behavior. */
  44818. webVROptions: VRExperienceHelperOptions;
  44819. private _scene;
  44820. private _position;
  44821. private _btnVR;
  44822. private _btnVRDisplayed;
  44823. private _webVRsupported;
  44824. private _webVRready;
  44825. private _webVRrequesting;
  44826. private _webVRpresenting;
  44827. private _hasEnteredVR;
  44828. private _fullscreenVRpresenting;
  44829. private _inputElement;
  44830. private _webVRCamera;
  44831. private _vrDeviceOrientationCamera;
  44832. private _deviceOrientationCamera;
  44833. private _existingCamera;
  44834. private _onKeyDown;
  44835. private _onVrDisplayPresentChange;
  44836. private _onVRDisplayChanged;
  44837. private _onVRRequestPresentStart;
  44838. private _onVRRequestPresentComplete;
  44839. /**
  44840. * 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)
  44841. */
  44842. enableGazeEvenWhenNoPointerLock: boolean;
  44843. /**
  44844. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44845. */
  44846. exitVROnDoubleTap: boolean;
  44847. /**
  44848. * Observable raised right before entering VR.
  44849. */
  44850. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44851. /**
  44852. * Observable raised when entering VR has completed.
  44853. */
  44854. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44855. /**
  44856. * Observable raised when exiting VR.
  44857. */
  44858. onExitingVRObservable: Observable<VRExperienceHelper>;
  44859. /**
  44860. * Observable raised when controller mesh is loaded.
  44861. */
  44862. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44863. /** Return this.onEnteringVRObservable
  44864. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44865. */
  44866. get onEnteringVR(): Observable<VRExperienceHelper>;
  44867. /** Return this.onExitingVRObservable
  44868. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44869. */
  44870. get onExitingVR(): Observable<VRExperienceHelper>;
  44871. /** Return this.onControllerMeshLoadedObservable
  44872. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44873. */
  44874. get onControllerMeshLoaded(): Observable<WebVRController>;
  44875. private _rayLength;
  44876. private _useCustomVRButton;
  44877. private _teleportationRequested;
  44878. private _teleportActive;
  44879. private _floorMeshName;
  44880. private _floorMeshesCollection;
  44881. private _teleportationMode;
  44882. private _teleportationTime;
  44883. private _teleportationSpeed;
  44884. private _teleportationEasing;
  44885. private _rotationAllowed;
  44886. private _teleportBackwardsVector;
  44887. private _teleportationTarget;
  44888. private _isDefaultTeleportationTarget;
  44889. private _postProcessMove;
  44890. private _teleportationFillColor;
  44891. private _teleportationBorderColor;
  44892. private _rotationAngle;
  44893. private _haloCenter;
  44894. private _cameraGazer;
  44895. private _padSensibilityUp;
  44896. private _padSensibilityDown;
  44897. private _leftController;
  44898. private _rightController;
  44899. private _gazeColor;
  44900. private _laserColor;
  44901. private _pickedLaserColor;
  44902. private _pickedGazeColor;
  44903. /**
  44904. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44905. */
  44906. onNewMeshSelected: Observable<AbstractMesh>;
  44907. /**
  44908. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44909. * This observable will provide the mesh and the controller used to select the mesh
  44910. */
  44911. onMeshSelectedWithController: Observable<{
  44912. mesh: AbstractMesh;
  44913. controller: WebVRController;
  44914. }>;
  44915. /**
  44916. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44917. */
  44918. onNewMeshPicked: Observable<PickingInfo>;
  44919. private _circleEase;
  44920. /**
  44921. * Observable raised before camera teleportation
  44922. */
  44923. onBeforeCameraTeleport: Observable<Vector3>;
  44924. /**
  44925. * Observable raised after camera teleportation
  44926. */
  44927. onAfterCameraTeleport: Observable<Vector3>;
  44928. /**
  44929. * Observable raised when current selected mesh gets unselected
  44930. */
  44931. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44932. private _raySelectionPredicate;
  44933. /**
  44934. * To be optionaly changed by user to define custom ray selection
  44935. */
  44936. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44937. /**
  44938. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44939. */
  44940. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44941. /**
  44942. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44943. */
  44944. teleportationEnabled: boolean;
  44945. private _defaultHeight;
  44946. private _teleportationInitialized;
  44947. private _interactionsEnabled;
  44948. private _interactionsRequested;
  44949. private _displayGaze;
  44950. private _displayLaserPointer;
  44951. /**
  44952. * The mesh used to display where the user is going to teleport.
  44953. */
  44954. get teleportationTarget(): Mesh;
  44955. /**
  44956. * Sets the mesh to be used to display where the user is going to teleport.
  44957. */
  44958. set teleportationTarget(value: Mesh);
  44959. /**
  44960. * 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
  44961. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44962. * See http://doc.babylonjs.com/resources/baking_transformations
  44963. */
  44964. get gazeTrackerMesh(): Mesh;
  44965. set gazeTrackerMesh(value: Mesh);
  44966. /**
  44967. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44968. */
  44969. updateGazeTrackerScale: boolean;
  44970. /**
  44971. * If the gaze trackers color should be updated when selecting meshes
  44972. */
  44973. updateGazeTrackerColor: boolean;
  44974. /**
  44975. * If the controller laser color should be updated when selecting meshes
  44976. */
  44977. updateControllerLaserColor: boolean;
  44978. /**
  44979. * The gaze tracking mesh corresponding to the left controller
  44980. */
  44981. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44982. /**
  44983. * The gaze tracking mesh corresponding to the right controller
  44984. */
  44985. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44986. /**
  44987. * If the ray of the gaze should be displayed.
  44988. */
  44989. get displayGaze(): boolean;
  44990. /**
  44991. * Sets if the ray of the gaze should be displayed.
  44992. */
  44993. set displayGaze(value: boolean);
  44994. /**
  44995. * If the ray of the LaserPointer should be displayed.
  44996. */
  44997. get displayLaserPointer(): boolean;
  44998. /**
  44999. * Sets if the ray of the LaserPointer should be displayed.
  45000. */
  45001. set displayLaserPointer(value: boolean);
  45002. /**
  45003. * The deviceOrientationCamera used as the camera when not in VR.
  45004. */
  45005. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45006. /**
  45007. * Based on the current WebVR support, returns the current VR camera used.
  45008. */
  45009. get currentVRCamera(): Nullable<Camera>;
  45010. /**
  45011. * The webVRCamera which is used when in VR.
  45012. */
  45013. get webVRCamera(): WebVRFreeCamera;
  45014. /**
  45015. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45016. */
  45017. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45018. /**
  45019. * The html button that is used to trigger entering into VR.
  45020. */
  45021. get vrButton(): Nullable<HTMLButtonElement>;
  45022. private get _teleportationRequestInitiated();
  45023. /**
  45024. * Defines wether or not Pointer lock should be requested when switching to
  45025. * full screen.
  45026. */
  45027. requestPointerLockOnFullScreen: boolean;
  45028. /**
  45029. * If asking to force XR, this will be populated with the default xr experience
  45030. */
  45031. xr: WebXRDefaultExperience;
  45032. /**
  45033. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45034. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45035. */
  45036. xrTestDone: boolean;
  45037. /**
  45038. * Instantiates a VRExperienceHelper.
  45039. * Helps to quickly add VR support to an existing scene.
  45040. * @param scene The scene the VRExperienceHelper belongs to.
  45041. * @param webVROptions Options to modify the vr experience helper's behavior.
  45042. */
  45043. constructor(scene: Scene,
  45044. /** Options to modify the vr experience helper's behavior. */
  45045. webVROptions?: VRExperienceHelperOptions);
  45046. private completeVRInit;
  45047. private _onDefaultMeshLoaded;
  45048. private _onResize;
  45049. private _onFullscreenChange;
  45050. /**
  45051. * Gets a value indicating if we are currently in VR mode.
  45052. */
  45053. get isInVRMode(): boolean;
  45054. private onVrDisplayPresentChange;
  45055. private onVRDisplayChanged;
  45056. private moveButtonToBottomRight;
  45057. private displayVRButton;
  45058. private updateButtonVisibility;
  45059. private _cachedAngularSensibility;
  45060. /**
  45061. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45062. * Otherwise, will use the fullscreen API.
  45063. */
  45064. enterVR(): void;
  45065. /**
  45066. * Attempt to exit VR, or fullscreen.
  45067. */
  45068. exitVR(): void;
  45069. /**
  45070. * The position of the vr experience helper.
  45071. */
  45072. get position(): Vector3;
  45073. /**
  45074. * Sets the position of the vr experience helper.
  45075. */
  45076. set position(value: Vector3);
  45077. /**
  45078. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45079. */
  45080. enableInteractions(): void;
  45081. private get _noControllerIsActive();
  45082. private beforeRender;
  45083. private _isTeleportationFloor;
  45084. /**
  45085. * Adds a floor mesh to be used for teleportation.
  45086. * @param floorMesh the mesh to be used for teleportation.
  45087. */
  45088. addFloorMesh(floorMesh: Mesh): void;
  45089. /**
  45090. * Removes a floor mesh from being used for teleportation.
  45091. * @param floorMesh the mesh to be removed.
  45092. */
  45093. removeFloorMesh(floorMesh: Mesh): void;
  45094. /**
  45095. * Enables interactions and teleportation using the VR controllers and gaze.
  45096. * @param vrTeleportationOptions options to modify teleportation behavior.
  45097. */
  45098. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45099. private _onNewGamepadConnected;
  45100. private _tryEnableInteractionOnController;
  45101. private _onNewGamepadDisconnected;
  45102. private _enableInteractionOnController;
  45103. private _checkTeleportWithRay;
  45104. private _checkRotate;
  45105. private _checkTeleportBackwards;
  45106. private _enableTeleportationOnController;
  45107. private _createTeleportationCircles;
  45108. private _displayTeleportationTarget;
  45109. private _hideTeleportationTarget;
  45110. private _rotateCamera;
  45111. private _moveTeleportationSelectorTo;
  45112. private _workingVector;
  45113. private _workingQuaternion;
  45114. private _workingMatrix;
  45115. /**
  45116. * Time Constant Teleportation Mode
  45117. */
  45118. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45119. /**
  45120. * Speed Constant Teleportation Mode
  45121. */
  45122. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45123. /**
  45124. * Teleports the users feet to the desired location
  45125. * @param location The location where the user's feet should be placed
  45126. */
  45127. teleportCamera(location: Vector3): void;
  45128. private _convertNormalToDirectionOfRay;
  45129. private _castRayAndSelectObject;
  45130. private _notifySelectedMeshUnselected;
  45131. /**
  45132. * Permanently set new colors for the laser pointer
  45133. * @param color the new laser color
  45134. * @param pickedColor the new laser color when picked mesh detected
  45135. */
  45136. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45137. /**
  45138. * Set lighting enabled / disabled on the laser pointer of both controllers
  45139. * @param enabled should the lighting be enabled on the laser pointer
  45140. */
  45141. setLaserLightingState(enabled?: boolean): void;
  45142. /**
  45143. * Permanently set new colors for the gaze pointer
  45144. * @param color the new gaze color
  45145. * @param pickedColor the new gaze color when picked mesh detected
  45146. */
  45147. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45148. /**
  45149. * Sets the color of the laser ray from the vr controllers.
  45150. * @param color new color for the ray.
  45151. */
  45152. changeLaserColor(color: Color3): void;
  45153. /**
  45154. * Sets the color of the ray from the vr headsets gaze.
  45155. * @param color new color for the ray.
  45156. */
  45157. changeGazeColor(color: Color3): void;
  45158. /**
  45159. * Exits VR and disposes of the vr experience helper
  45160. */
  45161. dispose(): void;
  45162. /**
  45163. * Gets the name of the VRExperienceHelper class
  45164. * @returns "VRExperienceHelper"
  45165. */
  45166. getClassName(): string;
  45167. }
  45168. }
  45169. declare module BABYLON {
  45170. /**
  45171. * Options used for hit testing
  45172. */
  45173. export interface IWebXRHitTestOptions {
  45174. /**
  45175. * Only test when user interacted with the scene. Default - hit test every frame
  45176. */
  45177. testOnPointerDownOnly?: boolean;
  45178. /**
  45179. * The node to use to transform the local results to world coordinates
  45180. */
  45181. worldParentNode?: TransformNode;
  45182. }
  45183. /**
  45184. * Interface defining the babylon result of raycasting/hit-test
  45185. */
  45186. export interface IWebXRHitResult {
  45187. /**
  45188. * The native hit test result
  45189. */
  45190. xrHitResult: XRHitResult;
  45191. /**
  45192. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45193. */
  45194. transformationMatrix: Matrix;
  45195. }
  45196. /**
  45197. * The currently-working hit-test module.
  45198. * Hit test (or raycasting) is used to interact with the real world.
  45199. * For further information read here - https://github.com/immersive-web/hit-test
  45200. */
  45201. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  45202. /**
  45203. * options to use when constructing this feature
  45204. */
  45205. readonly options: IWebXRHitTestOptions;
  45206. /**
  45207. * The module's name
  45208. */
  45209. static readonly Name: string;
  45210. /**
  45211. * The (Babylon) version of this module.
  45212. * This is an integer representing the implementation version.
  45213. * This number does not correspond to the webxr specs version
  45214. */
  45215. static readonly Version: number;
  45216. /**
  45217. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45218. * @param event the (select) event to use to select with
  45219. * @param referenceSpace the reference space to use for this hit test
  45220. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45221. */
  45222. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45223. /**
  45224. * execute a hit test with an XR Ray
  45225. *
  45226. * @param xrSession a native xrSession that will execute this hit test
  45227. * @param xrRay the ray (position and direction) to use for raycasting
  45228. * @param referenceSpace native XR reference space to use for the hit-test
  45229. * @param filter filter function that will filter the results
  45230. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45231. */
  45232. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45233. /**
  45234. * Triggered when new babylon (transformed) hit test results are available
  45235. */
  45236. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45237. private _onSelectEnabled;
  45238. /**
  45239. * Creates a new instance of the (legacy version) hit test feature
  45240. * @param _xrSessionManager an instance of WebXRSessionManager
  45241. * @param options options to use when constructing this feature
  45242. */
  45243. constructor(_xrSessionManager: WebXRSessionManager,
  45244. /**
  45245. * options to use when constructing this feature
  45246. */
  45247. options?: IWebXRHitTestOptions);
  45248. /**
  45249. * Populated with the last native XR Hit Results
  45250. */
  45251. lastNativeXRHitResults: XRHitResult[];
  45252. /**
  45253. * attach this feature
  45254. * Will usually be called by the features manager
  45255. *
  45256. * @returns true if successful.
  45257. */
  45258. attach(): boolean;
  45259. /**
  45260. * detach this feature.
  45261. * Will usually be called by the features manager
  45262. *
  45263. * @returns true if successful.
  45264. */
  45265. detach(): boolean;
  45266. private _onHitTestResults;
  45267. private _origin;
  45268. private _direction;
  45269. private _mat;
  45270. protected _onXRFrame(frame: XRFrame): void;
  45271. private _onSelect;
  45272. /**
  45273. * Dispose this feature and all of the resources attached
  45274. */
  45275. dispose(): void;
  45276. }
  45277. }
  45278. declare module BABYLON {
  45279. /**
  45280. * Options used in the plane detector module
  45281. */
  45282. export interface IWebXRPlaneDetectorOptions {
  45283. /**
  45284. * The node to use to transform the local results to world coordinates
  45285. */
  45286. worldParentNode?: TransformNode;
  45287. }
  45288. /**
  45289. * A babylon interface for a webxr plane.
  45290. * A Plane is actually a polygon, built from N points in space
  45291. *
  45292. * Supported in chrome 79, not supported in canary 81 ATM
  45293. */
  45294. export interface IWebXRPlane {
  45295. /**
  45296. * a babylon-assigned ID for this polygon
  45297. */
  45298. id: number;
  45299. /**
  45300. * the native xr-plane object
  45301. */
  45302. xrPlane: XRPlane;
  45303. /**
  45304. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45305. */
  45306. polygonDefinition: Array<Vector3>;
  45307. /**
  45308. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45309. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45310. */
  45311. transformationMatrix: Matrix;
  45312. }
  45313. /**
  45314. * The plane detector is used to detect planes in the real world when in AR
  45315. * For more information see https://github.com/immersive-web/real-world-geometry/
  45316. */
  45317. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  45318. private _options;
  45319. /**
  45320. * The module's name
  45321. */
  45322. static readonly Name: string;
  45323. /**
  45324. * The (Babylon) version of this module.
  45325. * This is an integer representing the implementation version.
  45326. * This number does not correspond to the webxr specs version
  45327. */
  45328. static readonly Version: number;
  45329. /**
  45330. * Observers registered here will be executed when a new plane was added to the session
  45331. */
  45332. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45333. /**
  45334. * Observers registered here will be executed when a plane is no longer detected in the session
  45335. */
  45336. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45337. /**
  45338. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45339. * This can execute N times every frame
  45340. */
  45341. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45342. private _enabled;
  45343. private _detectedPlanes;
  45344. private _lastFrameDetected;
  45345. /**
  45346. * construct a new Plane Detector
  45347. * @param _xrSessionManager an instance of xr Session manager
  45348. * @param _options configuration to use when constructing this feature
  45349. */
  45350. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45351. private _init;
  45352. protected _onXRFrame(frame: XRFrame): void;
  45353. /**
  45354. * Dispose this feature and all of the resources attached
  45355. */
  45356. dispose(): void;
  45357. private _updatePlaneWithXRPlane;
  45358. /**
  45359. * avoiding using Array.find for global support.
  45360. * @param xrPlane the plane to find in the array
  45361. */
  45362. private findIndexInPlaneArray;
  45363. }
  45364. }
  45365. declare module BABYLON {
  45366. /**
  45367. * Configuration options of the anchor system
  45368. */
  45369. export interface IWebXRAnchorSystemOptions {
  45370. /**
  45371. * a node that will be used to convert local to world coordinates
  45372. */
  45373. worldParentNode?: TransformNode;
  45374. /**
  45375. * should the anchor system use plane detection.
  45376. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45377. */
  45378. usePlaneDetection?: boolean;
  45379. /**
  45380. * Should a new anchor be added every time a select event is triggered
  45381. */
  45382. addAnchorOnSelect?: boolean;
  45383. }
  45384. /**
  45385. * A babylon container for an XR Anchor
  45386. */
  45387. export interface IWebXRAnchor {
  45388. /**
  45389. * A babylon-assigned ID for this anchor
  45390. */
  45391. id: number;
  45392. /**
  45393. * The native anchor object
  45394. */
  45395. xrAnchor: XRAnchor;
  45396. /**
  45397. * Transformation matrix to apply to an object attached to this anchor
  45398. */
  45399. transformationMatrix: Matrix;
  45400. }
  45401. /**
  45402. * An implementation of the anchor system of WebXR.
  45403. * Note that the current documented implementation is not available in any browser. Future implementations
  45404. * will use the frame to create an anchor and not the session or a detected plane
  45405. * For further information see https://github.com/immersive-web/anchors/
  45406. */
  45407. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  45408. private _options;
  45409. /**
  45410. * The module's name
  45411. */
  45412. static readonly Name: string;
  45413. /**
  45414. * The (Babylon) version of this module.
  45415. * This is an integer representing the implementation version.
  45416. * This number does not correspond to the webxr specs version
  45417. */
  45418. static readonly Version: number;
  45419. /**
  45420. * Observers registered here will be executed when a new anchor was added to the session
  45421. */
  45422. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45423. /**
  45424. * Observers registered here will be executed when an existing anchor updates
  45425. * This can execute N times every frame
  45426. */
  45427. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45428. /**
  45429. * Observers registered here will be executed when an anchor was removed from the session
  45430. */
  45431. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45432. private _planeDetector;
  45433. private _hitTestModule;
  45434. private _enabled;
  45435. private _trackedAnchors;
  45436. private _lastFrameDetected;
  45437. /**
  45438. * constructs a new anchor system
  45439. * @param _xrSessionManager an instance of WebXRSessionManager
  45440. * @param _options configuration object for this feature
  45441. */
  45442. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45443. /**
  45444. * set the plane detector to use in order to create anchors from frames
  45445. * @param planeDetector the plane-detector module to use
  45446. * @param enable enable plane-anchors. default is true
  45447. */
  45448. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45449. /**
  45450. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  45451. * @param hitTestModule the hit-test module to use.
  45452. */
  45453. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  45454. /**
  45455. * attach this feature
  45456. * Will usually be called by the features manager
  45457. *
  45458. * @returns true if successful.
  45459. */
  45460. attach(): boolean;
  45461. /**
  45462. * detach this feature.
  45463. * Will usually be called by the features manager
  45464. *
  45465. * @returns true if successful.
  45466. */
  45467. detach(): boolean;
  45468. /**
  45469. * Dispose this feature and all of the resources attached
  45470. */
  45471. dispose(): void;
  45472. protected _onXRFrame(frame: XRFrame): void;
  45473. private _onSelect;
  45474. /**
  45475. * Add anchor at a specific XR point.
  45476. *
  45477. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  45478. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  45479. * @returns a promise the fulfills when the anchor was created
  45480. */
  45481. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  45482. private _updateAnchorWithXRFrame;
  45483. /**
  45484. * avoiding using Array.find for global support.
  45485. * @param xrAnchor the plane to find in the array
  45486. */
  45487. private _findIndexInAnchorArray;
  45488. }
  45489. }
  45490. declare module BABYLON {
  45491. /**
  45492. * Options interface for the background remover plugin
  45493. */
  45494. export interface IWebXRBackgroundRemoverOptions {
  45495. /**
  45496. * don't disable the environment helper
  45497. */
  45498. ignoreEnvironmentHelper?: boolean;
  45499. /**
  45500. * flags to configure the removal of the environment helper.
  45501. * If not set, the entire background will be removed. If set, flags should be set as well.
  45502. */
  45503. environmentHelperRemovalFlags?: {
  45504. /**
  45505. * Should the skybox be removed (default false)
  45506. */
  45507. skyBox?: boolean;
  45508. /**
  45509. * Should the ground be removed (default false)
  45510. */
  45511. ground?: boolean;
  45512. };
  45513. /**
  45514. * Further background meshes to disable when entering AR
  45515. */
  45516. backgroundMeshes?: AbstractMesh[];
  45517. }
  45518. /**
  45519. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  45520. */
  45521. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  45522. /**
  45523. * read-only options to be used in this module
  45524. */
  45525. readonly options: IWebXRBackgroundRemoverOptions;
  45526. /**
  45527. * The module's name
  45528. */
  45529. static readonly Name: string;
  45530. /**
  45531. * The (Babylon) version of this module.
  45532. * This is an integer representing the implementation version.
  45533. * This number does not correspond to the webxr specs version
  45534. */
  45535. static readonly Version: number;
  45536. /**
  45537. * registered observers will be triggered when the background state changes
  45538. */
  45539. onBackgroundStateChangedObservable: Observable<boolean>;
  45540. /**
  45541. * constructs a new background remover module
  45542. * @param _xrSessionManager the session manager for this module
  45543. * @param options read-only options to be used in this module
  45544. */
  45545. constructor(_xrSessionManager: WebXRSessionManager,
  45546. /**
  45547. * read-only options to be used in this module
  45548. */
  45549. options?: IWebXRBackgroundRemoverOptions);
  45550. /**
  45551. * attach this feature
  45552. * Will usually be called by the features manager
  45553. *
  45554. * @returns true if successful.
  45555. */
  45556. attach(): boolean;
  45557. /**
  45558. * detach this feature.
  45559. * Will usually be called by the features manager
  45560. *
  45561. * @returns true if successful.
  45562. */
  45563. detach(): boolean;
  45564. private _setBackgroundState;
  45565. /**
  45566. * Dispose this feature and all of the resources attached
  45567. */
  45568. dispose(): void;
  45569. protected _onXRFrame(_xrFrame: XRFrame): void;
  45570. }
  45571. }
  45572. declare module BABYLON {
  45573. /**
  45574. * The motion controller class for all microsoft mixed reality controllers
  45575. */
  45576. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  45577. /**
  45578. * The base url used to load the left and right controller models
  45579. */
  45580. static MODEL_BASE_URL: string;
  45581. /**
  45582. * The name of the left controller model file
  45583. */
  45584. static MODEL_LEFT_FILENAME: string;
  45585. /**
  45586. * The name of the right controller model file
  45587. */
  45588. static MODEL_RIGHT_FILENAME: string;
  45589. profileId: string;
  45590. protected readonly _mapping: {
  45591. defaultButton: {
  45592. "valueNodeName": string;
  45593. "unpressedNodeName": string;
  45594. "pressedNodeName": string;
  45595. };
  45596. defaultAxis: {
  45597. "valueNodeName": string;
  45598. "minNodeName": string;
  45599. "maxNodeName": string;
  45600. };
  45601. buttons: {
  45602. "xr-standard-trigger": {
  45603. "rootNodeName": string;
  45604. "componentProperty": string;
  45605. "states": string[];
  45606. };
  45607. "xr-standard-squeeze": {
  45608. "rootNodeName": string;
  45609. "componentProperty": string;
  45610. "states": string[];
  45611. };
  45612. "xr-standard-touchpad": {
  45613. "rootNodeName": string;
  45614. "labelAnchorNodeName": string;
  45615. "touchPointNodeName": string;
  45616. };
  45617. "xr-standard-thumbstick": {
  45618. "rootNodeName": string;
  45619. "componentProperty": string;
  45620. "states": string[];
  45621. };
  45622. };
  45623. axes: {
  45624. "xr-standard-touchpad": {
  45625. "x-axis": {
  45626. "rootNodeName": string;
  45627. };
  45628. "y-axis": {
  45629. "rootNodeName": string;
  45630. };
  45631. };
  45632. "xr-standard-thumbstick": {
  45633. "x-axis": {
  45634. "rootNodeName": string;
  45635. };
  45636. "y-axis": {
  45637. "rootNodeName": string;
  45638. };
  45639. };
  45640. };
  45641. };
  45642. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45643. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45644. protected _getFilenameAndPath(): {
  45645. filename: string;
  45646. path: string;
  45647. };
  45648. protected _updateModel(): void;
  45649. protected _getModelLoadingConstraints(): boolean;
  45650. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45651. }
  45652. }
  45653. declare module BABYLON {
  45654. /**
  45655. * The motion controller class for oculus touch (quest, rift).
  45656. * This class supports legacy mapping as well the standard xr mapping
  45657. */
  45658. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  45659. private _forceLegacyControllers;
  45660. /**
  45661. * The base url used to load the left and right controller models
  45662. */
  45663. static MODEL_BASE_URL: string;
  45664. /**
  45665. * The name of the left controller model file
  45666. */
  45667. static MODEL_LEFT_FILENAME: string;
  45668. /**
  45669. * The name of the right controller model file
  45670. */
  45671. static MODEL_RIGHT_FILENAME: string;
  45672. /**
  45673. * Base Url for the Quest controller model.
  45674. */
  45675. static QUEST_MODEL_BASE_URL: string;
  45676. profileId: string;
  45677. private _modelRootNode;
  45678. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  45679. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45680. protected _getFilenameAndPath(): {
  45681. filename: string;
  45682. path: string;
  45683. };
  45684. /**
  45685. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  45686. * between the touch and touch 2.
  45687. */
  45688. private _isQuest;
  45689. protected _updateModel(): void;
  45690. protected _getModelLoadingConstraints(): boolean;
  45691. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45692. }
  45693. }
  45694. declare module BABYLON {
  45695. /**
  45696. * The motion controller class for the standard HTC-Vive controllers
  45697. */
  45698. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  45699. /**
  45700. * The base url used to load the left and right controller models
  45701. */
  45702. static MODEL_BASE_URL: string;
  45703. /**
  45704. * File name for the controller model.
  45705. */
  45706. static MODEL_FILENAME: string;
  45707. profileId: string;
  45708. private _modelRootNode;
  45709. /**
  45710. * Create a new Vive motion controller object
  45711. * @param scene the scene to use to create this controller
  45712. * @param gamepadObject the corresponding gamepad object
  45713. * @param handness the handness of the controller
  45714. */
  45715. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45716. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45717. protected _getFilenameAndPath(): {
  45718. filename: string;
  45719. path: string;
  45720. };
  45721. protected _updateModel(): void;
  45722. protected _getModelLoadingConstraints(): boolean;
  45723. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45724. }
  45725. }
  45726. declare module BABYLON {
  45727. /**
  45728. * Contains an array of blocks representing the octree
  45729. */
  45730. export interface IOctreeContainer<T> {
  45731. /**
  45732. * Blocks within the octree
  45733. */
  45734. blocks: Array<OctreeBlock<T>>;
  45735. }
  45736. /**
  45737. * Class used to store a cell in an octree
  45738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45739. */
  45740. export class OctreeBlock<T> {
  45741. /**
  45742. * Gets the content of the current block
  45743. */
  45744. entries: T[];
  45745. /**
  45746. * Gets the list of block children
  45747. */
  45748. blocks: Array<OctreeBlock<T>>;
  45749. private _depth;
  45750. private _maxDepth;
  45751. private _capacity;
  45752. private _minPoint;
  45753. private _maxPoint;
  45754. private _boundingVectors;
  45755. private _creationFunc;
  45756. /**
  45757. * Creates a new block
  45758. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45759. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45760. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45761. * @param depth defines the current depth of this block in the octree
  45762. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45763. * @param creationFunc defines a callback to call when an element is added to the block
  45764. */
  45765. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45766. /**
  45767. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45768. */
  45769. get capacity(): number;
  45770. /**
  45771. * Gets the minimum vector (in world space) of the block's bounding box
  45772. */
  45773. get minPoint(): Vector3;
  45774. /**
  45775. * Gets the maximum vector (in world space) of the block's bounding box
  45776. */
  45777. get maxPoint(): Vector3;
  45778. /**
  45779. * Add a new element to this block
  45780. * @param entry defines the element to add
  45781. */
  45782. addEntry(entry: T): void;
  45783. /**
  45784. * Remove an element from this block
  45785. * @param entry defines the element to remove
  45786. */
  45787. removeEntry(entry: T): void;
  45788. /**
  45789. * Add an array of elements to this block
  45790. * @param entries defines the array of elements to add
  45791. */
  45792. addEntries(entries: T[]): void;
  45793. /**
  45794. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45795. * @param frustumPlanes defines the frustum planes to test
  45796. * @param selection defines the array to store current content if selection is positive
  45797. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45798. */
  45799. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45800. /**
  45801. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45802. * @param sphereCenter defines the bounding sphere center
  45803. * @param sphereRadius defines the bounding sphere radius
  45804. * @param selection defines the array to store current content if selection is positive
  45805. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45806. */
  45807. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45808. /**
  45809. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45810. * @param ray defines the ray to test with
  45811. * @param selection defines the array to store current content if selection is positive
  45812. */
  45813. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45814. /**
  45815. * Subdivide the content into child blocks (this block will then be empty)
  45816. */
  45817. createInnerBlocks(): void;
  45818. /**
  45819. * @hidden
  45820. */
  45821. 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;
  45822. }
  45823. }
  45824. declare module BABYLON {
  45825. /**
  45826. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45827. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45828. */
  45829. export class Octree<T> {
  45830. /** 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.) */
  45831. maxDepth: number;
  45832. /**
  45833. * Blocks within the octree containing objects
  45834. */
  45835. blocks: Array<OctreeBlock<T>>;
  45836. /**
  45837. * Content stored in the octree
  45838. */
  45839. dynamicContent: T[];
  45840. private _maxBlockCapacity;
  45841. private _selectionContent;
  45842. private _creationFunc;
  45843. /**
  45844. * Creates a octree
  45845. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45846. * @param creationFunc function to be used to instatiate the octree
  45847. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45848. * @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.)
  45849. */
  45850. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45851. /** 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.) */
  45852. maxDepth?: number);
  45853. /**
  45854. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45855. * @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);
  45856. * @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);
  45857. * @param entries meshes to be added to the octree blocks
  45858. */
  45859. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45860. /**
  45861. * Adds a mesh to the octree
  45862. * @param entry Mesh to add to the octree
  45863. */
  45864. addMesh(entry: T): void;
  45865. /**
  45866. * Remove an element from the octree
  45867. * @param entry defines the element to remove
  45868. */
  45869. removeMesh(entry: T): void;
  45870. /**
  45871. * Selects an array of meshes within the frustum
  45872. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45873. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45874. * @returns array of meshes within the frustum
  45875. */
  45876. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45877. /**
  45878. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45879. * @param sphereCenter defines the bounding sphere center
  45880. * @param sphereRadius defines the bounding sphere radius
  45881. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45882. * @returns an array of objects that intersect the sphere
  45883. */
  45884. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45885. /**
  45886. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45887. * @param ray defines the ray to test with
  45888. * @returns array of intersected objects
  45889. */
  45890. intersectsRay(ray: Ray): SmartArray<T>;
  45891. /**
  45892. * Adds a mesh into the octree block if it intersects the block
  45893. */
  45894. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45895. /**
  45896. * Adds a submesh into the octree block if it intersects the block
  45897. */
  45898. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45899. }
  45900. }
  45901. declare module BABYLON {
  45902. interface Scene {
  45903. /**
  45904. * @hidden
  45905. * Backing Filed
  45906. */
  45907. _selectionOctree: Octree<AbstractMesh>;
  45908. /**
  45909. * Gets the octree used to boost mesh selection (picking)
  45910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45911. */
  45912. selectionOctree: Octree<AbstractMesh>;
  45913. /**
  45914. * Creates or updates the octree used to boost selection (picking)
  45915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45916. * @param maxCapacity defines the maximum capacity per leaf
  45917. * @param maxDepth defines the maximum depth of the octree
  45918. * @returns an octree of AbstractMesh
  45919. */
  45920. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45921. }
  45922. interface AbstractMesh {
  45923. /**
  45924. * @hidden
  45925. * Backing Field
  45926. */
  45927. _submeshesOctree: Octree<SubMesh>;
  45928. /**
  45929. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45930. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45931. * @param maxCapacity defines the maximum size of each block (64 by default)
  45932. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45933. * @returns the new octree
  45934. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45936. */
  45937. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45938. }
  45939. /**
  45940. * Defines the octree scene component responsible to manage any octrees
  45941. * in a given scene.
  45942. */
  45943. export class OctreeSceneComponent {
  45944. /**
  45945. * The component name help to identify the component in the list of scene components.
  45946. */
  45947. readonly name: string;
  45948. /**
  45949. * The scene the component belongs to.
  45950. */
  45951. scene: Scene;
  45952. /**
  45953. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45954. */
  45955. readonly checksIsEnabled: boolean;
  45956. /**
  45957. * Creates a new instance of the component for the given scene
  45958. * @param scene Defines the scene to register the component in
  45959. */
  45960. constructor(scene: Scene);
  45961. /**
  45962. * Registers the component in a given scene
  45963. */
  45964. register(): void;
  45965. /**
  45966. * Return the list of active meshes
  45967. * @returns the list of active meshes
  45968. */
  45969. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45970. /**
  45971. * Return the list of active sub meshes
  45972. * @param mesh The mesh to get the candidates sub meshes from
  45973. * @returns the list of active sub meshes
  45974. */
  45975. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45976. private _tempRay;
  45977. /**
  45978. * Return the list of sub meshes intersecting with a given local ray
  45979. * @param mesh defines the mesh to find the submesh for
  45980. * @param localRay defines the ray in local space
  45981. * @returns the list of intersecting sub meshes
  45982. */
  45983. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45984. /**
  45985. * Return the list of sub meshes colliding with a collider
  45986. * @param mesh defines the mesh to find the submesh for
  45987. * @param collider defines the collider to evaluate the collision against
  45988. * @returns the list of colliding sub meshes
  45989. */
  45990. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45991. /**
  45992. * Rebuilds the elements related to this component in case of
  45993. * context lost for instance.
  45994. */
  45995. rebuild(): void;
  45996. /**
  45997. * Disposes the component and the associated ressources.
  45998. */
  45999. dispose(): void;
  46000. }
  46001. }
  46002. declare module BABYLON {
  46003. /**
  46004. * Renders a layer on top of an existing scene
  46005. */
  46006. export class UtilityLayerRenderer implements IDisposable {
  46007. /** the original scene that will be rendered on top of */
  46008. originalScene: Scene;
  46009. private _pointerCaptures;
  46010. private _lastPointerEvents;
  46011. private static _DefaultUtilityLayer;
  46012. private static _DefaultKeepDepthUtilityLayer;
  46013. private _sharedGizmoLight;
  46014. private _renderCamera;
  46015. /**
  46016. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46017. * @returns the camera that is used when rendering the utility layer
  46018. */
  46019. getRenderCamera(): Camera;
  46020. /**
  46021. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46022. * @param cam the camera that should be used when rendering the utility layer
  46023. */
  46024. setRenderCamera(cam: Nullable<Camera>): void;
  46025. /**
  46026. * @hidden
  46027. * Light which used by gizmos to get light shading
  46028. */
  46029. _getSharedGizmoLight(): HemisphericLight;
  46030. /**
  46031. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46032. */
  46033. pickUtilitySceneFirst: boolean;
  46034. /**
  46035. * 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)
  46036. */
  46037. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46038. /**
  46039. * 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)
  46040. */
  46041. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46042. /**
  46043. * The scene that is rendered on top of the original scene
  46044. */
  46045. utilityLayerScene: Scene;
  46046. /**
  46047. * If the utility layer should automatically be rendered on top of existing scene
  46048. */
  46049. shouldRender: boolean;
  46050. /**
  46051. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46052. */
  46053. onlyCheckPointerDownEvents: boolean;
  46054. /**
  46055. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46056. */
  46057. processAllEvents: boolean;
  46058. /**
  46059. * Observable raised when the pointer move from the utility layer scene to the main scene
  46060. */
  46061. onPointerOutObservable: Observable<number>;
  46062. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46063. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46064. private _afterRenderObserver;
  46065. private _sceneDisposeObserver;
  46066. private _originalPointerObserver;
  46067. /**
  46068. * Instantiates a UtilityLayerRenderer
  46069. * @param originalScene the original scene that will be rendered on top of
  46070. * @param handleEvents boolean indicating if the utility layer should handle events
  46071. */
  46072. constructor(
  46073. /** the original scene that will be rendered on top of */
  46074. originalScene: Scene, handleEvents?: boolean);
  46075. private _notifyObservers;
  46076. /**
  46077. * Renders the utility layers scene on top of the original scene
  46078. */
  46079. render(): void;
  46080. /**
  46081. * Disposes of the renderer
  46082. */
  46083. dispose(): void;
  46084. private _updateCamera;
  46085. }
  46086. }
  46087. declare module BABYLON {
  46088. /**
  46089. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46090. */
  46091. export class Gizmo implements IDisposable {
  46092. /** The utility layer the gizmo will be added to */
  46093. gizmoLayer: UtilityLayerRenderer;
  46094. /**
  46095. * The root mesh of the gizmo
  46096. */
  46097. _rootMesh: Mesh;
  46098. private _attachedMesh;
  46099. /**
  46100. * Ratio for the scale of the gizmo (Default: 1)
  46101. */
  46102. scaleRatio: number;
  46103. /**
  46104. * If a custom mesh has been set (Default: false)
  46105. */
  46106. protected _customMeshSet: boolean;
  46107. /**
  46108. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46109. * * When set, interactions will be enabled
  46110. */
  46111. get attachedMesh(): Nullable<AbstractMesh>;
  46112. set attachedMesh(value: Nullable<AbstractMesh>);
  46113. /**
  46114. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46115. * @param mesh The mesh to replace the default mesh of the gizmo
  46116. */
  46117. setCustomMesh(mesh: Mesh): void;
  46118. /**
  46119. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46120. */
  46121. updateGizmoRotationToMatchAttachedMesh: boolean;
  46122. /**
  46123. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46124. */
  46125. updateGizmoPositionToMatchAttachedMesh: boolean;
  46126. /**
  46127. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46128. */
  46129. updateScale: boolean;
  46130. protected _interactionsEnabled: boolean;
  46131. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46132. private _beforeRenderObserver;
  46133. private _tempVector;
  46134. /**
  46135. * Creates a gizmo
  46136. * @param gizmoLayer The utility layer the gizmo will be added to
  46137. */
  46138. constructor(
  46139. /** The utility layer the gizmo will be added to */
  46140. gizmoLayer?: UtilityLayerRenderer);
  46141. /**
  46142. * Updates the gizmo to match the attached mesh's position/rotation
  46143. */
  46144. protected _update(): void;
  46145. /**
  46146. * Disposes of the gizmo
  46147. */
  46148. dispose(): void;
  46149. }
  46150. }
  46151. declare module BABYLON {
  46152. /**
  46153. * Single plane drag gizmo
  46154. */
  46155. export class PlaneDragGizmo extends Gizmo {
  46156. /**
  46157. * Drag behavior responsible for the gizmos dragging interactions
  46158. */
  46159. dragBehavior: PointerDragBehavior;
  46160. private _pointerObserver;
  46161. /**
  46162. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46163. */
  46164. snapDistance: number;
  46165. /**
  46166. * Event that fires each time the gizmo snaps to a new location.
  46167. * * snapDistance is the the change in distance
  46168. */
  46169. onSnapObservable: Observable<{
  46170. snapDistance: number;
  46171. }>;
  46172. private _plane;
  46173. private _coloredMaterial;
  46174. private _hoverMaterial;
  46175. private _isEnabled;
  46176. private _parent;
  46177. /** @hidden */
  46178. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46179. /** @hidden */
  46180. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46181. /**
  46182. * Creates a PlaneDragGizmo
  46183. * @param gizmoLayer The utility layer the gizmo will be added to
  46184. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46185. * @param color The color of the gizmo
  46186. */
  46187. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46188. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46189. /**
  46190. * If the gizmo is enabled
  46191. */
  46192. set isEnabled(value: boolean);
  46193. get isEnabled(): boolean;
  46194. /**
  46195. * Disposes of the gizmo
  46196. */
  46197. dispose(): void;
  46198. }
  46199. }
  46200. declare module BABYLON {
  46201. /**
  46202. * Gizmo that enables dragging a mesh along 3 axis
  46203. */
  46204. export class PositionGizmo extends Gizmo {
  46205. /**
  46206. * Internal gizmo used for interactions on the x axis
  46207. */
  46208. xGizmo: AxisDragGizmo;
  46209. /**
  46210. * Internal gizmo used for interactions on the y axis
  46211. */
  46212. yGizmo: AxisDragGizmo;
  46213. /**
  46214. * Internal gizmo used for interactions on the z axis
  46215. */
  46216. zGizmo: AxisDragGizmo;
  46217. /**
  46218. * Internal gizmo used for interactions on the yz plane
  46219. */
  46220. xPlaneGizmo: PlaneDragGizmo;
  46221. /**
  46222. * Internal gizmo used for interactions on the xz plane
  46223. */
  46224. yPlaneGizmo: PlaneDragGizmo;
  46225. /**
  46226. * Internal gizmo used for interactions on the xy plane
  46227. */
  46228. zPlaneGizmo: PlaneDragGizmo;
  46229. /**
  46230. * private variables
  46231. */
  46232. private _meshAttached;
  46233. private _updateGizmoRotationToMatchAttachedMesh;
  46234. private _snapDistance;
  46235. private _scaleRatio;
  46236. /** Fires an event when any of it's sub gizmos are dragged */
  46237. onDragStartObservable: Observable<unknown>;
  46238. /** Fires an event when any of it's sub gizmos are released from dragging */
  46239. onDragEndObservable: Observable<unknown>;
  46240. /**
  46241. * If set to true, planar drag is enabled
  46242. */
  46243. private _planarGizmoEnabled;
  46244. get attachedMesh(): Nullable<AbstractMesh>;
  46245. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46246. /**
  46247. * Creates a PositionGizmo
  46248. * @param gizmoLayer The utility layer the gizmo will be added to
  46249. */
  46250. constructor(gizmoLayer?: UtilityLayerRenderer);
  46251. /**
  46252. * If the planar drag gizmo is enabled
  46253. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46254. */
  46255. set planarGizmoEnabled(value: boolean);
  46256. get planarGizmoEnabled(): boolean;
  46257. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46258. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46259. /**
  46260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46261. */
  46262. set snapDistance(value: number);
  46263. get snapDistance(): number;
  46264. /**
  46265. * Ratio for the scale of the gizmo (Default: 1)
  46266. */
  46267. set scaleRatio(value: number);
  46268. get scaleRatio(): number;
  46269. /**
  46270. * Disposes of the gizmo
  46271. */
  46272. dispose(): void;
  46273. /**
  46274. * CustomMeshes are not supported by this gizmo
  46275. * @param mesh The mesh to replace the default mesh of the gizmo
  46276. */
  46277. setCustomMesh(mesh: Mesh): void;
  46278. }
  46279. }
  46280. declare module BABYLON {
  46281. /**
  46282. * Single axis drag gizmo
  46283. */
  46284. export class AxisDragGizmo extends Gizmo {
  46285. /**
  46286. * Drag behavior responsible for the gizmos dragging interactions
  46287. */
  46288. dragBehavior: PointerDragBehavior;
  46289. private _pointerObserver;
  46290. /**
  46291. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46292. */
  46293. snapDistance: number;
  46294. /**
  46295. * Event that fires each time the gizmo snaps to a new location.
  46296. * * snapDistance is the the change in distance
  46297. */
  46298. onSnapObservable: Observable<{
  46299. snapDistance: number;
  46300. }>;
  46301. private _isEnabled;
  46302. private _parent;
  46303. private _arrow;
  46304. private _coloredMaterial;
  46305. private _hoverMaterial;
  46306. /** @hidden */
  46307. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46308. /** @hidden */
  46309. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46310. /**
  46311. * Creates an AxisDragGizmo
  46312. * @param gizmoLayer The utility layer the gizmo will be added to
  46313. * @param dragAxis The axis which the gizmo will be able to drag on
  46314. * @param color The color of the gizmo
  46315. */
  46316. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46317. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46318. /**
  46319. * If the gizmo is enabled
  46320. */
  46321. set isEnabled(value: boolean);
  46322. get isEnabled(): boolean;
  46323. /**
  46324. * Disposes of the gizmo
  46325. */
  46326. dispose(): void;
  46327. }
  46328. }
  46329. declare module BABYLON.Debug {
  46330. /**
  46331. * The Axes viewer will show 3 axes in a specific point in space
  46332. */
  46333. export class AxesViewer {
  46334. private _xAxis;
  46335. private _yAxis;
  46336. private _zAxis;
  46337. private _scaleLinesFactor;
  46338. private _instanced;
  46339. /**
  46340. * Gets the hosting scene
  46341. */
  46342. scene: Scene;
  46343. /**
  46344. * Gets or sets a number used to scale line length
  46345. */
  46346. scaleLines: number;
  46347. /** Gets the node hierarchy used to render x-axis */
  46348. get xAxis(): TransformNode;
  46349. /** Gets the node hierarchy used to render y-axis */
  46350. get yAxis(): TransformNode;
  46351. /** Gets the node hierarchy used to render z-axis */
  46352. get zAxis(): TransformNode;
  46353. /**
  46354. * Creates a new AxesViewer
  46355. * @param scene defines the hosting scene
  46356. * @param scaleLines defines a number used to scale line length (1 by default)
  46357. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46358. * @param xAxis defines the node hierarchy used to render the x-axis
  46359. * @param yAxis defines the node hierarchy used to render the y-axis
  46360. * @param zAxis defines the node hierarchy used to render the z-axis
  46361. */
  46362. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46363. /**
  46364. * Force the viewer to update
  46365. * @param position defines the position of the viewer
  46366. * @param xaxis defines the x axis of the viewer
  46367. * @param yaxis defines the y axis of the viewer
  46368. * @param zaxis defines the z axis of the viewer
  46369. */
  46370. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46371. /**
  46372. * Creates an instance of this axes viewer.
  46373. * @returns a new axes viewer with instanced meshes
  46374. */
  46375. createInstance(): AxesViewer;
  46376. /** Releases resources */
  46377. dispose(): void;
  46378. private static _SetRenderingGroupId;
  46379. }
  46380. }
  46381. declare module BABYLON.Debug {
  46382. /**
  46383. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46384. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46385. */
  46386. export class BoneAxesViewer extends AxesViewer {
  46387. /**
  46388. * Gets or sets the target mesh where to display the axes viewer
  46389. */
  46390. mesh: Nullable<Mesh>;
  46391. /**
  46392. * Gets or sets the target bone where to display the axes viewer
  46393. */
  46394. bone: Nullable<Bone>;
  46395. /** Gets current position */
  46396. pos: Vector3;
  46397. /** Gets direction of X axis */
  46398. xaxis: Vector3;
  46399. /** Gets direction of Y axis */
  46400. yaxis: Vector3;
  46401. /** Gets direction of Z axis */
  46402. zaxis: Vector3;
  46403. /**
  46404. * Creates a new BoneAxesViewer
  46405. * @param scene defines the hosting scene
  46406. * @param bone defines the target bone
  46407. * @param mesh defines the target mesh
  46408. * @param scaleLines defines a scaling factor for line length (1 by default)
  46409. */
  46410. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46411. /**
  46412. * Force the viewer to update
  46413. */
  46414. update(): void;
  46415. /** Releases resources */
  46416. dispose(): void;
  46417. }
  46418. }
  46419. declare module BABYLON {
  46420. /**
  46421. * Interface used to define scene explorer extensibility option
  46422. */
  46423. export interface IExplorerExtensibilityOption {
  46424. /**
  46425. * Define the option label
  46426. */
  46427. label: string;
  46428. /**
  46429. * Defines the action to execute on click
  46430. */
  46431. action: (entity: any) => void;
  46432. }
  46433. /**
  46434. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46435. */
  46436. export interface IExplorerExtensibilityGroup {
  46437. /**
  46438. * Defines a predicate to test if a given type mut be extended
  46439. */
  46440. predicate: (entity: any) => boolean;
  46441. /**
  46442. * Gets the list of options added to a type
  46443. */
  46444. entries: IExplorerExtensibilityOption[];
  46445. }
  46446. /**
  46447. * Interface used to define the options to use to create the Inspector
  46448. */
  46449. export interface IInspectorOptions {
  46450. /**
  46451. * Display in overlay mode (default: false)
  46452. */
  46453. overlay?: boolean;
  46454. /**
  46455. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46456. */
  46457. globalRoot?: HTMLElement;
  46458. /**
  46459. * Display the Scene explorer
  46460. */
  46461. showExplorer?: boolean;
  46462. /**
  46463. * Display the property inspector
  46464. */
  46465. showInspector?: boolean;
  46466. /**
  46467. * Display in embed mode (both panes on the right)
  46468. */
  46469. embedMode?: boolean;
  46470. /**
  46471. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46472. */
  46473. handleResize?: boolean;
  46474. /**
  46475. * Allow the panes to popup (default: true)
  46476. */
  46477. enablePopup?: boolean;
  46478. /**
  46479. * Allow the panes to be closed by users (default: true)
  46480. */
  46481. enableClose?: boolean;
  46482. /**
  46483. * Optional list of extensibility entries
  46484. */
  46485. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46486. /**
  46487. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46488. */
  46489. inspectorURL?: string;
  46490. /**
  46491. * Optional initial tab (default to DebugLayerTab.Properties)
  46492. */
  46493. initialTab?: DebugLayerTab;
  46494. }
  46495. interface Scene {
  46496. /**
  46497. * @hidden
  46498. * Backing field
  46499. */
  46500. _debugLayer: DebugLayer;
  46501. /**
  46502. * Gets the debug layer (aka Inspector) associated with the scene
  46503. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46504. */
  46505. debugLayer: DebugLayer;
  46506. }
  46507. /**
  46508. * Enum of inspector action tab
  46509. */
  46510. export enum DebugLayerTab {
  46511. /**
  46512. * Properties tag (default)
  46513. */
  46514. Properties = 0,
  46515. /**
  46516. * Debug tab
  46517. */
  46518. Debug = 1,
  46519. /**
  46520. * Statistics tab
  46521. */
  46522. Statistics = 2,
  46523. /**
  46524. * Tools tab
  46525. */
  46526. Tools = 3,
  46527. /**
  46528. * Settings tab
  46529. */
  46530. Settings = 4
  46531. }
  46532. /**
  46533. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46534. * what is happening in your scene
  46535. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46536. */
  46537. export class DebugLayer {
  46538. /**
  46539. * Define the url to get the inspector script from.
  46540. * By default it uses the babylonjs CDN.
  46541. * @ignoreNaming
  46542. */
  46543. static InspectorURL: string;
  46544. private _scene;
  46545. private BJSINSPECTOR;
  46546. private _onPropertyChangedObservable?;
  46547. /**
  46548. * Observable triggered when a property is changed through the inspector.
  46549. */
  46550. get onPropertyChangedObservable(): any;
  46551. /**
  46552. * Instantiates a new debug layer.
  46553. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46554. * what is happening in your scene
  46555. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46556. * @param scene Defines the scene to inspect
  46557. */
  46558. constructor(scene: Scene);
  46559. /** Creates the inspector window. */
  46560. private _createInspector;
  46561. /**
  46562. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46563. * @param entity defines the entity to select
  46564. * @param lineContainerTitle defines the specific block to highlight
  46565. */
  46566. select(entity: any, lineContainerTitle?: string): void;
  46567. /** Get the inspector from bundle or global */
  46568. private _getGlobalInspector;
  46569. /**
  46570. * Get if the inspector is visible or not.
  46571. * @returns true if visible otherwise, false
  46572. */
  46573. isVisible(): boolean;
  46574. /**
  46575. * Hide the inspector and close its window.
  46576. */
  46577. hide(): void;
  46578. /**
  46579. * Launch the debugLayer.
  46580. * @param config Define the configuration of the inspector
  46581. * @return a promise fulfilled when the debug layer is visible
  46582. */
  46583. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46584. }
  46585. }
  46586. declare module BABYLON {
  46587. /**
  46588. * Class containing static functions to help procedurally build meshes
  46589. */
  46590. export class BoxBuilder {
  46591. /**
  46592. * Creates a box mesh
  46593. * * The parameter `size` sets the size (float) of each box side (default 1)
  46594. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46595. * * 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)
  46596. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46598. * * 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
  46599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46600. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46601. * @param name defines the name of the mesh
  46602. * @param options defines the options used to create the mesh
  46603. * @param scene defines the hosting scene
  46604. * @returns the box mesh
  46605. */
  46606. static CreateBox(name: string, options: {
  46607. size?: number;
  46608. width?: number;
  46609. height?: number;
  46610. depth?: number;
  46611. faceUV?: Vector4[];
  46612. faceColors?: Color4[];
  46613. sideOrientation?: number;
  46614. frontUVs?: Vector4;
  46615. backUVs?: Vector4;
  46616. wrap?: boolean;
  46617. topBaseAt?: number;
  46618. bottomBaseAt?: number;
  46619. updatable?: boolean;
  46620. }, scene?: Nullable<Scene>): Mesh;
  46621. }
  46622. }
  46623. declare module BABYLON.Debug {
  46624. /**
  46625. * Used to show the physics impostor around the specific mesh
  46626. */
  46627. export class PhysicsViewer {
  46628. /** @hidden */
  46629. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46630. /** @hidden */
  46631. protected _meshes: Array<Nullable<AbstractMesh>>;
  46632. /** @hidden */
  46633. protected _scene: Nullable<Scene>;
  46634. /** @hidden */
  46635. protected _numMeshes: number;
  46636. /** @hidden */
  46637. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46638. private _renderFunction;
  46639. private _utilityLayer;
  46640. private _debugBoxMesh;
  46641. private _debugSphereMesh;
  46642. private _debugCylinderMesh;
  46643. private _debugMaterial;
  46644. private _debugMeshMeshes;
  46645. /**
  46646. * Creates a new PhysicsViewer
  46647. * @param scene defines the hosting scene
  46648. */
  46649. constructor(scene: Scene);
  46650. /** @hidden */
  46651. protected _updateDebugMeshes(): void;
  46652. /**
  46653. * Renders a specified physic impostor
  46654. * @param impostor defines the impostor to render
  46655. * @param targetMesh defines the mesh represented by the impostor
  46656. * @returns the new debug mesh used to render the impostor
  46657. */
  46658. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46659. /**
  46660. * Hides a specified physic impostor
  46661. * @param impostor defines the impostor to hide
  46662. */
  46663. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46664. private _getDebugMaterial;
  46665. private _getDebugBoxMesh;
  46666. private _getDebugSphereMesh;
  46667. private _getDebugCylinderMesh;
  46668. private _getDebugMeshMesh;
  46669. private _getDebugMesh;
  46670. /** Releases all resources */
  46671. dispose(): void;
  46672. }
  46673. }
  46674. declare module BABYLON {
  46675. /**
  46676. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46677. * in order to better appreciate the issue one might have.
  46678. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46679. */
  46680. export class RayHelper {
  46681. /**
  46682. * Defines the ray we are currently tryin to visualize.
  46683. */
  46684. ray: Nullable<Ray>;
  46685. private _renderPoints;
  46686. private _renderLine;
  46687. private _renderFunction;
  46688. private _scene;
  46689. private _updateToMeshFunction;
  46690. private _attachedToMesh;
  46691. private _meshSpaceDirection;
  46692. private _meshSpaceOrigin;
  46693. /**
  46694. * Helper function to create a colored helper in a scene in one line.
  46695. * @param ray Defines the ray we are currently tryin to visualize
  46696. * @param scene Defines the scene the ray is used in
  46697. * @param color Defines the color we want to see the ray in
  46698. * @returns The newly created ray helper.
  46699. */
  46700. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46701. /**
  46702. * Instantiate a new ray helper.
  46703. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46704. * in order to better appreciate the issue one might have.
  46705. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46706. * @param ray Defines the ray we are currently tryin to visualize
  46707. */
  46708. constructor(ray: Ray);
  46709. /**
  46710. * Shows the ray we are willing to debug.
  46711. * @param scene Defines the scene the ray needs to be rendered in
  46712. * @param color Defines the color the ray needs to be rendered in
  46713. */
  46714. show(scene: Scene, color?: Color3): void;
  46715. /**
  46716. * Hides the ray we are debugging.
  46717. */
  46718. hide(): void;
  46719. private _render;
  46720. /**
  46721. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46722. * @param mesh Defines the mesh we want the helper attached to
  46723. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46724. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46725. * @param length Defines the length of the ray
  46726. */
  46727. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46728. /**
  46729. * Detach the ray helper from the mesh it has previously been attached to.
  46730. */
  46731. detachFromMesh(): void;
  46732. private _updateToMesh;
  46733. /**
  46734. * Dispose the helper and release its associated resources.
  46735. */
  46736. dispose(): void;
  46737. }
  46738. }
  46739. declare module BABYLON.Debug {
  46740. /**
  46741. * Class used to render a debug view of a given skeleton
  46742. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46743. */
  46744. export class SkeletonViewer {
  46745. /** defines the skeleton to render */
  46746. skeleton: Skeleton;
  46747. /** defines the mesh attached to the skeleton */
  46748. mesh: AbstractMesh;
  46749. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46750. autoUpdateBonesMatrices: boolean;
  46751. /** defines the rendering group id to use with the viewer */
  46752. renderingGroupId: number;
  46753. /** Gets or sets the color used to render the skeleton */
  46754. color: Color3;
  46755. private _scene;
  46756. private _debugLines;
  46757. private _debugMesh;
  46758. private _isEnabled;
  46759. private _renderFunction;
  46760. private _utilityLayer;
  46761. /**
  46762. * Returns the mesh used to render the bones
  46763. */
  46764. get debugMesh(): Nullable<LinesMesh>;
  46765. /**
  46766. * Creates a new SkeletonViewer
  46767. * @param skeleton defines the skeleton to render
  46768. * @param mesh defines the mesh attached to the skeleton
  46769. * @param scene defines the hosting scene
  46770. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46771. * @param renderingGroupId defines the rendering group id to use with the viewer
  46772. */
  46773. constructor(
  46774. /** defines the skeleton to render */
  46775. skeleton: Skeleton,
  46776. /** defines the mesh attached to the skeleton */
  46777. mesh: AbstractMesh, scene: Scene,
  46778. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46779. autoUpdateBonesMatrices?: boolean,
  46780. /** defines the rendering group id to use with the viewer */
  46781. renderingGroupId?: number);
  46782. /** Gets or sets a boolean indicating if the viewer is enabled */
  46783. set isEnabled(value: boolean);
  46784. get isEnabled(): boolean;
  46785. private _getBonePosition;
  46786. private _getLinesForBonesWithLength;
  46787. private _getLinesForBonesNoLength;
  46788. /** Update the viewer to sync with current skeleton state */
  46789. update(): void;
  46790. /** Release associated resources */
  46791. dispose(): void;
  46792. }
  46793. }
  46794. declare module BABYLON {
  46795. /**
  46796. * Options to create the null engine
  46797. */
  46798. export class NullEngineOptions {
  46799. /**
  46800. * Render width (Default: 512)
  46801. */
  46802. renderWidth: number;
  46803. /**
  46804. * Render height (Default: 256)
  46805. */
  46806. renderHeight: number;
  46807. /**
  46808. * Texture size (Default: 512)
  46809. */
  46810. textureSize: number;
  46811. /**
  46812. * If delta time between frames should be constant
  46813. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46814. */
  46815. deterministicLockstep: boolean;
  46816. /**
  46817. * Maximum about of steps between frames (Default: 4)
  46818. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46819. */
  46820. lockstepMaxSteps: number;
  46821. }
  46822. /**
  46823. * The null engine class provides support for headless version of babylon.js.
  46824. * This can be used in server side scenario or for testing purposes
  46825. */
  46826. export class NullEngine extends Engine {
  46827. private _options;
  46828. /**
  46829. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46831. * @returns true if engine is in deterministic lock step mode
  46832. */
  46833. isDeterministicLockStep(): boolean;
  46834. /**
  46835. * Gets the max steps when engine is running in deterministic lock step
  46836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46837. * @returns the max steps
  46838. */
  46839. getLockstepMaxSteps(): number;
  46840. /**
  46841. * Gets the current hardware scaling level.
  46842. * By default the hardware scaling level is computed from the window device ratio.
  46843. * 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.
  46844. * @returns a number indicating the current hardware scaling level
  46845. */
  46846. getHardwareScalingLevel(): number;
  46847. constructor(options?: NullEngineOptions);
  46848. /**
  46849. * Creates a vertex buffer
  46850. * @param vertices the data for the vertex buffer
  46851. * @returns the new WebGL static buffer
  46852. */
  46853. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46854. /**
  46855. * Creates a new index buffer
  46856. * @param indices defines the content of the index buffer
  46857. * @param updatable defines if the index buffer must be updatable
  46858. * @returns a new webGL buffer
  46859. */
  46860. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46861. /**
  46862. * Clear the current render buffer or the current render target (if any is set up)
  46863. * @param color defines the color to use
  46864. * @param backBuffer defines if the back buffer must be cleared
  46865. * @param depth defines if the depth buffer must be cleared
  46866. * @param stencil defines if the stencil buffer must be cleared
  46867. */
  46868. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46869. /**
  46870. * Gets the current render width
  46871. * @param useScreen defines if screen size must be used (or the current render target if any)
  46872. * @returns a number defining the current render width
  46873. */
  46874. getRenderWidth(useScreen?: boolean): number;
  46875. /**
  46876. * Gets the current render height
  46877. * @param useScreen defines if screen size must be used (or the current render target if any)
  46878. * @returns a number defining the current render height
  46879. */
  46880. getRenderHeight(useScreen?: boolean): number;
  46881. /**
  46882. * Set the WebGL's viewport
  46883. * @param viewport defines the viewport element to be used
  46884. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46885. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46886. */
  46887. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46888. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46889. /**
  46890. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46891. * @param pipelineContext defines the pipeline context to use
  46892. * @param uniformsNames defines the list of uniform names
  46893. * @returns an array of webGL uniform locations
  46894. */
  46895. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46896. /**
  46897. * Gets the lsit of active attributes for a given webGL program
  46898. * @param pipelineContext defines the pipeline context to use
  46899. * @param attributesNames defines the list of attribute names to get
  46900. * @returns an array of indices indicating the offset of each attribute
  46901. */
  46902. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46903. /**
  46904. * Binds an effect to the webGL context
  46905. * @param effect defines the effect to bind
  46906. */
  46907. bindSamplers(effect: Effect): void;
  46908. /**
  46909. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46910. * @param effect defines the effect to activate
  46911. */
  46912. enableEffect(effect: Effect): void;
  46913. /**
  46914. * Set various states to the webGL context
  46915. * @param culling defines backface culling state
  46916. * @param zOffset defines the value to apply to zOffset (0 by default)
  46917. * @param force defines if states must be applied even if cache is up to date
  46918. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46919. */
  46920. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46921. /**
  46922. * Set the value of an uniform to an array of int32
  46923. * @param uniform defines the webGL uniform location where to store the value
  46924. * @param array defines the array of int32 to store
  46925. */
  46926. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46927. /**
  46928. * Set the value of an uniform to an array of int32 (stored as vec2)
  46929. * @param uniform defines the webGL uniform location where to store the value
  46930. * @param array defines the array of int32 to store
  46931. */
  46932. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46933. /**
  46934. * Set the value of an uniform to an array of int32 (stored as vec3)
  46935. * @param uniform defines the webGL uniform location where to store the value
  46936. * @param array defines the array of int32 to store
  46937. */
  46938. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46939. /**
  46940. * Set the value of an uniform to an array of int32 (stored as vec4)
  46941. * @param uniform defines the webGL uniform location where to store the value
  46942. * @param array defines the array of int32 to store
  46943. */
  46944. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46945. /**
  46946. * Set the value of an uniform to an array of float32
  46947. * @param uniform defines the webGL uniform location where to store the value
  46948. * @param array defines the array of float32 to store
  46949. */
  46950. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46951. /**
  46952. * Set the value of an uniform to an array of float32 (stored as vec2)
  46953. * @param uniform defines the webGL uniform location where to store the value
  46954. * @param array defines the array of float32 to store
  46955. */
  46956. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46957. /**
  46958. * Set the value of an uniform to an array of float32 (stored as vec3)
  46959. * @param uniform defines the webGL uniform location where to store the value
  46960. * @param array defines the array of float32 to store
  46961. */
  46962. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46963. /**
  46964. * Set the value of an uniform to an array of float32 (stored as vec4)
  46965. * @param uniform defines the webGL uniform location where to store the value
  46966. * @param array defines the array of float32 to store
  46967. */
  46968. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46969. /**
  46970. * Set the value of an uniform to an array of number
  46971. * @param uniform defines the webGL uniform location where to store the value
  46972. * @param array defines the array of number to store
  46973. */
  46974. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46975. /**
  46976. * Set the value of an uniform to an array of number (stored as vec2)
  46977. * @param uniform defines the webGL uniform location where to store the value
  46978. * @param array defines the array of number to store
  46979. */
  46980. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46981. /**
  46982. * Set the value of an uniform to an array of number (stored as vec3)
  46983. * @param uniform defines the webGL uniform location where to store the value
  46984. * @param array defines the array of number to store
  46985. */
  46986. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46987. /**
  46988. * Set the value of an uniform to an array of number (stored as vec4)
  46989. * @param uniform defines the webGL uniform location where to store the value
  46990. * @param array defines the array of number to store
  46991. */
  46992. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46993. /**
  46994. * Set the value of an uniform to an array of float32 (stored as matrices)
  46995. * @param uniform defines the webGL uniform location where to store the value
  46996. * @param matrices defines the array of float32 to store
  46997. */
  46998. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46999. /**
  47000. * Set the value of an uniform to a matrix (3x3)
  47001. * @param uniform defines the webGL uniform location where to store the value
  47002. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47003. */
  47004. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47005. /**
  47006. * Set the value of an uniform to a matrix (2x2)
  47007. * @param uniform defines the webGL uniform location where to store the value
  47008. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47009. */
  47010. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47011. /**
  47012. * Set the value of an uniform to a number (float)
  47013. * @param uniform defines the webGL uniform location where to store the value
  47014. * @param value defines the float number to store
  47015. */
  47016. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47017. /**
  47018. * Set the value of an uniform to a vec2
  47019. * @param uniform defines the webGL uniform location where to store the value
  47020. * @param x defines the 1st component of the value
  47021. * @param y defines the 2nd component of the value
  47022. */
  47023. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47024. /**
  47025. * Set the value of an uniform to a vec3
  47026. * @param uniform defines the webGL uniform location where to store the value
  47027. * @param x defines the 1st component of the value
  47028. * @param y defines the 2nd component of the value
  47029. * @param z defines the 3rd component of the value
  47030. */
  47031. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47032. /**
  47033. * Set the value of an uniform to a boolean
  47034. * @param uniform defines the webGL uniform location where to store the value
  47035. * @param bool defines the boolean to store
  47036. */
  47037. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47038. /**
  47039. * Set the value of an uniform to a vec4
  47040. * @param uniform defines the webGL uniform location where to store the value
  47041. * @param x defines the 1st component of the value
  47042. * @param y defines the 2nd component of the value
  47043. * @param z defines the 3rd component of the value
  47044. * @param w defines the 4th component of the value
  47045. */
  47046. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47047. /**
  47048. * Sets the current alpha mode
  47049. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47050. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47051. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47052. */
  47053. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47054. /**
  47055. * Bind webGl buffers directly to the webGL context
  47056. * @param vertexBuffers defines the vertex buffer to bind
  47057. * @param indexBuffer defines the index buffer to bind
  47058. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47059. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47060. * @param effect defines the effect associated with the vertex buffer
  47061. */
  47062. bindBuffers(vertexBuffers: {
  47063. [key: string]: VertexBuffer;
  47064. }, indexBuffer: DataBuffer, effect: Effect): void;
  47065. /**
  47066. * Force the entire cache to be cleared
  47067. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47068. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47069. */
  47070. wipeCaches(bruteForce?: boolean): void;
  47071. /**
  47072. * Send a draw order
  47073. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47074. * @param indexStart defines the starting index
  47075. * @param indexCount defines the number of index to draw
  47076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47077. */
  47078. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47079. /**
  47080. * Draw a list of indexed primitives
  47081. * @param fillMode defines the primitive to use
  47082. * @param indexStart defines the starting index
  47083. * @param indexCount defines the number of index to draw
  47084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47085. */
  47086. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47087. /**
  47088. * Draw a list of unindexed primitives
  47089. * @param fillMode defines the primitive to use
  47090. * @param verticesStart defines the index of first vertex to draw
  47091. * @param verticesCount defines the count of vertices to draw
  47092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47093. */
  47094. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47095. /** @hidden */
  47096. _createTexture(): WebGLTexture;
  47097. /** @hidden */
  47098. _releaseTexture(texture: InternalTexture): void;
  47099. /**
  47100. * Usually called from Texture.ts.
  47101. * Passed information to create a WebGLTexture
  47102. * @param urlArg defines a value which contains one of the following:
  47103. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47104. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47105. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47106. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47107. * @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)
  47108. * @param scene needed for loading to the correct scene
  47109. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47110. * @param onLoad optional callback to be called upon successful completion
  47111. * @param onError optional callback to be called upon failure
  47112. * @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
  47113. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47114. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47115. * @param forcedExtension defines the extension to use to pick the right loader
  47116. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47117. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47118. */
  47119. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  47120. /**
  47121. * Creates a new render target texture
  47122. * @param size defines the size of the texture
  47123. * @param options defines the options used to create the texture
  47124. * @returns a new render target texture stored in an InternalTexture
  47125. */
  47126. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47127. /**
  47128. * Update the sampling mode of a given texture
  47129. * @param samplingMode defines the required sampling mode
  47130. * @param texture defines the texture to update
  47131. */
  47132. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47133. /**
  47134. * Binds the frame buffer to the specified texture.
  47135. * @param texture The texture to render to or null for the default canvas
  47136. * @param faceIndex The face of the texture to render to in case of cube texture
  47137. * @param requiredWidth The width of the target to render to
  47138. * @param requiredHeight The height of the target to render to
  47139. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47140. * @param lodLevel defines le lod level to bind to the frame buffer
  47141. */
  47142. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47143. /**
  47144. * Unbind the current render target texture from the webGL context
  47145. * @param texture defines the render target texture to unbind
  47146. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47147. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47148. */
  47149. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47150. /**
  47151. * Creates a dynamic vertex buffer
  47152. * @param vertices the data for the dynamic vertex buffer
  47153. * @returns the new WebGL dynamic buffer
  47154. */
  47155. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47156. /**
  47157. * Update the content of a dynamic texture
  47158. * @param texture defines the texture to update
  47159. * @param canvas defines the canvas containing the source
  47160. * @param invertY defines if data must be stored with Y axis inverted
  47161. * @param premulAlpha defines if alpha is stored as premultiplied
  47162. * @param format defines the format of the data
  47163. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47164. */
  47165. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47166. /**
  47167. * Gets a boolean indicating if all created effects are ready
  47168. * @returns true if all effects are ready
  47169. */
  47170. areAllEffectsReady(): boolean;
  47171. /**
  47172. * @hidden
  47173. * Get the current error code of the webGL context
  47174. * @returns the error code
  47175. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47176. */
  47177. getError(): number;
  47178. /** @hidden */
  47179. _getUnpackAlignement(): number;
  47180. /** @hidden */
  47181. _unpackFlipY(value: boolean): void;
  47182. /**
  47183. * Update a dynamic index buffer
  47184. * @param indexBuffer defines the target index buffer
  47185. * @param indices defines the data to update
  47186. * @param offset defines the offset in the target index buffer where update should start
  47187. */
  47188. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47189. /**
  47190. * Updates a dynamic vertex buffer.
  47191. * @param vertexBuffer the vertex buffer to update
  47192. * @param vertices the data used to update the vertex buffer
  47193. * @param byteOffset the byte offset of the data (optional)
  47194. * @param byteLength the byte length of the data (optional)
  47195. */
  47196. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47197. /** @hidden */
  47198. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47199. /** @hidden */
  47200. _bindTexture(channel: number, texture: InternalTexture): void;
  47201. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47202. /**
  47203. * 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
  47204. */
  47205. releaseEffects(): void;
  47206. displayLoadingUI(): void;
  47207. hideLoadingUI(): void;
  47208. /** @hidden */
  47209. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47210. /** @hidden */
  47211. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47212. /** @hidden */
  47213. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47214. /** @hidden */
  47215. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47216. }
  47217. }
  47218. declare module BABYLON {
  47219. /** @hidden */
  47220. export class _OcclusionDataStorage {
  47221. /** @hidden */
  47222. occlusionInternalRetryCounter: number;
  47223. /** @hidden */
  47224. isOcclusionQueryInProgress: boolean;
  47225. /** @hidden */
  47226. isOccluded: boolean;
  47227. /** @hidden */
  47228. occlusionRetryCount: number;
  47229. /** @hidden */
  47230. occlusionType: number;
  47231. /** @hidden */
  47232. occlusionQueryAlgorithmType: number;
  47233. }
  47234. interface Engine {
  47235. /**
  47236. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47237. * @return the new query
  47238. */
  47239. createQuery(): WebGLQuery;
  47240. /**
  47241. * Delete and release a webGL query
  47242. * @param query defines the query to delete
  47243. * @return the current engine
  47244. */
  47245. deleteQuery(query: WebGLQuery): Engine;
  47246. /**
  47247. * Check if a given query has resolved and got its value
  47248. * @param query defines the query to check
  47249. * @returns true if the query got its value
  47250. */
  47251. isQueryResultAvailable(query: WebGLQuery): boolean;
  47252. /**
  47253. * Gets the value of a given query
  47254. * @param query defines the query to check
  47255. * @returns the value of the query
  47256. */
  47257. getQueryResult(query: WebGLQuery): number;
  47258. /**
  47259. * Initiates an occlusion query
  47260. * @param algorithmType defines the algorithm to use
  47261. * @param query defines the query to use
  47262. * @returns the current engine
  47263. * @see http://doc.babylonjs.com/features/occlusionquery
  47264. */
  47265. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47266. /**
  47267. * Ends an occlusion query
  47268. * @see http://doc.babylonjs.com/features/occlusionquery
  47269. * @param algorithmType defines the algorithm to use
  47270. * @returns the current engine
  47271. */
  47272. endOcclusionQuery(algorithmType: number): Engine;
  47273. /**
  47274. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47275. * Please note that only one query can be issued at a time
  47276. * @returns a time token used to track the time span
  47277. */
  47278. startTimeQuery(): Nullable<_TimeToken>;
  47279. /**
  47280. * Ends a time query
  47281. * @param token defines the token used to measure the time span
  47282. * @returns the time spent (in ns)
  47283. */
  47284. endTimeQuery(token: _TimeToken): int;
  47285. /** @hidden */
  47286. _currentNonTimestampToken: Nullable<_TimeToken>;
  47287. /** @hidden */
  47288. _createTimeQuery(): WebGLQuery;
  47289. /** @hidden */
  47290. _deleteTimeQuery(query: WebGLQuery): void;
  47291. /** @hidden */
  47292. _getGlAlgorithmType(algorithmType: number): number;
  47293. /** @hidden */
  47294. _getTimeQueryResult(query: WebGLQuery): any;
  47295. /** @hidden */
  47296. _getTimeQueryAvailability(query: WebGLQuery): any;
  47297. }
  47298. interface AbstractMesh {
  47299. /**
  47300. * Backing filed
  47301. * @hidden
  47302. */
  47303. __occlusionDataStorage: _OcclusionDataStorage;
  47304. /**
  47305. * Access property
  47306. * @hidden
  47307. */
  47308. _occlusionDataStorage: _OcclusionDataStorage;
  47309. /**
  47310. * 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.
  47311. * The default value is -1 which means don't break the query and wait till the result
  47312. * @see http://doc.babylonjs.com/features/occlusionquery
  47313. */
  47314. occlusionRetryCount: number;
  47315. /**
  47316. * 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:
  47317. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47318. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47319. * * 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.
  47320. * @see http://doc.babylonjs.com/features/occlusionquery
  47321. */
  47322. occlusionType: number;
  47323. /**
  47324. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47325. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47326. * * 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.
  47327. * @see http://doc.babylonjs.com/features/occlusionquery
  47328. */
  47329. occlusionQueryAlgorithmType: number;
  47330. /**
  47331. * 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
  47332. * @see http://doc.babylonjs.com/features/occlusionquery
  47333. */
  47334. isOccluded: boolean;
  47335. /**
  47336. * Flag to check the progress status of the query
  47337. * @see http://doc.babylonjs.com/features/occlusionquery
  47338. */
  47339. isOcclusionQueryInProgress: boolean;
  47340. }
  47341. }
  47342. declare module BABYLON {
  47343. /** @hidden */
  47344. export var _forceTransformFeedbackToBundle: boolean;
  47345. interface Engine {
  47346. /**
  47347. * Creates a webGL transform feedback object
  47348. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47349. * @returns the webGL transform feedback object
  47350. */
  47351. createTransformFeedback(): WebGLTransformFeedback;
  47352. /**
  47353. * Delete a webGL transform feedback object
  47354. * @param value defines the webGL transform feedback object to delete
  47355. */
  47356. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47357. /**
  47358. * Bind a webGL transform feedback object to the webgl context
  47359. * @param value defines the webGL transform feedback object to bind
  47360. */
  47361. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47362. /**
  47363. * Begins a transform feedback operation
  47364. * @param usePoints defines if points or triangles must be used
  47365. */
  47366. beginTransformFeedback(usePoints: boolean): void;
  47367. /**
  47368. * Ends a transform feedback operation
  47369. */
  47370. endTransformFeedback(): void;
  47371. /**
  47372. * Specify the varyings to use with transform feedback
  47373. * @param program defines the associated webGL program
  47374. * @param value defines the list of strings representing the varying names
  47375. */
  47376. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47377. /**
  47378. * Bind a webGL buffer for a transform feedback operation
  47379. * @param value defines the webGL buffer to bind
  47380. */
  47381. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47382. }
  47383. }
  47384. declare module BABYLON {
  47385. /**
  47386. * Creation options of the multi render target texture.
  47387. */
  47388. export interface IMultiRenderTargetOptions {
  47389. /**
  47390. * Define if the texture needs to create mip maps after render.
  47391. */
  47392. generateMipMaps?: boolean;
  47393. /**
  47394. * Define the types of all the draw buffers we want to create
  47395. */
  47396. types?: number[];
  47397. /**
  47398. * Define the sampling modes of all the draw buffers we want to create
  47399. */
  47400. samplingModes?: number[];
  47401. /**
  47402. * Define if a depth buffer is required
  47403. */
  47404. generateDepthBuffer?: boolean;
  47405. /**
  47406. * Define if a stencil buffer is required
  47407. */
  47408. generateStencilBuffer?: boolean;
  47409. /**
  47410. * Define if a depth texture is required instead of a depth buffer
  47411. */
  47412. generateDepthTexture?: boolean;
  47413. /**
  47414. * Define the number of desired draw buffers
  47415. */
  47416. textureCount?: number;
  47417. /**
  47418. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47419. */
  47420. doNotChangeAspectRatio?: boolean;
  47421. /**
  47422. * Define the default type of the buffers we are creating
  47423. */
  47424. defaultType?: number;
  47425. }
  47426. /**
  47427. * A multi render target, like a render target provides the ability to render to a texture.
  47428. * Unlike the render target, it can render to several draw buffers in one draw.
  47429. * This is specially interesting in deferred rendering or for any effects requiring more than
  47430. * just one color from a single pass.
  47431. */
  47432. export class MultiRenderTarget extends RenderTargetTexture {
  47433. private _internalTextures;
  47434. private _textures;
  47435. private _multiRenderTargetOptions;
  47436. /**
  47437. * Get if draw buffers are currently supported by the used hardware and browser.
  47438. */
  47439. get isSupported(): boolean;
  47440. /**
  47441. * Get the list of textures generated by the multi render target.
  47442. */
  47443. get textures(): Texture[];
  47444. /**
  47445. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47446. */
  47447. get depthTexture(): Texture;
  47448. /**
  47449. * Set the wrapping mode on U of all the textures we are rendering to.
  47450. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47451. */
  47452. set wrapU(wrap: number);
  47453. /**
  47454. * Set the wrapping mode on V of all the textures we are rendering to.
  47455. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47456. */
  47457. set wrapV(wrap: number);
  47458. /**
  47459. * Instantiate a new multi render target texture.
  47460. * A multi render target, like a render target provides the ability to render to a texture.
  47461. * Unlike the render target, it can render to several draw buffers in one draw.
  47462. * This is specially interesting in deferred rendering or for any effects requiring more than
  47463. * just one color from a single pass.
  47464. * @param name Define the name of the texture
  47465. * @param size Define the size of the buffers to render to
  47466. * @param count Define the number of target we are rendering into
  47467. * @param scene Define the scene the texture belongs to
  47468. * @param options Define the options used to create the multi render target
  47469. */
  47470. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47471. /** @hidden */
  47472. _rebuild(): void;
  47473. private _createInternalTextures;
  47474. private _createTextures;
  47475. /**
  47476. * Define the number of samples used if MSAA is enabled.
  47477. */
  47478. get samples(): number;
  47479. set samples(value: number);
  47480. /**
  47481. * Resize all the textures in the multi render target.
  47482. * Be carrefull as it will recreate all the data in the new texture.
  47483. * @param size Define the new size
  47484. */
  47485. resize(size: any): void;
  47486. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47487. /**
  47488. * Dispose the render targets and their associated resources
  47489. */
  47490. dispose(): void;
  47491. /**
  47492. * Release all the underlying texture used as draw buffers.
  47493. */
  47494. releaseInternalTextures(): void;
  47495. }
  47496. }
  47497. declare module BABYLON {
  47498. interface ThinEngine {
  47499. /**
  47500. * Unbind a list of render target textures from the webGL context
  47501. * This is used only when drawBuffer extension or webGL2 are active
  47502. * @param textures defines the render target textures to unbind
  47503. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47504. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47505. */
  47506. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47507. /**
  47508. * Create a multi render target texture
  47509. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47510. * @param size defines the size of the texture
  47511. * @param options defines the creation options
  47512. * @returns the cube texture as an InternalTexture
  47513. */
  47514. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47515. /**
  47516. * Update the sample count for a given multiple render target texture
  47517. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47518. * @param textures defines the textures to update
  47519. * @param samples defines the sample count to set
  47520. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47521. */
  47522. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47523. }
  47524. }
  47525. declare module BABYLON {
  47526. /**
  47527. * Class used to define an additional view for the engine
  47528. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47529. */
  47530. export class EngineView {
  47531. /** Defines the canvas where to render the view */
  47532. target: HTMLCanvasElement;
  47533. /** Defines an optional camera used to render the view (will use active camera else) */
  47534. camera?: Camera;
  47535. }
  47536. interface Engine {
  47537. /**
  47538. * Gets or sets the HTML element to use for attaching events
  47539. */
  47540. inputElement: Nullable<HTMLElement>;
  47541. /**
  47542. * Gets the current engine view
  47543. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47544. */
  47545. activeView: Nullable<EngineView>;
  47546. /** Gets or sets the list of views */
  47547. views: EngineView[];
  47548. /**
  47549. * Register a new child canvas
  47550. * @param canvas defines the canvas to register
  47551. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47552. * @returns the associated view
  47553. */
  47554. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47555. /**
  47556. * Remove a registered child canvas
  47557. * @param canvas defines the canvas to remove
  47558. * @returns the current engine
  47559. */
  47560. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47561. }
  47562. }
  47563. declare module BABYLON {
  47564. /**
  47565. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47566. */
  47567. export interface CubeMapInfo {
  47568. /**
  47569. * The pixel array for the front face.
  47570. * This is stored in format, left to right, up to down format.
  47571. */
  47572. front: Nullable<ArrayBufferView>;
  47573. /**
  47574. * The pixel array for the back face.
  47575. * This is stored in format, left to right, up to down format.
  47576. */
  47577. back: Nullable<ArrayBufferView>;
  47578. /**
  47579. * The pixel array for the left face.
  47580. * This is stored in format, left to right, up to down format.
  47581. */
  47582. left: Nullable<ArrayBufferView>;
  47583. /**
  47584. * The pixel array for the right face.
  47585. * This is stored in format, left to right, up to down format.
  47586. */
  47587. right: Nullable<ArrayBufferView>;
  47588. /**
  47589. * The pixel array for the up face.
  47590. * This is stored in format, left to right, up to down format.
  47591. */
  47592. up: Nullable<ArrayBufferView>;
  47593. /**
  47594. * The pixel array for the down face.
  47595. * This is stored in format, left to right, up to down format.
  47596. */
  47597. down: Nullable<ArrayBufferView>;
  47598. /**
  47599. * The size of the cubemap stored.
  47600. *
  47601. * Each faces will be size * size pixels.
  47602. */
  47603. size: number;
  47604. /**
  47605. * The format of the texture.
  47606. *
  47607. * RGBA, RGB.
  47608. */
  47609. format: number;
  47610. /**
  47611. * The type of the texture data.
  47612. *
  47613. * UNSIGNED_INT, FLOAT.
  47614. */
  47615. type: number;
  47616. /**
  47617. * Specifies whether the texture is in gamma space.
  47618. */
  47619. gammaSpace: boolean;
  47620. }
  47621. /**
  47622. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47623. */
  47624. export class PanoramaToCubeMapTools {
  47625. private static FACE_FRONT;
  47626. private static FACE_BACK;
  47627. private static FACE_RIGHT;
  47628. private static FACE_LEFT;
  47629. private static FACE_DOWN;
  47630. private static FACE_UP;
  47631. /**
  47632. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47633. *
  47634. * @param float32Array The source data.
  47635. * @param inputWidth The width of the input panorama.
  47636. * @param inputHeight The height of the input panorama.
  47637. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47638. * @return The cubemap data
  47639. */
  47640. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47641. private static CreateCubemapTexture;
  47642. private static CalcProjectionSpherical;
  47643. }
  47644. }
  47645. declare module BABYLON {
  47646. /**
  47647. * Helper class dealing with the extraction of spherical polynomial dataArray
  47648. * from a cube map.
  47649. */
  47650. export class CubeMapToSphericalPolynomialTools {
  47651. private static FileFaces;
  47652. /**
  47653. * Converts a texture to the according Spherical Polynomial data.
  47654. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47655. *
  47656. * @param texture The texture to extract the information from.
  47657. * @return The Spherical Polynomial data.
  47658. */
  47659. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47660. /**
  47661. * Converts a cubemap to the according Spherical Polynomial data.
  47662. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47663. *
  47664. * @param cubeInfo The Cube map to extract the information from.
  47665. * @return The Spherical Polynomial data.
  47666. */
  47667. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47668. }
  47669. }
  47670. declare module BABYLON {
  47671. interface BaseTexture {
  47672. /**
  47673. * Get the polynomial representation of the texture data.
  47674. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47675. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47676. */
  47677. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47678. }
  47679. }
  47680. declare module BABYLON {
  47681. /** @hidden */
  47682. export var rgbdEncodePixelShader: {
  47683. name: string;
  47684. shader: string;
  47685. };
  47686. }
  47687. declare module BABYLON {
  47688. /** @hidden */
  47689. export var rgbdDecodePixelShader: {
  47690. name: string;
  47691. shader: string;
  47692. };
  47693. }
  47694. declare module BABYLON {
  47695. /**
  47696. * Raw texture data and descriptor sufficient for WebGL texture upload
  47697. */
  47698. export interface EnvironmentTextureInfo {
  47699. /**
  47700. * Version of the environment map
  47701. */
  47702. version: number;
  47703. /**
  47704. * Width of image
  47705. */
  47706. width: number;
  47707. /**
  47708. * Irradiance information stored in the file.
  47709. */
  47710. irradiance: any;
  47711. /**
  47712. * Specular information stored in the file.
  47713. */
  47714. specular: any;
  47715. }
  47716. /**
  47717. * Defines One Image in the file. It requires only the position in the file
  47718. * as well as the length.
  47719. */
  47720. interface BufferImageData {
  47721. /**
  47722. * Length of the image data.
  47723. */
  47724. length: number;
  47725. /**
  47726. * Position of the data from the null terminator delimiting the end of the JSON.
  47727. */
  47728. position: number;
  47729. }
  47730. /**
  47731. * Defines the specular data enclosed in the file.
  47732. * This corresponds to the version 1 of the data.
  47733. */
  47734. export interface EnvironmentTextureSpecularInfoV1 {
  47735. /**
  47736. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47737. */
  47738. specularDataPosition?: number;
  47739. /**
  47740. * This contains all the images data needed to reconstruct the cubemap.
  47741. */
  47742. mipmaps: Array<BufferImageData>;
  47743. /**
  47744. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47745. */
  47746. lodGenerationScale: number;
  47747. }
  47748. /**
  47749. * Sets of helpers addressing the serialization and deserialization of environment texture
  47750. * stored in a BabylonJS env file.
  47751. * Those files are usually stored as .env files.
  47752. */
  47753. export class EnvironmentTextureTools {
  47754. /**
  47755. * Magic number identifying the env file.
  47756. */
  47757. private static _MagicBytes;
  47758. /**
  47759. * Gets the environment info from an env file.
  47760. * @param data The array buffer containing the .env bytes.
  47761. * @returns the environment file info (the json header) if successfully parsed.
  47762. */
  47763. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47764. /**
  47765. * Creates an environment texture from a loaded cube texture.
  47766. * @param texture defines the cube texture to convert in env file
  47767. * @return a promise containing the environment data if succesfull.
  47768. */
  47769. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47770. /**
  47771. * Creates a JSON representation of the spherical data.
  47772. * @param texture defines the texture containing the polynomials
  47773. * @return the JSON representation of the spherical info
  47774. */
  47775. private static _CreateEnvTextureIrradiance;
  47776. /**
  47777. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47778. * @param data the image data
  47779. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47780. * @return the views described by info providing access to the underlying buffer
  47781. */
  47782. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47783. /**
  47784. * Uploads the texture info contained in the env file to the GPU.
  47785. * @param texture defines the internal texture to upload to
  47786. * @param data defines the data to load
  47787. * @param info defines the texture info retrieved through the GetEnvInfo method
  47788. * @returns a promise
  47789. */
  47790. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47791. private static _OnImageReadyAsync;
  47792. /**
  47793. * Uploads the levels of image data to the GPU.
  47794. * @param texture defines the internal texture to upload to
  47795. * @param imageData defines the array buffer views of image data [mipmap][face]
  47796. * @returns a promise
  47797. */
  47798. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47799. /**
  47800. * Uploads spherical polynomials information to the texture.
  47801. * @param texture defines the texture we are trying to upload the information to
  47802. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47803. */
  47804. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47805. /** @hidden */
  47806. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47807. }
  47808. }
  47809. declare module BABYLON {
  47810. /**
  47811. * Contains position and normal vectors for a vertex
  47812. */
  47813. export class PositionNormalVertex {
  47814. /** the position of the vertex (defaut: 0,0,0) */
  47815. position: Vector3;
  47816. /** the normal of the vertex (defaut: 0,1,0) */
  47817. normal: Vector3;
  47818. /**
  47819. * Creates a PositionNormalVertex
  47820. * @param position the position of the vertex (defaut: 0,0,0)
  47821. * @param normal the normal of the vertex (defaut: 0,1,0)
  47822. */
  47823. constructor(
  47824. /** the position of the vertex (defaut: 0,0,0) */
  47825. position?: Vector3,
  47826. /** the normal of the vertex (defaut: 0,1,0) */
  47827. normal?: Vector3);
  47828. /**
  47829. * Clones the PositionNormalVertex
  47830. * @returns the cloned PositionNormalVertex
  47831. */
  47832. clone(): PositionNormalVertex;
  47833. }
  47834. /**
  47835. * Contains position, normal and uv vectors for a vertex
  47836. */
  47837. export class PositionNormalTextureVertex {
  47838. /** the position of the vertex (defaut: 0,0,0) */
  47839. position: Vector3;
  47840. /** the normal of the vertex (defaut: 0,1,0) */
  47841. normal: Vector3;
  47842. /** the uv of the vertex (default: 0,0) */
  47843. uv: Vector2;
  47844. /**
  47845. * Creates a PositionNormalTextureVertex
  47846. * @param position the position of the vertex (defaut: 0,0,0)
  47847. * @param normal the normal of the vertex (defaut: 0,1,0)
  47848. * @param uv the uv of the vertex (default: 0,0)
  47849. */
  47850. constructor(
  47851. /** the position of the vertex (defaut: 0,0,0) */
  47852. position?: Vector3,
  47853. /** the normal of the vertex (defaut: 0,1,0) */
  47854. normal?: Vector3,
  47855. /** the uv of the vertex (default: 0,0) */
  47856. uv?: Vector2);
  47857. /**
  47858. * Clones the PositionNormalTextureVertex
  47859. * @returns the cloned PositionNormalTextureVertex
  47860. */
  47861. clone(): PositionNormalTextureVertex;
  47862. }
  47863. }
  47864. declare module BABYLON {
  47865. /** @hidden */
  47866. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47867. private _genericAttributeLocation;
  47868. private _varyingLocationCount;
  47869. private _varyingLocationMap;
  47870. private _replacements;
  47871. private _textureCount;
  47872. private _uniforms;
  47873. lineProcessor(line: string): string;
  47874. attributeProcessor(attribute: string): string;
  47875. varyingProcessor(varying: string, isFragment: boolean): string;
  47876. uniformProcessor(uniform: string): string;
  47877. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47878. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47879. }
  47880. }
  47881. declare module BABYLON {
  47882. /**
  47883. * Container for accessors for natively-stored mesh data buffers.
  47884. */
  47885. class NativeDataBuffer extends DataBuffer {
  47886. /**
  47887. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47888. */
  47889. nativeIndexBuffer?: any;
  47890. /**
  47891. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47892. */
  47893. nativeVertexBuffer?: any;
  47894. }
  47895. /** @hidden */
  47896. class NativeTexture extends InternalTexture {
  47897. getInternalTexture(): InternalTexture;
  47898. getViewCount(): number;
  47899. }
  47900. /** @hidden */
  47901. export class NativeEngine extends Engine {
  47902. private readonly _native;
  47903. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47904. private readonly INVALID_HANDLE;
  47905. getHardwareScalingLevel(): number;
  47906. constructor();
  47907. /**
  47908. * Can be used to override the current requestAnimationFrame requester.
  47909. * @hidden
  47910. */
  47911. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47912. /**
  47913. * Override default engine behavior.
  47914. * @param color
  47915. * @param backBuffer
  47916. * @param depth
  47917. * @param stencil
  47918. */
  47919. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47920. /**
  47921. * Gets host document
  47922. * @returns the host document object
  47923. */
  47924. getHostDocument(): Nullable<Document>;
  47925. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47926. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47927. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47928. recordVertexArrayObject(vertexBuffers: {
  47929. [key: string]: VertexBuffer;
  47930. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47931. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47932. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47933. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47934. /**
  47935. * Draw a list of indexed primitives
  47936. * @param fillMode defines the primitive to use
  47937. * @param indexStart defines the starting index
  47938. * @param indexCount defines the number of index to draw
  47939. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47940. */
  47941. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47942. /**
  47943. * Draw a list of unindexed primitives
  47944. * @param fillMode defines the primitive to use
  47945. * @param verticesStart defines the index of first vertex to draw
  47946. * @param verticesCount defines the count of vertices to draw
  47947. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47948. */
  47949. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47950. createPipelineContext(): IPipelineContext;
  47951. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47952. /** @hidden */
  47953. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47954. /** @hidden */
  47955. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47956. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47957. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47958. protected _setProgram(program: WebGLProgram): void;
  47959. _releaseEffect(effect: Effect): void;
  47960. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47961. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47962. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47963. bindSamplers(effect: Effect): void;
  47964. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47965. getRenderWidth(useScreen?: boolean): number;
  47966. getRenderHeight(useScreen?: boolean): number;
  47967. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47968. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47969. /**
  47970. * Set the z offset to apply to current rendering
  47971. * @param value defines the offset to apply
  47972. */
  47973. setZOffset(value: number): void;
  47974. /**
  47975. * Gets the current value of the zOffset
  47976. * @returns the current zOffset state
  47977. */
  47978. getZOffset(): number;
  47979. /**
  47980. * Enable or disable depth buffering
  47981. * @param enable defines the state to set
  47982. */
  47983. setDepthBuffer(enable: boolean): void;
  47984. /**
  47985. * Gets a boolean indicating if depth writing is enabled
  47986. * @returns the current depth writing state
  47987. */
  47988. getDepthWrite(): boolean;
  47989. /**
  47990. * Enable or disable depth writing
  47991. * @param enable defines the state to set
  47992. */
  47993. setDepthWrite(enable: boolean): void;
  47994. /**
  47995. * Enable or disable color writing
  47996. * @param enable defines the state to set
  47997. */
  47998. setColorWrite(enable: boolean): void;
  47999. /**
  48000. * Gets a boolean indicating if color writing is enabled
  48001. * @returns the current color writing state
  48002. */
  48003. getColorWrite(): boolean;
  48004. /**
  48005. * Sets alpha constants used by some alpha blending modes
  48006. * @param r defines the red component
  48007. * @param g defines the green component
  48008. * @param b defines the blue component
  48009. * @param a defines the alpha component
  48010. */
  48011. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48012. /**
  48013. * Sets the current alpha mode
  48014. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48015. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48016. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48017. */
  48018. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48019. /**
  48020. * Gets the current alpha mode
  48021. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48022. * @returns the current alpha mode
  48023. */
  48024. getAlphaMode(): number;
  48025. setInt(uniform: WebGLUniformLocation, int: number): void;
  48026. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48027. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48028. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48029. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48030. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48031. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48032. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48033. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48034. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48035. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48036. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48037. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48038. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48039. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48040. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48041. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48042. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48043. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48044. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48045. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48046. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48047. wipeCaches(bruteForce?: boolean): void;
  48048. _createTexture(): WebGLTexture;
  48049. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48050. /**
  48051. * Usually called from BABYLON.Texture.ts.
  48052. * Passed information to create a WebGLTexture
  48053. * @param urlArg defines a value which contains one of the following:
  48054. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48055. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48056. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48057. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48058. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48059. * @param scene needed for loading to the correct scene
  48060. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48061. * @param onLoad optional callback to be called upon successful completion
  48062. * @param onError optional callback to be called upon failure
  48063. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48064. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48065. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48066. * @param forcedExtension defines the extension to use to pick the right loader
  48067. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48068. */
  48069. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  48070. /**
  48071. * Creates a cube texture
  48072. * @param rootUrl defines the url where the files to load is located
  48073. * @param scene defines the current scene
  48074. * @param files defines the list of files to load (1 per face)
  48075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48076. * @param onLoad defines an optional callback raised when the texture is loaded
  48077. * @param onError defines an optional callback raised if there is an issue to load the texture
  48078. * @param format defines the format of the data
  48079. * @param forcedExtension defines the extension to use to pick the right loader
  48080. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48081. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48082. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48083. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48084. * @returns the cube texture as an InternalTexture
  48085. */
  48086. 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;
  48087. private _getSamplingFilter;
  48088. private static _GetNativeTextureFormat;
  48089. createRenderTargetTexture(size: number | {
  48090. width: number;
  48091. height: number;
  48092. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48093. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48094. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48095. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48096. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48097. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48098. /**
  48099. * Updates a dynamic vertex buffer.
  48100. * @param vertexBuffer the vertex buffer to update
  48101. * @param data the data used to update the vertex buffer
  48102. * @param byteOffset the byte offset of the data (optional)
  48103. * @param byteLength the byte length of the data (optional)
  48104. */
  48105. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48106. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48107. private _updateAnisotropicLevel;
  48108. private _getAddressMode;
  48109. /** @hidden */
  48110. _bindTexture(channel: number, texture: InternalTexture): void;
  48111. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48112. releaseEffects(): void;
  48113. /** @hidden */
  48114. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48115. /** @hidden */
  48116. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48117. /** @hidden */
  48118. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48119. /** @hidden */
  48120. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48121. }
  48122. }
  48123. declare module BABYLON {
  48124. /**
  48125. * Gather the list of clipboard event types as constants.
  48126. */
  48127. export class ClipboardEventTypes {
  48128. /**
  48129. * The clipboard event is fired when a copy command is active (pressed).
  48130. */
  48131. static readonly COPY: number;
  48132. /**
  48133. * The clipboard event is fired when a cut command is active (pressed).
  48134. */
  48135. static readonly CUT: number;
  48136. /**
  48137. * The clipboard event is fired when a paste command is active (pressed).
  48138. */
  48139. static readonly PASTE: number;
  48140. }
  48141. /**
  48142. * This class is used to store clipboard related info for the onClipboardObservable event.
  48143. */
  48144. export class ClipboardInfo {
  48145. /**
  48146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48147. */
  48148. type: number;
  48149. /**
  48150. * Defines the related dom event
  48151. */
  48152. event: ClipboardEvent;
  48153. /**
  48154. *Creates an instance of ClipboardInfo.
  48155. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48156. * @param event Defines the related dom event
  48157. */
  48158. constructor(
  48159. /**
  48160. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48161. */
  48162. type: number,
  48163. /**
  48164. * Defines the related dom event
  48165. */
  48166. event: ClipboardEvent);
  48167. /**
  48168. * Get the clipboard event's type from the keycode.
  48169. * @param keyCode Defines the keyCode for the current keyboard event.
  48170. * @return {number}
  48171. */
  48172. static GetTypeFromCharacter(keyCode: number): number;
  48173. }
  48174. }
  48175. declare module BABYLON {
  48176. /**
  48177. * Google Daydream controller
  48178. */
  48179. export class DaydreamController extends WebVRController {
  48180. /**
  48181. * Base Url for the controller model.
  48182. */
  48183. static MODEL_BASE_URL: string;
  48184. /**
  48185. * File name for the controller model.
  48186. */
  48187. static MODEL_FILENAME: string;
  48188. /**
  48189. * Gamepad Id prefix used to identify Daydream Controller.
  48190. */
  48191. static readonly GAMEPAD_ID_PREFIX: string;
  48192. /**
  48193. * Creates a new DaydreamController from a gamepad
  48194. * @param vrGamepad the gamepad that the controller should be created from
  48195. */
  48196. constructor(vrGamepad: any);
  48197. /**
  48198. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48199. * @param scene scene in which to add meshes
  48200. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48201. */
  48202. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48203. /**
  48204. * Called once for each button that changed state since the last frame
  48205. * @param buttonIdx Which button index changed
  48206. * @param state New state of the button
  48207. * @param changes Which properties on the state changed since last frame
  48208. */
  48209. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48210. }
  48211. }
  48212. declare module BABYLON {
  48213. /**
  48214. * Gear VR Controller
  48215. */
  48216. export class GearVRController extends WebVRController {
  48217. /**
  48218. * Base Url for the controller model.
  48219. */
  48220. static MODEL_BASE_URL: string;
  48221. /**
  48222. * File name for the controller model.
  48223. */
  48224. static MODEL_FILENAME: string;
  48225. /**
  48226. * Gamepad Id prefix used to identify this controller.
  48227. */
  48228. static readonly GAMEPAD_ID_PREFIX: string;
  48229. private readonly _buttonIndexToObservableNameMap;
  48230. /**
  48231. * Creates a new GearVRController from a gamepad
  48232. * @param vrGamepad the gamepad that the controller should be created from
  48233. */
  48234. constructor(vrGamepad: any);
  48235. /**
  48236. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48237. * @param scene scene in which to add meshes
  48238. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48239. */
  48240. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48241. /**
  48242. * Called once for each button that changed state since the last frame
  48243. * @param buttonIdx Which button index changed
  48244. * @param state New state of the button
  48245. * @param changes Which properties on the state changed since last frame
  48246. */
  48247. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48248. }
  48249. }
  48250. declare module BABYLON {
  48251. /**
  48252. * Generic Controller
  48253. */
  48254. export class GenericController extends WebVRController {
  48255. /**
  48256. * Base Url for the controller model.
  48257. */
  48258. static readonly MODEL_BASE_URL: string;
  48259. /**
  48260. * File name for the controller model.
  48261. */
  48262. static readonly MODEL_FILENAME: string;
  48263. /**
  48264. * Creates a new GenericController from a gamepad
  48265. * @param vrGamepad the gamepad that the controller should be created from
  48266. */
  48267. constructor(vrGamepad: any);
  48268. /**
  48269. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48270. * @param scene scene in which to add meshes
  48271. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48272. */
  48273. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48274. /**
  48275. * Called once for each button that changed state since the last frame
  48276. * @param buttonIdx Which button index changed
  48277. * @param state New state of the button
  48278. * @param changes Which properties on the state changed since last frame
  48279. */
  48280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48281. }
  48282. }
  48283. declare module BABYLON {
  48284. /**
  48285. * Oculus Touch Controller
  48286. */
  48287. export class OculusTouchController extends WebVRController {
  48288. /**
  48289. * Base Url for the controller model.
  48290. */
  48291. static MODEL_BASE_URL: string;
  48292. /**
  48293. * File name for the left controller model.
  48294. */
  48295. static MODEL_LEFT_FILENAME: string;
  48296. /**
  48297. * File name for the right controller model.
  48298. */
  48299. static MODEL_RIGHT_FILENAME: string;
  48300. /**
  48301. * Base Url for the Quest controller model.
  48302. */
  48303. static QUEST_MODEL_BASE_URL: string;
  48304. /**
  48305. * @hidden
  48306. * If the controllers are running on a device that needs the updated Quest controller models
  48307. */
  48308. static _IsQuest: boolean;
  48309. /**
  48310. * Fired when the secondary trigger on this controller is modified
  48311. */
  48312. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48313. /**
  48314. * Fired when the thumb rest on this controller is modified
  48315. */
  48316. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48317. /**
  48318. * Creates a new OculusTouchController from a gamepad
  48319. * @param vrGamepad the gamepad that the controller should be created from
  48320. */
  48321. constructor(vrGamepad: any);
  48322. /**
  48323. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48324. * @param scene scene in which to add meshes
  48325. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48326. */
  48327. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48328. /**
  48329. * Fired when the A button on this controller is modified
  48330. */
  48331. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48332. /**
  48333. * Fired when the B button on this controller is modified
  48334. */
  48335. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48336. /**
  48337. * Fired when the X button on this controller is modified
  48338. */
  48339. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48340. /**
  48341. * Fired when the Y button on this controller is modified
  48342. */
  48343. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48344. /**
  48345. * Called once for each button that changed state since the last frame
  48346. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48347. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48348. * 2) secondary trigger (same)
  48349. * 3) A (right) X (left), touch, pressed = value
  48350. * 4) B / Y
  48351. * 5) thumb rest
  48352. * @param buttonIdx Which button index changed
  48353. * @param state New state of the button
  48354. * @param changes Which properties on the state changed since last frame
  48355. */
  48356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48357. }
  48358. }
  48359. declare module BABYLON {
  48360. /**
  48361. * Vive Controller
  48362. */
  48363. export class ViveController extends WebVRController {
  48364. /**
  48365. * Base Url for the controller model.
  48366. */
  48367. static MODEL_BASE_URL: string;
  48368. /**
  48369. * File name for the controller model.
  48370. */
  48371. static MODEL_FILENAME: string;
  48372. /**
  48373. * Creates a new ViveController from a gamepad
  48374. * @param vrGamepad the gamepad that the controller should be created from
  48375. */
  48376. constructor(vrGamepad: any);
  48377. /**
  48378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48379. * @param scene scene in which to add meshes
  48380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48381. */
  48382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48383. /**
  48384. * Fired when the left button on this controller is modified
  48385. */
  48386. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48387. /**
  48388. * Fired when the right button on this controller is modified
  48389. */
  48390. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48391. /**
  48392. * Fired when the menu button on this controller is modified
  48393. */
  48394. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48395. /**
  48396. * Called once for each button that changed state since the last frame
  48397. * Vive mapping:
  48398. * 0: touchpad
  48399. * 1: trigger
  48400. * 2: left AND right buttons
  48401. * 3: menu button
  48402. * @param buttonIdx Which button index changed
  48403. * @param state New state of the button
  48404. * @param changes Which properties on the state changed since last frame
  48405. */
  48406. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * Defines the WindowsMotionController object that the state of the windows motion controller
  48412. */
  48413. export class WindowsMotionController extends WebVRController {
  48414. /**
  48415. * The base url used to load the left and right controller models
  48416. */
  48417. static MODEL_BASE_URL: string;
  48418. /**
  48419. * The name of the left controller model file
  48420. */
  48421. static MODEL_LEFT_FILENAME: string;
  48422. /**
  48423. * The name of the right controller model file
  48424. */
  48425. static MODEL_RIGHT_FILENAME: string;
  48426. /**
  48427. * The controller name prefix for this controller type
  48428. */
  48429. static readonly GAMEPAD_ID_PREFIX: string;
  48430. /**
  48431. * The controller id pattern for this controller type
  48432. */
  48433. private static readonly GAMEPAD_ID_PATTERN;
  48434. private _loadedMeshInfo;
  48435. protected readonly _mapping: {
  48436. buttons: string[];
  48437. buttonMeshNames: {
  48438. 'trigger': string;
  48439. 'menu': string;
  48440. 'grip': string;
  48441. 'thumbstick': string;
  48442. 'trackpad': string;
  48443. };
  48444. buttonObservableNames: {
  48445. 'trigger': string;
  48446. 'menu': string;
  48447. 'grip': string;
  48448. 'thumbstick': string;
  48449. 'trackpad': string;
  48450. };
  48451. axisMeshNames: string[];
  48452. pointingPoseMeshName: string;
  48453. };
  48454. /**
  48455. * Fired when the trackpad on this controller is clicked
  48456. */
  48457. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48458. /**
  48459. * Fired when the trackpad on this controller is modified
  48460. */
  48461. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48462. /**
  48463. * The current x and y values of this controller's trackpad
  48464. */
  48465. trackpad: StickValues;
  48466. /**
  48467. * Creates a new WindowsMotionController from a gamepad
  48468. * @param vrGamepad the gamepad that the controller should be created from
  48469. */
  48470. constructor(vrGamepad: any);
  48471. /**
  48472. * Fired when the trigger on this controller is modified
  48473. */
  48474. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48475. /**
  48476. * Fired when the menu button on this controller is modified
  48477. */
  48478. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48479. /**
  48480. * Fired when the grip button on this controller is modified
  48481. */
  48482. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48483. /**
  48484. * Fired when the thumbstick button on this controller is modified
  48485. */
  48486. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48487. /**
  48488. * Fired when the touchpad button on this controller is modified
  48489. */
  48490. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48491. /**
  48492. * Fired when the touchpad values on this controller are modified
  48493. */
  48494. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48495. protected _updateTrackpad(): void;
  48496. /**
  48497. * Called once per frame by the engine.
  48498. */
  48499. update(): void;
  48500. /**
  48501. * Called once for each button that changed state since the last frame
  48502. * @param buttonIdx Which button index changed
  48503. * @param state New state of the button
  48504. * @param changes Which properties on the state changed since last frame
  48505. */
  48506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48507. /**
  48508. * Moves the buttons on the controller mesh based on their current state
  48509. * @param buttonName the name of the button to move
  48510. * @param buttonValue the value of the button which determines the buttons new position
  48511. */
  48512. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48513. /**
  48514. * Moves the axis on the controller mesh based on its current state
  48515. * @param axis the index of the axis
  48516. * @param axisValue the value of the axis which determines the meshes new position
  48517. * @hidden
  48518. */
  48519. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48520. /**
  48521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48522. * @param scene scene in which to add meshes
  48523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48524. */
  48525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48526. /**
  48527. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48528. * can be transformed by button presses and axes values, based on this._mapping.
  48529. *
  48530. * @param scene scene in which the meshes exist
  48531. * @param meshes list of meshes that make up the controller model to process
  48532. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48533. */
  48534. private processModel;
  48535. private createMeshInfo;
  48536. /**
  48537. * Gets the ray of the controller in the direction the controller is pointing
  48538. * @param length the length the resulting ray should be
  48539. * @returns a ray in the direction the controller is pointing
  48540. */
  48541. getForwardRay(length?: number): Ray;
  48542. /**
  48543. * Disposes of the controller
  48544. */
  48545. dispose(): void;
  48546. }
  48547. /**
  48548. * This class represents a new windows motion controller in XR.
  48549. */
  48550. export class XRWindowsMotionController extends WindowsMotionController {
  48551. /**
  48552. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48553. */
  48554. protected readonly _mapping: {
  48555. buttons: string[];
  48556. buttonMeshNames: {
  48557. 'trigger': string;
  48558. 'menu': string;
  48559. 'grip': string;
  48560. 'thumbstick': string;
  48561. 'trackpad': string;
  48562. };
  48563. buttonObservableNames: {
  48564. 'trigger': string;
  48565. 'menu': string;
  48566. 'grip': string;
  48567. 'thumbstick': string;
  48568. 'trackpad': string;
  48569. };
  48570. axisMeshNames: string[];
  48571. pointingPoseMeshName: string;
  48572. };
  48573. /**
  48574. * Construct a new XR-Based windows motion controller
  48575. *
  48576. * @param gamepadInfo the gamepad object from the browser
  48577. */
  48578. constructor(gamepadInfo: any);
  48579. /**
  48580. * holds the thumbstick values (X,Y)
  48581. */
  48582. thumbstickValues: StickValues;
  48583. /**
  48584. * Fired when the thumbstick on this controller is clicked
  48585. */
  48586. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48587. /**
  48588. * Fired when the thumbstick on this controller is modified
  48589. */
  48590. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48591. /**
  48592. * Fired when the touchpad button on this controller is modified
  48593. */
  48594. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48595. /**
  48596. * Fired when the touchpad values on this controller are modified
  48597. */
  48598. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48599. /**
  48600. * Fired when the thumbstick button on this controller is modified
  48601. * here to prevent breaking changes
  48602. */
  48603. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48604. /**
  48605. * updating the thumbstick(!) and not the trackpad.
  48606. * This is named this way due to the difference between WebVR and XR and to avoid
  48607. * changing the parent class.
  48608. */
  48609. protected _updateTrackpad(): void;
  48610. /**
  48611. * Disposes the class with joy
  48612. */
  48613. dispose(): void;
  48614. }
  48615. }
  48616. declare module BABYLON {
  48617. /**
  48618. * Class containing static functions to help procedurally build meshes
  48619. */
  48620. export class PolyhedronBuilder {
  48621. /**
  48622. * Creates a polyhedron mesh
  48623. * * 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
  48624. * * The parameter `size` (positive float, default 1) sets the polygon size
  48625. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48626. * * 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`
  48627. * * 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
  48628. * * 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)`)
  48629. * * 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
  48630. * * 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
  48631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48632. * * 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
  48633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48634. * @param name defines the name of the mesh
  48635. * @param options defines the options used to create the mesh
  48636. * @param scene defines the hosting scene
  48637. * @returns the polyhedron mesh
  48638. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48639. */
  48640. static CreatePolyhedron(name: string, options: {
  48641. type?: number;
  48642. size?: number;
  48643. sizeX?: number;
  48644. sizeY?: number;
  48645. sizeZ?: number;
  48646. custom?: any;
  48647. faceUV?: Vector4[];
  48648. faceColors?: Color4[];
  48649. flat?: boolean;
  48650. updatable?: boolean;
  48651. sideOrientation?: number;
  48652. frontUVs?: Vector4;
  48653. backUVs?: Vector4;
  48654. }, scene?: Nullable<Scene>): Mesh;
  48655. }
  48656. }
  48657. declare module BABYLON {
  48658. /**
  48659. * Gizmo that enables scaling a mesh along 3 axis
  48660. */
  48661. export class ScaleGizmo extends Gizmo {
  48662. /**
  48663. * Internal gizmo used for interactions on the x axis
  48664. */
  48665. xGizmo: AxisScaleGizmo;
  48666. /**
  48667. * Internal gizmo used for interactions on the y axis
  48668. */
  48669. yGizmo: AxisScaleGizmo;
  48670. /**
  48671. * Internal gizmo used for interactions on the z axis
  48672. */
  48673. zGizmo: AxisScaleGizmo;
  48674. /**
  48675. * Internal gizmo used to scale all axis equally
  48676. */
  48677. uniformScaleGizmo: AxisScaleGizmo;
  48678. private _meshAttached;
  48679. private _updateGizmoRotationToMatchAttachedMesh;
  48680. private _snapDistance;
  48681. private _scaleRatio;
  48682. private _uniformScalingMesh;
  48683. private _octahedron;
  48684. private _sensitivity;
  48685. /** Fires an event when any of it's sub gizmos are dragged */
  48686. onDragStartObservable: Observable<unknown>;
  48687. /** Fires an event when any of it's sub gizmos are released from dragging */
  48688. onDragEndObservable: Observable<unknown>;
  48689. get attachedMesh(): Nullable<AbstractMesh>;
  48690. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48691. /**
  48692. * Creates a ScaleGizmo
  48693. * @param gizmoLayer The utility layer the gizmo will be added to
  48694. */
  48695. constructor(gizmoLayer?: UtilityLayerRenderer);
  48696. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48697. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48698. /**
  48699. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48700. */
  48701. set snapDistance(value: number);
  48702. get snapDistance(): number;
  48703. /**
  48704. * Ratio for the scale of the gizmo (Default: 1)
  48705. */
  48706. set scaleRatio(value: number);
  48707. get scaleRatio(): number;
  48708. /**
  48709. * Sensitivity factor for dragging (Default: 1)
  48710. */
  48711. set sensitivity(value: number);
  48712. get sensitivity(): number;
  48713. /**
  48714. * Disposes of the gizmo
  48715. */
  48716. dispose(): void;
  48717. }
  48718. }
  48719. declare module BABYLON {
  48720. /**
  48721. * Single axis scale gizmo
  48722. */
  48723. export class AxisScaleGizmo extends Gizmo {
  48724. /**
  48725. * Drag behavior responsible for the gizmos dragging interactions
  48726. */
  48727. dragBehavior: PointerDragBehavior;
  48728. private _pointerObserver;
  48729. /**
  48730. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48731. */
  48732. snapDistance: number;
  48733. /**
  48734. * Event that fires each time the gizmo snaps to a new location.
  48735. * * snapDistance is the the change in distance
  48736. */
  48737. onSnapObservable: Observable<{
  48738. snapDistance: number;
  48739. }>;
  48740. /**
  48741. * If the scaling operation should be done on all axis (default: false)
  48742. */
  48743. uniformScaling: boolean;
  48744. /**
  48745. * Custom sensitivity value for the drag strength
  48746. */
  48747. sensitivity: number;
  48748. private _isEnabled;
  48749. private _parent;
  48750. private _arrow;
  48751. private _coloredMaterial;
  48752. private _hoverMaterial;
  48753. /**
  48754. * Creates an AxisScaleGizmo
  48755. * @param gizmoLayer The utility layer the gizmo will be added to
  48756. * @param dragAxis The axis which the gizmo will be able to scale on
  48757. * @param color The color of the gizmo
  48758. */
  48759. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48760. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48761. /**
  48762. * If the gizmo is enabled
  48763. */
  48764. set isEnabled(value: boolean);
  48765. get isEnabled(): boolean;
  48766. /**
  48767. * Disposes of the gizmo
  48768. */
  48769. dispose(): void;
  48770. /**
  48771. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48772. * @param mesh The mesh to replace the default mesh of the gizmo
  48773. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48774. */
  48775. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48776. }
  48777. }
  48778. declare module BABYLON {
  48779. /**
  48780. * Bounding box gizmo
  48781. */
  48782. export class BoundingBoxGizmo extends Gizmo {
  48783. private _lineBoundingBox;
  48784. private _rotateSpheresParent;
  48785. private _scaleBoxesParent;
  48786. private _boundingDimensions;
  48787. private _renderObserver;
  48788. private _pointerObserver;
  48789. private _scaleDragSpeed;
  48790. private _tmpQuaternion;
  48791. private _tmpVector;
  48792. private _tmpRotationMatrix;
  48793. /**
  48794. * 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)
  48795. */
  48796. ignoreChildren: boolean;
  48797. /**
  48798. * 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)
  48799. */
  48800. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48801. /**
  48802. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48803. */
  48804. rotationSphereSize: number;
  48805. /**
  48806. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48807. */
  48808. scaleBoxSize: number;
  48809. /**
  48810. * 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)
  48811. */
  48812. fixedDragMeshScreenSize: boolean;
  48813. /**
  48814. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48815. */
  48816. fixedDragMeshScreenSizeDistanceFactor: number;
  48817. /**
  48818. * Fired when a rotation sphere or scale box is dragged
  48819. */
  48820. onDragStartObservable: Observable<{}>;
  48821. /**
  48822. * Fired when a scale box is dragged
  48823. */
  48824. onScaleBoxDragObservable: Observable<{}>;
  48825. /**
  48826. * Fired when a scale box drag is ended
  48827. */
  48828. onScaleBoxDragEndObservable: Observable<{}>;
  48829. /**
  48830. * Fired when a rotation sphere is dragged
  48831. */
  48832. onRotationSphereDragObservable: Observable<{}>;
  48833. /**
  48834. * Fired when a rotation sphere drag is ended
  48835. */
  48836. onRotationSphereDragEndObservable: Observable<{}>;
  48837. /**
  48838. * 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)
  48839. */
  48840. scalePivot: Nullable<Vector3>;
  48841. /**
  48842. * Mesh used as a pivot to rotate the attached mesh
  48843. */
  48844. private _anchorMesh;
  48845. private _existingMeshScale;
  48846. private _dragMesh;
  48847. private pointerDragBehavior;
  48848. private coloredMaterial;
  48849. private hoverColoredMaterial;
  48850. /**
  48851. * Sets the color of the bounding box gizmo
  48852. * @param color the color to set
  48853. */
  48854. setColor(color: Color3): void;
  48855. /**
  48856. * Creates an BoundingBoxGizmo
  48857. * @param gizmoLayer The utility layer the gizmo will be added to
  48858. * @param color The color of the gizmo
  48859. */
  48860. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48862. private _selectNode;
  48863. /**
  48864. * Updates the bounding box information for the Gizmo
  48865. */
  48866. updateBoundingBox(): void;
  48867. private _updateRotationSpheres;
  48868. private _updateScaleBoxes;
  48869. /**
  48870. * Enables rotation on the specified axis and disables rotation on the others
  48871. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48872. */
  48873. setEnabledRotationAxis(axis: string): void;
  48874. /**
  48875. * Enables/disables scaling
  48876. * @param enable if scaling should be enabled
  48877. */
  48878. setEnabledScaling(enable: boolean): void;
  48879. private _updateDummy;
  48880. /**
  48881. * Enables a pointer drag behavior on the bounding box of the gizmo
  48882. */
  48883. enableDragBehavior(): void;
  48884. /**
  48885. * Disposes of the gizmo
  48886. */
  48887. dispose(): void;
  48888. /**
  48889. * 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)
  48890. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48891. * @returns the bounding box mesh with the passed in mesh as a child
  48892. */
  48893. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48894. /**
  48895. * CustomMeshes are not supported by this gizmo
  48896. * @param mesh The mesh to replace the default mesh of the gizmo
  48897. */
  48898. setCustomMesh(mesh: Mesh): void;
  48899. }
  48900. }
  48901. declare module BABYLON {
  48902. /**
  48903. * Single plane rotation gizmo
  48904. */
  48905. export class PlaneRotationGizmo extends Gizmo {
  48906. /**
  48907. * Drag behavior responsible for the gizmos dragging interactions
  48908. */
  48909. dragBehavior: PointerDragBehavior;
  48910. private _pointerObserver;
  48911. /**
  48912. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48913. */
  48914. snapDistance: number;
  48915. /**
  48916. * Event that fires each time the gizmo snaps to a new location.
  48917. * * snapDistance is the the change in distance
  48918. */
  48919. onSnapObservable: Observable<{
  48920. snapDistance: number;
  48921. }>;
  48922. private _isEnabled;
  48923. private _parent;
  48924. /**
  48925. * Creates a PlaneRotationGizmo
  48926. * @param gizmoLayer The utility layer the gizmo will be added to
  48927. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48928. * @param color The color of the gizmo
  48929. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48930. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48931. */
  48932. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48934. /**
  48935. * If the gizmo is enabled
  48936. */
  48937. set isEnabled(value: boolean);
  48938. get isEnabled(): boolean;
  48939. /**
  48940. * Disposes of the gizmo
  48941. */
  48942. dispose(): void;
  48943. }
  48944. }
  48945. declare module BABYLON {
  48946. /**
  48947. * Gizmo that enables rotating a mesh along 3 axis
  48948. */
  48949. export class RotationGizmo extends Gizmo {
  48950. /**
  48951. * Internal gizmo used for interactions on the x axis
  48952. */
  48953. xGizmo: PlaneRotationGizmo;
  48954. /**
  48955. * Internal gizmo used for interactions on the y axis
  48956. */
  48957. yGizmo: PlaneRotationGizmo;
  48958. /**
  48959. * Internal gizmo used for interactions on the z axis
  48960. */
  48961. zGizmo: PlaneRotationGizmo;
  48962. /** Fires an event when any of it's sub gizmos are dragged */
  48963. onDragStartObservable: Observable<unknown>;
  48964. /** Fires an event when any of it's sub gizmos are released from dragging */
  48965. onDragEndObservable: Observable<unknown>;
  48966. private _meshAttached;
  48967. get attachedMesh(): Nullable<AbstractMesh>;
  48968. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48969. /**
  48970. * Creates a RotationGizmo
  48971. * @param gizmoLayer The utility layer the gizmo will be added to
  48972. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48973. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48974. */
  48975. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48976. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48977. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48978. /**
  48979. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48980. */
  48981. set snapDistance(value: number);
  48982. get snapDistance(): number;
  48983. /**
  48984. * Ratio for the scale of the gizmo (Default: 1)
  48985. */
  48986. set scaleRatio(value: number);
  48987. get scaleRatio(): number;
  48988. /**
  48989. * Disposes of the gizmo
  48990. */
  48991. dispose(): void;
  48992. /**
  48993. * CustomMeshes are not supported by this gizmo
  48994. * @param mesh The mesh to replace the default mesh of the gizmo
  48995. */
  48996. setCustomMesh(mesh: Mesh): void;
  48997. }
  48998. }
  48999. declare module BABYLON {
  49000. /**
  49001. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49002. */
  49003. export class GizmoManager implements IDisposable {
  49004. private scene;
  49005. /**
  49006. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49007. */
  49008. gizmos: {
  49009. positionGizmo: Nullable<PositionGizmo>;
  49010. rotationGizmo: Nullable<RotationGizmo>;
  49011. scaleGizmo: Nullable<ScaleGizmo>;
  49012. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49013. };
  49014. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49015. clearGizmoOnEmptyPointerEvent: boolean;
  49016. /** Fires an event when the manager is attached to a mesh */
  49017. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49018. private _gizmosEnabled;
  49019. private _pointerObserver;
  49020. private _attachedMesh;
  49021. private _boundingBoxColor;
  49022. private _defaultUtilityLayer;
  49023. private _defaultKeepDepthUtilityLayer;
  49024. /**
  49025. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49026. */
  49027. boundingBoxDragBehavior: SixDofDragBehavior;
  49028. /**
  49029. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49030. */
  49031. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49032. /**
  49033. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49034. */
  49035. usePointerToAttachGizmos: boolean;
  49036. /**
  49037. * Utility layer that the bounding box gizmo belongs to
  49038. */
  49039. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49040. /**
  49041. * Utility layer that all gizmos besides bounding box belong to
  49042. */
  49043. get utilityLayer(): UtilityLayerRenderer;
  49044. /**
  49045. * Instatiates a gizmo manager
  49046. * @param scene the scene to overlay the gizmos on top of
  49047. */
  49048. constructor(scene: Scene);
  49049. /**
  49050. * Attaches a set of gizmos to the specified mesh
  49051. * @param mesh The mesh the gizmo's should be attached to
  49052. */
  49053. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49054. /**
  49055. * If the position gizmo is enabled
  49056. */
  49057. set positionGizmoEnabled(value: boolean);
  49058. get positionGizmoEnabled(): boolean;
  49059. /**
  49060. * If the rotation gizmo is enabled
  49061. */
  49062. set rotationGizmoEnabled(value: boolean);
  49063. get rotationGizmoEnabled(): boolean;
  49064. /**
  49065. * If the scale gizmo is enabled
  49066. */
  49067. set scaleGizmoEnabled(value: boolean);
  49068. get scaleGizmoEnabled(): boolean;
  49069. /**
  49070. * If the boundingBox gizmo is enabled
  49071. */
  49072. set boundingBoxGizmoEnabled(value: boolean);
  49073. get boundingBoxGizmoEnabled(): boolean;
  49074. /**
  49075. * Disposes of the gizmo manager
  49076. */
  49077. dispose(): void;
  49078. }
  49079. }
  49080. declare module BABYLON {
  49081. /**
  49082. * A directional light is defined by a direction (what a surprise!).
  49083. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49084. * 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.
  49085. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49086. */
  49087. export class DirectionalLight extends ShadowLight {
  49088. private _shadowFrustumSize;
  49089. /**
  49090. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49091. */
  49092. get shadowFrustumSize(): number;
  49093. /**
  49094. * Specifies a fix frustum size for the shadow generation.
  49095. */
  49096. set shadowFrustumSize(value: number);
  49097. private _shadowOrthoScale;
  49098. /**
  49099. * Gets the shadow projection scale against the optimal computed one.
  49100. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49101. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49102. */
  49103. get shadowOrthoScale(): number;
  49104. /**
  49105. * Sets the shadow projection scale against the optimal computed one.
  49106. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49107. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49108. */
  49109. set shadowOrthoScale(value: number);
  49110. /**
  49111. * Automatically compute the projection matrix to best fit (including all the casters)
  49112. * on each frame.
  49113. */
  49114. autoUpdateExtends: boolean;
  49115. /**
  49116. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49117. * on each frame. autoUpdateExtends must be set to true for this to work
  49118. */
  49119. autoCalcShadowZBounds: boolean;
  49120. private _orthoLeft;
  49121. private _orthoRight;
  49122. private _orthoTop;
  49123. private _orthoBottom;
  49124. /**
  49125. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49126. * The directional light is emitted from everywhere in the given direction.
  49127. * It can cast shadows.
  49128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49129. * @param name The friendly name of the light
  49130. * @param direction The direction of the light
  49131. * @param scene The scene the light belongs to
  49132. */
  49133. constructor(name: string, direction: Vector3, scene: Scene);
  49134. /**
  49135. * Returns the string "DirectionalLight".
  49136. * @return The class name
  49137. */
  49138. getClassName(): string;
  49139. /**
  49140. * Returns the integer 1.
  49141. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49142. */
  49143. getTypeID(): number;
  49144. /**
  49145. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49146. * Returns the DirectionalLight Shadow projection matrix.
  49147. */
  49148. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49149. /**
  49150. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49151. * Returns the DirectionalLight Shadow projection matrix.
  49152. */
  49153. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49154. /**
  49155. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49156. * Returns the DirectionalLight Shadow projection matrix.
  49157. */
  49158. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49159. protected _buildUniformLayout(): void;
  49160. /**
  49161. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49162. * @param effect The effect to update
  49163. * @param lightIndex The index of the light in the effect to update
  49164. * @returns The directional light
  49165. */
  49166. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49167. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49168. /**
  49169. * Gets the minZ used for shadow according to both the scene and the light.
  49170. *
  49171. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49172. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49173. * @param activeCamera The camera we are returning the min for
  49174. * @returns the depth min z
  49175. */
  49176. getDepthMinZ(activeCamera: Camera): number;
  49177. /**
  49178. * Gets the maxZ used for shadow according to both the scene and the light.
  49179. *
  49180. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49181. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49182. * @param activeCamera The camera we are returning the max for
  49183. * @returns the depth max z
  49184. */
  49185. getDepthMaxZ(activeCamera: Camera): number;
  49186. /**
  49187. * Prepares the list of defines specific to the light type.
  49188. * @param defines the list of defines
  49189. * @param lightIndex defines the index of the light for the effect
  49190. */
  49191. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49192. }
  49193. }
  49194. declare module BABYLON {
  49195. /**
  49196. * Class containing static functions to help procedurally build meshes
  49197. */
  49198. export class HemisphereBuilder {
  49199. /**
  49200. * Creates a hemisphere mesh
  49201. * @param name defines the name of the mesh
  49202. * @param options defines the options used to create the mesh
  49203. * @param scene defines the hosting scene
  49204. * @returns the hemisphere mesh
  49205. */
  49206. static CreateHemisphere(name: string, options: {
  49207. segments?: number;
  49208. diameter?: number;
  49209. sideOrientation?: number;
  49210. }, scene: any): Mesh;
  49211. }
  49212. }
  49213. declare module BABYLON {
  49214. /**
  49215. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49216. * These values define a cone of light starting from the position, emitting toward the direction.
  49217. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49218. * and the exponent defines the speed of the decay of the light with distance (reach).
  49219. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49220. */
  49221. export class SpotLight extends ShadowLight {
  49222. private _angle;
  49223. private _innerAngle;
  49224. private _cosHalfAngle;
  49225. private _lightAngleScale;
  49226. private _lightAngleOffset;
  49227. /**
  49228. * Gets the cone angle of the spot light in Radians.
  49229. */
  49230. get angle(): number;
  49231. /**
  49232. * Sets the cone angle of the spot light in Radians.
  49233. */
  49234. set angle(value: number);
  49235. /**
  49236. * Only used in gltf falloff mode, this defines the angle where
  49237. * the directional falloff will start before cutting at angle which could be seen
  49238. * as outer angle.
  49239. */
  49240. get innerAngle(): number;
  49241. /**
  49242. * Only used in gltf falloff mode, this defines the angle where
  49243. * the directional falloff will start before cutting at angle which could be seen
  49244. * as outer angle.
  49245. */
  49246. set innerAngle(value: number);
  49247. private _shadowAngleScale;
  49248. /**
  49249. * Allows scaling the angle of the light for shadow generation only.
  49250. */
  49251. get shadowAngleScale(): number;
  49252. /**
  49253. * Allows scaling the angle of the light for shadow generation only.
  49254. */
  49255. set shadowAngleScale(value: number);
  49256. /**
  49257. * The light decay speed with the distance from the emission spot.
  49258. */
  49259. exponent: number;
  49260. private _projectionTextureMatrix;
  49261. /**
  49262. * Allows reading the projecton texture
  49263. */
  49264. get projectionTextureMatrix(): Matrix;
  49265. protected _projectionTextureLightNear: number;
  49266. /**
  49267. * Gets the near clip of the Spotlight for texture projection.
  49268. */
  49269. get projectionTextureLightNear(): number;
  49270. /**
  49271. * Sets the near clip of the Spotlight for texture projection.
  49272. */
  49273. set projectionTextureLightNear(value: number);
  49274. protected _projectionTextureLightFar: number;
  49275. /**
  49276. * Gets the far clip of the Spotlight for texture projection.
  49277. */
  49278. get projectionTextureLightFar(): number;
  49279. /**
  49280. * Sets the far clip of the Spotlight for texture projection.
  49281. */
  49282. set projectionTextureLightFar(value: number);
  49283. protected _projectionTextureUpDirection: Vector3;
  49284. /**
  49285. * Gets the Up vector of the Spotlight for texture projection.
  49286. */
  49287. get projectionTextureUpDirection(): Vector3;
  49288. /**
  49289. * Sets the Up vector of the Spotlight for texture projection.
  49290. */
  49291. set projectionTextureUpDirection(value: Vector3);
  49292. private _projectionTexture;
  49293. /**
  49294. * Gets the projection texture of the light.
  49295. */
  49296. get projectionTexture(): Nullable<BaseTexture>;
  49297. /**
  49298. * Sets the projection texture of the light.
  49299. */
  49300. set projectionTexture(value: Nullable<BaseTexture>);
  49301. private _projectionTextureViewLightDirty;
  49302. private _projectionTextureProjectionLightDirty;
  49303. private _projectionTextureDirty;
  49304. private _projectionTextureViewTargetVector;
  49305. private _projectionTextureViewLightMatrix;
  49306. private _projectionTextureProjectionLightMatrix;
  49307. private _projectionTextureScalingMatrix;
  49308. /**
  49309. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49310. * It can cast shadows.
  49311. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49312. * @param name The light friendly name
  49313. * @param position The position of the spot light in the scene
  49314. * @param direction The direction of the light in the scene
  49315. * @param angle The cone angle of the light in Radians
  49316. * @param exponent The light decay speed with the distance from the emission spot
  49317. * @param scene The scene the lights belongs to
  49318. */
  49319. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49320. /**
  49321. * Returns the string "SpotLight".
  49322. * @returns the class name
  49323. */
  49324. getClassName(): string;
  49325. /**
  49326. * Returns the integer 2.
  49327. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49328. */
  49329. getTypeID(): number;
  49330. /**
  49331. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49332. */
  49333. protected _setDirection(value: Vector3): void;
  49334. /**
  49335. * Overrides the position setter to recompute the projection texture view light Matrix.
  49336. */
  49337. protected _setPosition(value: Vector3): void;
  49338. /**
  49339. * 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.
  49340. * Returns the SpotLight.
  49341. */
  49342. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49343. protected _computeProjectionTextureViewLightMatrix(): void;
  49344. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49345. /**
  49346. * Main function for light texture projection matrix computing.
  49347. */
  49348. protected _computeProjectionTextureMatrix(): void;
  49349. protected _buildUniformLayout(): void;
  49350. private _computeAngleValues;
  49351. /**
  49352. * Sets the passed Effect "effect" with the Light textures.
  49353. * @param effect The effect to update
  49354. * @param lightIndex The index of the light in the effect to update
  49355. * @returns The light
  49356. */
  49357. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49358. /**
  49359. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49360. * @param effect The effect to update
  49361. * @param lightIndex The index of the light in the effect to update
  49362. * @returns The spot light
  49363. */
  49364. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49365. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49366. /**
  49367. * Disposes the light and the associated resources.
  49368. */
  49369. dispose(): void;
  49370. /**
  49371. * Prepares the list of defines specific to the light type.
  49372. * @param defines the list of defines
  49373. * @param lightIndex defines the index of the light for the effect
  49374. */
  49375. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49376. }
  49377. }
  49378. declare module BABYLON {
  49379. /**
  49380. * Gizmo that enables viewing a light
  49381. */
  49382. export class LightGizmo extends Gizmo {
  49383. private _lightMesh;
  49384. private _material;
  49385. private _cachedPosition;
  49386. private _cachedForward;
  49387. private _attachedMeshParent;
  49388. /**
  49389. * Creates a LightGizmo
  49390. * @param gizmoLayer The utility layer the gizmo will be added to
  49391. */
  49392. constructor(gizmoLayer?: UtilityLayerRenderer);
  49393. private _light;
  49394. /**
  49395. * The light that the gizmo is attached to
  49396. */
  49397. set light(light: Nullable<Light>);
  49398. get light(): Nullable<Light>;
  49399. /**
  49400. * Gets the material used to render the light gizmo
  49401. */
  49402. get material(): StandardMaterial;
  49403. /**
  49404. * @hidden
  49405. * Updates the gizmo to match the attached mesh's position/rotation
  49406. */
  49407. protected _update(): void;
  49408. private static _Scale;
  49409. /**
  49410. * Creates the lines for a light mesh
  49411. */
  49412. private static _CreateLightLines;
  49413. /**
  49414. * Disposes of the light gizmo
  49415. */
  49416. dispose(): void;
  49417. private static _CreateHemisphericLightMesh;
  49418. private static _CreatePointLightMesh;
  49419. private static _CreateSpotLightMesh;
  49420. private static _CreateDirectionalLightMesh;
  49421. }
  49422. }
  49423. declare module BABYLON {
  49424. /** @hidden */
  49425. export var backgroundFragmentDeclaration: {
  49426. name: string;
  49427. shader: string;
  49428. };
  49429. }
  49430. declare module BABYLON {
  49431. /** @hidden */
  49432. export var backgroundUboDeclaration: {
  49433. name: string;
  49434. shader: string;
  49435. };
  49436. }
  49437. declare module BABYLON {
  49438. /** @hidden */
  49439. export var backgroundPixelShader: {
  49440. name: string;
  49441. shader: string;
  49442. };
  49443. }
  49444. declare module BABYLON {
  49445. /** @hidden */
  49446. export var backgroundVertexDeclaration: {
  49447. name: string;
  49448. shader: string;
  49449. };
  49450. }
  49451. declare module BABYLON {
  49452. /** @hidden */
  49453. export var backgroundVertexShader: {
  49454. name: string;
  49455. shader: string;
  49456. };
  49457. }
  49458. declare module BABYLON {
  49459. /**
  49460. * Background material used to create an efficient environement around your scene.
  49461. */
  49462. export class BackgroundMaterial extends PushMaterial {
  49463. /**
  49464. * Standard reflectance value at parallel view angle.
  49465. */
  49466. static StandardReflectance0: number;
  49467. /**
  49468. * Standard reflectance value at grazing angle.
  49469. */
  49470. static StandardReflectance90: number;
  49471. protected _primaryColor: Color3;
  49472. /**
  49473. * Key light Color (multiply against the environement texture)
  49474. */
  49475. primaryColor: Color3;
  49476. protected __perceptualColor: Nullable<Color3>;
  49477. /**
  49478. * Experimental Internal Use Only.
  49479. *
  49480. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49481. * This acts as a helper to set the primary color to a more "human friendly" value.
  49482. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49483. * output color as close as possible from the chosen value.
  49484. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49485. * part of lighting setup.)
  49486. */
  49487. get _perceptualColor(): Nullable<Color3>;
  49488. set _perceptualColor(value: Nullable<Color3>);
  49489. protected _primaryColorShadowLevel: float;
  49490. /**
  49491. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49492. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49493. */
  49494. get primaryColorShadowLevel(): float;
  49495. set primaryColorShadowLevel(value: float);
  49496. protected _primaryColorHighlightLevel: float;
  49497. /**
  49498. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49499. * The primary color is used at the level chosen to define what the white area would look.
  49500. */
  49501. get primaryColorHighlightLevel(): float;
  49502. set primaryColorHighlightLevel(value: float);
  49503. protected _reflectionTexture: Nullable<BaseTexture>;
  49504. /**
  49505. * Reflection Texture used in the material.
  49506. * Should be author in a specific way for the best result (refer to the documentation).
  49507. */
  49508. reflectionTexture: Nullable<BaseTexture>;
  49509. protected _reflectionBlur: float;
  49510. /**
  49511. * Reflection Texture level of blur.
  49512. *
  49513. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49514. * texture twice.
  49515. */
  49516. reflectionBlur: float;
  49517. protected _diffuseTexture: Nullable<BaseTexture>;
  49518. /**
  49519. * Diffuse Texture used in the material.
  49520. * Should be author in a specific way for the best result (refer to the documentation).
  49521. */
  49522. diffuseTexture: Nullable<BaseTexture>;
  49523. protected _shadowLights: Nullable<IShadowLight[]>;
  49524. /**
  49525. * Specify the list of lights casting shadow on the material.
  49526. * All scene shadow lights will be included if null.
  49527. */
  49528. shadowLights: Nullable<IShadowLight[]>;
  49529. protected _shadowLevel: float;
  49530. /**
  49531. * Helps adjusting the shadow to a softer level if required.
  49532. * 0 means black shadows and 1 means no shadows.
  49533. */
  49534. shadowLevel: float;
  49535. protected _sceneCenter: Vector3;
  49536. /**
  49537. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49538. * It is usually zero but might be interesting to modify according to your setup.
  49539. */
  49540. sceneCenter: Vector3;
  49541. protected _opacityFresnel: boolean;
  49542. /**
  49543. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49544. * This helps ensuring a nice transition when the camera goes under the ground.
  49545. */
  49546. opacityFresnel: boolean;
  49547. protected _reflectionFresnel: boolean;
  49548. /**
  49549. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49550. * This helps adding a mirror texture on the ground.
  49551. */
  49552. reflectionFresnel: boolean;
  49553. protected _reflectionFalloffDistance: number;
  49554. /**
  49555. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49556. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49557. */
  49558. reflectionFalloffDistance: number;
  49559. protected _reflectionAmount: number;
  49560. /**
  49561. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49562. */
  49563. reflectionAmount: number;
  49564. protected _reflectionReflectance0: number;
  49565. /**
  49566. * This specifies the weight of the reflection at grazing angle.
  49567. */
  49568. reflectionReflectance0: number;
  49569. protected _reflectionReflectance90: number;
  49570. /**
  49571. * This specifies the weight of the reflection at a perpendicular point of view.
  49572. */
  49573. reflectionReflectance90: number;
  49574. /**
  49575. * Sets the reflection reflectance fresnel values according to the default standard
  49576. * empirically know to work well :-)
  49577. */
  49578. set reflectionStandardFresnelWeight(value: number);
  49579. protected _useRGBColor: boolean;
  49580. /**
  49581. * Helps to directly use the maps channels instead of their level.
  49582. */
  49583. useRGBColor: boolean;
  49584. protected _enableNoise: boolean;
  49585. /**
  49586. * This helps reducing the banding effect that could occur on the background.
  49587. */
  49588. enableNoise: boolean;
  49589. /**
  49590. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49591. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49592. * Recommended to be keep at 1.0 except for special cases.
  49593. */
  49594. get fovMultiplier(): number;
  49595. set fovMultiplier(value: number);
  49596. private _fovMultiplier;
  49597. /**
  49598. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49599. */
  49600. useEquirectangularFOV: boolean;
  49601. private _maxSimultaneousLights;
  49602. /**
  49603. * Number of Simultaneous lights allowed on the material.
  49604. */
  49605. maxSimultaneousLights: int;
  49606. /**
  49607. * Default configuration related to image processing available in the Background Material.
  49608. */
  49609. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49610. /**
  49611. * Keep track of the image processing observer to allow dispose and replace.
  49612. */
  49613. private _imageProcessingObserver;
  49614. /**
  49615. * Attaches a new image processing configuration to the PBR Material.
  49616. * @param configuration (if null the scene configuration will be use)
  49617. */
  49618. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49619. /**
  49620. * Gets the image processing configuration used either in this material.
  49621. */
  49622. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49623. /**
  49624. * Sets the Default image processing configuration used either in the this material.
  49625. *
  49626. * If sets to null, the scene one is in use.
  49627. */
  49628. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49629. /**
  49630. * Gets wether the color curves effect is enabled.
  49631. */
  49632. get cameraColorCurvesEnabled(): boolean;
  49633. /**
  49634. * Sets wether the color curves effect is enabled.
  49635. */
  49636. set cameraColorCurvesEnabled(value: boolean);
  49637. /**
  49638. * Gets wether the color grading effect is enabled.
  49639. */
  49640. get cameraColorGradingEnabled(): boolean;
  49641. /**
  49642. * Gets wether the color grading effect is enabled.
  49643. */
  49644. set cameraColorGradingEnabled(value: boolean);
  49645. /**
  49646. * Gets wether tonemapping is enabled or not.
  49647. */
  49648. get cameraToneMappingEnabled(): boolean;
  49649. /**
  49650. * Sets wether tonemapping is enabled or not
  49651. */
  49652. set cameraToneMappingEnabled(value: boolean);
  49653. /**
  49654. * The camera exposure used on this material.
  49655. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49656. * This corresponds to a photographic exposure.
  49657. */
  49658. get cameraExposure(): float;
  49659. /**
  49660. * The camera exposure used on this material.
  49661. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49662. * This corresponds to a photographic exposure.
  49663. */
  49664. set cameraExposure(value: float);
  49665. /**
  49666. * Gets The camera contrast used on this material.
  49667. */
  49668. get cameraContrast(): float;
  49669. /**
  49670. * Sets The camera contrast used on this material.
  49671. */
  49672. set cameraContrast(value: float);
  49673. /**
  49674. * Gets the Color Grading 2D Lookup Texture.
  49675. */
  49676. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49677. /**
  49678. * Sets the Color Grading 2D Lookup Texture.
  49679. */
  49680. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49681. /**
  49682. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49683. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49684. * 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;
  49685. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49686. */
  49687. get cameraColorCurves(): Nullable<ColorCurves>;
  49688. /**
  49689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49691. * 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;
  49692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49693. */
  49694. set cameraColorCurves(value: Nullable<ColorCurves>);
  49695. /**
  49696. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49697. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49698. */
  49699. switchToBGR: boolean;
  49700. private _renderTargets;
  49701. private _reflectionControls;
  49702. private _white;
  49703. private _primaryShadowColor;
  49704. private _primaryHighlightColor;
  49705. /**
  49706. * Instantiates a Background Material in the given scene
  49707. * @param name The friendly name of the material
  49708. * @param scene The scene to add the material to
  49709. */
  49710. constructor(name: string, scene: Scene);
  49711. /**
  49712. * Gets a boolean indicating that current material needs to register RTT
  49713. */
  49714. get hasRenderTargetTextures(): boolean;
  49715. /**
  49716. * The entire material has been created in order to prevent overdraw.
  49717. * @returns false
  49718. */
  49719. needAlphaTesting(): boolean;
  49720. /**
  49721. * The entire material has been created in order to prevent overdraw.
  49722. * @returns true if blending is enable
  49723. */
  49724. needAlphaBlending(): boolean;
  49725. /**
  49726. * Checks wether the material is ready to be rendered for a given mesh.
  49727. * @param mesh The mesh to render
  49728. * @param subMesh The submesh to check against
  49729. * @param useInstances Specify wether or not the material is used with instances
  49730. * @returns true if all the dependencies are ready (Textures, Effects...)
  49731. */
  49732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49733. /**
  49734. * Compute the primary color according to the chosen perceptual color.
  49735. */
  49736. private _computePrimaryColorFromPerceptualColor;
  49737. /**
  49738. * Compute the highlights and shadow colors according to their chosen levels.
  49739. */
  49740. private _computePrimaryColors;
  49741. /**
  49742. * Build the uniform buffer used in the material.
  49743. */
  49744. buildUniformLayout(): void;
  49745. /**
  49746. * Unbind the material.
  49747. */
  49748. unbind(): void;
  49749. /**
  49750. * Bind only the world matrix to the material.
  49751. * @param world The world matrix to bind.
  49752. */
  49753. bindOnlyWorldMatrix(world: Matrix): void;
  49754. /**
  49755. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49756. * @param world The world matrix to bind.
  49757. * @param subMesh The submesh to bind for.
  49758. */
  49759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49760. /**
  49761. * Checks to see if a texture is used in the material.
  49762. * @param texture - Base texture to use.
  49763. * @returns - Boolean specifying if a texture is used in the material.
  49764. */
  49765. hasTexture(texture: BaseTexture): boolean;
  49766. /**
  49767. * Dispose the material.
  49768. * @param forceDisposeEffect Force disposal of the associated effect.
  49769. * @param forceDisposeTextures Force disposal of the associated textures.
  49770. */
  49771. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49772. /**
  49773. * Clones the material.
  49774. * @param name The cloned name.
  49775. * @returns The cloned material.
  49776. */
  49777. clone(name: string): BackgroundMaterial;
  49778. /**
  49779. * Serializes the current material to its JSON representation.
  49780. * @returns The JSON representation.
  49781. */
  49782. serialize(): any;
  49783. /**
  49784. * Gets the class name of the material
  49785. * @returns "BackgroundMaterial"
  49786. */
  49787. getClassName(): string;
  49788. /**
  49789. * Parse a JSON input to create back a background material.
  49790. * @param source The JSON data to parse
  49791. * @param scene The scene to create the parsed material in
  49792. * @param rootUrl The root url of the assets the material depends upon
  49793. * @returns the instantiated BackgroundMaterial.
  49794. */
  49795. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49796. }
  49797. }
  49798. declare module BABYLON {
  49799. /**
  49800. * Represents the different options available during the creation of
  49801. * a Environment helper.
  49802. *
  49803. * This can control the default ground, skybox and image processing setup of your scene.
  49804. */
  49805. export interface IEnvironmentHelperOptions {
  49806. /**
  49807. * Specifies wether or not to create a ground.
  49808. * True by default.
  49809. */
  49810. createGround: boolean;
  49811. /**
  49812. * Specifies the ground size.
  49813. * 15 by default.
  49814. */
  49815. groundSize: number;
  49816. /**
  49817. * The texture used on the ground for the main color.
  49818. * Comes from the BabylonJS CDN by default.
  49819. *
  49820. * Remarks: Can be either a texture or a url.
  49821. */
  49822. groundTexture: string | BaseTexture;
  49823. /**
  49824. * The color mixed in the ground texture by default.
  49825. * BabylonJS clearColor by default.
  49826. */
  49827. groundColor: Color3;
  49828. /**
  49829. * Specifies the ground opacity.
  49830. * 1 by default.
  49831. */
  49832. groundOpacity: number;
  49833. /**
  49834. * Enables the ground to receive shadows.
  49835. * True by default.
  49836. */
  49837. enableGroundShadow: boolean;
  49838. /**
  49839. * Helps preventing the shadow to be fully black on the ground.
  49840. * 0.5 by default.
  49841. */
  49842. groundShadowLevel: number;
  49843. /**
  49844. * Creates a mirror texture attach to the ground.
  49845. * false by default.
  49846. */
  49847. enableGroundMirror: boolean;
  49848. /**
  49849. * Specifies the ground mirror size ratio.
  49850. * 0.3 by default as the default kernel is 64.
  49851. */
  49852. groundMirrorSizeRatio: number;
  49853. /**
  49854. * Specifies the ground mirror blur kernel size.
  49855. * 64 by default.
  49856. */
  49857. groundMirrorBlurKernel: number;
  49858. /**
  49859. * Specifies the ground mirror visibility amount.
  49860. * 1 by default
  49861. */
  49862. groundMirrorAmount: number;
  49863. /**
  49864. * Specifies the ground mirror reflectance weight.
  49865. * This uses the standard weight of the background material to setup the fresnel effect
  49866. * of the mirror.
  49867. * 1 by default.
  49868. */
  49869. groundMirrorFresnelWeight: number;
  49870. /**
  49871. * Specifies the ground mirror Falloff distance.
  49872. * This can helps reducing the size of the reflection.
  49873. * 0 by Default.
  49874. */
  49875. groundMirrorFallOffDistance: number;
  49876. /**
  49877. * Specifies the ground mirror texture type.
  49878. * Unsigned Int by Default.
  49879. */
  49880. groundMirrorTextureType: number;
  49881. /**
  49882. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49883. * the shown objects.
  49884. */
  49885. groundYBias: number;
  49886. /**
  49887. * Specifies wether or not to create a skybox.
  49888. * True by default.
  49889. */
  49890. createSkybox: boolean;
  49891. /**
  49892. * Specifies the skybox size.
  49893. * 20 by default.
  49894. */
  49895. skyboxSize: number;
  49896. /**
  49897. * The texture used on the skybox for the main color.
  49898. * Comes from the BabylonJS CDN by default.
  49899. *
  49900. * Remarks: Can be either a texture or a url.
  49901. */
  49902. skyboxTexture: string | BaseTexture;
  49903. /**
  49904. * The color mixed in the skybox texture by default.
  49905. * BabylonJS clearColor by default.
  49906. */
  49907. skyboxColor: Color3;
  49908. /**
  49909. * The background rotation around the Y axis of the scene.
  49910. * This helps aligning the key lights of your scene with the background.
  49911. * 0 by default.
  49912. */
  49913. backgroundYRotation: number;
  49914. /**
  49915. * Compute automatically the size of the elements to best fit with the scene.
  49916. */
  49917. sizeAuto: boolean;
  49918. /**
  49919. * Default position of the rootMesh if autoSize is not true.
  49920. */
  49921. rootPosition: Vector3;
  49922. /**
  49923. * Sets up the image processing in the scene.
  49924. * true by default.
  49925. */
  49926. setupImageProcessing: boolean;
  49927. /**
  49928. * The texture used as your environment texture in the scene.
  49929. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49930. *
  49931. * Remarks: Can be either a texture or a url.
  49932. */
  49933. environmentTexture: string | BaseTexture;
  49934. /**
  49935. * The value of the exposure to apply to the scene.
  49936. * 0.6 by default if setupImageProcessing is true.
  49937. */
  49938. cameraExposure: number;
  49939. /**
  49940. * The value of the contrast to apply to the scene.
  49941. * 1.6 by default if setupImageProcessing is true.
  49942. */
  49943. cameraContrast: number;
  49944. /**
  49945. * Specifies wether or not tonemapping should be enabled in the scene.
  49946. * true by default if setupImageProcessing is true.
  49947. */
  49948. toneMappingEnabled: boolean;
  49949. }
  49950. /**
  49951. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49952. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49953. * It also helps with the default setup of your imageProcessing configuration.
  49954. */
  49955. export class EnvironmentHelper {
  49956. /**
  49957. * Default ground texture URL.
  49958. */
  49959. private static _groundTextureCDNUrl;
  49960. /**
  49961. * Default skybox texture URL.
  49962. */
  49963. private static _skyboxTextureCDNUrl;
  49964. /**
  49965. * Default environment texture URL.
  49966. */
  49967. private static _environmentTextureCDNUrl;
  49968. /**
  49969. * Creates the default options for the helper.
  49970. */
  49971. private static _getDefaultOptions;
  49972. private _rootMesh;
  49973. /**
  49974. * Gets the root mesh created by the helper.
  49975. */
  49976. get rootMesh(): Mesh;
  49977. private _skybox;
  49978. /**
  49979. * Gets the skybox created by the helper.
  49980. */
  49981. get skybox(): Nullable<Mesh>;
  49982. private _skyboxTexture;
  49983. /**
  49984. * Gets the skybox texture created by the helper.
  49985. */
  49986. get skyboxTexture(): Nullable<BaseTexture>;
  49987. private _skyboxMaterial;
  49988. /**
  49989. * Gets the skybox material created by the helper.
  49990. */
  49991. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49992. private _ground;
  49993. /**
  49994. * Gets the ground mesh created by the helper.
  49995. */
  49996. get ground(): Nullable<Mesh>;
  49997. private _groundTexture;
  49998. /**
  49999. * Gets the ground texture created by the helper.
  50000. */
  50001. get groundTexture(): Nullable<BaseTexture>;
  50002. private _groundMirror;
  50003. /**
  50004. * Gets the ground mirror created by the helper.
  50005. */
  50006. get groundMirror(): Nullable<MirrorTexture>;
  50007. /**
  50008. * Gets the ground mirror render list to helps pushing the meshes
  50009. * you wish in the ground reflection.
  50010. */
  50011. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50012. private _groundMaterial;
  50013. /**
  50014. * Gets the ground material created by the helper.
  50015. */
  50016. get groundMaterial(): Nullable<BackgroundMaterial>;
  50017. /**
  50018. * Stores the creation options.
  50019. */
  50020. private readonly _scene;
  50021. private _options;
  50022. /**
  50023. * This observable will be notified with any error during the creation of the environment,
  50024. * mainly texture creation errors.
  50025. */
  50026. onErrorObservable: Observable<{
  50027. message?: string;
  50028. exception?: any;
  50029. }>;
  50030. /**
  50031. * constructor
  50032. * @param options Defines the options we want to customize the helper
  50033. * @param scene The scene to add the material to
  50034. */
  50035. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50036. /**
  50037. * Updates the background according to the new options
  50038. * @param options
  50039. */
  50040. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50041. /**
  50042. * Sets the primary color of all the available elements.
  50043. * @param color the main color to affect to the ground and the background
  50044. */
  50045. setMainColor(color: Color3): void;
  50046. /**
  50047. * Setup the image processing according to the specified options.
  50048. */
  50049. private _setupImageProcessing;
  50050. /**
  50051. * Setup the environment texture according to the specified options.
  50052. */
  50053. private _setupEnvironmentTexture;
  50054. /**
  50055. * Setup the background according to the specified options.
  50056. */
  50057. private _setupBackground;
  50058. /**
  50059. * Get the scene sizes according to the setup.
  50060. */
  50061. private _getSceneSize;
  50062. /**
  50063. * Setup the ground according to the specified options.
  50064. */
  50065. private _setupGround;
  50066. /**
  50067. * Setup the ground material according to the specified options.
  50068. */
  50069. private _setupGroundMaterial;
  50070. /**
  50071. * Setup the ground diffuse texture according to the specified options.
  50072. */
  50073. private _setupGroundDiffuseTexture;
  50074. /**
  50075. * Setup the ground mirror texture according to the specified options.
  50076. */
  50077. private _setupGroundMirrorTexture;
  50078. /**
  50079. * Setup the ground to receive the mirror texture.
  50080. */
  50081. private _setupMirrorInGroundMaterial;
  50082. /**
  50083. * Setup the skybox according to the specified options.
  50084. */
  50085. private _setupSkybox;
  50086. /**
  50087. * Setup the skybox material according to the specified options.
  50088. */
  50089. private _setupSkyboxMaterial;
  50090. /**
  50091. * Setup the skybox reflection texture according to the specified options.
  50092. */
  50093. private _setupSkyboxReflectionTexture;
  50094. private _errorHandler;
  50095. /**
  50096. * Dispose all the elements created by the Helper.
  50097. */
  50098. dispose(): void;
  50099. }
  50100. }
  50101. declare module BABYLON {
  50102. /**
  50103. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50104. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50105. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50106. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50107. */
  50108. export class PhotoDome extends TransformNode {
  50109. /**
  50110. * Define the image as a Monoscopic panoramic 360 image.
  50111. */
  50112. static readonly MODE_MONOSCOPIC: number;
  50113. /**
  50114. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50115. */
  50116. static readonly MODE_TOPBOTTOM: number;
  50117. /**
  50118. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50119. */
  50120. static readonly MODE_SIDEBYSIDE: number;
  50121. private _useDirectMapping;
  50122. /**
  50123. * The texture being displayed on the sphere
  50124. */
  50125. protected _photoTexture: Texture;
  50126. /**
  50127. * Gets or sets the texture being displayed on the sphere
  50128. */
  50129. get photoTexture(): Texture;
  50130. set photoTexture(value: Texture);
  50131. /**
  50132. * Observable raised when an error occured while loading the 360 image
  50133. */
  50134. onLoadErrorObservable: Observable<string>;
  50135. /**
  50136. * The skybox material
  50137. */
  50138. protected _material: BackgroundMaterial;
  50139. /**
  50140. * The surface used for the skybox
  50141. */
  50142. protected _mesh: Mesh;
  50143. /**
  50144. * Gets the mesh used for the skybox.
  50145. */
  50146. get mesh(): Mesh;
  50147. /**
  50148. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50149. * Also see the options.resolution property.
  50150. */
  50151. get fovMultiplier(): number;
  50152. set fovMultiplier(value: number);
  50153. private _imageMode;
  50154. /**
  50155. * Gets or set the current video mode for the video. It can be:
  50156. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50157. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50158. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50159. */
  50160. get imageMode(): number;
  50161. set imageMode(value: number);
  50162. /**
  50163. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50164. * @param name Element's name, child elements will append suffixes for their own names.
  50165. * @param urlsOfPhoto defines the url of the photo to display
  50166. * @param options defines an object containing optional or exposed sub element properties
  50167. * @param onError defines a callback called when an error occured while loading the texture
  50168. */
  50169. constructor(name: string, urlOfPhoto: string, options: {
  50170. resolution?: number;
  50171. size?: number;
  50172. useDirectMapping?: boolean;
  50173. faceForward?: boolean;
  50174. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50175. private _onBeforeCameraRenderObserver;
  50176. private _changeImageMode;
  50177. /**
  50178. * Releases resources associated with this node.
  50179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50181. */
  50182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50183. }
  50184. }
  50185. declare module BABYLON {
  50186. /**
  50187. * Class used to host RGBD texture specific utilities
  50188. */
  50189. export class RGBDTextureTools {
  50190. /**
  50191. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50192. * @param texture the texture to expand.
  50193. */
  50194. static ExpandRGBDTexture(texture: Texture): void;
  50195. }
  50196. }
  50197. declare module BABYLON {
  50198. /**
  50199. * Class used to host texture specific utilities
  50200. */
  50201. export class BRDFTextureTools {
  50202. /**
  50203. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50204. * @param scene defines the hosting scene
  50205. * @returns the environment BRDF texture
  50206. */
  50207. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50208. private static _environmentBRDFBase64Texture;
  50209. }
  50210. }
  50211. declare module BABYLON {
  50212. /**
  50213. * @hidden
  50214. */
  50215. export interface IMaterialClearCoatDefines {
  50216. CLEARCOAT: boolean;
  50217. CLEARCOAT_DEFAULTIOR: boolean;
  50218. CLEARCOAT_TEXTURE: boolean;
  50219. CLEARCOAT_TEXTUREDIRECTUV: number;
  50220. CLEARCOAT_BUMP: boolean;
  50221. CLEARCOAT_BUMPDIRECTUV: number;
  50222. CLEARCOAT_TINT: boolean;
  50223. CLEARCOAT_TINT_TEXTURE: boolean;
  50224. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50225. /** @hidden */
  50226. _areTexturesDirty: boolean;
  50227. }
  50228. /**
  50229. * Define the code related to the clear coat parameters of the pbr material.
  50230. */
  50231. export class PBRClearCoatConfiguration {
  50232. /**
  50233. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50234. * The default fits with a polyurethane material.
  50235. */
  50236. private static readonly _DefaultIndexOfRefraction;
  50237. private _isEnabled;
  50238. /**
  50239. * Defines if the clear coat is enabled in the material.
  50240. */
  50241. isEnabled: boolean;
  50242. /**
  50243. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50244. */
  50245. intensity: number;
  50246. /**
  50247. * Defines the clear coat layer roughness.
  50248. */
  50249. roughness: number;
  50250. private _indexOfRefraction;
  50251. /**
  50252. * Defines the index of refraction of the clear coat.
  50253. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50254. * The default fits with a polyurethane material.
  50255. * Changing the default value is more performance intensive.
  50256. */
  50257. indexOfRefraction: number;
  50258. private _texture;
  50259. /**
  50260. * Stores the clear coat values in a texture.
  50261. */
  50262. texture: Nullable<BaseTexture>;
  50263. private _bumpTexture;
  50264. /**
  50265. * Define the clear coat specific bump texture.
  50266. */
  50267. bumpTexture: Nullable<BaseTexture>;
  50268. private _isTintEnabled;
  50269. /**
  50270. * Defines if the clear coat tint is enabled in the material.
  50271. */
  50272. isTintEnabled: boolean;
  50273. /**
  50274. * Defines the clear coat tint of the material.
  50275. * This is only use if tint is enabled
  50276. */
  50277. tintColor: Color3;
  50278. /**
  50279. * Defines the distance at which the tint color should be found in the
  50280. * clear coat media.
  50281. * This is only use if tint is enabled
  50282. */
  50283. tintColorAtDistance: number;
  50284. /**
  50285. * Defines the clear coat layer thickness.
  50286. * This is only use if tint is enabled
  50287. */
  50288. tintThickness: number;
  50289. private _tintTexture;
  50290. /**
  50291. * Stores the clear tint values in a texture.
  50292. * rgb is tint
  50293. * a is a thickness factor
  50294. */
  50295. tintTexture: Nullable<BaseTexture>;
  50296. /** @hidden */
  50297. private _internalMarkAllSubMeshesAsTexturesDirty;
  50298. /** @hidden */
  50299. _markAllSubMeshesAsTexturesDirty(): void;
  50300. /**
  50301. * Instantiate a new istance of clear coat configuration.
  50302. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50303. */
  50304. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50305. /**
  50306. * Gets wehter the submesh is ready to be used or not.
  50307. * @param defines the list of "defines" to update.
  50308. * @param scene defines the scene the material belongs to.
  50309. * @param engine defines the engine the material belongs to.
  50310. * @param disableBumpMap defines wether the material disables bump or not.
  50311. * @returns - boolean indicating that the submesh is ready or not.
  50312. */
  50313. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50314. /**
  50315. * Checks to see if a texture is used in the material.
  50316. * @param defines the list of "defines" to update.
  50317. * @param scene defines the scene to the material belongs to.
  50318. */
  50319. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50320. /**
  50321. * Binds the material data.
  50322. * @param uniformBuffer defines the Uniform buffer to fill in.
  50323. * @param scene defines the scene the material belongs to.
  50324. * @param engine defines the engine the material belongs to.
  50325. * @param disableBumpMap defines wether the material disables bump or not.
  50326. * @param isFrozen defines wether the material is frozen or not.
  50327. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50328. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50329. */
  50330. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50331. /**
  50332. * Checks to see if a texture is used in the material.
  50333. * @param texture - Base texture to use.
  50334. * @returns - Boolean specifying if a texture is used in the material.
  50335. */
  50336. hasTexture(texture: BaseTexture): boolean;
  50337. /**
  50338. * Returns an array of the actively used textures.
  50339. * @param activeTextures Array of BaseTextures
  50340. */
  50341. getActiveTextures(activeTextures: BaseTexture[]): void;
  50342. /**
  50343. * Returns the animatable textures.
  50344. * @param animatables Array of animatable textures.
  50345. */
  50346. getAnimatables(animatables: IAnimatable[]): void;
  50347. /**
  50348. * Disposes the resources of the material.
  50349. * @param forceDisposeTextures - Forces the disposal of all textures.
  50350. */
  50351. dispose(forceDisposeTextures?: boolean): void;
  50352. /**
  50353. * Get the current class name of the texture useful for serialization or dynamic coding.
  50354. * @returns "PBRClearCoatConfiguration"
  50355. */
  50356. getClassName(): string;
  50357. /**
  50358. * Add fallbacks to the effect fallbacks list.
  50359. * @param defines defines the Base texture to use.
  50360. * @param fallbacks defines the current fallback list.
  50361. * @param currentRank defines the current fallback rank.
  50362. * @returns the new fallback rank.
  50363. */
  50364. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50365. /**
  50366. * Add the required uniforms to the current list.
  50367. * @param uniforms defines the current uniform list.
  50368. */
  50369. static AddUniforms(uniforms: string[]): void;
  50370. /**
  50371. * Add the required samplers to the current list.
  50372. * @param samplers defines the current sampler list.
  50373. */
  50374. static AddSamplers(samplers: string[]): void;
  50375. /**
  50376. * Add the required uniforms to the current buffer.
  50377. * @param uniformBuffer defines the current uniform buffer.
  50378. */
  50379. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50380. /**
  50381. * Makes a duplicate of the current configuration into another one.
  50382. * @param clearCoatConfiguration define the config where to copy the info
  50383. */
  50384. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50385. /**
  50386. * Serializes this clear coat configuration.
  50387. * @returns - An object with the serialized config.
  50388. */
  50389. serialize(): any;
  50390. /**
  50391. * Parses a anisotropy Configuration from a serialized object.
  50392. * @param source - Serialized object.
  50393. * @param scene Defines the scene we are parsing for
  50394. * @param rootUrl Defines the rootUrl to load from
  50395. */
  50396. parse(source: any, scene: Scene, rootUrl: string): void;
  50397. }
  50398. }
  50399. declare module BABYLON {
  50400. /**
  50401. * @hidden
  50402. */
  50403. export interface IMaterialAnisotropicDefines {
  50404. ANISOTROPIC: boolean;
  50405. ANISOTROPIC_TEXTURE: boolean;
  50406. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50407. MAINUV1: boolean;
  50408. _areTexturesDirty: boolean;
  50409. _needUVs: boolean;
  50410. }
  50411. /**
  50412. * Define the code related to the anisotropic parameters of the pbr material.
  50413. */
  50414. export class PBRAnisotropicConfiguration {
  50415. private _isEnabled;
  50416. /**
  50417. * Defines if the anisotropy is enabled in the material.
  50418. */
  50419. isEnabled: boolean;
  50420. /**
  50421. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50422. */
  50423. intensity: number;
  50424. /**
  50425. * Defines if the effect is along the tangents, bitangents or in between.
  50426. * By default, the effect is "strectching" the highlights along the tangents.
  50427. */
  50428. direction: Vector2;
  50429. private _texture;
  50430. /**
  50431. * Stores the anisotropy values in a texture.
  50432. * rg is direction (like normal from -1 to 1)
  50433. * b is a intensity
  50434. */
  50435. texture: Nullable<BaseTexture>;
  50436. /** @hidden */
  50437. private _internalMarkAllSubMeshesAsTexturesDirty;
  50438. /** @hidden */
  50439. _markAllSubMeshesAsTexturesDirty(): void;
  50440. /**
  50441. * Instantiate a new istance of anisotropy configuration.
  50442. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50443. */
  50444. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50445. /**
  50446. * Specifies that the submesh is ready to be used.
  50447. * @param defines the list of "defines" to update.
  50448. * @param scene defines the scene the material belongs to.
  50449. * @returns - boolean indicating that the submesh is ready or not.
  50450. */
  50451. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50452. /**
  50453. * Checks to see if a texture is used in the material.
  50454. * @param defines the list of "defines" to update.
  50455. * @param mesh the mesh we are preparing the defines for.
  50456. * @param scene defines the scene the material belongs to.
  50457. */
  50458. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50459. /**
  50460. * Binds the material data.
  50461. * @param uniformBuffer defines the Uniform buffer to fill in.
  50462. * @param scene defines the scene the material belongs to.
  50463. * @param isFrozen defines wether the material is frozen or not.
  50464. */
  50465. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50466. /**
  50467. * Checks to see if a texture is used in the material.
  50468. * @param texture - Base texture to use.
  50469. * @returns - Boolean specifying if a texture is used in the material.
  50470. */
  50471. hasTexture(texture: BaseTexture): boolean;
  50472. /**
  50473. * Returns an array of the actively used textures.
  50474. * @param activeTextures Array of BaseTextures
  50475. */
  50476. getActiveTextures(activeTextures: BaseTexture[]): void;
  50477. /**
  50478. * Returns the animatable textures.
  50479. * @param animatables Array of animatable textures.
  50480. */
  50481. getAnimatables(animatables: IAnimatable[]): void;
  50482. /**
  50483. * Disposes the resources of the material.
  50484. * @param forceDisposeTextures - Forces the disposal of all textures.
  50485. */
  50486. dispose(forceDisposeTextures?: boolean): void;
  50487. /**
  50488. * Get the current class name of the texture useful for serialization or dynamic coding.
  50489. * @returns "PBRAnisotropicConfiguration"
  50490. */
  50491. getClassName(): string;
  50492. /**
  50493. * Add fallbacks to the effect fallbacks list.
  50494. * @param defines defines the Base texture to use.
  50495. * @param fallbacks defines the current fallback list.
  50496. * @param currentRank defines the current fallback rank.
  50497. * @returns the new fallback rank.
  50498. */
  50499. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50500. /**
  50501. * Add the required uniforms to the current list.
  50502. * @param uniforms defines the current uniform list.
  50503. */
  50504. static AddUniforms(uniforms: string[]): void;
  50505. /**
  50506. * Add the required uniforms to the current buffer.
  50507. * @param uniformBuffer defines the current uniform buffer.
  50508. */
  50509. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50510. /**
  50511. * Add the required samplers to the current list.
  50512. * @param samplers defines the current sampler list.
  50513. */
  50514. static AddSamplers(samplers: string[]): void;
  50515. /**
  50516. * Makes a duplicate of the current configuration into another one.
  50517. * @param anisotropicConfiguration define the config where to copy the info
  50518. */
  50519. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50520. /**
  50521. * Serializes this anisotropy configuration.
  50522. * @returns - An object with the serialized config.
  50523. */
  50524. serialize(): any;
  50525. /**
  50526. * Parses a anisotropy Configuration from a serialized object.
  50527. * @param source - Serialized object.
  50528. * @param scene Defines the scene we are parsing for
  50529. * @param rootUrl Defines the rootUrl to load from
  50530. */
  50531. parse(source: any, scene: Scene, rootUrl: string): void;
  50532. }
  50533. }
  50534. declare module BABYLON {
  50535. /**
  50536. * @hidden
  50537. */
  50538. export interface IMaterialBRDFDefines {
  50539. BRDF_V_HEIGHT_CORRELATED: boolean;
  50540. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50541. SPHERICAL_HARMONICS: boolean;
  50542. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50543. /** @hidden */
  50544. _areMiscDirty: boolean;
  50545. }
  50546. /**
  50547. * Define the code related to the BRDF parameters of the pbr material.
  50548. */
  50549. export class PBRBRDFConfiguration {
  50550. /**
  50551. * Default value used for the energy conservation.
  50552. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50553. */
  50554. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50555. /**
  50556. * Default value used for the Smith Visibility Height Correlated mode.
  50557. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50558. */
  50559. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50560. /**
  50561. * Default value used for the IBL diffuse part.
  50562. * This can help switching back to the polynomials mode globally which is a tiny bit
  50563. * less GPU intensive at the drawback of a lower quality.
  50564. */
  50565. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50566. /**
  50567. * Default value used for activating energy conservation for the specular workflow.
  50568. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50569. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50570. */
  50571. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50572. private _useEnergyConservation;
  50573. /**
  50574. * Defines if the material uses energy conservation.
  50575. */
  50576. useEnergyConservation: boolean;
  50577. private _useSmithVisibilityHeightCorrelated;
  50578. /**
  50579. * LEGACY Mode set to false
  50580. * Defines if the material uses height smith correlated visibility term.
  50581. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50582. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50583. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50584. * Not relying on height correlated will also disable energy conservation.
  50585. */
  50586. useSmithVisibilityHeightCorrelated: boolean;
  50587. private _useSphericalHarmonics;
  50588. /**
  50589. * LEGACY Mode set to false
  50590. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50591. * diffuse part of the IBL.
  50592. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50593. * to the ground truth.
  50594. */
  50595. useSphericalHarmonics: boolean;
  50596. private _useSpecularGlossinessInputEnergyConservation;
  50597. /**
  50598. * Defines if the material uses energy conservation, when the specular workflow is active.
  50599. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50600. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50601. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50602. */
  50603. useSpecularGlossinessInputEnergyConservation: boolean;
  50604. /** @hidden */
  50605. private _internalMarkAllSubMeshesAsMiscDirty;
  50606. /** @hidden */
  50607. _markAllSubMeshesAsMiscDirty(): void;
  50608. /**
  50609. * Instantiate a new istance of clear coat configuration.
  50610. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50611. */
  50612. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50613. /**
  50614. * Checks to see if a texture is used in the material.
  50615. * @param defines the list of "defines" to update.
  50616. */
  50617. prepareDefines(defines: IMaterialBRDFDefines): void;
  50618. /**
  50619. * Get the current class name of the texture useful for serialization or dynamic coding.
  50620. * @returns "PBRClearCoatConfiguration"
  50621. */
  50622. getClassName(): string;
  50623. /**
  50624. * Makes a duplicate of the current configuration into another one.
  50625. * @param brdfConfiguration define the config where to copy the info
  50626. */
  50627. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50628. /**
  50629. * Serializes this BRDF configuration.
  50630. * @returns - An object with the serialized config.
  50631. */
  50632. serialize(): any;
  50633. /**
  50634. * Parses a anisotropy Configuration from a serialized object.
  50635. * @param source - Serialized object.
  50636. * @param scene Defines the scene we are parsing for
  50637. * @param rootUrl Defines the rootUrl to load from
  50638. */
  50639. parse(source: any, scene: Scene, rootUrl: string): void;
  50640. }
  50641. }
  50642. declare module BABYLON {
  50643. /**
  50644. * @hidden
  50645. */
  50646. export interface IMaterialSheenDefines {
  50647. SHEEN: boolean;
  50648. SHEEN_TEXTURE: boolean;
  50649. SHEEN_TEXTUREDIRECTUV: number;
  50650. SHEEN_LINKWITHALBEDO: boolean;
  50651. /** @hidden */
  50652. _areTexturesDirty: boolean;
  50653. }
  50654. /**
  50655. * Define the code related to the Sheen parameters of the pbr material.
  50656. */
  50657. export class PBRSheenConfiguration {
  50658. private _isEnabled;
  50659. /**
  50660. * Defines if the material uses sheen.
  50661. */
  50662. isEnabled: boolean;
  50663. private _linkSheenWithAlbedo;
  50664. /**
  50665. * Defines if the sheen is linked to the sheen color.
  50666. */
  50667. linkSheenWithAlbedo: boolean;
  50668. /**
  50669. * Defines the sheen intensity.
  50670. */
  50671. intensity: number;
  50672. /**
  50673. * Defines the sheen color.
  50674. */
  50675. color: Color3;
  50676. private _texture;
  50677. /**
  50678. * Stores the sheen tint values in a texture.
  50679. * rgb is tint
  50680. * a is a intensity
  50681. */
  50682. texture: Nullable<BaseTexture>;
  50683. /** @hidden */
  50684. private _internalMarkAllSubMeshesAsTexturesDirty;
  50685. /** @hidden */
  50686. _markAllSubMeshesAsTexturesDirty(): void;
  50687. /**
  50688. * Instantiate a new istance of clear coat configuration.
  50689. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50690. */
  50691. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50692. /**
  50693. * Specifies that the submesh is ready to be used.
  50694. * @param defines the list of "defines" to update.
  50695. * @param scene defines the scene the material belongs to.
  50696. * @returns - boolean indicating that the submesh is ready or not.
  50697. */
  50698. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50699. /**
  50700. * Checks to see if a texture is used in the material.
  50701. * @param defines the list of "defines" to update.
  50702. * @param scene defines the scene the material belongs to.
  50703. */
  50704. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50705. /**
  50706. * Binds the material data.
  50707. * @param uniformBuffer defines the Uniform buffer to fill in.
  50708. * @param scene defines the scene the material belongs to.
  50709. * @param isFrozen defines wether the material is frozen or not.
  50710. */
  50711. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50712. /**
  50713. * Checks to see if a texture is used in the material.
  50714. * @param texture - Base texture to use.
  50715. * @returns - Boolean specifying if a texture is used in the material.
  50716. */
  50717. hasTexture(texture: BaseTexture): boolean;
  50718. /**
  50719. * Returns an array of the actively used textures.
  50720. * @param activeTextures Array of BaseTextures
  50721. */
  50722. getActiveTextures(activeTextures: BaseTexture[]): void;
  50723. /**
  50724. * Returns the animatable textures.
  50725. * @param animatables Array of animatable textures.
  50726. */
  50727. getAnimatables(animatables: IAnimatable[]): void;
  50728. /**
  50729. * Disposes the resources of the material.
  50730. * @param forceDisposeTextures - Forces the disposal of all textures.
  50731. */
  50732. dispose(forceDisposeTextures?: boolean): void;
  50733. /**
  50734. * Get the current class name of the texture useful for serialization or dynamic coding.
  50735. * @returns "PBRSheenConfiguration"
  50736. */
  50737. getClassName(): string;
  50738. /**
  50739. * Add fallbacks to the effect fallbacks list.
  50740. * @param defines defines the Base texture to use.
  50741. * @param fallbacks defines the current fallback list.
  50742. * @param currentRank defines the current fallback rank.
  50743. * @returns the new fallback rank.
  50744. */
  50745. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50746. /**
  50747. * Add the required uniforms to the current list.
  50748. * @param uniforms defines the current uniform list.
  50749. */
  50750. static AddUniforms(uniforms: string[]): void;
  50751. /**
  50752. * Add the required uniforms to the current buffer.
  50753. * @param uniformBuffer defines the current uniform buffer.
  50754. */
  50755. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50756. /**
  50757. * Add the required samplers to the current list.
  50758. * @param samplers defines the current sampler list.
  50759. */
  50760. static AddSamplers(samplers: string[]): void;
  50761. /**
  50762. * Makes a duplicate of the current configuration into another one.
  50763. * @param sheenConfiguration define the config where to copy the info
  50764. */
  50765. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50766. /**
  50767. * Serializes this BRDF configuration.
  50768. * @returns - An object with the serialized config.
  50769. */
  50770. serialize(): any;
  50771. /**
  50772. * Parses a anisotropy Configuration from a serialized object.
  50773. * @param source - Serialized object.
  50774. * @param scene Defines the scene we are parsing for
  50775. * @param rootUrl Defines the rootUrl to load from
  50776. */
  50777. parse(source: any, scene: Scene, rootUrl: string): void;
  50778. }
  50779. }
  50780. declare module BABYLON {
  50781. /**
  50782. * @hidden
  50783. */
  50784. export interface IMaterialSubSurfaceDefines {
  50785. SUBSURFACE: boolean;
  50786. SS_REFRACTION: boolean;
  50787. SS_TRANSLUCENCY: boolean;
  50788. SS_SCATERRING: boolean;
  50789. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50790. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50791. SS_REFRACTIONMAP_3D: boolean;
  50792. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50793. SS_LODINREFRACTIONALPHA: boolean;
  50794. SS_GAMMAREFRACTION: boolean;
  50795. SS_RGBDREFRACTION: boolean;
  50796. SS_LINEARSPECULARREFRACTION: boolean;
  50797. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50798. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50799. /** @hidden */
  50800. _areTexturesDirty: boolean;
  50801. }
  50802. /**
  50803. * Define the code related to the sub surface parameters of the pbr material.
  50804. */
  50805. export class PBRSubSurfaceConfiguration {
  50806. private _isRefractionEnabled;
  50807. /**
  50808. * Defines if the refraction is enabled in the material.
  50809. */
  50810. isRefractionEnabled: boolean;
  50811. private _isTranslucencyEnabled;
  50812. /**
  50813. * Defines if the translucency is enabled in the material.
  50814. */
  50815. isTranslucencyEnabled: boolean;
  50816. private _isScatteringEnabled;
  50817. /**
  50818. * Defines the refraction intensity of the material.
  50819. * The refraction when enabled replaces the Diffuse part of the material.
  50820. * The intensity helps transitionning between diffuse and refraction.
  50821. */
  50822. refractionIntensity: number;
  50823. /**
  50824. * Defines the translucency intensity of the material.
  50825. * When translucency has been enabled, this defines how much of the "translucency"
  50826. * is addded to the diffuse part of the material.
  50827. */
  50828. translucencyIntensity: number;
  50829. /**
  50830. * Defines the scattering intensity of the material.
  50831. * When scattering has been enabled, this defines how much of the "scattered light"
  50832. * is addded to the diffuse part of the material.
  50833. */
  50834. scatteringIntensity: number;
  50835. private _thicknessTexture;
  50836. /**
  50837. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50838. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50839. * 0 would mean minimumThickness
  50840. * 1 would mean maximumThickness
  50841. * The other channels might be use as a mask to vary the different effects intensity.
  50842. */
  50843. thicknessTexture: Nullable<BaseTexture>;
  50844. private _refractionTexture;
  50845. /**
  50846. * Defines the texture to use for refraction.
  50847. */
  50848. refractionTexture: Nullable<BaseTexture>;
  50849. private _indexOfRefraction;
  50850. /**
  50851. * Defines the index of refraction used in the material.
  50852. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50853. */
  50854. indexOfRefraction: number;
  50855. private _invertRefractionY;
  50856. /**
  50857. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50858. */
  50859. invertRefractionY: boolean;
  50860. private _linkRefractionWithTransparency;
  50861. /**
  50862. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50863. * Materials half opaque for instance using refraction could benefit from this control.
  50864. */
  50865. linkRefractionWithTransparency: boolean;
  50866. /**
  50867. * Defines the minimum thickness stored in the thickness map.
  50868. * If no thickness map is defined, this value will be used to simulate thickness.
  50869. */
  50870. minimumThickness: number;
  50871. /**
  50872. * Defines the maximum thickness stored in the thickness map.
  50873. */
  50874. maximumThickness: number;
  50875. /**
  50876. * Defines the volume tint of the material.
  50877. * This is used for both translucency and scattering.
  50878. */
  50879. tintColor: Color3;
  50880. /**
  50881. * Defines the distance at which the tint color should be found in the media.
  50882. * This is used for refraction only.
  50883. */
  50884. tintColorAtDistance: number;
  50885. /**
  50886. * Defines how far each channel transmit through the media.
  50887. * It is defined as a color to simplify it selection.
  50888. */
  50889. diffusionDistance: Color3;
  50890. private _useMaskFromThicknessTexture;
  50891. /**
  50892. * Stores the intensity of the different subsurface effects in the thickness texture.
  50893. * * the green channel is the translucency intensity.
  50894. * * the blue channel is the scattering intensity.
  50895. * * the alpha channel is the refraction intensity.
  50896. */
  50897. useMaskFromThicknessTexture: boolean;
  50898. /** @hidden */
  50899. private _internalMarkAllSubMeshesAsTexturesDirty;
  50900. /** @hidden */
  50901. _markAllSubMeshesAsTexturesDirty(): void;
  50902. /**
  50903. * Instantiate a new istance of sub surface configuration.
  50904. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50905. */
  50906. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50907. /**
  50908. * Gets wehter the submesh is ready to be used or not.
  50909. * @param defines the list of "defines" to update.
  50910. * @param scene defines the scene the material belongs to.
  50911. * @returns - boolean indicating that the submesh is ready or not.
  50912. */
  50913. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50914. /**
  50915. * Checks to see if a texture is used in the material.
  50916. * @param defines the list of "defines" to update.
  50917. * @param scene defines the scene to the material belongs to.
  50918. */
  50919. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50920. /**
  50921. * Binds the material data.
  50922. * @param uniformBuffer defines the Uniform buffer to fill in.
  50923. * @param scene defines the scene the material belongs to.
  50924. * @param engine defines the engine the material belongs to.
  50925. * @param isFrozen defines wether the material is frozen or not.
  50926. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50927. */
  50928. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50929. /**
  50930. * Unbinds the material from the mesh.
  50931. * @param activeEffect defines the effect that should be unbound from.
  50932. * @returns true if unbound, otherwise false
  50933. */
  50934. unbind(activeEffect: Effect): boolean;
  50935. /**
  50936. * Returns the texture used for refraction or null if none is used.
  50937. * @param scene defines the scene the material belongs to.
  50938. * @returns - Refraction texture if present. If no refraction texture and refraction
  50939. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50940. */
  50941. private _getRefractionTexture;
  50942. /**
  50943. * Returns true if alpha blending should be disabled.
  50944. */
  50945. get disableAlphaBlending(): boolean;
  50946. /**
  50947. * Fills the list of render target textures.
  50948. * @param renderTargets the list of render targets to update
  50949. */
  50950. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50951. /**
  50952. * Checks to see if a texture is used in the material.
  50953. * @param texture - Base texture to use.
  50954. * @returns - Boolean specifying if a texture is used in the material.
  50955. */
  50956. hasTexture(texture: BaseTexture): boolean;
  50957. /**
  50958. * Gets a boolean indicating that current material needs to register RTT
  50959. * @returns true if this uses a render target otherwise false.
  50960. */
  50961. hasRenderTargetTextures(): boolean;
  50962. /**
  50963. * Returns an array of the actively used textures.
  50964. * @param activeTextures Array of BaseTextures
  50965. */
  50966. getActiveTextures(activeTextures: BaseTexture[]): void;
  50967. /**
  50968. * Returns the animatable textures.
  50969. * @param animatables Array of animatable textures.
  50970. */
  50971. getAnimatables(animatables: IAnimatable[]): void;
  50972. /**
  50973. * Disposes the resources of the material.
  50974. * @param forceDisposeTextures - Forces the disposal of all textures.
  50975. */
  50976. dispose(forceDisposeTextures?: boolean): void;
  50977. /**
  50978. * Get the current class name of the texture useful for serialization or dynamic coding.
  50979. * @returns "PBRSubSurfaceConfiguration"
  50980. */
  50981. getClassName(): string;
  50982. /**
  50983. * Add fallbacks to the effect fallbacks list.
  50984. * @param defines defines the Base texture to use.
  50985. * @param fallbacks defines the current fallback list.
  50986. * @param currentRank defines the current fallback rank.
  50987. * @returns the new fallback rank.
  50988. */
  50989. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50990. /**
  50991. * Add the required uniforms to the current list.
  50992. * @param uniforms defines the current uniform list.
  50993. */
  50994. static AddUniforms(uniforms: string[]): void;
  50995. /**
  50996. * Add the required samplers to the current list.
  50997. * @param samplers defines the current sampler list.
  50998. */
  50999. static AddSamplers(samplers: string[]): void;
  51000. /**
  51001. * Add the required uniforms to the current buffer.
  51002. * @param uniformBuffer defines the current uniform buffer.
  51003. */
  51004. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51005. /**
  51006. * Makes a duplicate of the current configuration into another one.
  51007. * @param configuration define the config where to copy the info
  51008. */
  51009. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51010. /**
  51011. * Serializes this Sub Surface configuration.
  51012. * @returns - An object with the serialized config.
  51013. */
  51014. serialize(): any;
  51015. /**
  51016. * Parses a anisotropy Configuration from a serialized object.
  51017. * @param source - Serialized object.
  51018. * @param scene Defines the scene we are parsing for
  51019. * @param rootUrl Defines the rootUrl to load from
  51020. */
  51021. parse(source: any, scene: Scene, rootUrl: string): void;
  51022. }
  51023. }
  51024. declare module BABYLON {
  51025. /** @hidden */
  51026. export var pbrFragmentDeclaration: {
  51027. name: string;
  51028. shader: string;
  51029. };
  51030. }
  51031. declare module BABYLON {
  51032. /** @hidden */
  51033. export var pbrUboDeclaration: {
  51034. name: string;
  51035. shader: string;
  51036. };
  51037. }
  51038. declare module BABYLON {
  51039. /** @hidden */
  51040. export var pbrFragmentExtraDeclaration: {
  51041. name: string;
  51042. shader: string;
  51043. };
  51044. }
  51045. declare module BABYLON {
  51046. /** @hidden */
  51047. export var pbrFragmentSamplersDeclaration: {
  51048. name: string;
  51049. shader: string;
  51050. };
  51051. }
  51052. declare module BABYLON {
  51053. /** @hidden */
  51054. export var pbrHelperFunctions: {
  51055. name: string;
  51056. shader: string;
  51057. };
  51058. }
  51059. declare module BABYLON {
  51060. /** @hidden */
  51061. export var harmonicsFunctions: {
  51062. name: string;
  51063. shader: string;
  51064. };
  51065. }
  51066. declare module BABYLON {
  51067. /** @hidden */
  51068. export var pbrDirectLightingSetupFunctions: {
  51069. name: string;
  51070. shader: string;
  51071. };
  51072. }
  51073. declare module BABYLON {
  51074. /** @hidden */
  51075. export var pbrDirectLightingFalloffFunctions: {
  51076. name: string;
  51077. shader: string;
  51078. };
  51079. }
  51080. declare module BABYLON {
  51081. /** @hidden */
  51082. export var pbrBRDFFunctions: {
  51083. name: string;
  51084. shader: string;
  51085. };
  51086. }
  51087. declare module BABYLON {
  51088. /** @hidden */
  51089. export var pbrDirectLightingFunctions: {
  51090. name: string;
  51091. shader: string;
  51092. };
  51093. }
  51094. declare module BABYLON {
  51095. /** @hidden */
  51096. export var pbrIBLFunctions: {
  51097. name: string;
  51098. shader: string;
  51099. };
  51100. }
  51101. declare module BABYLON {
  51102. /** @hidden */
  51103. export var pbrDebug: {
  51104. name: string;
  51105. shader: string;
  51106. };
  51107. }
  51108. declare module BABYLON {
  51109. /** @hidden */
  51110. export var pbrPixelShader: {
  51111. name: string;
  51112. shader: string;
  51113. };
  51114. }
  51115. declare module BABYLON {
  51116. /** @hidden */
  51117. export var pbrVertexDeclaration: {
  51118. name: string;
  51119. shader: string;
  51120. };
  51121. }
  51122. declare module BABYLON {
  51123. /** @hidden */
  51124. export var pbrVertexShader: {
  51125. name: string;
  51126. shader: string;
  51127. };
  51128. }
  51129. declare module BABYLON {
  51130. /**
  51131. * Manages the defines for the PBR Material.
  51132. * @hidden
  51133. */
  51134. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51135. PBR: boolean;
  51136. MAINUV1: boolean;
  51137. MAINUV2: boolean;
  51138. UV1: boolean;
  51139. UV2: boolean;
  51140. ALBEDO: boolean;
  51141. ALBEDODIRECTUV: number;
  51142. VERTEXCOLOR: boolean;
  51143. AMBIENT: boolean;
  51144. AMBIENTDIRECTUV: number;
  51145. AMBIENTINGRAYSCALE: boolean;
  51146. OPACITY: boolean;
  51147. VERTEXALPHA: boolean;
  51148. OPACITYDIRECTUV: number;
  51149. OPACITYRGB: boolean;
  51150. ALPHATEST: boolean;
  51151. DEPTHPREPASS: boolean;
  51152. ALPHABLEND: boolean;
  51153. ALPHAFROMALBEDO: boolean;
  51154. ALPHATESTVALUE: string;
  51155. SPECULAROVERALPHA: boolean;
  51156. RADIANCEOVERALPHA: boolean;
  51157. ALPHAFRESNEL: boolean;
  51158. LINEARALPHAFRESNEL: boolean;
  51159. PREMULTIPLYALPHA: boolean;
  51160. EMISSIVE: boolean;
  51161. EMISSIVEDIRECTUV: number;
  51162. REFLECTIVITY: boolean;
  51163. REFLECTIVITYDIRECTUV: number;
  51164. SPECULARTERM: boolean;
  51165. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51166. MICROSURFACEAUTOMATIC: boolean;
  51167. LODBASEDMICROSFURACE: boolean;
  51168. MICROSURFACEMAP: boolean;
  51169. MICROSURFACEMAPDIRECTUV: number;
  51170. METALLICWORKFLOW: boolean;
  51171. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51172. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51173. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51174. AOSTOREINMETALMAPRED: boolean;
  51175. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51176. ENVIRONMENTBRDF: boolean;
  51177. ENVIRONMENTBRDF_RGBD: boolean;
  51178. NORMAL: boolean;
  51179. TANGENT: boolean;
  51180. BUMP: boolean;
  51181. BUMPDIRECTUV: number;
  51182. OBJECTSPACE_NORMALMAP: boolean;
  51183. PARALLAX: boolean;
  51184. PARALLAXOCCLUSION: boolean;
  51185. NORMALXYSCALE: boolean;
  51186. LIGHTMAP: boolean;
  51187. LIGHTMAPDIRECTUV: number;
  51188. USELIGHTMAPASSHADOWMAP: boolean;
  51189. GAMMALIGHTMAP: boolean;
  51190. RGBDLIGHTMAP: boolean;
  51191. REFLECTION: boolean;
  51192. REFLECTIONMAP_3D: boolean;
  51193. REFLECTIONMAP_SPHERICAL: boolean;
  51194. REFLECTIONMAP_PLANAR: boolean;
  51195. REFLECTIONMAP_CUBIC: boolean;
  51196. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51197. REFLECTIONMAP_PROJECTION: boolean;
  51198. REFLECTIONMAP_SKYBOX: boolean;
  51199. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51200. REFLECTIONMAP_EXPLICIT: boolean;
  51201. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51202. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51203. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51204. INVERTCUBICMAP: boolean;
  51205. USESPHERICALFROMREFLECTIONMAP: boolean;
  51206. USEIRRADIANCEMAP: boolean;
  51207. SPHERICAL_HARMONICS: boolean;
  51208. USESPHERICALINVERTEX: boolean;
  51209. REFLECTIONMAP_OPPOSITEZ: boolean;
  51210. LODINREFLECTIONALPHA: boolean;
  51211. GAMMAREFLECTION: boolean;
  51212. RGBDREFLECTION: boolean;
  51213. LINEARSPECULARREFLECTION: boolean;
  51214. RADIANCEOCCLUSION: boolean;
  51215. HORIZONOCCLUSION: boolean;
  51216. INSTANCES: boolean;
  51217. NUM_BONE_INFLUENCERS: number;
  51218. BonesPerMesh: number;
  51219. BONETEXTURE: boolean;
  51220. NONUNIFORMSCALING: boolean;
  51221. MORPHTARGETS: boolean;
  51222. MORPHTARGETS_NORMAL: boolean;
  51223. MORPHTARGETS_TANGENT: boolean;
  51224. MORPHTARGETS_UV: boolean;
  51225. NUM_MORPH_INFLUENCERS: number;
  51226. IMAGEPROCESSING: boolean;
  51227. VIGNETTE: boolean;
  51228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51229. VIGNETTEBLENDMODEOPAQUE: boolean;
  51230. TONEMAPPING: boolean;
  51231. TONEMAPPING_ACES: boolean;
  51232. CONTRAST: boolean;
  51233. COLORCURVES: boolean;
  51234. COLORGRADING: boolean;
  51235. COLORGRADING3D: boolean;
  51236. SAMPLER3DGREENDEPTH: boolean;
  51237. SAMPLER3DBGRMAP: boolean;
  51238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51239. EXPOSURE: boolean;
  51240. MULTIVIEW: boolean;
  51241. USEPHYSICALLIGHTFALLOFF: boolean;
  51242. USEGLTFLIGHTFALLOFF: boolean;
  51243. TWOSIDEDLIGHTING: boolean;
  51244. SHADOWFLOAT: boolean;
  51245. CLIPPLANE: boolean;
  51246. CLIPPLANE2: boolean;
  51247. CLIPPLANE3: boolean;
  51248. CLIPPLANE4: boolean;
  51249. CLIPPLANE5: boolean;
  51250. CLIPPLANE6: boolean;
  51251. POINTSIZE: boolean;
  51252. FOG: boolean;
  51253. LOGARITHMICDEPTH: boolean;
  51254. FORCENORMALFORWARD: boolean;
  51255. SPECULARAA: boolean;
  51256. CLEARCOAT: boolean;
  51257. CLEARCOAT_DEFAULTIOR: boolean;
  51258. CLEARCOAT_TEXTURE: boolean;
  51259. CLEARCOAT_TEXTUREDIRECTUV: number;
  51260. CLEARCOAT_BUMP: boolean;
  51261. CLEARCOAT_BUMPDIRECTUV: number;
  51262. CLEARCOAT_TINT: boolean;
  51263. CLEARCOAT_TINT_TEXTURE: boolean;
  51264. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51265. ANISOTROPIC: boolean;
  51266. ANISOTROPIC_TEXTURE: boolean;
  51267. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51268. BRDF_V_HEIGHT_CORRELATED: boolean;
  51269. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51270. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51271. SHEEN: boolean;
  51272. SHEEN_TEXTURE: boolean;
  51273. SHEEN_TEXTUREDIRECTUV: number;
  51274. SHEEN_LINKWITHALBEDO: boolean;
  51275. SUBSURFACE: boolean;
  51276. SS_REFRACTION: boolean;
  51277. SS_TRANSLUCENCY: boolean;
  51278. SS_SCATERRING: boolean;
  51279. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51280. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51281. SS_REFRACTIONMAP_3D: boolean;
  51282. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51283. SS_LODINREFRACTIONALPHA: boolean;
  51284. SS_GAMMAREFRACTION: boolean;
  51285. SS_RGBDREFRACTION: boolean;
  51286. SS_LINEARSPECULARREFRACTION: boolean;
  51287. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51288. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51289. UNLIT: boolean;
  51290. DEBUGMODE: number;
  51291. /**
  51292. * Initializes the PBR Material defines.
  51293. */
  51294. constructor();
  51295. /**
  51296. * Resets the PBR Material defines.
  51297. */
  51298. reset(): void;
  51299. }
  51300. /**
  51301. * The Physically based material base class of BJS.
  51302. *
  51303. * This offers the main features of a standard PBR material.
  51304. * For more information, please refer to the documentation :
  51305. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51306. */
  51307. export abstract class PBRBaseMaterial extends PushMaterial {
  51308. /**
  51309. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51310. */
  51311. static readonly PBRMATERIAL_OPAQUE: number;
  51312. /**
  51313. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51314. */
  51315. static readonly PBRMATERIAL_ALPHATEST: number;
  51316. /**
  51317. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51318. */
  51319. static readonly PBRMATERIAL_ALPHABLEND: number;
  51320. /**
  51321. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51322. * They are also discarded below the alpha cutoff threshold to improve performances.
  51323. */
  51324. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51325. /**
  51326. * Defines the default value of how much AO map is occluding the analytical lights
  51327. * (point spot...).
  51328. */
  51329. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51330. /**
  51331. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51332. */
  51333. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51334. /**
  51335. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51336. * to enhance interoperability with other engines.
  51337. */
  51338. static readonly LIGHTFALLOFF_GLTF: number;
  51339. /**
  51340. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51341. * to enhance interoperability with other materials.
  51342. */
  51343. static readonly LIGHTFALLOFF_STANDARD: number;
  51344. /**
  51345. * Intensity of the direct lights e.g. the four lights available in your scene.
  51346. * This impacts both the direct diffuse and specular highlights.
  51347. */
  51348. protected _directIntensity: number;
  51349. /**
  51350. * Intensity of the emissive part of the material.
  51351. * This helps controlling the emissive effect without modifying the emissive color.
  51352. */
  51353. protected _emissiveIntensity: number;
  51354. /**
  51355. * Intensity of the environment e.g. how much the environment will light the object
  51356. * either through harmonics for rough material or through the refelction for shiny ones.
  51357. */
  51358. protected _environmentIntensity: number;
  51359. /**
  51360. * This is a special control allowing the reduction of the specular highlights coming from the
  51361. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51362. */
  51363. protected _specularIntensity: number;
  51364. /**
  51365. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51366. */
  51367. private _lightingInfos;
  51368. /**
  51369. * Debug Control allowing disabling the bump map on this material.
  51370. */
  51371. protected _disableBumpMap: boolean;
  51372. /**
  51373. * AKA Diffuse Texture in standard nomenclature.
  51374. */
  51375. protected _albedoTexture: Nullable<BaseTexture>;
  51376. /**
  51377. * AKA Occlusion Texture in other nomenclature.
  51378. */
  51379. protected _ambientTexture: Nullable<BaseTexture>;
  51380. /**
  51381. * AKA Occlusion Texture Intensity in other nomenclature.
  51382. */
  51383. protected _ambientTextureStrength: number;
  51384. /**
  51385. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51386. * 1 means it completely occludes it
  51387. * 0 mean it has no impact
  51388. */
  51389. protected _ambientTextureImpactOnAnalyticalLights: number;
  51390. /**
  51391. * Stores the alpha values in a texture.
  51392. */
  51393. protected _opacityTexture: Nullable<BaseTexture>;
  51394. /**
  51395. * Stores the reflection values in a texture.
  51396. */
  51397. protected _reflectionTexture: Nullable<BaseTexture>;
  51398. /**
  51399. * Stores the emissive values in a texture.
  51400. */
  51401. protected _emissiveTexture: Nullable<BaseTexture>;
  51402. /**
  51403. * AKA Specular texture in other nomenclature.
  51404. */
  51405. protected _reflectivityTexture: Nullable<BaseTexture>;
  51406. /**
  51407. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51408. */
  51409. protected _metallicTexture: Nullable<BaseTexture>;
  51410. /**
  51411. * Specifies the metallic scalar of the metallic/roughness workflow.
  51412. * Can also be used to scale the metalness values of the metallic texture.
  51413. */
  51414. protected _metallic: Nullable<number>;
  51415. /**
  51416. * Specifies the roughness scalar of the metallic/roughness workflow.
  51417. * Can also be used to scale the roughness values of the metallic texture.
  51418. */
  51419. protected _roughness: Nullable<number>;
  51420. /**
  51421. * Specifies the an F0 factor to help configuring the material F0.
  51422. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51423. * to 0.5 the previously hard coded value stays the same.
  51424. * Can also be used to scale the F0 values of the metallic texture.
  51425. */
  51426. protected _metallicF0Factor: number;
  51427. /**
  51428. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51429. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51430. * your expectation as it multiplies with the texture data.
  51431. */
  51432. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51433. /**
  51434. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51435. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51436. */
  51437. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51438. /**
  51439. * Stores surface normal data used to displace a mesh in a texture.
  51440. */
  51441. protected _bumpTexture: Nullable<BaseTexture>;
  51442. /**
  51443. * Stores the pre-calculated light information of a mesh in a texture.
  51444. */
  51445. protected _lightmapTexture: Nullable<BaseTexture>;
  51446. /**
  51447. * The color of a material in ambient lighting.
  51448. */
  51449. protected _ambientColor: Color3;
  51450. /**
  51451. * AKA Diffuse Color in other nomenclature.
  51452. */
  51453. protected _albedoColor: Color3;
  51454. /**
  51455. * AKA Specular Color in other nomenclature.
  51456. */
  51457. protected _reflectivityColor: Color3;
  51458. /**
  51459. * The color applied when light is reflected from a material.
  51460. */
  51461. protected _reflectionColor: Color3;
  51462. /**
  51463. * The color applied when light is emitted from a material.
  51464. */
  51465. protected _emissiveColor: Color3;
  51466. /**
  51467. * AKA Glossiness in other nomenclature.
  51468. */
  51469. protected _microSurface: number;
  51470. /**
  51471. * Specifies that the material will use the light map as a show map.
  51472. */
  51473. protected _useLightmapAsShadowmap: boolean;
  51474. /**
  51475. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51476. * makes the reflect vector face the model (under horizon).
  51477. */
  51478. protected _useHorizonOcclusion: boolean;
  51479. /**
  51480. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51481. * too much the area relying on ambient texture to define their ambient occlusion.
  51482. */
  51483. protected _useRadianceOcclusion: boolean;
  51484. /**
  51485. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51486. */
  51487. protected _useAlphaFromAlbedoTexture: boolean;
  51488. /**
  51489. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51490. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51491. */
  51492. protected _useSpecularOverAlpha: boolean;
  51493. /**
  51494. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51495. */
  51496. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51497. /**
  51498. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51499. */
  51500. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51501. /**
  51502. * Specifies if the metallic texture contains the roughness information in its green channel.
  51503. */
  51504. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51505. /**
  51506. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51507. */
  51508. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51509. /**
  51510. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51511. */
  51512. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51513. /**
  51514. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51515. */
  51516. protected _useAmbientInGrayScale: boolean;
  51517. /**
  51518. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51519. * The material will try to infer what glossiness each pixel should be.
  51520. */
  51521. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51522. /**
  51523. * Defines the falloff type used in this material.
  51524. * It by default is Physical.
  51525. */
  51526. protected _lightFalloff: number;
  51527. /**
  51528. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51529. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51530. */
  51531. protected _useRadianceOverAlpha: boolean;
  51532. /**
  51533. * Allows using an object space normal map (instead of tangent space).
  51534. */
  51535. protected _useObjectSpaceNormalMap: boolean;
  51536. /**
  51537. * Allows using the bump map in parallax mode.
  51538. */
  51539. protected _useParallax: boolean;
  51540. /**
  51541. * Allows using the bump map in parallax occlusion mode.
  51542. */
  51543. protected _useParallaxOcclusion: boolean;
  51544. /**
  51545. * Controls the scale bias of the parallax mode.
  51546. */
  51547. protected _parallaxScaleBias: number;
  51548. /**
  51549. * If sets to true, disables all the lights affecting the material.
  51550. */
  51551. protected _disableLighting: boolean;
  51552. /**
  51553. * Number of Simultaneous lights allowed on the material.
  51554. */
  51555. protected _maxSimultaneousLights: number;
  51556. /**
  51557. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51558. */
  51559. protected _invertNormalMapX: boolean;
  51560. /**
  51561. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51562. */
  51563. protected _invertNormalMapY: boolean;
  51564. /**
  51565. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51566. */
  51567. protected _twoSidedLighting: boolean;
  51568. /**
  51569. * Defines the alpha limits in alpha test mode.
  51570. */
  51571. protected _alphaCutOff: number;
  51572. /**
  51573. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51574. */
  51575. protected _forceAlphaTest: boolean;
  51576. /**
  51577. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51578. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51579. */
  51580. protected _useAlphaFresnel: boolean;
  51581. /**
  51582. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51583. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51584. */
  51585. protected _useLinearAlphaFresnel: boolean;
  51586. /**
  51587. * The transparency mode of the material.
  51588. */
  51589. protected _transparencyMode: Nullable<number>;
  51590. /**
  51591. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51592. * from cos thetav and roughness:
  51593. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51594. */
  51595. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51596. /**
  51597. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51598. */
  51599. protected _forceIrradianceInFragment: boolean;
  51600. /**
  51601. * Force normal to face away from face.
  51602. */
  51603. protected _forceNormalForward: boolean;
  51604. /**
  51605. * Enables specular anti aliasing in the PBR shader.
  51606. * It will both interacts on the Geometry for analytical and IBL lighting.
  51607. * It also prefilter the roughness map based on the bump values.
  51608. */
  51609. protected _enableSpecularAntiAliasing: boolean;
  51610. /**
  51611. * Default configuration related to image processing available in the PBR Material.
  51612. */
  51613. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51614. /**
  51615. * Keep track of the image processing observer to allow dispose and replace.
  51616. */
  51617. private _imageProcessingObserver;
  51618. /**
  51619. * Attaches a new image processing configuration to the PBR Material.
  51620. * @param configuration
  51621. */
  51622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51623. /**
  51624. * Stores the available render targets.
  51625. */
  51626. private _renderTargets;
  51627. /**
  51628. * Sets the global ambient color for the material used in lighting calculations.
  51629. */
  51630. private _globalAmbientColor;
  51631. /**
  51632. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51633. */
  51634. private _useLogarithmicDepth;
  51635. /**
  51636. * If set to true, no lighting calculations will be applied.
  51637. */
  51638. private _unlit;
  51639. private _debugMode;
  51640. /**
  51641. * @hidden
  51642. * This is reserved for the inspector.
  51643. * Defines the material debug mode.
  51644. * It helps seeing only some components of the material while troubleshooting.
  51645. */
  51646. debugMode: number;
  51647. /**
  51648. * @hidden
  51649. * This is reserved for the inspector.
  51650. * Specify from where on screen the debug mode should start.
  51651. * The value goes from -1 (full screen) to 1 (not visible)
  51652. * It helps with side by side comparison against the final render
  51653. * This defaults to -1
  51654. */
  51655. private debugLimit;
  51656. /**
  51657. * @hidden
  51658. * This is reserved for the inspector.
  51659. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51660. * You can use the factor to better multiply the final value.
  51661. */
  51662. private debugFactor;
  51663. /**
  51664. * Defines the clear coat layer parameters for the material.
  51665. */
  51666. readonly clearCoat: PBRClearCoatConfiguration;
  51667. /**
  51668. * Defines the anisotropic parameters for the material.
  51669. */
  51670. readonly anisotropy: PBRAnisotropicConfiguration;
  51671. /**
  51672. * Defines the BRDF parameters for the material.
  51673. */
  51674. readonly brdf: PBRBRDFConfiguration;
  51675. /**
  51676. * Defines the Sheen parameters for the material.
  51677. */
  51678. readonly sheen: PBRSheenConfiguration;
  51679. /**
  51680. * Defines the SubSurface parameters for the material.
  51681. */
  51682. readonly subSurface: PBRSubSurfaceConfiguration;
  51683. /**
  51684. * Custom callback helping to override the default shader used in the material.
  51685. */
  51686. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51687. protected _rebuildInParallel: boolean;
  51688. /**
  51689. * Instantiates a new PBRMaterial instance.
  51690. *
  51691. * @param name The material name
  51692. * @param scene The scene the material will be use in.
  51693. */
  51694. constructor(name: string, scene: Scene);
  51695. /**
  51696. * Gets a boolean indicating that current material needs to register RTT
  51697. */
  51698. get hasRenderTargetTextures(): boolean;
  51699. /**
  51700. * Gets the name of the material class.
  51701. */
  51702. getClassName(): string;
  51703. /**
  51704. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51705. */
  51706. get useLogarithmicDepth(): boolean;
  51707. /**
  51708. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51709. */
  51710. set useLogarithmicDepth(value: boolean);
  51711. /**
  51712. * Gets the current transparency mode.
  51713. */
  51714. get transparencyMode(): Nullable<number>;
  51715. /**
  51716. * Sets the transparency mode of the material.
  51717. *
  51718. * | Value | Type | Description |
  51719. * | ----- | ----------------------------------- | ----------- |
  51720. * | 0 | OPAQUE | |
  51721. * | 1 | ALPHATEST | |
  51722. * | 2 | ALPHABLEND | |
  51723. * | 3 | ALPHATESTANDBLEND | |
  51724. *
  51725. */
  51726. set transparencyMode(value: Nullable<number>);
  51727. /**
  51728. * Returns true if alpha blending should be disabled.
  51729. */
  51730. private get _disableAlphaBlending();
  51731. /**
  51732. * Specifies whether or not this material should be rendered in alpha blend mode.
  51733. */
  51734. needAlphaBlending(): boolean;
  51735. /**
  51736. * Specifies if the mesh will require alpha blending.
  51737. * @param mesh - BJS mesh.
  51738. */
  51739. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51740. /**
  51741. * Specifies whether or not this material should be rendered in alpha test mode.
  51742. */
  51743. needAlphaTesting(): boolean;
  51744. /**
  51745. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51746. */
  51747. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51748. /**
  51749. * Gets the texture used for the alpha test.
  51750. */
  51751. getAlphaTestTexture(): Nullable<BaseTexture>;
  51752. /**
  51753. * Specifies that the submesh is ready to be used.
  51754. * @param mesh - BJS mesh.
  51755. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51756. * @param useInstances - Specifies that instances should be used.
  51757. * @returns - boolean indicating that the submesh is ready or not.
  51758. */
  51759. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51760. /**
  51761. * Specifies if the material uses metallic roughness workflow.
  51762. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51763. */
  51764. isMetallicWorkflow(): boolean;
  51765. private _prepareEffect;
  51766. private _prepareDefines;
  51767. /**
  51768. * Force shader compilation
  51769. */
  51770. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51771. /**
  51772. * Initializes the uniform buffer layout for the shader.
  51773. */
  51774. buildUniformLayout(): void;
  51775. /**
  51776. * Unbinds the material from the mesh
  51777. */
  51778. unbind(): void;
  51779. /**
  51780. * Binds the submesh data.
  51781. * @param world - The world matrix.
  51782. * @param mesh - The BJS mesh.
  51783. * @param subMesh - A submesh of the BJS mesh.
  51784. */
  51785. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51786. /**
  51787. * Returns the animatable textures.
  51788. * @returns - Array of animatable textures.
  51789. */
  51790. getAnimatables(): IAnimatable[];
  51791. /**
  51792. * Returns the texture used for reflections.
  51793. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51794. */
  51795. private _getReflectionTexture;
  51796. /**
  51797. * Returns an array of the actively used textures.
  51798. * @returns - Array of BaseTextures
  51799. */
  51800. getActiveTextures(): BaseTexture[];
  51801. /**
  51802. * Checks to see if a texture is used in the material.
  51803. * @param texture - Base texture to use.
  51804. * @returns - Boolean specifying if a texture is used in the material.
  51805. */
  51806. hasTexture(texture: BaseTexture): boolean;
  51807. /**
  51808. * Disposes the resources of the material.
  51809. * @param forceDisposeEffect - Forces the disposal of effects.
  51810. * @param forceDisposeTextures - Forces the disposal of all textures.
  51811. */
  51812. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51813. }
  51814. }
  51815. declare module BABYLON {
  51816. /**
  51817. * The Physically based material of BJS.
  51818. *
  51819. * This offers the main features of a standard PBR material.
  51820. * For more information, please refer to the documentation :
  51821. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51822. */
  51823. export class PBRMaterial extends PBRBaseMaterial {
  51824. /**
  51825. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51826. */
  51827. static readonly PBRMATERIAL_OPAQUE: number;
  51828. /**
  51829. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51830. */
  51831. static readonly PBRMATERIAL_ALPHATEST: number;
  51832. /**
  51833. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51834. */
  51835. static readonly PBRMATERIAL_ALPHABLEND: number;
  51836. /**
  51837. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51838. * They are also discarded below the alpha cutoff threshold to improve performances.
  51839. */
  51840. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51841. /**
  51842. * Defines the default value of how much AO map is occluding the analytical lights
  51843. * (point spot...).
  51844. */
  51845. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51846. /**
  51847. * Intensity of the direct lights e.g. the four lights available in your scene.
  51848. * This impacts both the direct diffuse and specular highlights.
  51849. */
  51850. directIntensity: number;
  51851. /**
  51852. * Intensity of the emissive part of the material.
  51853. * This helps controlling the emissive effect without modifying the emissive color.
  51854. */
  51855. emissiveIntensity: number;
  51856. /**
  51857. * Intensity of the environment e.g. how much the environment will light the object
  51858. * either through harmonics for rough material or through the refelction for shiny ones.
  51859. */
  51860. environmentIntensity: number;
  51861. /**
  51862. * This is a special control allowing the reduction of the specular highlights coming from the
  51863. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51864. */
  51865. specularIntensity: number;
  51866. /**
  51867. * Debug Control allowing disabling the bump map on this material.
  51868. */
  51869. disableBumpMap: boolean;
  51870. /**
  51871. * AKA Diffuse Texture in standard nomenclature.
  51872. */
  51873. albedoTexture: BaseTexture;
  51874. /**
  51875. * AKA Occlusion Texture in other nomenclature.
  51876. */
  51877. ambientTexture: BaseTexture;
  51878. /**
  51879. * AKA Occlusion Texture Intensity in other nomenclature.
  51880. */
  51881. ambientTextureStrength: number;
  51882. /**
  51883. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51884. * 1 means it completely occludes it
  51885. * 0 mean it has no impact
  51886. */
  51887. ambientTextureImpactOnAnalyticalLights: number;
  51888. /**
  51889. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51890. */
  51891. opacityTexture: BaseTexture;
  51892. /**
  51893. * Stores the reflection values in a texture.
  51894. */
  51895. reflectionTexture: Nullable<BaseTexture>;
  51896. /**
  51897. * Stores the emissive values in a texture.
  51898. */
  51899. emissiveTexture: BaseTexture;
  51900. /**
  51901. * AKA Specular texture in other nomenclature.
  51902. */
  51903. reflectivityTexture: BaseTexture;
  51904. /**
  51905. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51906. */
  51907. metallicTexture: BaseTexture;
  51908. /**
  51909. * Specifies the metallic scalar of the metallic/roughness workflow.
  51910. * Can also be used to scale the metalness values of the metallic texture.
  51911. */
  51912. metallic: Nullable<number>;
  51913. /**
  51914. * Specifies the roughness scalar of the metallic/roughness workflow.
  51915. * Can also be used to scale the roughness values of the metallic texture.
  51916. */
  51917. roughness: Nullable<number>;
  51918. /**
  51919. * Specifies the an F0 factor to help configuring the material F0.
  51920. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51921. * to 0.5 the previously hard coded value stays the same.
  51922. * Can also be used to scale the F0 values of the metallic texture.
  51923. */
  51924. metallicF0Factor: number;
  51925. /**
  51926. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51927. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51928. * your expectation as it multiplies with the texture data.
  51929. */
  51930. useMetallicF0FactorFromMetallicTexture: boolean;
  51931. /**
  51932. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51933. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51934. */
  51935. microSurfaceTexture: BaseTexture;
  51936. /**
  51937. * Stores surface normal data used to displace a mesh in a texture.
  51938. */
  51939. bumpTexture: BaseTexture;
  51940. /**
  51941. * Stores the pre-calculated light information of a mesh in a texture.
  51942. */
  51943. lightmapTexture: BaseTexture;
  51944. /**
  51945. * Stores the refracted light information in a texture.
  51946. */
  51947. get refractionTexture(): Nullable<BaseTexture>;
  51948. set refractionTexture(value: Nullable<BaseTexture>);
  51949. /**
  51950. * The color of a material in ambient lighting.
  51951. */
  51952. ambientColor: Color3;
  51953. /**
  51954. * AKA Diffuse Color in other nomenclature.
  51955. */
  51956. albedoColor: Color3;
  51957. /**
  51958. * AKA Specular Color in other nomenclature.
  51959. */
  51960. reflectivityColor: Color3;
  51961. /**
  51962. * The color reflected from the material.
  51963. */
  51964. reflectionColor: Color3;
  51965. /**
  51966. * The color emitted from the material.
  51967. */
  51968. emissiveColor: Color3;
  51969. /**
  51970. * AKA Glossiness in other nomenclature.
  51971. */
  51972. microSurface: number;
  51973. /**
  51974. * source material index of refraction (IOR)' / 'destination material IOR.
  51975. */
  51976. get indexOfRefraction(): number;
  51977. set indexOfRefraction(value: number);
  51978. /**
  51979. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51980. */
  51981. get invertRefractionY(): boolean;
  51982. set invertRefractionY(value: boolean);
  51983. /**
  51984. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51985. * Materials half opaque for instance using refraction could benefit from this control.
  51986. */
  51987. get linkRefractionWithTransparency(): boolean;
  51988. set linkRefractionWithTransparency(value: boolean);
  51989. /**
  51990. * If true, the light map contains occlusion information instead of lighting info.
  51991. */
  51992. useLightmapAsShadowmap: boolean;
  51993. /**
  51994. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51995. */
  51996. useAlphaFromAlbedoTexture: boolean;
  51997. /**
  51998. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51999. */
  52000. forceAlphaTest: boolean;
  52001. /**
  52002. * Defines the alpha limits in alpha test mode.
  52003. */
  52004. alphaCutOff: number;
  52005. /**
  52006. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52007. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52008. */
  52009. useSpecularOverAlpha: boolean;
  52010. /**
  52011. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52012. */
  52013. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52014. /**
  52015. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52016. */
  52017. useRoughnessFromMetallicTextureAlpha: boolean;
  52018. /**
  52019. * Specifies if the metallic texture contains the roughness information in its green channel.
  52020. */
  52021. useRoughnessFromMetallicTextureGreen: boolean;
  52022. /**
  52023. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52024. */
  52025. useMetallnessFromMetallicTextureBlue: boolean;
  52026. /**
  52027. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52028. */
  52029. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52030. /**
  52031. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52032. */
  52033. useAmbientInGrayScale: boolean;
  52034. /**
  52035. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52036. * The material will try to infer what glossiness each pixel should be.
  52037. */
  52038. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52039. /**
  52040. * BJS is using an harcoded light falloff based on a manually sets up range.
  52041. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52042. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52043. */
  52044. get usePhysicalLightFalloff(): boolean;
  52045. /**
  52046. * BJS is using an harcoded light falloff based on a manually sets up range.
  52047. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52048. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52049. */
  52050. set usePhysicalLightFalloff(value: boolean);
  52051. /**
  52052. * In order to support the falloff compatibility with gltf, a special mode has been added
  52053. * to reproduce the gltf light falloff.
  52054. */
  52055. get useGLTFLightFalloff(): boolean;
  52056. /**
  52057. * In order to support the falloff compatibility with gltf, a special mode has been added
  52058. * to reproduce the gltf light falloff.
  52059. */
  52060. set useGLTFLightFalloff(value: boolean);
  52061. /**
  52062. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52063. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52064. */
  52065. useRadianceOverAlpha: boolean;
  52066. /**
  52067. * Allows using an object space normal map (instead of tangent space).
  52068. */
  52069. useObjectSpaceNormalMap: boolean;
  52070. /**
  52071. * Allows using the bump map in parallax mode.
  52072. */
  52073. useParallax: boolean;
  52074. /**
  52075. * Allows using the bump map in parallax occlusion mode.
  52076. */
  52077. useParallaxOcclusion: boolean;
  52078. /**
  52079. * Controls the scale bias of the parallax mode.
  52080. */
  52081. parallaxScaleBias: number;
  52082. /**
  52083. * If sets to true, disables all the lights affecting the material.
  52084. */
  52085. disableLighting: boolean;
  52086. /**
  52087. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52088. */
  52089. forceIrradianceInFragment: boolean;
  52090. /**
  52091. * Number of Simultaneous lights allowed on the material.
  52092. */
  52093. maxSimultaneousLights: number;
  52094. /**
  52095. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52096. */
  52097. invertNormalMapX: boolean;
  52098. /**
  52099. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52100. */
  52101. invertNormalMapY: boolean;
  52102. /**
  52103. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52104. */
  52105. twoSidedLighting: boolean;
  52106. /**
  52107. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52108. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52109. */
  52110. useAlphaFresnel: boolean;
  52111. /**
  52112. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52113. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52114. */
  52115. useLinearAlphaFresnel: boolean;
  52116. /**
  52117. * Let user defines the brdf lookup texture used for IBL.
  52118. * A default 8bit version is embedded but you could point at :
  52119. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52120. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52121. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52122. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52123. */
  52124. environmentBRDFTexture: Nullable<BaseTexture>;
  52125. /**
  52126. * Force normal to face away from face.
  52127. */
  52128. forceNormalForward: boolean;
  52129. /**
  52130. * Enables specular anti aliasing in the PBR shader.
  52131. * It will both interacts on the Geometry for analytical and IBL lighting.
  52132. * It also prefilter the roughness map based on the bump values.
  52133. */
  52134. enableSpecularAntiAliasing: boolean;
  52135. /**
  52136. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52137. * makes the reflect vector face the model (under horizon).
  52138. */
  52139. useHorizonOcclusion: boolean;
  52140. /**
  52141. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52142. * too much the area relying on ambient texture to define their ambient occlusion.
  52143. */
  52144. useRadianceOcclusion: boolean;
  52145. /**
  52146. * If set to true, no lighting calculations will be applied.
  52147. */
  52148. unlit: boolean;
  52149. /**
  52150. * Gets the image processing configuration used either in this material.
  52151. */
  52152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52153. /**
  52154. * Sets the Default image processing configuration used either in the this material.
  52155. *
  52156. * If sets to null, the scene one is in use.
  52157. */
  52158. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52159. /**
  52160. * Gets wether the color curves effect is enabled.
  52161. */
  52162. get cameraColorCurvesEnabled(): boolean;
  52163. /**
  52164. * Sets wether the color curves effect is enabled.
  52165. */
  52166. set cameraColorCurvesEnabled(value: boolean);
  52167. /**
  52168. * Gets wether the color grading effect is enabled.
  52169. */
  52170. get cameraColorGradingEnabled(): boolean;
  52171. /**
  52172. * Gets wether the color grading effect is enabled.
  52173. */
  52174. set cameraColorGradingEnabled(value: boolean);
  52175. /**
  52176. * Gets wether tonemapping is enabled or not.
  52177. */
  52178. get cameraToneMappingEnabled(): boolean;
  52179. /**
  52180. * Sets wether tonemapping is enabled or not
  52181. */
  52182. set cameraToneMappingEnabled(value: boolean);
  52183. /**
  52184. * The camera exposure used on this material.
  52185. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52186. * This corresponds to a photographic exposure.
  52187. */
  52188. get cameraExposure(): number;
  52189. /**
  52190. * The camera exposure used on this material.
  52191. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52192. * This corresponds to a photographic exposure.
  52193. */
  52194. set cameraExposure(value: number);
  52195. /**
  52196. * Gets The camera contrast used on this material.
  52197. */
  52198. get cameraContrast(): number;
  52199. /**
  52200. * Sets The camera contrast used on this material.
  52201. */
  52202. set cameraContrast(value: number);
  52203. /**
  52204. * Gets the Color Grading 2D Lookup Texture.
  52205. */
  52206. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52207. /**
  52208. * Sets the Color Grading 2D Lookup Texture.
  52209. */
  52210. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52211. /**
  52212. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52213. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52214. * 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;
  52215. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52216. */
  52217. get cameraColorCurves(): Nullable<ColorCurves>;
  52218. /**
  52219. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52220. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52221. * 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;
  52222. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52223. */
  52224. set cameraColorCurves(value: Nullable<ColorCurves>);
  52225. /**
  52226. * Instantiates a new PBRMaterial instance.
  52227. *
  52228. * @param name The material name
  52229. * @param scene The scene the material will be use in.
  52230. */
  52231. constructor(name: string, scene: Scene);
  52232. /**
  52233. * Returns the name of this material class.
  52234. */
  52235. getClassName(): string;
  52236. /**
  52237. * Makes a duplicate of the current material.
  52238. * @param name - name to use for the new material.
  52239. */
  52240. clone(name: string): PBRMaterial;
  52241. /**
  52242. * Serializes this PBR Material.
  52243. * @returns - An object with the serialized material.
  52244. */
  52245. serialize(): any;
  52246. /**
  52247. * Parses a PBR Material from a serialized object.
  52248. * @param source - Serialized object.
  52249. * @param scene - BJS scene instance.
  52250. * @param rootUrl - url for the scene object
  52251. * @returns - PBRMaterial
  52252. */
  52253. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52254. }
  52255. }
  52256. declare module BABYLON {
  52257. /**
  52258. * Direct draw surface info
  52259. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52260. */
  52261. export interface DDSInfo {
  52262. /**
  52263. * Width of the texture
  52264. */
  52265. width: number;
  52266. /**
  52267. * Width of the texture
  52268. */
  52269. height: number;
  52270. /**
  52271. * Number of Mipmaps for the texture
  52272. * @see https://en.wikipedia.org/wiki/Mipmap
  52273. */
  52274. mipmapCount: number;
  52275. /**
  52276. * If the textures format is a known fourCC format
  52277. * @see https://www.fourcc.org/
  52278. */
  52279. isFourCC: boolean;
  52280. /**
  52281. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52282. */
  52283. isRGB: boolean;
  52284. /**
  52285. * If the texture is a lumincance format
  52286. */
  52287. isLuminance: boolean;
  52288. /**
  52289. * If this is a cube texture
  52290. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52291. */
  52292. isCube: boolean;
  52293. /**
  52294. * If the texture is a compressed format eg. FOURCC_DXT1
  52295. */
  52296. isCompressed: boolean;
  52297. /**
  52298. * The dxgiFormat of the texture
  52299. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52300. */
  52301. dxgiFormat: number;
  52302. /**
  52303. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52304. */
  52305. textureType: number;
  52306. /**
  52307. * Sphericle polynomial created for the dds texture
  52308. */
  52309. sphericalPolynomial?: SphericalPolynomial;
  52310. }
  52311. /**
  52312. * Class used to provide DDS decompression tools
  52313. */
  52314. export class DDSTools {
  52315. /**
  52316. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52317. */
  52318. static StoreLODInAlphaChannel: boolean;
  52319. /**
  52320. * Gets DDS information from an array buffer
  52321. * @param data defines the array buffer view to read data from
  52322. * @returns the DDS information
  52323. */
  52324. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52325. private static _FloatView;
  52326. private static _Int32View;
  52327. private static _ToHalfFloat;
  52328. private static _FromHalfFloat;
  52329. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52330. private static _GetHalfFloatRGBAArrayBuffer;
  52331. private static _GetFloatRGBAArrayBuffer;
  52332. private static _GetFloatAsUIntRGBAArrayBuffer;
  52333. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52334. private static _GetRGBAArrayBuffer;
  52335. private static _ExtractLongWordOrder;
  52336. private static _GetRGBArrayBuffer;
  52337. private static _GetLuminanceArrayBuffer;
  52338. /**
  52339. * Uploads DDS Levels to a Babylon Texture
  52340. * @hidden
  52341. */
  52342. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52343. }
  52344. interface ThinEngine {
  52345. /**
  52346. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52347. * @param rootUrl defines the url where the file to load is located
  52348. * @param scene defines the current scene
  52349. * @param lodScale defines scale to apply to the mip map selection
  52350. * @param lodOffset defines offset to apply to the mip map selection
  52351. * @param onLoad defines an optional callback raised when the texture is loaded
  52352. * @param onError defines an optional callback raised if there is an issue to load the texture
  52353. * @param format defines the format of the data
  52354. * @param forcedExtension defines the extension to use to pick the right loader
  52355. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52356. * @returns the cube texture as an InternalTexture
  52357. */
  52358. 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;
  52359. }
  52360. }
  52361. declare module BABYLON {
  52362. /**
  52363. * Implementation of the DDS Texture Loader.
  52364. * @hidden
  52365. */
  52366. export class _DDSTextureLoader implements IInternalTextureLoader {
  52367. /**
  52368. * Defines wether the loader supports cascade loading the different faces.
  52369. */
  52370. readonly supportCascades: boolean;
  52371. /**
  52372. * This returns if the loader support the current file information.
  52373. * @param extension defines the file extension of the file being loaded
  52374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52375. * @param fallback defines the fallback internal texture if any
  52376. * @param isBase64 defines whether the texture is encoded as a base64
  52377. * @param isBuffer defines whether the texture data are stored as a buffer
  52378. * @returns true if the loader can load the specified file
  52379. */
  52380. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52381. /**
  52382. * Transform the url before loading if required.
  52383. * @param rootUrl the url of the texture
  52384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52385. * @returns the transformed texture
  52386. */
  52387. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52388. /**
  52389. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52390. * @param rootUrl the url of the texture
  52391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52392. * @returns the fallback texture
  52393. */
  52394. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52395. /**
  52396. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52397. * @param data contains the texture data
  52398. * @param texture defines the BabylonJS internal texture
  52399. * @param createPolynomials will be true if polynomials have been requested
  52400. * @param onLoad defines the callback to trigger once the texture is ready
  52401. * @param onError defines the callback to trigger in case of error
  52402. */
  52403. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52404. /**
  52405. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52406. * @param data contains the texture data
  52407. * @param texture defines the BabylonJS internal texture
  52408. * @param callback defines the method to call once ready to upload
  52409. */
  52410. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52411. }
  52412. }
  52413. declare module BABYLON {
  52414. /**
  52415. * Implementation of the ENV Texture Loader.
  52416. * @hidden
  52417. */
  52418. export class _ENVTextureLoader implements IInternalTextureLoader {
  52419. /**
  52420. * Defines wether the loader supports cascade loading the different faces.
  52421. */
  52422. readonly supportCascades: boolean;
  52423. /**
  52424. * This returns if the loader support the current file information.
  52425. * @param extension defines the file extension of the file being loaded
  52426. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52427. * @param fallback defines the fallback internal texture if any
  52428. * @param isBase64 defines whether the texture is encoded as a base64
  52429. * @param isBuffer defines whether the texture data are stored as a buffer
  52430. * @returns true if the loader can load the specified file
  52431. */
  52432. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52433. /**
  52434. * Transform the url before loading if required.
  52435. * @param rootUrl the url of the texture
  52436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52437. * @returns the transformed texture
  52438. */
  52439. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52440. /**
  52441. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52442. * @param rootUrl the url of the texture
  52443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52444. * @returns the fallback texture
  52445. */
  52446. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52447. /**
  52448. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52449. * @param data contains the texture data
  52450. * @param texture defines the BabylonJS internal texture
  52451. * @param createPolynomials will be true if polynomials have been requested
  52452. * @param onLoad defines the callback to trigger once the texture is ready
  52453. * @param onError defines the callback to trigger in case of error
  52454. */
  52455. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52456. /**
  52457. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52458. * @param data contains the texture data
  52459. * @param texture defines the BabylonJS internal texture
  52460. * @param callback defines the method to call once ready to upload
  52461. */
  52462. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52463. }
  52464. }
  52465. declare module BABYLON {
  52466. /**
  52467. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52468. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52469. */
  52470. export class KhronosTextureContainer {
  52471. /** contents of the KTX container file */
  52472. data: ArrayBufferView;
  52473. private static HEADER_LEN;
  52474. private static COMPRESSED_2D;
  52475. private static COMPRESSED_3D;
  52476. private static TEX_2D;
  52477. private static TEX_3D;
  52478. /**
  52479. * Gets the openGL type
  52480. */
  52481. glType: number;
  52482. /**
  52483. * Gets the openGL type size
  52484. */
  52485. glTypeSize: number;
  52486. /**
  52487. * Gets the openGL format
  52488. */
  52489. glFormat: number;
  52490. /**
  52491. * Gets the openGL internal format
  52492. */
  52493. glInternalFormat: number;
  52494. /**
  52495. * Gets the base internal format
  52496. */
  52497. glBaseInternalFormat: number;
  52498. /**
  52499. * Gets image width in pixel
  52500. */
  52501. pixelWidth: number;
  52502. /**
  52503. * Gets image height in pixel
  52504. */
  52505. pixelHeight: number;
  52506. /**
  52507. * Gets image depth in pixels
  52508. */
  52509. pixelDepth: number;
  52510. /**
  52511. * Gets the number of array elements
  52512. */
  52513. numberOfArrayElements: number;
  52514. /**
  52515. * Gets the number of faces
  52516. */
  52517. numberOfFaces: number;
  52518. /**
  52519. * Gets the number of mipmap levels
  52520. */
  52521. numberOfMipmapLevels: number;
  52522. /**
  52523. * Gets the bytes of key value data
  52524. */
  52525. bytesOfKeyValueData: number;
  52526. /**
  52527. * Gets the load type
  52528. */
  52529. loadType: number;
  52530. /**
  52531. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52532. */
  52533. isInvalid: boolean;
  52534. /**
  52535. * Creates a new KhronosTextureContainer
  52536. * @param data contents of the KTX container file
  52537. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52538. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52539. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52540. */
  52541. constructor(
  52542. /** contents of the KTX container file */
  52543. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52544. /**
  52545. * Uploads KTX content to a Babylon Texture.
  52546. * It is assumed that the texture has already been created & is currently bound
  52547. * @hidden
  52548. */
  52549. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52550. private _upload2DCompressedLevels;
  52551. }
  52552. }
  52553. declare module BABYLON {
  52554. /**
  52555. * Implementation of the KTX Texture Loader.
  52556. * @hidden
  52557. */
  52558. export class _KTXTextureLoader implements IInternalTextureLoader {
  52559. /**
  52560. * Defines wether the loader supports cascade loading the different faces.
  52561. */
  52562. readonly supportCascades: boolean;
  52563. /**
  52564. * This returns if the loader support the current file information.
  52565. * @param extension defines the file extension of the file being loaded
  52566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52567. * @param fallback defines the fallback internal texture if any
  52568. * @param isBase64 defines whether the texture is encoded as a base64
  52569. * @param isBuffer defines whether the texture data are stored as a buffer
  52570. * @returns true if the loader can load the specified file
  52571. */
  52572. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52573. /**
  52574. * Transform the url before loading if required.
  52575. * @param rootUrl the url of the texture
  52576. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52577. * @returns the transformed texture
  52578. */
  52579. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52580. /**
  52581. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52582. * @param rootUrl the url of the texture
  52583. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52584. * @returns the fallback texture
  52585. */
  52586. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52587. /**
  52588. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52589. * @param data contains the texture data
  52590. * @param texture defines the BabylonJS internal texture
  52591. * @param createPolynomials will be true if polynomials have been requested
  52592. * @param onLoad defines the callback to trigger once the texture is ready
  52593. * @param onError defines the callback to trigger in case of error
  52594. */
  52595. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52596. /**
  52597. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52598. * @param data contains the texture data
  52599. * @param texture defines the BabylonJS internal texture
  52600. * @param callback defines the method to call once ready to upload
  52601. */
  52602. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52603. }
  52604. }
  52605. declare module BABYLON {
  52606. /** @hidden */
  52607. export var _forceSceneHelpersToBundle: boolean;
  52608. interface Scene {
  52609. /**
  52610. * Creates a default light for the scene.
  52611. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52612. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52613. */
  52614. createDefaultLight(replace?: boolean): void;
  52615. /**
  52616. * Creates a default camera for the scene.
  52617. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52618. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52619. * @param replace has default false, when true replaces the active camera in the scene
  52620. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52621. */
  52622. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52623. /**
  52624. * Creates a default camera and a default light.
  52625. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52626. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52627. * @param replace has the default false, when true replaces the active camera/light in the scene
  52628. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52629. */
  52630. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52631. /**
  52632. * Creates a new sky box
  52633. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52634. * @param environmentTexture defines the texture to use as environment texture
  52635. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52636. * @param scale defines the overall scale of the skybox
  52637. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52638. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52639. * @returns a new mesh holding the sky box
  52640. */
  52641. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52642. /**
  52643. * Creates a new environment
  52644. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52645. * @param options defines the options you can use to configure the environment
  52646. * @returns the new EnvironmentHelper
  52647. */
  52648. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52649. /**
  52650. * Creates a new VREXperienceHelper
  52651. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52652. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52653. * @returns a new VREXperienceHelper
  52654. */
  52655. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52656. /**
  52657. * Creates a new WebXRDefaultExperience
  52658. * @see http://doc.babylonjs.com/how_to/webxr
  52659. * @param options experience options
  52660. * @returns a promise for a new WebXRDefaultExperience
  52661. */
  52662. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52668. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52669. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52670. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52671. */
  52672. export class VideoDome extends TransformNode {
  52673. /**
  52674. * Define the video source as a Monoscopic panoramic 360 video.
  52675. */
  52676. static readonly MODE_MONOSCOPIC: number;
  52677. /**
  52678. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52679. */
  52680. static readonly MODE_TOPBOTTOM: number;
  52681. /**
  52682. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52683. */
  52684. static readonly MODE_SIDEBYSIDE: number;
  52685. private _halfDome;
  52686. private _useDirectMapping;
  52687. /**
  52688. * The video texture being displayed on the sphere
  52689. */
  52690. protected _videoTexture: VideoTexture;
  52691. /**
  52692. * Gets the video texture being displayed on the sphere
  52693. */
  52694. get videoTexture(): VideoTexture;
  52695. /**
  52696. * The skybox material
  52697. */
  52698. protected _material: BackgroundMaterial;
  52699. /**
  52700. * The surface used for the skybox
  52701. */
  52702. protected _mesh: Mesh;
  52703. /**
  52704. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52705. */
  52706. private _halfDomeMask;
  52707. /**
  52708. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52709. * Also see the options.resolution property.
  52710. */
  52711. get fovMultiplier(): number;
  52712. set fovMultiplier(value: number);
  52713. private _videoMode;
  52714. /**
  52715. * Gets or set the current video mode for the video. It can be:
  52716. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52717. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52718. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52719. */
  52720. get videoMode(): number;
  52721. set videoMode(value: number);
  52722. /**
  52723. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52724. *
  52725. */
  52726. get halfDome(): boolean;
  52727. /**
  52728. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52729. */
  52730. set halfDome(enabled: boolean);
  52731. /**
  52732. * Oberserver used in Stereoscopic VR Mode.
  52733. */
  52734. private _onBeforeCameraRenderObserver;
  52735. /**
  52736. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52737. * @param name Element's name, child elements will append suffixes for their own names.
  52738. * @param urlsOrVideo defines the url(s) or the video element to use
  52739. * @param options An object containing optional or exposed sub element properties
  52740. */
  52741. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52742. resolution?: number;
  52743. clickToPlay?: boolean;
  52744. autoPlay?: boolean;
  52745. loop?: boolean;
  52746. size?: number;
  52747. poster?: string;
  52748. faceForward?: boolean;
  52749. useDirectMapping?: boolean;
  52750. halfDomeMode?: boolean;
  52751. }, scene: Scene);
  52752. private _changeVideoMode;
  52753. /**
  52754. * Releases resources associated with this node.
  52755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52757. */
  52758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52759. }
  52760. }
  52761. declare module BABYLON {
  52762. /**
  52763. * This class can be used to get instrumentation data from a Babylon engine
  52764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52765. */
  52766. export class EngineInstrumentation implements IDisposable {
  52767. /**
  52768. * Define the instrumented engine.
  52769. */
  52770. engine: Engine;
  52771. private _captureGPUFrameTime;
  52772. private _gpuFrameTimeToken;
  52773. private _gpuFrameTime;
  52774. private _captureShaderCompilationTime;
  52775. private _shaderCompilationTime;
  52776. private _onBeginFrameObserver;
  52777. private _onEndFrameObserver;
  52778. private _onBeforeShaderCompilationObserver;
  52779. private _onAfterShaderCompilationObserver;
  52780. /**
  52781. * Gets the perf counter used for GPU frame time
  52782. */
  52783. get gpuFrameTimeCounter(): PerfCounter;
  52784. /**
  52785. * Gets the GPU frame time capture status
  52786. */
  52787. get captureGPUFrameTime(): boolean;
  52788. /**
  52789. * Enable or disable the GPU frame time capture
  52790. */
  52791. set captureGPUFrameTime(value: boolean);
  52792. /**
  52793. * Gets the perf counter used for shader compilation time
  52794. */
  52795. get shaderCompilationTimeCounter(): PerfCounter;
  52796. /**
  52797. * Gets the shader compilation time capture status
  52798. */
  52799. get captureShaderCompilationTime(): boolean;
  52800. /**
  52801. * Enable or disable the shader compilation time capture
  52802. */
  52803. set captureShaderCompilationTime(value: boolean);
  52804. /**
  52805. * Instantiates a new engine instrumentation.
  52806. * This class can be used to get instrumentation data from a Babylon engine
  52807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52808. * @param engine Defines the engine to instrument
  52809. */
  52810. constructor(
  52811. /**
  52812. * Define the instrumented engine.
  52813. */
  52814. engine: Engine);
  52815. /**
  52816. * Dispose and release associated resources.
  52817. */
  52818. dispose(): void;
  52819. }
  52820. }
  52821. declare module BABYLON {
  52822. /**
  52823. * This class can be used to get instrumentation data from a Babylon engine
  52824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52825. */
  52826. export class SceneInstrumentation implements IDisposable {
  52827. /**
  52828. * Defines the scene to instrument
  52829. */
  52830. scene: Scene;
  52831. private _captureActiveMeshesEvaluationTime;
  52832. private _activeMeshesEvaluationTime;
  52833. private _captureRenderTargetsRenderTime;
  52834. private _renderTargetsRenderTime;
  52835. private _captureFrameTime;
  52836. private _frameTime;
  52837. private _captureRenderTime;
  52838. private _renderTime;
  52839. private _captureInterFrameTime;
  52840. private _interFrameTime;
  52841. private _captureParticlesRenderTime;
  52842. private _particlesRenderTime;
  52843. private _captureSpritesRenderTime;
  52844. private _spritesRenderTime;
  52845. private _capturePhysicsTime;
  52846. private _physicsTime;
  52847. private _captureAnimationsTime;
  52848. private _animationsTime;
  52849. private _captureCameraRenderTime;
  52850. private _cameraRenderTime;
  52851. private _onBeforeActiveMeshesEvaluationObserver;
  52852. private _onAfterActiveMeshesEvaluationObserver;
  52853. private _onBeforeRenderTargetsRenderObserver;
  52854. private _onAfterRenderTargetsRenderObserver;
  52855. private _onAfterRenderObserver;
  52856. private _onBeforeDrawPhaseObserver;
  52857. private _onAfterDrawPhaseObserver;
  52858. private _onBeforeAnimationsObserver;
  52859. private _onBeforeParticlesRenderingObserver;
  52860. private _onAfterParticlesRenderingObserver;
  52861. private _onBeforeSpritesRenderingObserver;
  52862. private _onAfterSpritesRenderingObserver;
  52863. private _onBeforePhysicsObserver;
  52864. private _onAfterPhysicsObserver;
  52865. private _onAfterAnimationsObserver;
  52866. private _onBeforeCameraRenderObserver;
  52867. private _onAfterCameraRenderObserver;
  52868. /**
  52869. * Gets the perf counter used for active meshes evaluation time
  52870. */
  52871. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52872. /**
  52873. * Gets the active meshes evaluation time capture status
  52874. */
  52875. get captureActiveMeshesEvaluationTime(): boolean;
  52876. /**
  52877. * Enable or disable the active meshes evaluation time capture
  52878. */
  52879. set captureActiveMeshesEvaluationTime(value: boolean);
  52880. /**
  52881. * Gets the perf counter used for render targets render time
  52882. */
  52883. get renderTargetsRenderTimeCounter(): PerfCounter;
  52884. /**
  52885. * Gets the render targets render time capture status
  52886. */
  52887. get captureRenderTargetsRenderTime(): boolean;
  52888. /**
  52889. * Enable or disable the render targets render time capture
  52890. */
  52891. set captureRenderTargetsRenderTime(value: boolean);
  52892. /**
  52893. * Gets the perf counter used for particles render time
  52894. */
  52895. get particlesRenderTimeCounter(): PerfCounter;
  52896. /**
  52897. * Gets the particles render time capture status
  52898. */
  52899. get captureParticlesRenderTime(): boolean;
  52900. /**
  52901. * Enable or disable the particles render time capture
  52902. */
  52903. set captureParticlesRenderTime(value: boolean);
  52904. /**
  52905. * Gets the perf counter used for sprites render time
  52906. */
  52907. get spritesRenderTimeCounter(): PerfCounter;
  52908. /**
  52909. * Gets the sprites render time capture status
  52910. */
  52911. get captureSpritesRenderTime(): boolean;
  52912. /**
  52913. * Enable or disable the sprites render time capture
  52914. */
  52915. set captureSpritesRenderTime(value: boolean);
  52916. /**
  52917. * Gets the perf counter used for physics time
  52918. */
  52919. get physicsTimeCounter(): PerfCounter;
  52920. /**
  52921. * Gets the physics time capture status
  52922. */
  52923. get capturePhysicsTime(): boolean;
  52924. /**
  52925. * Enable or disable the physics time capture
  52926. */
  52927. set capturePhysicsTime(value: boolean);
  52928. /**
  52929. * Gets the perf counter used for animations time
  52930. */
  52931. get animationsTimeCounter(): PerfCounter;
  52932. /**
  52933. * Gets the animations time capture status
  52934. */
  52935. get captureAnimationsTime(): boolean;
  52936. /**
  52937. * Enable or disable the animations time capture
  52938. */
  52939. set captureAnimationsTime(value: boolean);
  52940. /**
  52941. * Gets the perf counter used for frame time capture
  52942. */
  52943. get frameTimeCounter(): PerfCounter;
  52944. /**
  52945. * Gets the frame time capture status
  52946. */
  52947. get captureFrameTime(): boolean;
  52948. /**
  52949. * Enable or disable the frame time capture
  52950. */
  52951. set captureFrameTime(value: boolean);
  52952. /**
  52953. * Gets the perf counter used for inter-frames time capture
  52954. */
  52955. get interFrameTimeCounter(): PerfCounter;
  52956. /**
  52957. * Gets the inter-frames time capture status
  52958. */
  52959. get captureInterFrameTime(): boolean;
  52960. /**
  52961. * Enable or disable the inter-frames time capture
  52962. */
  52963. set captureInterFrameTime(value: boolean);
  52964. /**
  52965. * Gets the perf counter used for render time capture
  52966. */
  52967. get renderTimeCounter(): PerfCounter;
  52968. /**
  52969. * Gets the render time capture status
  52970. */
  52971. get captureRenderTime(): boolean;
  52972. /**
  52973. * Enable or disable the render time capture
  52974. */
  52975. set captureRenderTime(value: boolean);
  52976. /**
  52977. * Gets the perf counter used for camera render time capture
  52978. */
  52979. get cameraRenderTimeCounter(): PerfCounter;
  52980. /**
  52981. * Gets the camera render time capture status
  52982. */
  52983. get captureCameraRenderTime(): boolean;
  52984. /**
  52985. * Enable or disable the camera render time capture
  52986. */
  52987. set captureCameraRenderTime(value: boolean);
  52988. /**
  52989. * Gets the perf counter used for draw calls
  52990. */
  52991. get drawCallsCounter(): PerfCounter;
  52992. /**
  52993. * Instantiates a new scene instrumentation.
  52994. * This class can be used to get instrumentation data from a Babylon engine
  52995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52996. * @param scene Defines the scene to instrument
  52997. */
  52998. constructor(
  52999. /**
  53000. * Defines the scene to instrument
  53001. */
  53002. scene: Scene);
  53003. /**
  53004. * Dispose and release associated resources.
  53005. */
  53006. dispose(): void;
  53007. }
  53008. }
  53009. declare module BABYLON {
  53010. /** @hidden */
  53011. export var glowMapGenerationPixelShader: {
  53012. name: string;
  53013. shader: string;
  53014. };
  53015. }
  53016. declare module BABYLON {
  53017. /** @hidden */
  53018. export var glowMapGenerationVertexShader: {
  53019. name: string;
  53020. shader: string;
  53021. };
  53022. }
  53023. declare module BABYLON {
  53024. /**
  53025. * Effect layer options. This helps customizing the behaviour
  53026. * of the effect layer.
  53027. */
  53028. export interface IEffectLayerOptions {
  53029. /**
  53030. * Multiplication factor apply to the canvas size to compute the render target size
  53031. * used to generated the objects (the smaller the faster).
  53032. */
  53033. mainTextureRatio: number;
  53034. /**
  53035. * Enforces a fixed size texture to ensure effect stability across devices.
  53036. */
  53037. mainTextureFixedSize?: number;
  53038. /**
  53039. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53040. */
  53041. alphaBlendingMode: number;
  53042. /**
  53043. * The camera attached to the layer.
  53044. */
  53045. camera: Nullable<Camera>;
  53046. /**
  53047. * The rendering group to draw the layer in.
  53048. */
  53049. renderingGroupId: number;
  53050. }
  53051. /**
  53052. * The effect layer Helps adding post process effect blended with the main pass.
  53053. *
  53054. * This can be for instance use to generate glow or higlight effects on the scene.
  53055. *
  53056. * The effect layer class can not be used directly and is intented to inherited from to be
  53057. * customized per effects.
  53058. */
  53059. export abstract class EffectLayer {
  53060. private _vertexBuffers;
  53061. private _indexBuffer;
  53062. private _cachedDefines;
  53063. private _effectLayerMapGenerationEffect;
  53064. private _effectLayerOptions;
  53065. private _mergeEffect;
  53066. protected _scene: Scene;
  53067. protected _engine: Engine;
  53068. protected _maxSize: number;
  53069. protected _mainTextureDesiredSize: ISize;
  53070. protected _mainTexture: RenderTargetTexture;
  53071. protected _shouldRender: boolean;
  53072. protected _postProcesses: PostProcess[];
  53073. protected _textures: BaseTexture[];
  53074. protected _emissiveTextureAndColor: {
  53075. texture: Nullable<BaseTexture>;
  53076. color: Color4;
  53077. };
  53078. /**
  53079. * The name of the layer
  53080. */
  53081. name: string;
  53082. /**
  53083. * The clear color of the texture used to generate the glow map.
  53084. */
  53085. neutralColor: Color4;
  53086. /**
  53087. * Specifies wether the highlight layer is enabled or not.
  53088. */
  53089. isEnabled: boolean;
  53090. /**
  53091. * Gets the camera attached to the layer.
  53092. */
  53093. get camera(): Nullable<Camera>;
  53094. /**
  53095. * Gets the rendering group id the layer should render in.
  53096. */
  53097. get renderingGroupId(): number;
  53098. set renderingGroupId(renderingGroupId: number);
  53099. /**
  53100. * An event triggered when the effect layer has been disposed.
  53101. */
  53102. onDisposeObservable: Observable<EffectLayer>;
  53103. /**
  53104. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53105. */
  53106. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53107. /**
  53108. * An event triggered when the generated texture is being merged in the scene.
  53109. */
  53110. onBeforeComposeObservable: Observable<EffectLayer>;
  53111. /**
  53112. * An event triggered when the mesh is rendered into the effect render target.
  53113. */
  53114. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53115. /**
  53116. * An event triggered after the mesh has been rendered into the effect render target.
  53117. */
  53118. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53119. /**
  53120. * An event triggered when the generated texture has been merged in the scene.
  53121. */
  53122. onAfterComposeObservable: Observable<EffectLayer>;
  53123. /**
  53124. * An event triggered when the efffect layer changes its size.
  53125. */
  53126. onSizeChangedObservable: Observable<EffectLayer>;
  53127. /** @hidden */
  53128. static _SceneComponentInitialization: (scene: Scene) => void;
  53129. /**
  53130. * Instantiates a new effect Layer and references it in the scene.
  53131. * @param name The name of the layer
  53132. * @param scene The scene to use the layer in
  53133. */
  53134. constructor(
  53135. /** The Friendly of the effect in the scene */
  53136. name: string, scene: Scene);
  53137. /**
  53138. * Get the effect name of the layer.
  53139. * @return The effect name
  53140. */
  53141. abstract getEffectName(): string;
  53142. /**
  53143. * Checks for the readiness of the element composing the layer.
  53144. * @param subMesh the mesh to check for
  53145. * @param useInstances specify wether or not to use instances to render the mesh
  53146. * @return true if ready otherwise, false
  53147. */
  53148. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53149. /**
  53150. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53151. * @returns true if the effect requires stencil during the main canvas render pass.
  53152. */
  53153. abstract needStencil(): boolean;
  53154. /**
  53155. * Create the merge effect. This is the shader use to blit the information back
  53156. * to the main canvas at the end of the scene rendering.
  53157. * @returns The effect containing the shader used to merge the effect on the main canvas
  53158. */
  53159. protected abstract _createMergeEffect(): Effect;
  53160. /**
  53161. * Creates the render target textures and post processes used in the effect layer.
  53162. */
  53163. protected abstract _createTextureAndPostProcesses(): void;
  53164. /**
  53165. * Implementation specific of rendering the generating effect on the main canvas.
  53166. * @param effect The effect used to render through
  53167. */
  53168. protected abstract _internalRender(effect: Effect): void;
  53169. /**
  53170. * Sets the required values for both the emissive texture and and the main color.
  53171. */
  53172. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53173. /**
  53174. * Free any resources and references associated to a mesh.
  53175. * Internal use
  53176. * @param mesh The mesh to free.
  53177. */
  53178. abstract _disposeMesh(mesh: Mesh): void;
  53179. /**
  53180. * Serializes this layer (Glow or Highlight for example)
  53181. * @returns a serialized layer object
  53182. */
  53183. abstract serialize?(): any;
  53184. /**
  53185. * Initializes the effect layer with the required options.
  53186. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53187. */
  53188. protected _init(options: Partial<IEffectLayerOptions>): void;
  53189. /**
  53190. * Generates the index buffer of the full screen quad blending to the main canvas.
  53191. */
  53192. private _generateIndexBuffer;
  53193. /**
  53194. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53195. */
  53196. private _generateVertexBuffer;
  53197. /**
  53198. * Sets the main texture desired size which is the closest power of two
  53199. * of the engine canvas size.
  53200. */
  53201. private _setMainTextureSize;
  53202. /**
  53203. * Creates the main texture for the effect layer.
  53204. */
  53205. protected _createMainTexture(): void;
  53206. /**
  53207. * Adds specific effects defines.
  53208. * @param defines The defines to add specifics to.
  53209. */
  53210. protected _addCustomEffectDefines(defines: string[]): void;
  53211. /**
  53212. * Checks for the readiness of the element composing the layer.
  53213. * @param subMesh the mesh to check for
  53214. * @param useInstances specify wether or not to use instances to render the mesh
  53215. * @param emissiveTexture the associated emissive texture used to generate the glow
  53216. * @return true if ready otherwise, false
  53217. */
  53218. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53219. /**
  53220. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53221. */
  53222. render(): void;
  53223. /**
  53224. * Determine if a given mesh will be used in the current effect.
  53225. * @param mesh mesh to test
  53226. * @returns true if the mesh will be used
  53227. */
  53228. hasMesh(mesh: AbstractMesh): boolean;
  53229. /**
  53230. * Returns true if the layer contains information to display, otherwise false.
  53231. * @returns true if the glow layer should be rendered
  53232. */
  53233. shouldRender(): boolean;
  53234. /**
  53235. * Returns true if the mesh should render, otherwise false.
  53236. * @param mesh The mesh to render
  53237. * @returns true if it should render otherwise false
  53238. */
  53239. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53240. /**
  53241. * Returns true if the mesh can be rendered, otherwise false.
  53242. * @param mesh The mesh to render
  53243. * @param material The material used on the mesh
  53244. * @returns true if it can be rendered otherwise false
  53245. */
  53246. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53247. /**
  53248. * Returns true if the mesh should render, otherwise false.
  53249. * @param mesh The mesh to render
  53250. * @returns true if it should render otherwise false
  53251. */
  53252. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53253. /**
  53254. * Renders the submesh passed in parameter to the generation map.
  53255. */
  53256. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53257. /**
  53258. * Defines wether the current material of the mesh should be use to render the effect.
  53259. * @param mesh defines the current mesh to render
  53260. */
  53261. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53262. /**
  53263. * Rebuild the required buffers.
  53264. * @hidden Internal use only.
  53265. */
  53266. _rebuild(): void;
  53267. /**
  53268. * Dispose only the render target textures and post process.
  53269. */
  53270. private _disposeTextureAndPostProcesses;
  53271. /**
  53272. * Dispose the highlight layer and free resources.
  53273. */
  53274. dispose(): void;
  53275. /**
  53276. * Gets the class name of the effect layer
  53277. * @returns the string with the class name of the effect layer
  53278. */
  53279. getClassName(): string;
  53280. /**
  53281. * Creates an effect layer from parsed effect layer data
  53282. * @param parsedEffectLayer defines effect layer data
  53283. * @param scene defines the current scene
  53284. * @param rootUrl defines the root URL containing the effect layer information
  53285. * @returns a parsed effect Layer
  53286. */
  53287. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53288. }
  53289. }
  53290. declare module BABYLON {
  53291. interface AbstractScene {
  53292. /**
  53293. * The list of effect layers (highlights/glow) added to the scene
  53294. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53295. * @see http://doc.babylonjs.com/how_to/glow_layer
  53296. */
  53297. effectLayers: Array<EffectLayer>;
  53298. /**
  53299. * Removes the given effect layer from this scene.
  53300. * @param toRemove defines the effect layer to remove
  53301. * @returns the index of the removed effect layer
  53302. */
  53303. removeEffectLayer(toRemove: EffectLayer): number;
  53304. /**
  53305. * Adds the given effect layer to this scene
  53306. * @param newEffectLayer defines the effect layer to add
  53307. */
  53308. addEffectLayer(newEffectLayer: EffectLayer): void;
  53309. }
  53310. /**
  53311. * Defines the layer scene component responsible to manage any effect layers
  53312. * in a given scene.
  53313. */
  53314. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53315. /**
  53316. * The component name helpfull to identify the component in the list of scene components.
  53317. */
  53318. readonly name: string;
  53319. /**
  53320. * The scene the component belongs to.
  53321. */
  53322. scene: Scene;
  53323. private _engine;
  53324. private _renderEffects;
  53325. private _needStencil;
  53326. private _previousStencilState;
  53327. /**
  53328. * Creates a new instance of the component for the given scene
  53329. * @param scene Defines the scene to register the component in
  53330. */
  53331. constructor(scene: Scene);
  53332. /**
  53333. * Registers the component in a given scene
  53334. */
  53335. register(): void;
  53336. /**
  53337. * Rebuilds the elements related to this component in case of
  53338. * context lost for instance.
  53339. */
  53340. rebuild(): void;
  53341. /**
  53342. * Serializes the component data to the specified json object
  53343. * @param serializationObject The object to serialize to
  53344. */
  53345. serialize(serializationObject: any): void;
  53346. /**
  53347. * Adds all the elements from the container to the scene
  53348. * @param container the container holding the elements
  53349. */
  53350. addFromContainer(container: AbstractScene): void;
  53351. /**
  53352. * Removes all the elements in the container from the scene
  53353. * @param container contains the elements to remove
  53354. * @param dispose if the removed element should be disposed (default: false)
  53355. */
  53356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53357. /**
  53358. * Disposes the component and the associated ressources.
  53359. */
  53360. dispose(): void;
  53361. private _isReadyForMesh;
  53362. private _renderMainTexture;
  53363. private _setStencil;
  53364. private _setStencilBack;
  53365. private _draw;
  53366. private _drawCamera;
  53367. private _drawRenderingGroup;
  53368. }
  53369. }
  53370. declare module BABYLON {
  53371. /** @hidden */
  53372. export var glowMapMergePixelShader: {
  53373. name: string;
  53374. shader: string;
  53375. };
  53376. }
  53377. declare module BABYLON {
  53378. /** @hidden */
  53379. export var glowMapMergeVertexShader: {
  53380. name: string;
  53381. shader: string;
  53382. };
  53383. }
  53384. declare module BABYLON {
  53385. interface AbstractScene {
  53386. /**
  53387. * Return a the first highlight layer of the scene with a given name.
  53388. * @param name The name of the highlight layer to look for.
  53389. * @return The highlight layer if found otherwise null.
  53390. */
  53391. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53392. }
  53393. /**
  53394. * Glow layer options. This helps customizing the behaviour
  53395. * of the glow layer.
  53396. */
  53397. export interface IGlowLayerOptions {
  53398. /**
  53399. * Multiplication factor apply to the canvas size to compute the render target size
  53400. * used to generated the glowing objects (the smaller the faster).
  53401. */
  53402. mainTextureRatio: number;
  53403. /**
  53404. * Enforces a fixed size texture to ensure resize independant blur.
  53405. */
  53406. mainTextureFixedSize?: number;
  53407. /**
  53408. * How big is the kernel of the blur texture.
  53409. */
  53410. blurKernelSize: number;
  53411. /**
  53412. * The camera attached to the layer.
  53413. */
  53414. camera: Nullable<Camera>;
  53415. /**
  53416. * Enable MSAA by chosing the number of samples.
  53417. */
  53418. mainTextureSamples?: number;
  53419. /**
  53420. * The rendering group to draw the layer in.
  53421. */
  53422. renderingGroupId: number;
  53423. }
  53424. /**
  53425. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53426. *
  53427. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53428. *
  53429. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53430. */
  53431. export class GlowLayer extends EffectLayer {
  53432. /**
  53433. * Effect Name of the layer.
  53434. */
  53435. static readonly EffectName: string;
  53436. /**
  53437. * The default blur kernel size used for the glow.
  53438. */
  53439. static DefaultBlurKernelSize: number;
  53440. /**
  53441. * The default texture size ratio used for the glow.
  53442. */
  53443. static DefaultTextureRatio: number;
  53444. /**
  53445. * Sets the kernel size of the blur.
  53446. */
  53447. set blurKernelSize(value: number);
  53448. /**
  53449. * Gets the kernel size of the blur.
  53450. */
  53451. get blurKernelSize(): number;
  53452. /**
  53453. * Sets the glow intensity.
  53454. */
  53455. set intensity(value: number);
  53456. /**
  53457. * Gets the glow intensity.
  53458. */
  53459. get intensity(): number;
  53460. private _options;
  53461. private _intensity;
  53462. private _horizontalBlurPostprocess1;
  53463. private _verticalBlurPostprocess1;
  53464. private _horizontalBlurPostprocess2;
  53465. private _verticalBlurPostprocess2;
  53466. private _blurTexture1;
  53467. private _blurTexture2;
  53468. private _postProcesses1;
  53469. private _postProcesses2;
  53470. private _includedOnlyMeshes;
  53471. private _excludedMeshes;
  53472. private _meshesUsingTheirOwnMaterials;
  53473. /**
  53474. * Callback used to let the user override the color selection on a per mesh basis
  53475. */
  53476. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53477. /**
  53478. * Callback used to let the user override the texture selection on a per mesh basis
  53479. */
  53480. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53481. /**
  53482. * Instantiates a new glow Layer and references it to the scene.
  53483. * @param name The name of the layer
  53484. * @param scene The scene to use the layer in
  53485. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53486. */
  53487. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53488. /**
  53489. * Get the effect name of the layer.
  53490. * @return The effect name
  53491. */
  53492. getEffectName(): string;
  53493. /**
  53494. * Create the merge effect. This is the shader use to blit the information back
  53495. * to the main canvas at the end of the scene rendering.
  53496. */
  53497. protected _createMergeEffect(): Effect;
  53498. /**
  53499. * Creates the render target textures and post processes used in the glow layer.
  53500. */
  53501. protected _createTextureAndPostProcesses(): void;
  53502. /**
  53503. * Checks for the readiness of the element composing the layer.
  53504. * @param subMesh the mesh to check for
  53505. * @param useInstances specify wether or not to use instances to render the mesh
  53506. * @param emissiveTexture the associated emissive texture used to generate the glow
  53507. * @return true if ready otherwise, false
  53508. */
  53509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53510. /**
  53511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53512. */
  53513. needStencil(): boolean;
  53514. /**
  53515. * Returns true if the mesh can be rendered, otherwise false.
  53516. * @param mesh The mesh to render
  53517. * @param material The material used on the mesh
  53518. * @returns true if it can be rendered otherwise false
  53519. */
  53520. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53521. /**
  53522. * Implementation specific of rendering the generating effect on the main canvas.
  53523. * @param effect The effect used to render through
  53524. */
  53525. protected _internalRender(effect: Effect): void;
  53526. /**
  53527. * Sets the required values for both the emissive texture and and the main color.
  53528. */
  53529. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53530. /**
  53531. * Returns true if the mesh should render, otherwise false.
  53532. * @param mesh The mesh to render
  53533. * @returns true if it should render otherwise false
  53534. */
  53535. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53536. /**
  53537. * Adds specific effects defines.
  53538. * @param defines The defines to add specifics to.
  53539. */
  53540. protected _addCustomEffectDefines(defines: string[]): void;
  53541. /**
  53542. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53543. * @param mesh The mesh to exclude from the glow layer
  53544. */
  53545. addExcludedMesh(mesh: Mesh): void;
  53546. /**
  53547. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53548. * @param mesh The mesh to remove
  53549. */
  53550. removeExcludedMesh(mesh: Mesh): void;
  53551. /**
  53552. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53553. * @param mesh The mesh to include in the glow layer
  53554. */
  53555. addIncludedOnlyMesh(mesh: Mesh): void;
  53556. /**
  53557. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53558. * @param mesh The mesh to remove
  53559. */
  53560. removeIncludedOnlyMesh(mesh: Mesh): void;
  53561. /**
  53562. * Determine if a given mesh will be used in the glow layer
  53563. * @param mesh The mesh to test
  53564. * @returns true if the mesh will be highlighted by the current glow layer
  53565. */
  53566. hasMesh(mesh: AbstractMesh): boolean;
  53567. /**
  53568. * Defines wether the current material of the mesh should be use to render the effect.
  53569. * @param mesh defines the current mesh to render
  53570. */
  53571. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53572. /**
  53573. * Add a mesh to be rendered through its own material and not with emissive only.
  53574. * @param mesh The mesh for which we need to use its material
  53575. */
  53576. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53577. /**
  53578. * Remove a mesh from being rendered through its own material and not with emissive only.
  53579. * @param mesh The mesh for which we need to not use its material
  53580. */
  53581. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53582. /**
  53583. * Free any resources and references associated to a mesh.
  53584. * Internal use
  53585. * @param mesh The mesh to free.
  53586. * @hidden
  53587. */
  53588. _disposeMesh(mesh: Mesh): void;
  53589. /**
  53590. * Gets the class name of the effect layer
  53591. * @returns the string with the class name of the effect layer
  53592. */
  53593. getClassName(): string;
  53594. /**
  53595. * Serializes this glow layer
  53596. * @returns a serialized glow layer object
  53597. */
  53598. serialize(): any;
  53599. /**
  53600. * Creates a Glow Layer from parsed glow layer data
  53601. * @param parsedGlowLayer defines glow layer data
  53602. * @param scene defines the current scene
  53603. * @param rootUrl defines the root URL containing the glow layer information
  53604. * @returns a parsed Glow Layer
  53605. */
  53606. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53607. }
  53608. }
  53609. declare module BABYLON {
  53610. /** @hidden */
  53611. export var glowBlurPostProcessPixelShader: {
  53612. name: string;
  53613. shader: string;
  53614. };
  53615. }
  53616. declare module BABYLON {
  53617. interface AbstractScene {
  53618. /**
  53619. * Return a the first highlight layer of the scene with a given name.
  53620. * @param name The name of the highlight layer to look for.
  53621. * @return The highlight layer if found otherwise null.
  53622. */
  53623. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53624. }
  53625. /**
  53626. * Highlight layer options. This helps customizing the behaviour
  53627. * of the highlight layer.
  53628. */
  53629. export interface IHighlightLayerOptions {
  53630. /**
  53631. * Multiplication factor apply to the canvas size to compute the render target size
  53632. * used to generated the glowing objects (the smaller the faster).
  53633. */
  53634. mainTextureRatio: number;
  53635. /**
  53636. * Enforces a fixed size texture to ensure resize independant blur.
  53637. */
  53638. mainTextureFixedSize?: number;
  53639. /**
  53640. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53641. * of the picture to blur (the smaller the faster).
  53642. */
  53643. blurTextureSizeRatio: number;
  53644. /**
  53645. * How big in texel of the blur texture is the vertical blur.
  53646. */
  53647. blurVerticalSize: number;
  53648. /**
  53649. * How big in texel of the blur texture is the horizontal blur.
  53650. */
  53651. blurHorizontalSize: number;
  53652. /**
  53653. * Alpha blending mode used to apply the blur. Default is combine.
  53654. */
  53655. alphaBlendingMode: number;
  53656. /**
  53657. * The camera attached to the layer.
  53658. */
  53659. camera: Nullable<Camera>;
  53660. /**
  53661. * Should we display highlight as a solid stroke?
  53662. */
  53663. isStroke?: boolean;
  53664. /**
  53665. * The rendering group to draw the layer in.
  53666. */
  53667. renderingGroupId: number;
  53668. }
  53669. /**
  53670. * The highlight layer Helps adding a glow effect around a mesh.
  53671. *
  53672. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53673. * glowy meshes to your scene.
  53674. *
  53675. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53676. */
  53677. export class HighlightLayer extends EffectLayer {
  53678. name: string;
  53679. /**
  53680. * Effect Name of the highlight layer.
  53681. */
  53682. static readonly EffectName: string;
  53683. /**
  53684. * The neutral color used during the preparation of the glow effect.
  53685. * This is black by default as the blend operation is a blend operation.
  53686. */
  53687. static NeutralColor: Color4;
  53688. /**
  53689. * Stencil value used for glowing meshes.
  53690. */
  53691. static GlowingMeshStencilReference: number;
  53692. /**
  53693. * Stencil value used for the other meshes in the scene.
  53694. */
  53695. static NormalMeshStencilReference: number;
  53696. /**
  53697. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53698. */
  53699. innerGlow: boolean;
  53700. /**
  53701. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53702. */
  53703. outerGlow: boolean;
  53704. /**
  53705. * Specifies the horizontal size of the blur.
  53706. */
  53707. set blurHorizontalSize(value: number);
  53708. /**
  53709. * Specifies the vertical size of the blur.
  53710. */
  53711. set blurVerticalSize(value: number);
  53712. /**
  53713. * Gets the horizontal size of the blur.
  53714. */
  53715. get blurHorizontalSize(): number;
  53716. /**
  53717. * Gets the vertical size of the blur.
  53718. */
  53719. get blurVerticalSize(): number;
  53720. /**
  53721. * An event triggered when the highlight layer is being blurred.
  53722. */
  53723. onBeforeBlurObservable: Observable<HighlightLayer>;
  53724. /**
  53725. * An event triggered when the highlight layer has been blurred.
  53726. */
  53727. onAfterBlurObservable: Observable<HighlightLayer>;
  53728. private _instanceGlowingMeshStencilReference;
  53729. private _options;
  53730. private _downSamplePostprocess;
  53731. private _horizontalBlurPostprocess;
  53732. private _verticalBlurPostprocess;
  53733. private _blurTexture;
  53734. private _meshes;
  53735. private _excludedMeshes;
  53736. /**
  53737. * Instantiates a new highlight Layer and references it to the scene..
  53738. * @param name The name of the layer
  53739. * @param scene The scene to use the layer in
  53740. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53741. */
  53742. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53743. /**
  53744. * Get the effect name of the layer.
  53745. * @return The effect name
  53746. */
  53747. getEffectName(): string;
  53748. /**
  53749. * Create the merge effect. This is the shader use to blit the information back
  53750. * to the main canvas at the end of the scene rendering.
  53751. */
  53752. protected _createMergeEffect(): Effect;
  53753. /**
  53754. * Creates the render target textures and post processes used in the highlight layer.
  53755. */
  53756. protected _createTextureAndPostProcesses(): void;
  53757. /**
  53758. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53759. */
  53760. needStencil(): boolean;
  53761. /**
  53762. * Checks for the readiness of the element composing the layer.
  53763. * @param subMesh the mesh to check for
  53764. * @param useInstances specify wether or not to use instances to render the mesh
  53765. * @param emissiveTexture the associated emissive texture used to generate the glow
  53766. * @return true if ready otherwise, false
  53767. */
  53768. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53769. /**
  53770. * Implementation specific of rendering the generating effect on the main canvas.
  53771. * @param effect The effect used to render through
  53772. */
  53773. protected _internalRender(effect: Effect): void;
  53774. /**
  53775. * Returns true if the layer contains information to display, otherwise false.
  53776. */
  53777. shouldRender(): boolean;
  53778. /**
  53779. * Returns true if the mesh should render, otherwise false.
  53780. * @param mesh The mesh to render
  53781. * @returns true if it should render otherwise false
  53782. */
  53783. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53784. /**
  53785. * Sets the required values for both the emissive texture and and the main color.
  53786. */
  53787. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53788. /**
  53789. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53790. * @param mesh The mesh to exclude from the highlight layer
  53791. */
  53792. addExcludedMesh(mesh: Mesh): void;
  53793. /**
  53794. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53795. * @param mesh The mesh to highlight
  53796. */
  53797. removeExcludedMesh(mesh: Mesh): void;
  53798. /**
  53799. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53800. * @param mesh mesh to test
  53801. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53802. */
  53803. hasMesh(mesh: AbstractMesh): boolean;
  53804. /**
  53805. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53806. * @param mesh The mesh to highlight
  53807. * @param color The color of the highlight
  53808. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53809. */
  53810. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53811. /**
  53812. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53813. * @param mesh The mesh to highlight
  53814. */
  53815. removeMesh(mesh: Mesh): void;
  53816. /**
  53817. * Force the stencil to the normal expected value for none glowing parts
  53818. */
  53819. private _defaultStencilReference;
  53820. /**
  53821. * Free any resources and references associated to a mesh.
  53822. * Internal use
  53823. * @param mesh The mesh to free.
  53824. * @hidden
  53825. */
  53826. _disposeMesh(mesh: Mesh): void;
  53827. /**
  53828. * Dispose the highlight layer and free resources.
  53829. */
  53830. dispose(): void;
  53831. /**
  53832. * Gets the class name of the effect layer
  53833. * @returns the string with the class name of the effect layer
  53834. */
  53835. getClassName(): string;
  53836. /**
  53837. * Serializes this Highlight layer
  53838. * @returns a serialized Highlight layer object
  53839. */
  53840. serialize(): any;
  53841. /**
  53842. * Creates a Highlight layer from parsed Highlight layer data
  53843. * @param parsedHightlightLayer defines the Highlight layer data
  53844. * @param scene defines the current scene
  53845. * @param rootUrl defines the root URL containing the Highlight layer information
  53846. * @returns a parsed Highlight layer
  53847. */
  53848. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53849. }
  53850. }
  53851. declare module BABYLON {
  53852. interface AbstractScene {
  53853. /**
  53854. * The list of layers (background and foreground) of the scene
  53855. */
  53856. layers: Array<Layer>;
  53857. }
  53858. /**
  53859. * Defines the layer scene component responsible to manage any layers
  53860. * in a given scene.
  53861. */
  53862. export class LayerSceneComponent implements ISceneComponent {
  53863. /**
  53864. * The component name helpfull to identify the component in the list of scene components.
  53865. */
  53866. readonly name: string;
  53867. /**
  53868. * The scene the component belongs to.
  53869. */
  53870. scene: Scene;
  53871. private _engine;
  53872. /**
  53873. * Creates a new instance of the component for the given scene
  53874. * @param scene Defines the scene to register the component in
  53875. */
  53876. constructor(scene: Scene);
  53877. /**
  53878. * Registers the component in a given scene
  53879. */
  53880. register(): void;
  53881. /**
  53882. * Rebuilds the elements related to this component in case of
  53883. * context lost for instance.
  53884. */
  53885. rebuild(): void;
  53886. /**
  53887. * Disposes the component and the associated ressources.
  53888. */
  53889. dispose(): void;
  53890. private _draw;
  53891. private _drawCameraPredicate;
  53892. private _drawCameraBackground;
  53893. private _drawCameraForeground;
  53894. private _drawRenderTargetPredicate;
  53895. private _drawRenderTargetBackground;
  53896. private _drawRenderTargetForeground;
  53897. /**
  53898. * Adds all the elements from the container to the scene
  53899. * @param container the container holding the elements
  53900. */
  53901. addFromContainer(container: AbstractScene): void;
  53902. /**
  53903. * Removes all the elements in the container from the scene
  53904. * @param container contains the elements to remove
  53905. * @param dispose if the removed element should be disposed (default: false)
  53906. */
  53907. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53908. }
  53909. }
  53910. declare module BABYLON {
  53911. /** @hidden */
  53912. export var layerPixelShader: {
  53913. name: string;
  53914. shader: string;
  53915. };
  53916. }
  53917. declare module BABYLON {
  53918. /** @hidden */
  53919. export var layerVertexShader: {
  53920. name: string;
  53921. shader: string;
  53922. };
  53923. }
  53924. declare module BABYLON {
  53925. /**
  53926. * This represents a full screen 2d layer.
  53927. * This can be useful to display a picture in the background of your scene for instance.
  53928. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53929. */
  53930. export class Layer {
  53931. /**
  53932. * Define the name of the layer.
  53933. */
  53934. name: string;
  53935. /**
  53936. * Define the texture the layer should display.
  53937. */
  53938. texture: Nullable<Texture>;
  53939. /**
  53940. * Is the layer in background or foreground.
  53941. */
  53942. isBackground: boolean;
  53943. /**
  53944. * Define the color of the layer (instead of texture).
  53945. */
  53946. color: Color4;
  53947. /**
  53948. * Define the scale of the layer in order to zoom in out of the texture.
  53949. */
  53950. scale: Vector2;
  53951. /**
  53952. * Define an offset for the layer in order to shift the texture.
  53953. */
  53954. offset: Vector2;
  53955. /**
  53956. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53957. */
  53958. alphaBlendingMode: number;
  53959. /**
  53960. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53961. * Alpha test will not mix with the background color in case of transparency.
  53962. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53963. */
  53964. alphaTest: boolean;
  53965. /**
  53966. * Define a mask to restrict the layer to only some of the scene cameras.
  53967. */
  53968. layerMask: number;
  53969. /**
  53970. * Define the list of render target the layer is visible into.
  53971. */
  53972. renderTargetTextures: RenderTargetTexture[];
  53973. /**
  53974. * Define if the layer is only used in renderTarget or if it also
  53975. * renders in the main frame buffer of the canvas.
  53976. */
  53977. renderOnlyInRenderTargetTextures: boolean;
  53978. private _scene;
  53979. private _vertexBuffers;
  53980. private _indexBuffer;
  53981. private _effect;
  53982. private _previousDefines;
  53983. /**
  53984. * An event triggered when the layer is disposed.
  53985. */
  53986. onDisposeObservable: Observable<Layer>;
  53987. private _onDisposeObserver;
  53988. /**
  53989. * Back compatibility with callback before the onDisposeObservable existed.
  53990. * The set callback will be triggered when the layer has been disposed.
  53991. */
  53992. set onDispose(callback: () => void);
  53993. /**
  53994. * An event triggered before rendering the scene
  53995. */
  53996. onBeforeRenderObservable: Observable<Layer>;
  53997. private _onBeforeRenderObserver;
  53998. /**
  53999. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54000. * The set callback will be triggered just before rendering the layer.
  54001. */
  54002. set onBeforeRender(callback: () => void);
  54003. /**
  54004. * An event triggered after rendering the scene
  54005. */
  54006. onAfterRenderObservable: Observable<Layer>;
  54007. private _onAfterRenderObserver;
  54008. /**
  54009. * Back compatibility with callback before the onAfterRenderObservable existed.
  54010. * The set callback will be triggered just after rendering the layer.
  54011. */
  54012. set onAfterRender(callback: () => void);
  54013. /**
  54014. * Instantiates a new layer.
  54015. * This represents a full screen 2d layer.
  54016. * This can be useful to display a picture in the background of your scene for instance.
  54017. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54018. * @param name Define the name of the layer in the scene
  54019. * @param imgUrl Define the url of the texture to display in the layer
  54020. * @param scene Define the scene the layer belongs to
  54021. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54022. * @param color Defines a color for the layer
  54023. */
  54024. constructor(
  54025. /**
  54026. * Define the name of the layer.
  54027. */
  54028. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54029. private _createIndexBuffer;
  54030. /** @hidden */
  54031. _rebuild(): void;
  54032. /**
  54033. * Renders the layer in the scene.
  54034. */
  54035. render(): void;
  54036. /**
  54037. * Disposes and releases the associated ressources.
  54038. */
  54039. dispose(): void;
  54040. }
  54041. }
  54042. declare module BABYLON {
  54043. /** @hidden */
  54044. export var lensFlarePixelShader: {
  54045. name: string;
  54046. shader: string;
  54047. };
  54048. }
  54049. declare module BABYLON {
  54050. /** @hidden */
  54051. export var lensFlareVertexShader: {
  54052. name: string;
  54053. shader: string;
  54054. };
  54055. }
  54056. declare module BABYLON {
  54057. /**
  54058. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54059. * It is usually composed of several `lensFlare`.
  54060. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54061. */
  54062. export class LensFlareSystem {
  54063. /**
  54064. * Define the name of the lens flare system
  54065. */
  54066. name: string;
  54067. /**
  54068. * List of lens flares used in this system.
  54069. */
  54070. lensFlares: LensFlare[];
  54071. /**
  54072. * Define a limit from the border the lens flare can be visible.
  54073. */
  54074. borderLimit: number;
  54075. /**
  54076. * Define a viewport border we do not want to see the lens flare in.
  54077. */
  54078. viewportBorder: number;
  54079. /**
  54080. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54081. */
  54082. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54083. /**
  54084. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54085. */
  54086. layerMask: number;
  54087. /**
  54088. * Define the id of the lens flare system in the scene.
  54089. * (equal to name by default)
  54090. */
  54091. id: string;
  54092. private _scene;
  54093. private _emitter;
  54094. private _vertexBuffers;
  54095. private _indexBuffer;
  54096. private _effect;
  54097. private _positionX;
  54098. private _positionY;
  54099. private _isEnabled;
  54100. /** @hidden */
  54101. static _SceneComponentInitialization: (scene: Scene) => void;
  54102. /**
  54103. * Instantiates a lens flare system.
  54104. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54105. * It is usually composed of several `lensFlare`.
  54106. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54107. * @param name Define the name of the lens flare system in the scene
  54108. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54109. * @param scene Define the scene the lens flare system belongs to
  54110. */
  54111. constructor(
  54112. /**
  54113. * Define the name of the lens flare system
  54114. */
  54115. name: string, emitter: any, scene: Scene);
  54116. /**
  54117. * Define if the lens flare system is enabled.
  54118. */
  54119. get isEnabled(): boolean;
  54120. set isEnabled(value: boolean);
  54121. /**
  54122. * Get the scene the effects belongs to.
  54123. * @returns the scene holding the lens flare system
  54124. */
  54125. getScene(): Scene;
  54126. /**
  54127. * Get the emitter of the lens flare system.
  54128. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54129. * @returns the emitter of the lens flare system
  54130. */
  54131. getEmitter(): any;
  54132. /**
  54133. * Set the emitter of the lens flare system.
  54134. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54135. * @param newEmitter Define the new emitter of the system
  54136. */
  54137. setEmitter(newEmitter: any): void;
  54138. /**
  54139. * Get the lens flare system emitter position.
  54140. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54141. * @returns the position
  54142. */
  54143. getEmitterPosition(): Vector3;
  54144. /**
  54145. * @hidden
  54146. */
  54147. computeEffectivePosition(globalViewport: Viewport): boolean;
  54148. /** @hidden */
  54149. _isVisible(): boolean;
  54150. /**
  54151. * @hidden
  54152. */
  54153. render(): boolean;
  54154. /**
  54155. * Dispose and release the lens flare with its associated resources.
  54156. */
  54157. dispose(): void;
  54158. /**
  54159. * Parse a lens flare system from a JSON repressentation
  54160. * @param parsedLensFlareSystem Define the JSON to parse
  54161. * @param scene Define the scene the parsed system should be instantiated in
  54162. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54163. * @returns the parsed system
  54164. */
  54165. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54166. /**
  54167. * Serialize the current Lens Flare System into a JSON representation.
  54168. * @returns the serialized JSON
  54169. */
  54170. serialize(): any;
  54171. }
  54172. }
  54173. declare module BABYLON {
  54174. /**
  54175. * This represents one of the lens effect in a `lensFlareSystem`.
  54176. * It controls one of the indiviual texture used in the effect.
  54177. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54178. */
  54179. export class LensFlare {
  54180. /**
  54181. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54182. */
  54183. size: number;
  54184. /**
  54185. * 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.
  54186. */
  54187. position: number;
  54188. /**
  54189. * Define the lens color.
  54190. */
  54191. color: Color3;
  54192. /**
  54193. * Define the lens texture.
  54194. */
  54195. texture: Nullable<Texture>;
  54196. /**
  54197. * Define the alpha mode to render this particular lens.
  54198. */
  54199. alphaMode: number;
  54200. private _system;
  54201. /**
  54202. * Creates a new Lens Flare.
  54203. * This represents one of the lens effect in a `lensFlareSystem`.
  54204. * It controls one of the indiviual texture used in the effect.
  54205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54206. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54207. * @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.
  54208. * @param color Define the lens color
  54209. * @param imgUrl Define the lens texture url
  54210. * @param system Define the `lensFlareSystem` this flare is part of
  54211. * @returns The newly created Lens Flare
  54212. */
  54213. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54214. /**
  54215. * Instantiates a new Lens Flare.
  54216. * This represents one of the lens effect in a `lensFlareSystem`.
  54217. * It controls one of the indiviual texture used in the effect.
  54218. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54219. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54220. * @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.
  54221. * @param color Define the lens color
  54222. * @param imgUrl Define the lens texture url
  54223. * @param system Define the `lensFlareSystem` this flare is part of
  54224. */
  54225. constructor(
  54226. /**
  54227. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54228. */
  54229. size: number,
  54230. /**
  54231. * 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.
  54232. */
  54233. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54234. /**
  54235. * Dispose and release the lens flare with its associated resources.
  54236. */
  54237. dispose(): void;
  54238. }
  54239. }
  54240. declare module BABYLON {
  54241. interface AbstractScene {
  54242. /**
  54243. * The list of lens flare system added to the scene
  54244. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54245. */
  54246. lensFlareSystems: Array<LensFlareSystem>;
  54247. /**
  54248. * Removes the given lens flare system from this scene.
  54249. * @param toRemove The lens flare system to remove
  54250. * @returns The index of the removed lens flare system
  54251. */
  54252. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54253. /**
  54254. * Adds the given lens flare system to this scene
  54255. * @param newLensFlareSystem The lens flare system to add
  54256. */
  54257. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54258. /**
  54259. * Gets a lens flare system using its name
  54260. * @param name defines the name to look for
  54261. * @returns the lens flare system or null if not found
  54262. */
  54263. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54264. /**
  54265. * Gets a lens flare system using its id
  54266. * @param id defines the id to look for
  54267. * @returns the lens flare system or null if not found
  54268. */
  54269. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54270. }
  54271. /**
  54272. * Defines the lens flare scene component responsible to manage any lens flares
  54273. * in a given scene.
  54274. */
  54275. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54276. /**
  54277. * The component name helpfull to identify the component in the list of scene components.
  54278. */
  54279. readonly name: string;
  54280. /**
  54281. * The scene the component belongs to.
  54282. */
  54283. scene: Scene;
  54284. /**
  54285. * Creates a new instance of the component for the given scene
  54286. * @param scene Defines the scene to register the component in
  54287. */
  54288. constructor(scene: Scene);
  54289. /**
  54290. * Registers the component in a given scene
  54291. */
  54292. register(): void;
  54293. /**
  54294. * Rebuilds the elements related to this component in case of
  54295. * context lost for instance.
  54296. */
  54297. rebuild(): void;
  54298. /**
  54299. * Adds all the elements from the container to the scene
  54300. * @param container the container holding the elements
  54301. */
  54302. addFromContainer(container: AbstractScene): void;
  54303. /**
  54304. * Removes all the elements in the container from the scene
  54305. * @param container contains the elements to remove
  54306. * @param dispose if the removed element should be disposed (default: false)
  54307. */
  54308. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54309. /**
  54310. * Serializes the component data to the specified json object
  54311. * @param serializationObject The object to serialize to
  54312. */
  54313. serialize(serializationObject: any): void;
  54314. /**
  54315. * Disposes the component and the associated ressources.
  54316. */
  54317. dispose(): void;
  54318. private _draw;
  54319. }
  54320. }
  54321. declare module BABYLON {
  54322. /** @hidden */
  54323. export var depthPixelShader: {
  54324. name: string;
  54325. shader: string;
  54326. };
  54327. }
  54328. declare module BABYLON {
  54329. /** @hidden */
  54330. export var depthVertexShader: {
  54331. name: string;
  54332. shader: string;
  54333. };
  54334. }
  54335. declare module BABYLON {
  54336. /**
  54337. * This represents a depth renderer in Babylon.
  54338. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54339. */
  54340. export class DepthRenderer {
  54341. private _scene;
  54342. private _depthMap;
  54343. private _effect;
  54344. private readonly _storeNonLinearDepth;
  54345. private readonly _clearColor;
  54346. /** Get if the depth renderer is using packed depth or not */
  54347. readonly isPacked: boolean;
  54348. private _cachedDefines;
  54349. private _camera;
  54350. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54351. enabled: boolean;
  54352. /**
  54353. * Specifiess that the depth renderer will only be used within
  54354. * the camera it is created for.
  54355. * This can help forcing its rendering during the camera processing.
  54356. */
  54357. useOnlyInActiveCamera: boolean;
  54358. /** @hidden */
  54359. static _SceneComponentInitialization: (scene: Scene) => void;
  54360. /**
  54361. * Instantiates a depth renderer
  54362. * @param scene The scene the renderer belongs to
  54363. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54364. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54365. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54366. */
  54367. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54368. /**
  54369. * Creates the depth rendering effect and checks if the effect is ready.
  54370. * @param subMesh The submesh to be used to render the depth map of
  54371. * @param useInstances If multiple world instances should be used
  54372. * @returns if the depth renderer is ready to render the depth map
  54373. */
  54374. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54375. /**
  54376. * Gets the texture which the depth map will be written to.
  54377. * @returns The depth map texture
  54378. */
  54379. getDepthMap(): RenderTargetTexture;
  54380. /**
  54381. * Disposes of the depth renderer.
  54382. */
  54383. dispose(): void;
  54384. }
  54385. }
  54386. declare module BABYLON {
  54387. /** @hidden */
  54388. export var minmaxReduxPixelShader: {
  54389. name: string;
  54390. shader: string;
  54391. };
  54392. }
  54393. declare module BABYLON {
  54394. /**
  54395. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54396. * and maximum values from all values of the texture.
  54397. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54398. * The source values are read from the red channel of the texture.
  54399. */
  54400. export class MinMaxReducer {
  54401. /**
  54402. * Observable triggered when the computation has been performed
  54403. */
  54404. onAfterReductionPerformed: Observable<{
  54405. min: number;
  54406. max: number;
  54407. }>;
  54408. protected _camera: Camera;
  54409. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54410. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54411. protected _postProcessManager: PostProcessManager;
  54412. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54413. protected _forceFullscreenViewport: boolean;
  54414. /**
  54415. * Creates a min/max reducer
  54416. * @param camera The camera to use for the post processes
  54417. */
  54418. constructor(camera: Camera);
  54419. /**
  54420. * Gets the texture used to read the values from.
  54421. */
  54422. get sourceTexture(): Nullable<RenderTargetTexture>;
  54423. /**
  54424. * Sets the source texture to read the values from.
  54425. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54426. * because in such textures '1' value must not be taken into account to compute the maximum
  54427. * as this value is used to clear the texture.
  54428. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54429. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54430. * @param depthRedux Indicates if the texture is a depth texture or not
  54431. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54432. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54433. */
  54434. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54435. /**
  54436. * Defines the refresh rate of the computation.
  54437. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54438. */
  54439. get refreshRate(): number;
  54440. set refreshRate(value: number);
  54441. protected _activated: boolean;
  54442. /**
  54443. * Gets the activation status of the reducer
  54444. */
  54445. get activated(): boolean;
  54446. /**
  54447. * Activates the reduction computation.
  54448. * When activated, the observers registered in onAfterReductionPerformed are
  54449. * called after the compuation is performed
  54450. */
  54451. activate(): void;
  54452. /**
  54453. * Deactivates the reduction computation.
  54454. */
  54455. deactivate(): void;
  54456. /**
  54457. * Disposes the min/max reducer
  54458. * @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.
  54459. */
  54460. dispose(disposeAll?: boolean): void;
  54461. }
  54462. }
  54463. declare module BABYLON {
  54464. /**
  54465. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54466. */
  54467. export class DepthReducer extends MinMaxReducer {
  54468. private _depthRenderer;
  54469. private _depthRendererId;
  54470. /**
  54471. * Gets the depth renderer used for the computation.
  54472. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54473. */
  54474. get depthRenderer(): Nullable<DepthRenderer>;
  54475. /**
  54476. * Creates a depth reducer
  54477. * @param camera The camera used to render the depth texture
  54478. */
  54479. constructor(camera: Camera);
  54480. /**
  54481. * Sets the depth renderer to use to generate the depth map
  54482. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54483. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54484. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54485. */
  54486. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54487. /** @hidden */
  54488. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54489. /**
  54490. * Activates the reduction computation.
  54491. * When activated, the observers registered in onAfterReductionPerformed are
  54492. * called after the compuation is performed
  54493. */
  54494. activate(): void;
  54495. /**
  54496. * Deactivates the reduction computation.
  54497. */
  54498. deactivate(): void;
  54499. /**
  54500. * Disposes the depth reducer
  54501. * @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.
  54502. */
  54503. dispose(disposeAll?: boolean): void;
  54504. }
  54505. }
  54506. declare module BABYLON {
  54507. /**
  54508. * A CSM implementation allowing casting shadows on large scenes.
  54509. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54510. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54511. */
  54512. export class CascadedShadowGenerator extends ShadowGenerator {
  54513. private static readonly frustumCornersNDCSpace;
  54514. /**
  54515. * Name of the CSM class
  54516. */
  54517. static CLASSNAME: string;
  54518. /**
  54519. * Defines the default number of cascades used by the CSM.
  54520. */
  54521. static readonly DEFAULT_CASCADES_COUNT: number;
  54522. /**
  54523. * Defines the minimum number of cascades used by the CSM.
  54524. */
  54525. static readonly MIN_CASCADES_COUNT: number;
  54526. /**
  54527. * Defines the maximum number of cascades used by the CSM.
  54528. */
  54529. static readonly MAX_CASCADES_COUNT: number;
  54530. protected _validateFilter(filter: number): number;
  54531. /**
  54532. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54533. */
  54534. penumbraDarkness: number;
  54535. private _numCascades;
  54536. /**
  54537. * Gets or set the number of cascades used by the CSM.
  54538. */
  54539. get numCascades(): number;
  54540. set numCascades(value: number);
  54541. /**
  54542. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54543. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54544. */
  54545. stabilizeCascades: boolean;
  54546. private _freezeShadowCastersBoundingInfo;
  54547. private _freezeShadowCastersBoundingInfoObservable;
  54548. /**
  54549. * Enables or disables the shadow casters bounding info computation.
  54550. * If your shadow casters don't move, you can disable this feature.
  54551. * If it is enabled, the bounding box computation is done every frame.
  54552. */
  54553. get freezeShadowCastersBoundingInfo(): boolean;
  54554. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54555. private _scbiMin;
  54556. private _scbiMax;
  54557. protected _computeShadowCastersBoundingInfo(): void;
  54558. protected _shadowCastersBoundingInfo: BoundingInfo;
  54559. /**
  54560. * Gets or sets the shadow casters bounding info.
  54561. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54562. * so that the system won't overwrite the bounds you provide
  54563. */
  54564. get shadowCastersBoundingInfo(): BoundingInfo;
  54565. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54566. protected _breaksAreDirty: boolean;
  54567. protected _minDistance: number;
  54568. protected _maxDistance: number;
  54569. /**
  54570. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54571. *
  54572. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54573. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54574. * @param min minimal distance for the breaks (default to 0.)
  54575. * @param max maximal distance for the breaks (default to 1.)
  54576. */
  54577. setMinMaxDistance(min: number, max: number): void;
  54578. /** Gets the minimal distance used in the cascade break computation */
  54579. get minDistance(): number;
  54580. /** Gets the maximal distance used in the cascade break computation */
  54581. get maxDistance(): number;
  54582. /**
  54583. * Gets the class name of that object
  54584. * @returns "CascadedShadowGenerator"
  54585. */
  54586. getClassName(): string;
  54587. private _cascadeMinExtents;
  54588. private _cascadeMaxExtents;
  54589. /**
  54590. * Gets a cascade minimum extents
  54591. * @param cascadeIndex index of the cascade
  54592. * @returns the minimum cascade extents
  54593. */
  54594. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54595. /**
  54596. * Gets a cascade maximum extents
  54597. * @param cascadeIndex index of the cascade
  54598. * @returns the maximum cascade extents
  54599. */
  54600. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54601. private _cascades;
  54602. private _currentLayer;
  54603. private _viewSpaceFrustumsZ;
  54604. private _viewMatrices;
  54605. private _projectionMatrices;
  54606. private _transformMatrices;
  54607. private _transformMatricesAsArray;
  54608. private _frustumLengths;
  54609. private _lightSizeUVCorrection;
  54610. private _depthCorrection;
  54611. private _frustumCornersWorldSpace;
  54612. private _frustumCenter;
  54613. private _shadowCameraPos;
  54614. private _shadowMaxZ;
  54615. /**
  54616. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54617. * It defaults to camera.maxZ
  54618. */
  54619. get shadowMaxZ(): number;
  54620. /**
  54621. * Sets the shadow max z distance.
  54622. */
  54623. set shadowMaxZ(value: number);
  54624. protected _debug: boolean;
  54625. /**
  54626. * Gets or sets the debug flag.
  54627. * When enabled, the cascades are materialized by different colors on the screen.
  54628. */
  54629. get debug(): boolean;
  54630. set debug(dbg: boolean);
  54631. private _depthClamp;
  54632. /**
  54633. * Gets or sets the depth clamping value.
  54634. *
  54635. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54636. * to account for the shadow casters far away.
  54637. *
  54638. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54639. */
  54640. get depthClamp(): boolean;
  54641. set depthClamp(value: boolean);
  54642. private _cascadeBlendPercentage;
  54643. /**
  54644. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54645. * It defaults to 0.1 (10% blending).
  54646. */
  54647. get cascadeBlendPercentage(): number;
  54648. set cascadeBlendPercentage(value: number);
  54649. private _lambda;
  54650. /**
  54651. * Gets or set the lambda parameter.
  54652. * This parameter is used to split the camera frustum and create the cascades.
  54653. * 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.
  54654. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54655. */
  54656. get lambda(): number;
  54657. set lambda(value: number);
  54658. /**
  54659. * Gets the view matrix corresponding to a given cascade
  54660. * @param cascadeNum cascade to retrieve the view matrix from
  54661. * @returns the cascade view matrix
  54662. */
  54663. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54664. /**
  54665. * Gets the projection matrix corresponding to a given cascade
  54666. * @param cascadeNum cascade to retrieve the projection matrix from
  54667. * @returns the cascade projection matrix
  54668. */
  54669. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54670. /**
  54671. * Gets the transformation matrix corresponding to a given cascade
  54672. * @param cascadeNum cascade to retrieve the transformation matrix from
  54673. * @returns the cascade transformation matrix
  54674. */
  54675. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54676. private _depthRenderer;
  54677. /**
  54678. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54679. *
  54680. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54681. *
  54682. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54683. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54684. * @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
  54685. */
  54686. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54687. private _depthReducer;
  54688. private _autoCalcDepthBounds;
  54689. /**
  54690. * Gets or sets the autoCalcDepthBounds property.
  54691. *
  54692. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54693. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54694. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54695. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54696. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54697. */
  54698. get autoCalcDepthBounds(): boolean;
  54699. set autoCalcDepthBounds(value: boolean);
  54700. /**
  54701. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54702. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54703. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54704. * for setting the refresh rate on the renderer yourself!
  54705. */
  54706. get autoCalcDepthBoundsRefreshRate(): number;
  54707. set autoCalcDepthBoundsRefreshRate(value: number);
  54708. /**
  54709. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54710. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54711. * you change the camera near/far planes!
  54712. */
  54713. splitFrustum(): void;
  54714. private _splitFrustum;
  54715. private _computeMatrices;
  54716. private _computeFrustumInWorldSpace;
  54717. private _computeCascadeFrustum;
  54718. /** @hidden */
  54719. static _SceneComponentInitialization: (scene: Scene) => void;
  54720. /**
  54721. * Creates a Cascaded Shadow Generator object.
  54722. * A ShadowGenerator is the required tool to use the shadows.
  54723. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54724. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54725. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54726. * @param light The directional light object generating the shadows.
  54727. * @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.
  54728. */
  54729. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54730. protected _initializeGenerator(): void;
  54731. protected _createTargetRenderTexture(): void;
  54732. protected _initializeShadowMap(): void;
  54733. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54734. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54735. /**
  54736. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54737. * @param defines Defines of the material we want to update
  54738. * @param lightIndex Index of the light in the enabled light list of the material
  54739. */
  54740. prepareDefines(defines: any, lightIndex: number): void;
  54741. /**
  54742. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54743. * defined in the generator but impacting the effect).
  54744. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54745. * @param effect The effect we are binfing the information for
  54746. */
  54747. bindShadowLight(lightIndex: string, effect: Effect): void;
  54748. /**
  54749. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54750. * (eq to view projection * shadow projection matrices)
  54751. * @returns The transform matrix used to create the shadow map
  54752. */
  54753. getTransformMatrix(): Matrix;
  54754. /**
  54755. * Disposes the ShadowGenerator.
  54756. * Returns nothing.
  54757. */
  54758. dispose(): void;
  54759. /**
  54760. * Serializes the shadow generator setup to a json object.
  54761. * @returns The serialized JSON object
  54762. */
  54763. serialize(): any;
  54764. /**
  54765. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54766. * @param parsedShadowGenerator The JSON object to parse
  54767. * @param scene The scene to create the shadow map for
  54768. * @returns The parsed shadow generator
  54769. */
  54770. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54771. }
  54772. }
  54773. declare module BABYLON {
  54774. /**
  54775. * Defines the shadow generator component responsible to manage any shadow generators
  54776. * in a given scene.
  54777. */
  54778. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54779. /**
  54780. * The component name helpfull to identify the component in the list of scene components.
  54781. */
  54782. readonly name: string;
  54783. /**
  54784. * The scene the component belongs to.
  54785. */
  54786. scene: Scene;
  54787. /**
  54788. * Creates a new instance of the component for the given scene
  54789. * @param scene Defines the scene to register the component in
  54790. */
  54791. constructor(scene: Scene);
  54792. /**
  54793. * Registers the component in a given scene
  54794. */
  54795. register(): void;
  54796. /**
  54797. * Rebuilds the elements related to this component in case of
  54798. * context lost for instance.
  54799. */
  54800. rebuild(): void;
  54801. /**
  54802. * Serializes the component data to the specified json object
  54803. * @param serializationObject The object to serialize to
  54804. */
  54805. serialize(serializationObject: any): void;
  54806. /**
  54807. * Adds all the elements from the container to the scene
  54808. * @param container the container holding the elements
  54809. */
  54810. addFromContainer(container: AbstractScene): void;
  54811. /**
  54812. * Removes all the elements in the container from the scene
  54813. * @param container contains the elements to remove
  54814. * @param dispose if the removed element should be disposed (default: false)
  54815. */
  54816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54817. /**
  54818. * Rebuilds the elements related to this component in case of
  54819. * context lost for instance.
  54820. */
  54821. dispose(): void;
  54822. private _gatherRenderTargets;
  54823. }
  54824. }
  54825. declare module BABYLON {
  54826. /**
  54827. * A point light is a light defined by an unique point in world space.
  54828. * The light is emitted in every direction from this point.
  54829. * A good example of a point light is a standard light bulb.
  54830. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54831. */
  54832. export class PointLight extends ShadowLight {
  54833. private _shadowAngle;
  54834. /**
  54835. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54836. * This specifies what angle the shadow will use to be created.
  54837. *
  54838. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54839. */
  54840. get shadowAngle(): number;
  54841. /**
  54842. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54843. * This specifies what angle the shadow will use to be created.
  54844. *
  54845. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54846. */
  54847. set shadowAngle(value: number);
  54848. /**
  54849. * Gets the direction if it has been set.
  54850. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54851. */
  54852. get direction(): Vector3;
  54853. /**
  54854. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54855. */
  54856. set direction(value: Vector3);
  54857. /**
  54858. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54859. * A PointLight emits the light in every direction.
  54860. * It can cast shadows.
  54861. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54862. * ```javascript
  54863. * var pointLight = new PointLight("pl", camera.position, scene);
  54864. * ```
  54865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54866. * @param name The light friendly name
  54867. * @param position The position of the point light in the scene
  54868. * @param scene The scene the lights belongs to
  54869. */
  54870. constructor(name: string, position: Vector3, scene: Scene);
  54871. /**
  54872. * Returns the string "PointLight"
  54873. * @returns the class name
  54874. */
  54875. getClassName(): string;
  54876. /**
  54877. * Returns the integer 0.
  54878. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54879. */
  54880. getTypeID(): number;
  54881. /**
  54882. * Specifies wether or not the shadowmap should be a cube texture.
  54883. * @returns true if the shadowmap needs to be a cube texture.
  54884. */
  54885. needCube(): boolean;
  54886. /**
  54887. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54888. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54889. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54890. */
  54891. getShadowDirection(faceIndex?: number): Vector3;
  54892. /**
  54893. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54894. * - fov = PI / 2
  54895. * - aspect ratio : 1.0
  54896. * - z-near and far equal to the active camera minZ and maxZ.
  54897. * Returns the PointLight.
  54898. */
  54899. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54900. protected _buildUniformLayout(): void;
  54901. /**
  54902. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54903. * @param effect The effect to update
  54904. * @param lightIndex The index of the light in the effect to update
  54905. * @returns The point light
  54906. */
  54907. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54908. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54909. /**
  54910. * Prepares the list of defines specific to the light type.
  54911. * @param defines the list of defines
  54912. * @param lightIndex defines the index of the light for the effect
  54913. */
  54914. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54915. }
  54916. }
  54917. declare module BABYLON {
  54918. /**
  54919. * Header information of HDR texture files.
  54920. */
  54921. export interface HDRInfo {
  54922. /**
  54923. * The height of the texture in pixels.
  54924. */
  54925. height: number;
  54926. /**
  54927. * The width of the texture in pixels.
  54928. */
  54929. width: number;
  54930. /**
  54931. * The index of the beginning of the data in the binary file.
  54932. */
  54933. dataPosition: number;
  54934. }
  54935. /**
  54936. * This groups tools to convert HDR texture to native colors array.
  54937. */
  54938. export class HDRTools {
  54939. private static Ldexp;
  54940. private static Rgbe2float;
  54941. private static readStringLine;
  54942. /**
  54943. * Reads header information from an RGBE texture stored in a native array.
  54944. * More information on this format are available here:
  54945. * https://en.wikipedia.org/wiki/RGBE_image_format
  54946. *
  54947. * @param uint8array The binary file stored in native array.
  54948. * @return The header information.
  54949. */
  54950. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54951. /**
  54952. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54953. * This RGBE texture needs to store the information as a panorama.
  54954. *
  54955. * More information on this format are available here:
  54956. * https://en.wikipedia.org/wiki/RGBE_image_format
  54957. *
  54958. * @param buffer The binary file stored in an array buffer.
  54959. * @param size The expected size of the extracted cubemap.
  54960. * @return The Cube Map information.
  54961. */
  54962. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54963. /**
  54964. * Returns the pixels data extracted from an RGBE texture.
  54965. * This pixels will be stored left to right up to down in the R G B order in one array.
  54966. *
  54967. * More information on this format are available here:
  54968. * https://en.wikipedia.org/wiki/RGBE_image_format
  54969. *
  54970. * @param uint8array The binary file stored in an array buffer.
  54971. * @param hdrInfo The header information of the file.
  54972. * @return The pixels data in RGB right to left up to down order.
  54973. */
  54974. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54975. private static RGBE_ReadPixels_RLE;
  54976. }
  54977. }
  54978. declare module BABYLON {
  54979. /**
  54980. * This represents a texture coming from an HDR input.
  54981. *
  54982. * The only supported format is currently panorama picture stored in RGBE format.
  54983. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54984. */
  54985. export class HDRCubeTexture extends BaseTexture {
  54986. private static _facesMapping;
  54987. private _generateHarmonics;
  54988. private _noMipmap;
  54989. private _textureMatrix;
  54990. private _size;
  54991. private _onLoad;
  54992. private _onError;
  54993. /**
  54994. * The texture URL.
  54995. */
  54996. url: string;
  54997. /**
  54998. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54999. */
  55000. coordinatesMode: number;
  55001. protected _isBlocking: boolean;
  55002. /**
  55003. * Sets wether or not the texture is blocking during loading.
  55004. */
  55005. set isBlocking(value: boolean);
  55006. /**
  55007. * Gets wether or not the texture is blocking during loading.
  55008. */
  55009. get isBlocking(): boolean;
  55010. protected _rotationY: number;
  55011. /**
  55012. * Sets texture matrix rotation angle around Y axis in radians.
  55013. */
  55014. set rotationY(value: number);
  55015. /**
  55016. * Gets texture matrix rotation angle around Y axis radians.
  55017. */
  55018. get rotationY(): number;
  55019. /**
  55020. * Gets or sets the center of the bounding box associated with the cube texture
  55021. * It must define where the camera used to render the texture was set
  55022. */
  55023. boundingBoxPosition: Vector3;
  55024. private _boundingBoxSize;
  55025. /**
  55026. * Gets or sets the size of the bounding box associated with the cube texture
  55027. * When defined, the cubemap will switch to local mode
  55028. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55029. * @example https://www.babylonjs-playground.com/#RNASML
  55030. */
  55031. set boundingBoxSize(value: Vector3);
  55032. get boundingBoxSize(): Vector3;
  55033. /**
  55034. * Instantiates an HDRTexture from the following parameters.
  55035. *
  55036. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55037. * @param scene The scene the texture will be used in
  55038. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55039. * @param noMipmap Forces to not generate the mipmap if true
  55040. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55041. * @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)
  55042. * @param reserved Reserved flag for internal use.
  55043. */
  55044. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55045. /**
  55046. * Get the current class name of the texture useful for serialization or dynamic coding.
  55047. * @returns "HDRCubeTexture"
  55048. */
  55049. getClassName(): string;
  55050. /**
  55051. * Occurs when the file is raw .hdr file.
  55052. */
  55053. private loadTexture;
  55054. clone(): HDRCubeTexture;
  55055. delayLoad(): void;
  55056. /**
  55057. * Get the texture reflection matrix used to rotate/transform the reflection.
  55058. * @returns the reflection matrix
  55059. */
  55060. getReflectionTextureMatrix(): Matrix;
  55061. /**
  55062. * Set the texture reflection matrix used to rotate/transform the reflection.
  55063. * @param value Define the reflection matrix to set
  55064. */
  55065. setReflectionTextureMatrix(value: Matrix): void;
  55066. /**
  55067. * Parses a JSON representation of an HDR Texture in order to create the texture
  55068. * @param parsedTexture Define the JSON representation
  55069. * @param scene Define the scene the texture should be created in
  55070. * @param rootUrl Define the root url in case we need to load relative dependencies
  55071. * @returns the newly created texture after parsing
  55072. */
  55073. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55074. serialize(): any;
  55075. }
  55076. }
  55077. declare module BABYLON {
  55078. /**
  55079. * Class used to control physics engine
  55080. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55081. */
  55082. export class PhysicsEngine implements IPhysicsEngine {
  55083. private _physicsPlugin;
  55084. /**
  55085. * Global value used to control the smallest number supported by the simulation
  55086. */
  55087. static Epsilon: number;
  55088. private _impostors;
  55089. private _joints;
  55090. private _subTimeStep;
  55091. /**
  55092. * Gets the gravity vector used by the simulation
  55093. */
  55094. gravity: Vector3;
  55095. /**
  55096. * Factory used to create the default physics plugin.
  55097. * @returns The default physics plugin
  55098. */
  55099. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55100. /**
  55101. * Creates a new Physics Engine
  55102. * @param gravity defines the gravity vector used by the simulation
  55103. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55104. */
  55105. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55106. /**
  55107. * Sets the gravity vector used by the simulation
  55108. * @param gravity defines the gravity vector to use
  55109. */
  55110. setGravity(gravity: Vector3): void;
  55111. /**
  55112. * Set the time step of the physics engine.
  55113. * Default is 1/60.
  55114. * To slow it down, enter 1/600 for example.
  55115. * To speed it up, 1/30
  55116. * @param newTimeStep defines the new timestep to apply to this world.
  55117. */
  55118. setTimeStep(newTimeStep?: number): void;
  55119. /**
  55120. * Get the time step of the physics engine.
  55121. * @returns the current time step
  55122. */
  55123. getTimeStep(): number;
  55124. /**
  55125. * Set the sub time step of the physics engine.
  55126. * Default is 0 meaning there is no sub steps
  55127. * To increase physics resolution precision, set a small value (like 1 ms)
  55128. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55129. */
  55130. setSubTimeStep(subTimeStep?: number): void;
  55131. /**
  55132. * Get the sub time step of the physics engine.
  55133. * @returns the current sub time step
  55134. */
  55135. getSubTimeStep(): number;
  55136. /**
  55137. * Release all resources
  55138. */
  55139. dispose(): void;
  55140. /**
  55141. * Gets the name of the current physics plugin
  55142. * @returns the name of the plugin
  55143. */
  55144. getPhysicsPluginName(): string;
  55145. /**
  55146. * Adding a new impostor for the impostor tracking.
  55147. * This will be done by the impostor itself.
  55148. * @param impostor the impostor to add
  55149. */
  55150. addImpostor(impostor: PhysicsImpostor): void;
  55151. /**
  55152. * Remove an impostor from the engine.
  55153. * This impostor and its mesh will not longer be updated by the physics engine.
  55154. * @param impostor the impostor to remove
  55155. */
  55156. removeImpostor(impostor: PhysicsImpostor): void;
  55157. /**
  55158. * Add a joint to the physics engine
  55159. * @param mainImpostor defines the main impostor to which the joint is added.
  55160. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55161. * @param joint defines the joint that will connect both impostors.
  55162. */
  55163. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55164. /**
  55165. * Removes a joint from the simulation
  55166. * @param mainImpostor defines the impostor used with the joint
  55167. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55168. * @param joint defines the joint to remove
  55169. */
  55170. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55171. /**
  55172. * Called by the scene. No need to call it.
  55173. * @param delta defines the timespam between frames
  55174. */
  55175. _step(delta: number): void;
  55176. /**
  55177. * Gets the current plugin used to run the simulation
  55178. * @returns current plugin
  55179. */
  55180. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55181. /**
  55182. * Gets the list of physic impostors
  55183. * @returns an array of PhysicsImpostor
  55184. */
  55185. getImpostors(): Array<PhysicsImpostor>;
  55186. /**
  55187. * Gets the impostor for a physics enabled object
  55188. * @param object defines the object impersonated by the impostor
  55189. * @returns the PhysicsImpostor or null if not found
  55190. */
  55191. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55192. /**
  55193. * Gets the impostor for a physics body object
  55194. * @param body defines physics body used by the impostor
  55195. * @returns the PhysicsImpostor or null if not found
  55196. */
  55197. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55198. /**
  55199. * Does a raycast in the physics world
  55200. * @param from when should the ray start?
  55201. * @param to when should the ray end?
  55202. * @returns PhysicsRaycastResult
  55203. */
  55204. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55205. }
  55206. }
  55207. declare module BABYLON {
  55208. /** @hidden */
  55209. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55210. private _useDeltaForWorldStep;
  55211. world: any;
  55212. name: string;
  55213. private _physicsMaterials;
  55214. private _fixedTimeStep;
  55215. private _cannonRaycastResult;
  55216. private _raycastResult;
  55217. private _physicsBodysToRemoveAfterStep;
  55218. BJSCANNON: any;
  55219. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55220. setGravity(gravity: Vector3): void;
  55221. setTimeStep(timeStep: number): void;
  55222. getTimeStep(): number;
  55223. executeStep(delta: number): void;
  55224. private _removeMarkedPhysicsBodiesFromWorld;
  55225. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55226. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55227. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55228. private _processChildMeshes;
  55229. removePhysicsBody(impostor: PhysicsImpostor): void;
  55230. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55231. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55232. private _addMaterial;
  55233. private _checkWithEpsilon;
  55234. private _createShape;
  55235. private _createHeightmap;
  55236. private _minus90X;
  55237. private _plus90X;
  55238. private _tmpPosition;
  55239. private _tmpDeltaPosition;
  55240. private _tmpUnityRotation;
  55241. private _updatePhysicsBodyTransformation;
  55242. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55243. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55244. isSupported(): boolean;
  55245. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55246. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55247. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55248. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55249. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55250. getBodyMass(impostor: PhysicsImpostor): number;
  55251. getBodyFriction(impostor: PhysicsImpostor): number;
  55252. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55253. getBodyRestitution(impostor: PhysicsImpostor): number;
  55254. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55255. sleepBody(impostor: PhysicsImpostor): void;
  55256. wakeUpBody(impostor: PhysicsImpostor): void;
  55257. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55258. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55259. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55260. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55261. getRadius(impostor: PhysicsImpostor): number;
  55262. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55263. dispose(): void;
  55264. private _extendNamespace;
  55265. /**
  55266. * Does a raycast in the physics world
  55267. * @param from when should the ray start?
  55268. * @param to when should the ray end?
  55269. * @returns PhysicsRaycastResult
  55270. */
  55271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55272. }
  55273. }
  55274. declare module BABYLON {
  55275. /** @hidden */
  55276. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55277. world: any;
  55278. name: string;
  55279. BJSOIMO: any;
  55280. private _raycastResult;
  55281. constructor(iterations?: number, oimoInjection?: any);
  55282. setGravity(gravity: Vector3): void;
  55283. setTimeStep(timeStep: number): void;
  55284. getTimeStep(): number;
  55285. private _tmpImpostorsArray;
  55286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55290. private _tmpPositionVector;
  55291. removePhysicsBody(impostor: PhysicsImpostor): void;
  55292. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55293. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55294. isSupported(): boolean;
  55295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55296. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55299. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55302. getBodyMass(impostor: PhysicsImpostor): number;
  55303. getBodyFriction(impostor: PhysicsImpostor): number;
  55304. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55305. getBodyRestitution(impostor: PhysicsImpostor): number;
  55306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55307. sleepBody(impostor: PhysicsImpostor): void;
  55308. wakeUpBody(impostor: PhysicsImpostor): void;
  55309. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55310. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55312. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55313. getRadius(impostor: PhysicsImpostor): number;
  55314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55315. dispose(): void;
  55316. /**
  55317. * Does a raycast in the physics world
  55318. * @param from when should the ray start?
  55319. * @param to when should the ray end?
  55320. * @returns PhysicsRaycastResult
  55321. */
  55322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55323. }
  55324. }
  55325. declare module BABYLON {
  55326. /**
  55327. * Class containing static functions to help procedurally build meshes
  55328. */
  55329. export class RibbonBuilder {
  55330. /**
  55331. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55332. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55333. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55334. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55335. * * 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
  55336. * * 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
  55337. * * 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
  55338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55339. * * 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
  55340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55341. * * 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
  55342. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55343. * * 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
  55344. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55346. * @param name defines the name of the mesh
  55347. * @param options defines the options used to create the mesh
  55348. * @param scene defines the hosting scene
  55349. * @returns the ribbon mesh
  55350. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55352. */
  55353. static CreateRibbon(name: string, options: {
  55354. pathArray: Vector3[][];
  55355. closeArray?: boolean;
  55356. closePath?: boolean;
  55357. offset?: number;
  55358. updatable?: boolean;
  55359. sideOrientation?: number;
  55360. frontUVs?: Vector4;
  55361. backUVs?: Vector4;
  55362. instance?: Mesh;
  55363. invertUV?: boolean;
  55364. uvs?: Vector2[];
  55365. colors?: Color4[];
  55366. }, scene?: Nullable<Scene>): Mesh;
  55367. }
  55368. }
  55369. declare module BABYLON {
  55370. /**
  55371. * Class containing static functions to help procedurally build meshes
  55372. */
  55373. export class ShapeBuilder {
  55374. /**
  55375. * 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.
  55376. * * 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.
  55377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55378. * * 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.
  55379. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55380. * * 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
  55381. * * 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
  55382. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55384. * * 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
  55385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55387. * @param name defines the name of the mesh
  55388. * @param options defines the options used to create the mesh
  55389. * @param scene defines the hosting scene
  55390. * @returns the extruded shape mesh
  55391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55393. */
  55394. static ExtrudeShape(name: string, options: {
  55395. shape: Vector3[];
  55396. path: Vector3[];
  55397. scale?: number;
  55398. rotation?: number;
  55399. cap?: number;
  55400. updatable?: boolean;
  55401. sideOrientation?: number;
  55402. frontUVs?: Vector4;
  55403. backUVs?: Vector4;
  55404. instance?: Mesh;
  55405. invertUV?: boolean;
  55406. }, scene?: Nullable<Scene>): Mesh;
  55407. /**
  55408. * Creates an custom extruded shape mesh.
  55409. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55410. * * 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.
  55411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55412. * * 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
  55413. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55414. * * 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
  55415. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55416. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55417. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55418. * * 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
  55419. * * 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
  55420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55422. * * 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
  55423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55425. * @param name defines the name of the mesh
  55426. * @param options defines the options used to create the mesh
  55427. * @param scene defines the hosting scene
  55428. * @returns the custom extruded shape mesh
  55429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55432. */
  55433. static ExtrudeShapeCustom(name: string, options: {
  55434. shape: Vector3[];
  55435. path: Vector3[];
  55436. scaleFunction?: any;
  55437. rotationFunction?: any;
  55438. ribbonCloseArray?: boolean;
  55439. ribbonClosePath?: boolean;
  55440. cap?: number;
  55441. updatable?: boolean;
  55442. sideOrientation?: number;
  55443. frontUVs?: Vector4;
  55444. backUVs?: Vector4;
  55445. instance?: Mesh;
  55446. invertUV?: boolean;
  55447. }, scene?: Nullable<Scene>): Mesh;
  55448. private static _ExtrudeShapeGeneric;
  55449. }
  55450. }
  55451. declare module BABYLON {
  55452. /**
  55453. * AmmoJS Physics plugin
  55454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55455. * @see https://github.com/kripken/ammo.js/
  55456. */
  55457. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55458. private _useDeltaForWorldStep;
  55459. /**
  55460. * Reference to the Ammo library
  55461. */
  55462. bjsAMMO: any;
  55463. /**
  55464. * Created ammoJS world which physics bodies are added to
  55465. */
  55466. world: any;
  55467. /**
  55468. * Name of the plugin
  55469. */
  55470. name: string;
  55471. private _timeStep;
  55472. private _fixedTimeStep;
  55473. private _maxSteps;
  55474. private _tmpQuaternion;
  55475. private _tmpAmmoTransform;
  55476. private _tmpAmmoQuaternion;
  55477. private _tmpAmmoConcreteContactResultCallback;
  55478. private _collisionConfiguration;
  55479. private _dispatcher;
  55480. private _overlappingPairCache;
  55481. private _solver;
  55482. private _softBodySolver;
  55483. private _tmpAmmoVectorA;
  55484. private _tmpAmmoVectorB;
  55485. private _tmpAmmoVectorC;
  55486. private _tmpAmmoVectorD;
  55487. private _tmpContactCallbackResult;
  55488. private _tmpAmmoVectorRCA;
  55489. private _tmpAmmoVectorRCB;
  55490. private _raycastResult;
  55491. private static readonly DISABLE_COLLISION_FLAG;
  55492. private static readonly KINEMATIC_FLAG;
  55493. private static readonly DISABLE_DEACTIVATION_FLAG;
  55494. /**
  55495. * Initializes the ammoJS plugin
  55496. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55497. * @param ammoInjection can be used to inject your own ammo reference
  55498. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55499. */
  55500. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55501. /**
  55502. * Sets the gravity of the physics world (m/(s^2))
  55503. * @param gravity Gravity to set
  55504. */
  55505. setGravity(gravity: Vector3): void;
  55506. /**
  55507. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55508. * @param timeStep timestep to use in seconds
  55509. */
  55510. setTimeStep(timeStep: number): void;
  55511. /**
  55512. * 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)
  55513. * @param fixedTimeStep fixedTimeStep to use in seconds
  55514. */
  55515. setFixedTimeStep(fixedTimeStep: number): void;
  55516. /**
  55517. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55518. * @param maxSteps the maximum number of steps by the physics engine per frame
  55519. */
  55520. setMaxSteps(maxSteps: number): void;
  55521. /**
  55522. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55523. * @returns the current timestep in seconds
  55524. */
  55525. getTimeStep(): number;
  55526. /**
  55527. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55528. */
  55529. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55530. private _isImpostorInContact;
  55531. private _isImpostorPairInContact;
  55532. private _stepSimulation;
  55533. /**
  55534. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55535. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55536. * After the step the babylon meshes are set to the position of the physics imposters
  55537. * @param delta amount of time to step forward
  55538. * @param impostors array of imposters to update before/after the step
  55539. */
  55540. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55541. /**
  55542. * Update babylon mesh to match physics world object
  55543. * @param impostor imposter to match
  55544. */
  55545. private _afterSoftStep;
  55546. /**
  55547. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55548. * @param impostor imposter to match
  55549. */
  55550. private _ropeStep;
  55551. /**
  55552. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55553. * @param impostor imposter to match
  55554. */
  55555. private _softbodyOrClothStep;
  55556. private _tmpVector;
  55557. private _tmpMatrix;
  55558. /**
  55559. * Applies an impulse on the imposter
  55560. * @param impostor imposter to apply impulse to
  55561. * @param force amount of force to be applied to the imposter
  55562. * @param contactPoint the location to apply the impulse on the imposter
  55563. */
  55564. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55565. /**
  55566. * Applies a force on the imposter
  55567. * @param impostor imposter to apply force
  55568. * @param force amount of force to be applied to the imposter
  55569. * @param contactPoint the location to apply the force on the imposter
  55570. */
  55571. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55572. /**
  55573. * Creates a physics body using the plugin
  55574. * @param impostor the imposter to create the physics body on
  55575. */
  55576. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55577. /**
  55578. * Removes the physics body from the imposter and disposes of the body's memory
  55579. * @param impostor imposter to remove the physics body from
  55580. */
  55581. removePhysicsBody(impostor: PhysicsImpostor): void;
  55582. /**
  55583. * Generates a joint
  55584. * @param impostorJoint the imposter joint to create the joint with
  55585. */
  55586. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55587. /**
  55588. * Removes a joint
  55589. * @param impostorJoint the imposter joint to remove the joint from
  55590. */
  55591. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55592. private _addMeshVerts;
  55593. /**
  55594. * Initialise the soft body vertices to match its object's (mesh) vertices
  55595. * Softbody vertices (nodes) are in world space and to match this
  55596. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55597. * @param impostor to create the softbody for
  55598. */
  55599. private _softVertexData;
  55600. /**
  55601. * Create an impostor's soft body
  55602. * @param impostor to create the softbody for
  55603. */
  55604. private _createSoftbody;
  55605. /**
  55606. * Create cloth for an impostor
  55607. * @param impostor to create the softbody for
  55608. */
  55609. private _createCloth;
  55610. /**
  55611. * Create rope for an impostor
  55612. * @param impostor to create the softbody for
  55613. */
  55614. private _createRope;
  55615. /**
  55616. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55617. * @param impostor to create the custom physics shape for
  55618. */
  55619. private _createCustom;
  55620. private _addHullVerts;
  55621. private _createShape;
  55622. /**
  55623. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55624. * @param impostor imposter containing the physics body and babylon object
  55625. */
  55626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55627. /**
  55628. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55629. * @param impostor imposter containing the physics body and babylon object
  55630. * @param newPosition new position
  55631. * @param newRotation new rotation
  55632. */
  55633. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55634. /**
  55635. * If this plugin is supported
  55636. * @returns true if its supported
  55637. */
  55638. isSupported(): boolean;
  55639. /**
  55640. * Sets the linear velocity of the physics body
  55641. * @param impostor imposter to set the velocity on
  55642. * @param velocity velocity to set
  55643. */
  55644. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55645. /**
  55646. * Sets the angular velocity of the physics body
  55647. * @param impostor imposter to set the velocity on
  55648. * @param velocity velocity to set
  55649. */
  55650. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55651. /**
  55652. * gets the linear velocity
  55653. * @param impostor imposter to get linear velocity from
  55654. * @returns linear velocity
  55655. */
  55656. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55657. /**
  55658. * gets the angular velocity
  55659. * @param impostor imposter to get angular velocity from
  55660. * @returns angular velocity
  55661. */
  55662. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55663. /**
  55664. * Sets the mass of physics body
  55665. * @param impostor imposter to set the mass on
  55666. * @param mass mass to set
  55667. */
  55668. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55669. /**
  55670. * Gets the mass of the physics body
  55671. * @param impostor imposter to get the mass from
  55672. * @returns mass
  55673. */
  55674. getBodyMass(impostor: PhysicsImpostor): number;
  55675. /**
  55676. * Gets friction of the impostor
  55677. * @param impostor impostor to get friction from
  55678. * @returns friction value
  55679. */
  55680. getBodyFriction(impostor: PhysicsImpostor): number;
  55681. /**
  55682. * Sets friction of the impostor
  55683. * @param impostor impostor to set friction on
  55684. * @param friction friction value
  55685. */
  55686. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55687. /**
  55688. * Gets restitution of the impostor
  55689. * @param impostor impostor to get restitution from
  55690. * @returns restitution value
  55691. */
  55692. getBodyRestitution(impostor: PhysicsImpostor): number;
  55693. /**
  55694. * Sets resitution of the impostor
  55695. * @param impostor impostor to set resitution on
  55696. * @param restitution resitution value
  55697. */
  55698. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55699. /**
  55700. * Gets pressure inside the impostor
  55701. * @param impostor impostor to get pressure from
  55702. * @returns pressure value
  55703. */
  55704. getBodyPressure(impostor: PhysicsImpostor): number;
  55705. /**
  55706. * Sets pressure inside a soft body impostor
  55707. * Cloth and rope must remain 0 pressure
  55708. * @param impostor impostor to set pressure on
  55709. * @param pressure pressure value
  55710. */
  55711. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55712. /**
  55713. * Gets stiffness of the impostor
  55714. * @param impostor impostor to get stiffness from
  55715. * @returns pressure value
  55716. */
  55717. getBodyStiffness(impostor: PhysicsImpostor): number;
  55718. /**
  55719. * Sets stiffness of the impostor
  55720. * @param impostor impostor to set stiffness on
  55721. * @param stiffness stiffness value from 0 to 1
  55722. */
  55723. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55724. /**
  55725. * Gets velocityIterations of the impostor
  55726. * @param impostor impostor to get velocity iterations from
  55727. * @returns velocityIterations value
  55728. */
  55729. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55730. /**
  55731. * Sets velocityIterations of the impostor
  55732. * @param impostor impostor to set velocity iterations on
  55733. * @param velocityIterations velocityIterations value
  55734. */
  55735. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55736. /**
  55737. * Gets positionIterations of the impostor
  55738. * @param impostor impostor to get position iterations from
  55739. * @returns positionIterations value
  55740. */
  55741. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55742. /**
  55743. * Sets positionIterations of the impostor
  55744. * @param impostor impostor to set position on
  55745. * @param positionIterations positionIterations value
  55746. */
  55747. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55748. /**
  55749. * Append an anchor to a cloth object
  55750. * @param impostor is the cloth impostor to add anchor to
  55751. * @param otherImpostor is the rigid impostor to anchor to
  55752. * @param width ratio across width from 0 to 1
  55753. * @param height ratio up height from 0 to 1
  55754. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55755. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55756. */
  55757. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55758. /**
  55759. * Append an hook to a rope object
  55760. * @param impostor is the rope impostor to add hook to
  55761. * @param otherImpostor is the rigid impostor to hook to
  55762. * @param length ratio along the rope from 0 to 1
  55763. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55764. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55765. */
  55766. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55767. /**
  55768. * Sleeps the physics body and stops it from being active
  55769. * @param impostor impostor to sleep
  55770. */
  55771. sleepBody(impostor: PhysicsImpostor): void;
  55772. /**
  55773. * Activates the physics body
  55774. * @param impostor impostor to activate
  55775. */
  55776. wakeUpBody(impostor: PhysicsImpostor): void;
  55777. /**
  55778. * Updates the distance parameters of the joint
  55779. * @param joint joint to update
  55780. * @param maxDistance maximum distance of the joint
  55781. * @param minDistance minimum distance of the joint
  55782. */
  55783. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55784. /**
  55785. * Sets a motor on the joint
  55786. * @param joint joint to set motor on
  55787. * @param speed speed of the motor
  55788. * @param maxForce maximum force of the motor
  55789. * @param motorIndex index of the motor
  55790. */
  55791. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55792. /**
  55793. * Sets the motors limit
  55794. * @param joint joint to set limit on
  55795. * @param upperLimit upper limit
  55796. * @param lowerLimit lower limit
  55797. */
  55798. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55799. /**
  55800. * Syncs the position and rotation of a mesh with the impostor
  55801. * @param mesh mesh to sync
  55802. * @param impostor impostor to update the mesh with
  55803. */
  55804. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55805. /**
  55806. * Gets the radius of the impostor
  55807. * @param impostor impostor to get radius from
  55808. * @returns the radius
  55809. */
  55810. getRadius(impostor: PhysicsImpostor): number;
  55811. /**
  55812. * Gets the box size of the impostor
  55813. * @param impostor impostor to get box size from
  55814. * @param result the resulting box size
  55815. */
  55816. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55817. /**
  55818. * Disposes of the impostor
  55819. */
  55820. dispose(): void;
  55821. /**
  55822. * Does a raycast in the physics world
  55823. * @param from when should the ray start?
  55824. * @param to when should the ray end?
  55825. * @returns PhysicsRaycastResult
  55826. */
  55827. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55828. }
  55829. }
  55830. declare module BABYLON {
  55831. interface AbstractScene {
  55832. /**
  55833. * The list of reflection probes added to the scene
  55834. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55835. */
  55836. reflectionProbes: Array<ReflectionProbe>;
  55837. /**
  55838. * Removes the given reflection probe from this scene.
  55839. * @param toRemove The reflection probe to remove
  55840. * @returns The index of the removed reflection probe
  55841. */
  55842. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55843. /**
  55844. * Adds the given reflection probe to this scene.
  55845. * @param newReflectionProbe The reflection probe to add
  55846. */
  55847. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55848. }
  55849. /**
  55850. * Class used to generate realtime reflection / refraction cube textures
  55851. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55852. */
  55853. export class ReflectionProbe {
  55854. /** defines the name of the probe */
  55855. name: string;
  55856. private _scene;
  55857. private _renderTargetTexture;
  55858. private _projectionMatrix;
  55859. private _viewMatrix;
  55860. private _target;
  55861. private _add;
  55862. private _attachedMesh;
  55863. private _invertYAxis;
  55864. /** Gets or sets probe position (center of the cube map) */
  55865. position: Vector3;
  55866. /**
  55867. * Creates a new reflection probe
  55868. * @param name defines the name of the probe
  55869. * @param size defines the texture resolution (for each face)
  55870. * @param scene defines the hosting scene
  55871. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55872. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55873. */
  55874. constructor(
  55875. /** defines the name of the probe */
  55876. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55877. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55878. get samples(): number;
  55879. set samples(value: number);
  55880. /** Gets or sets the refresh rate to use (on every frame by default) */
  55881. get refreshRate(): number;
  55882. set refreshRate(value: number);
  55883. /**
  55884. * Gets the hosting scene
  55885. * @returns a Scene
  55886. */
  55887. getScene(): Scene;
  55888. /** Gets the internal CubeTexture used to render to */
  55889. get cubeTexture(): RenderTargetTexture;
  55890. /** Gets the list of meshes to render */
  55891. get renderList(): Nullable<AbstractMesh[]>;
  55892. /**
  55893. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55894. * @param mesh defines the mesh to attach to
  55895. */
  55896. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55897. /**
  55898. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55899. * @param renderingGroupId The rendering group id corresponding to its index
  55900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55901. */
  55902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55903. /**
  55904. * Clean all associated resources
  55905. */
  55906. dispose(): void;
  55907. /**
  55908. * Converts the reflection probe information to a readable string for debug purpose.
  55909. * @param fullDetails Supports for multiple levels of logging within scene loading
  55910. * @returns the human readable reflection probe info
  55911. */
  55912. toString(fullDetails?: boolean): string;
  55913. /**
  55914. * Get the class name of the relfection probe.
  55915. * @returns "ReflectionProbe"
  55916. */
  55917. getClassName(): string;
  55918. /**
  55919. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55920. * @returns The JSON representation of the texture
  55921. */
  55922. serialize(): any;
  55923. /**
  55924. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55925. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55926. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55927. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55928. * @returns The parsed reflection probe if successful
  55929. */
  55930. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55931. }
  55932. }
  55933. declare module BABYLON {
  55934. /** @hidden */
  55935. export var _BabylonLoaderRegistered: boolean;
  55936. /**
  55937. * Helps setting up some configuration for the babylon file loader.
  55938. */
  55939. export class BabylonFileLoaderConfiguration {
  55940. /**
  55941. * The loader does not allow injecting custom physix engine into the plugins.
  55942. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55943. * So you could set this variable to your engine import to make it work.
  55944. */
  55945. static LoaderInjectedPhysicsEngine: any;
  55946. }
  55947. }
  55948. declare module BABYLON {
  55949. /**
  55950. * The Physically based simple base material of BJS.
  55951. *
  55952. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55953. * It is used as the base class for both the specGloss and metalRough conventions.
  55954. */
  55955. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55956. /**
  55957. * Number of Simultaneous lights allowed on the material.
  55958. */
  55959. maxSimultaneousLights: number;
  55960. /**
  55961. * If sets to true, disables all the lights affecting the material.
  55962. */
  55963. disableLighting: boolean;
  55964. /**
  55965. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55966. */
  55967. environmentTexture: BaseTexture;
  55968. /**
  55969. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55970. */
  55971. invertNormalMapX: boolean;
  55972. /**
  55973. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55974. */
  55975. invertNormalMapY: boolean;
  55976. /**
  55977. * Normal map used in the model.
  55978. */
  55979. normalTexture: BaseTexture;
  55980. /**
  55981. * Emissivie color used to self-illuminate the model.
  55982. */
  55983. emissiveColor: Color3;
  55984. /**
  55985. * Emissivie texture used to self-illuminate the model.
  55986. */
  55987. emissiveTexture: BaseTexture;
  55988. /**
  55989. * Occlusion Channel Strenght.
  55990. */
  55991. occlusionStrength: number;
  55992. /**
  55993. * Occlusion Texture of the material (adding extra occlusion effects).
  55994. */
  55995. occlusionTexture: BaseTexture;
  55996. /**
  55997. * Defines the alpha limits in alpha test mode.
  55998. */
  55999. alphaCutOff: number;
  56000. /**
  56001. * Gets the current double sided mode.
  56002. */
  56003. get doubleSided(): boolean;
  56004. /**
  56005. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56006. */
  56007. set doubleSided(value: boolean);
  56008. /**
  56009. * Stores the pre-calculated light information of a mesh in a texture.
  56010. */
  56011. lightmapTexture: BaseTexture;
  56012. /**
  56013. * If true, the light map contains occlusion information instead of lighting info.
  56014. */
  56015. useLightmapAsShadowmap: boolean;
  56016. /**
  56017. * Instantiates a new PBRMaterial instance.
  56018. *
  56019. * @param name The material name
  56020. * @param scene The scene the material will be use in.
  56021. */
  56022. constructor(name: string, scene: Scene);
  56023. getClassName(): string;
  56024. }
  56025. }
  56026. declare module BABYLON {
  56027. /**
  56028. * The PBR material of BJS following the metal roughness convention.
  56029. *
  56030. * This fits to the PBR convention in the GLTF definition:
  56031. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56032. */
  56033. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56034. /**
  56035. * The base color has two different interpretations depending on the value of metalness.
  56036. * When the material is a metal, the base color is the specific measured reflectance value
  56037. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56038. * of the material.
  56039. */
  56040. baseColor: Color3;
  56041. /**
  56042. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56043. * well as opacity information in the alpha channel.
  56044. */
  56045. baseTexture: BaseTexture;
  56046. /**
  56047. * Specifies the metallic scalar value of the material.
  56048. * Can also be used to scale the metalness values of the metallic texture.
  56049. */
  56050. metallic: number;
  56051. /**
  56052. * Specifies the roughness scalar value of the material.
  56053. * Can also be used to scale the roughness values of the metallic texture.
  56054. */
  56055. roughness: number;
  56056. /**
  56057. * Texture containing both the metallic value in the B channel and the
  56058. * roughness value in the G channel to keep better precision.
  56059. */
  56060. metallicRoughnessTexture: BaseTexture;
  56061. /**
  56062. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56063. *
  56064. * @param name The material name
  56065. * @param scene The scene the material will be use in.
  56066. */
  56067. constructor(name: string, scene: Scene);
  56068. /**
  56069. * Return the currrent class name of the material.
  56070. */
  56071. getClassName(): string;
  56072. /**
  56073. * Makes a duplicate of the current material.
  56074. * @param name - name to use for the new material.
  56075. */
  56076. clone(name: string): PBRMetallicRoughnessMaterial;
  56077. /**
  56078. * Serialize the material to a parsable JSON object.
  56079. */
  56080. serialize(): any;
  56081. /**
  56082. * Parses a JSON object correponding to the serialize function.
  56083. */
  56084. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56085. }
  56086. }
  56087. declare module BABYLON {
  56088. /**
  56089. * The PBR material of BJS following the specular glossiness convention.
  56090. *
  56091. * This fits to the PBR convention in the GLTF definition:
  56092. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56093. */
  56094. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56095. /**
  56096. * Specifies the diffuse color of the material.
  56097. */
  56098. diffuseColor: Color3;
  56099. /**
  56100. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56101. * channel.
  56102. */
  56103. diffuseTexture: BaseTexture;
  56104. /**
  56105. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56106. */
  56107. specularColor: Color3;
  56108. /**
  56109. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56110. */
  56111. glossiness: number;
  56112. /**
  56113. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56114. */
  56115. specularGlossinessTexture: BaseTexture;
  56116. /**
  56117. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56118. *
  56119. * @param name The material name
  56120. * @param scene The scene the material will be use in.
  56121. */
  56122. constructor(name: string, scene: Scene);
  56123. /**
  56124. * Return the currrent class name of the material.
  56125. */
  56126. getClassName(): string;
  56127. /**
  56128. * Makes a duplicate of the current material.
  56129. * @param name - name to use for the new material.
  56130. */
  56131. clone(name: string): PBRSpecularGlossinessMaterial;
  56132. /**
  56133. * Serialize the material to a parsable JSON object.
  56134. */
  56135. serialize(): any;
  56136. /**
  56137. * Parses a JSON object correponding to the serialize function.
  56138. */
  56139. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56140. }
  56141. }
  56142. declare module BABYLON {
  56143. /**
  56144. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56145. * It can help converting any input color in a desired output one. This can then be used to create effects
  56146. * from sepia, black and white to sixties or futuristic rendering...
  56147. *
  56148. * The only supported format is currently 3dl.
  56149. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56150. */
  56151. export class ColorGradingTexture extends BaseTexture {
  56152. /**
  56153. * The current texture matrix. (will always be identity in color grading texture)
  56154. */
  56155. private _textureMatrix;
  56156. /**
  56157. * The texture URL.
  56158. */
  56159. url: string;
  56160. /**
  56161. * Empty line regex stored for GC.
  56162. */
  56163. private static _noneEmptyLineRegex;
  56164. private _engine;
  56165. /**
  56166. * Instantiates a ColorGradingTexture from the following parameters.
  56167. *
  56168. * @param url The location of the color gradind data (currently only supporting 3dl)
  56169. * @param scene The scene the texture will be used in
  56170. */
  56171. constructor(url: string, scene: Scene);
  56172. /**
  56173. * Returns the texture matrix used in most of the material.
  56174. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56175. */
  56176. getTextureMatrix(): Matrix;
  56177. /**
  56178. * Occurs when the file being loaded is a .3dl LUT file.
  56179. */
  56180. private load3dlTexture;
  56181. /**
  56182. * Starts the loading process of the texture.
  56183. */
  56184. private loadTexture;
  56185. /**
  56186. * Clones the color gradind texture.
  56187. */
  56188. clone(): ColorGradingTexture;
  56189. /**
  56190. * Called during delayed load for textures.
  56191. */
  56192. delayLoad(): void;
  56193. /**
  56194. * Parses a color grading texture serialized by Babylon.
  56195. * @param parsedTexture The texture information being parsedTexture
  56196. * @param scene The scene to load the texture in
  56197. * @param rootUrl The root url of the data assets to load
  56198. * @return A color gradind texture
  56199. */
  56200. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56201. /**
  56202. * Serializes the LUT texture to json format.
  56203. */
  56204. serialize(): any;
  56205. }
  56206. }
  56207. declare module BABYLON {
  56208. /**
  56209. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56210. */
  56211. export class EquiRectangularCubeTexture extends BaseTexture {
  56212. /** The six faces of the cube. */
  56213. private static _FacesMapping;
  56214. private _noMipmap;
  56215. private _onLoad;
  56216. private _onError;
  56217. /** The size of the cubemap. */
  56218. private _size;
  56219. /** The buffer of the image. */
  56220. private _buffer;
  56221. /** The width of the input image. */
  56222. private _width;
  56223. /** The height of the input image. */
  56224. private _height;
  56225. /** The URL to the image. */
  56226. url: string;
  56227. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56228. coordinatesMode: number;
  56229. /**
  56230. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56231. * @param url The location of the image
  56232. * @param scene The scene the texture will be used in
  56233. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56234. * @param noMipmap Forces to not generate the mipmap if true
  56235. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56236. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56237. * @param onLoad — defines a callback called when texture is loaded
  56238. * @param onError — defines a callback called if there is an error
  56239. */
  56240. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56241. /**
  56242. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56243. */
  56244. private loadImage;
  56245. /**
  56246. * Convert the image buffer into a cubemap and create a CubeTexture.
  56247. */
  56248. private loadTexture;
  56249. /**
  56250. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56251. * @param buffer The ArrayBuffer that should be converted.
  56252. * @returns The buffer as Float32Array.
  56253. */
  56254. private getFloat32ArrayFromArrayBuffer;
  56255. /**
  56256. * Get the current class name of the texture useful for serialization or dynamic coding.
  56257. * @returns "EquiRectangularCubeTexture"
  56258. */
  56259. getClassName(): string;
  56260. /**
  56261. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56262. * @returns A clone of the current EquiRectangularCubeTexture.
  56263. */
  56264. clone(): EquiRectangularCubeTexture;
  56265. }
  56266. }
  56267. declare module BABYLON {
  56268. /**
  56269. * Based on jsTGALoader - Javascript loader for TGA file
  56270. * By Vincent Thibault
  56271. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56272. */
  56273. export class TGATools {
  56274. private static _TYPE_INDEXED;
  56275. private static _TYPE_RGB;
  56276. private static _TYPE_GREY;
  56277. private static _TYPE_RLE_INDEXED;
  56278. private static _TYPE_RLE_RGB;
  56279. private static _TYPE_RLE_GREY;
  56280. private static _ORIGIN_MASK;
  56281. private static _ORIGIN_SHIFT;
  56282. private static _ORIGIN_BL;
  56283. private static _ORIGIN_BR;
  56284. private static _ORIGIN_UL;
  56285. private static _ORIGIN_UR;
  56286. /**
  56287. * Gets the header of a TGA file
  56288. * @param data defines the TGA data
  56289. * @returns the header
  56290. */
  56291. static GetTGAHeader(data: Uint8Array): any;
  56292. /**
  56293. * Uploads TGA content to a Babylon Texture
  56294. * @hidden
  56295. */
  56296. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56297. /** @hidden */
  56298. 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;
  56299. /** @hidden */
  56300. 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;
  56301. /** @hidden */
  56302. 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;
  56303. /** @hidden */
  56304. 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;
  56305. /** @hidden */
  56306. 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;
  56307. /** @hidden */
  56308. 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;
  56309. }
  56310. }
  56311. declare module BABYLON {
  56312. /**
  56313. * Implementation of the TGA Texture Loader.
  56314. * @hidden
  56315. */
  56316. export class _TGATextureLoader implements IInternalTextureLoader {
  56317. /**
  56318. * Defines wether the loader supports cascade loading the different faces.
  56319. */
  56320. readonly supportCascades: boolean;
  56321. /**
  56322. * This returns if the loader support the current file information.
  56323. * @param extension defines the file extension of the file being loaded
  56324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56325. * @param fallback defines the fallback internal texture if any
  56326. * @param isBase64 defines whether the texture is encoded as a base64
  56327. * @param isBuffer defines whether the texture data are stored as a buffer
  56328. * @returns true if the loader can load the specified file
  56329. */
  56330. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56331. /**
  56332. * Transform the url before loading if required.
  56333. * @param rootUrl the url of the texture
  56334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56335. * @returns the transformed texture
  56336. */
  56337. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56338. /**
  56339. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56340. * @param rootUrl the url of the texture
  56341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56342. * @returns the fallback texture
  56343. */
  56344. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56345. /**
  56346. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56347. * @param data contains the texture data
  56348. * @param texture defines the BabylonJS internal texture
  56349. * @param createPolynomials will be true if polynomials have been requested
  56350. * @param onLoad defines the callback to trigger once the texture is ready
  56351. * @param onError defines the callback to trigger in case of error
  56352. */
  56353. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56354. /**
  56355. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56356. * @param data contains the texture data
  56357. * @param texture defines the BabylonJS internal texture
  56358. * @param callback defines the method to call once ready to upload
  56359. */
  56360. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56361. }
  56362. }
  56363. declare module BABYLON {
  56364. /**
  56365. * Info about the .basis files
  56366. */
  56367. class BasisFileInfo {
  56368. /**
  56369. * If the file has alpha
  56370. */
  56371. hasAlpha: boolean;
  56372. /**
  56373. * Info about each image of the basis file
  56374. */
  56375. images: Array<{
  56376. levels: Array<{
  56377. width: number;
  56378. height: number;
  56379. transcodedPixels: ArrayBufferView;
  56380. }>;
  56381. }>;
  56382. }
  56383. /**
  56384. * Result of transcoding a basis file
  56385. */
  56386. class TranscodeResult {
  56387. /**
  56388. * Info about the .basis file
  56389. */
  56390. fileInfo: BasisFileInfo;
  56391. /**
  56392. * Format to use when loading the file
  56393. */
  56394. format: number;
  56395. }
  56396. /**
  56397. * Configuration options for the Basis transcoder
  56398. */
  56399. export class BasisTranscodeConfiguration {
  56400. /**
  56401. * Supported compression formats used to determine the supported output format of the transcoder
  56402. */
  56403. supportedCompressionFormats?: {
  56404. /**
  56405. * etc1 compression format
  56406. */
  56407. etc1?: boolean;
  56408. /**
  56409. * s3tc compression format
  56410. */
  56411. s3tc?: boolean;
  56412. /**
  56413. * pvrtc compression format
  56414. */
  56415. pvrtc?: boolean;
  56416. /**
  56417. * etc2 compression format
  56418. */
  56419. etc2?: boolean;
  56420. };
  56421. /**
  56422. * If mipmap levels should be loaded for transcoded images (Default: true)
  56423. */
  56424. loadMipmapLevels?: boolean;
  56425. /**
  56426. * Index of a single image to load (Default: all images)
  56427. */
  56428. loadSingleImage?: number;
  56429. }
  56430. /**
  56431. * Used to load .Basis files
  56432. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56433. */
  56434. export class BasisTools {
  56435. private static _IgnoreSupportedFormats;
  56436. /**
  56437. * URL to use when loading the basis transcoder
  56438. */
  56439. static JSModuleURL: string;
  56440. /**
  56441. * URL to use when loading the wasm module for the transcoder
  56442. */
  56443. static WasmModuleURL: string;
  56444. /**
  56445. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56446. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56447. * @returns internal format corresponding to the Basis format
  56448. */
  56449. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56450. private static _WorkerPromise;
  56451. private static _Worker;
  56452. private static _actionId;
  56453. private static _CreateWorkerAsync;
  56454. /**
  56455. * Transcodes a loaded image file to compressed pixel data
  56456. * @param data image data to transcode
  56457. * @param config configuration options for the transcoding
  56458. * @returns a promise resulting in the transcoded image
  56459. */
  56460. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56461. /**
  56462. * Loads a texture from the transcode result
  56463. * @param texture texture load to
  56464. * @param transcodeResult the result of transcoding the basis file to load from
  56465. */
  56466. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56467. }
  56468. }
  56469. declare module BABYLON {
  56470. /**
  56471. * Loader for .basis file format
  56472. */
  56473. export class _BasisTextureLoader implements IInternalTextureLoader {
  56474. /**
  56475. * Defines whether the loader supports cascade loading the different faces.
  56476. */
  56477. readonly supportCascades: boolean;
  56478. /**
  56479. * This returns if the loader support the current file information.
  56480. * @param extension defines the file extension of the file being loaded
  56481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56482. * @param fallback defines the fallback internal texture if any
  56483. * @param isBase64 defines whether the texture is encoded as a base64
  56484. * @param isBuffer defines whether the texture data are stored as a buffer
  56485. * @returns true if the loader can load the specified file
  56486. */
  56487. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56488. /**
  56489. * Transform the url before loading if required.
  56490. * @param rootUrl the url of the texture
  56491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56492. * @returns the transformed texture
  56493. */
  56494. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56495. /**
  56496. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56497. * @param rootUrl the url of the texture
  56498. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56499. * @returns the fallback texture
  56500. */
  56501. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56502. /**
  56503. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56504. * @param data contains the texture data
  56505. * @param texture defines the BabylonJS internal texture
  56506. * @param createPolynomials will be true if polynomials have been requested
  56507. * @param onLoad defines the callback to trigger once the texture is ready
  56508. * @param onError defines the callback to trigger in case of error
  56509. */
  56510. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56511. /**
  56512. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56513. * @param data contains the texture data
  56514. * @param texture defines the BabylonJS internal texture
  56515. * @param callback defines the method to call once ready to upload
  56516. */
  56517. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56518. }
  56519. }
  56520. declare module BABYLON {
  56521. /**
  56522. * 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.
  56523. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56524. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56525. */
  56526. export class CustomProceduralTexture extends ProceduralTexture {
  56527. private _animate;
  56528. private _time;
  56529. private _config;
  56530. private _texturePath;
  56531. /**
  56532. * Instantiates a new Custom Procedural Texture.
  56533. * 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.
  56534. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56535. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56536. * @param name Define the name of the texture
  56537. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56538. * @param size Define the size of the texture to create
  56539. * @param scene Define the scene the texture belongs to
  56540. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56541. * @param generateMipMaps Define if the texture should creates mip maps or not
  56542. */
  56543. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56544. private _loadJson;
  56545. /**
  56546. * Is the texture ready to be used ? (rendered at least once)
  56547. * @returns true if ready, otherwise, false.
  56548. */
  56549. isReady(): boolean;
  56550. /**
  56551. * Render the texture to its associated render target.
  56552. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56553. */
  56554. render(useCameraPostProcess?: boolean): void;
  56555. /**
  56556. * Update the list of dependant textures samplers in the shader.
  56557. */
  56558. updateTextures(): void;
  56559. /**
  56560. * Update the uniform values of the procedural texture in the shader.
  56561. */
  56562. updateShaderUniforms(): void;
  56563. /**
  56564. * Define if the texture animates or not.
  56565. */
  56566. get animate(): boolean;
  56567. set animate(value: boolean);
  56568. }
  56569. }
  56570. declare module BABYLON {
  56571. /** @hidden */
  56572. export var noisePixelShader: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module BABYLON {
  56578. /**
  56579. * Class used to generate noise procedural textures
  56580. */
  56581. export class NoiseProceduralTexture extends ProceduralTexture {
  56582. private _time;
  56583. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56584. brightness: number;
  56585. /** Defines the number of octaves to process */
  56586. octaves: number;
  56587. /** Defines the level of persistence (0.8 by default) */
  56588. persistence: number;
  56589. /** Gets or sets animation speed factor (default is 1) */
  56590. animationSpeedFactor: number;
  56591. /**
  56592. * Creates a new NoiseProceduralTexture
  56593. * @param name defines the name fo the texture
  56594. * @param size defines the size of the texture (default is 256)
  56595. * @param scene defines the hosting scene
  56596. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56597. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56598. */
  56599. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56600. private _updateShaderUniforms;
  56601. protected _getDefines(): string;
  56602. /** Generate the current state of the procedural texture */
  56603. render(useCameraPostProcess?: boolean): void;
  56604. /**
  56605. * Serializes this noise procedural texture
  56606. * @returns a serialized noise procedural texture object
  56607. */
  56608. serialize(): any;
  56609. /**
  56610. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56611. * @param parsedTexture defines parsed texture data
  56612. * @param scene defines the current scene
  56613. * @param rootUrl defines the root URL containing noise procedural texture information
  56614. * @returns a parsed NoiseProceduralTexture
  56615. */
  56616. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56617. }
  56618. }
  56619. declare module BABYLON {
  56620. /**
  56621. * Raw cube texture where the raw buffers are passed in
  56622. */
  56623. export class RawCubeTexture extends CubeTexture {
  56624. /**
  56625. * Creates a cube texture where the raw buffers are passed in.
  56626. * @param scene defines the scene the texture is attached to
  56627. * @param data defines the array of data to use to create each face
  56628. * @param size defines the size of the textures
  56629. * @param format defines the format of the data
  56630. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56631. * @param generateMipMaps defines if the engine should generate the mip levels
  56632. * @param invertY defines if data must be stored with Y axis inverted
  56633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56634. * @param compression defines the compression used (null by default)
  56635. */
  56636. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56637. /**
  56638. * Updates the raw cube texture.
  56639. * @param data defines the data to store
  56640. * @param format defines the data format
  56641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56642. * @param invertY defines if data must be stored with Y axis inverted
  56643. * @param compression defines the compression used (null by default)
  56644. * @param level defines which level of the texture to update
  56645. */
  56646. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56647. /**
  56648. * Updates a raw cube texture with RGBD encoded data.
  56649. * @param data defines the array of data [mipmap][face] to use to create each face
  56650. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56653. * @returns a promsie that resolves when the operation is complete
  56654. */
  56655. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56656. /**
  56657. * Clones the raw cube texture.
  56658. * @return a new cube texture
  56659. */
  56660. clone(): CubeTexture;
  56661. /** @hidden */
  56662. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56663. }
  56664. }
  56665. declare module BABYLON {
  56666. /**
  56667. * Class used to store 3D textures containing user data
  56668. */
  56669. export class RawTexture3D extends Texture {
  56670. /** Gets or sets the texture format to use */
  56671. format: number;
  56672. private _engine;
  56673. /**
  56674. * Create a new RawTexture3D
  56675. * @param data defines the data of the texture
  56676. * @param width defines the width of the texture
  56677. * @param height defines the height of the texture
  56678. * @param depth defines the depth of the texture
  56679. * @param format defines the texture format to use
  56680. * @param scene defines the hosting scene
  56681. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56682. * @param invertY defines if texture must be stored with Y axis inverted
  56683. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56684. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56685. */
  56686. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56687. /** Gets or sets the texture format to use */
  56688. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56689. /**
  56690. * Update the texture with new data
  56691. * @param data defines the data to store in the texture
  56692. */
  56693. update(data: ArrayBufferView): void;
  56694. }
  56695. }
  56696. declare module BABYLON {
  56697. /**
  56698. * Class used to store 2D array textures containing user data
  56699. */
  56700. export class RawTexture2DArray extends Texture {
  56701. /** Gets or sets the texture format to use */
  56702. format: number;
  56703. private _engine;
  56704. /**
  56705. * Create a new RawTexture2DArray
  56706. * @param data defines the data of the texture
  56707. * @param width defines the width of the texture
  56708. * @param height defines the height of the texture
  56709. * @param depth defines the number of layers of the texture
  56710. * @param format defines the texture format to use
  56711. * @param scene defines the hosting scene
  56712. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56713. * @param invertY defines if texture must be stored with Y axis inverted
  56714. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56715. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56716. */
  56717. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56718. /** Gets or sets the texture format to use */
  56719. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56720. /**
  56721. * Update the texture with new data
  56722. * @param data defines the data to store in the texture
  56723. */
  56724. update(data: ArrayBufferView): void;
  56725. }
  56726. }
  56727. declare module BABYLON {
  56728. /**
  56729. * Creates a refraction texture used by refraction channel of the standard material.
  56730. * It is like a mirror but to see through a material.
  56731. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56732. */
  56733. export class RefractionTexture extends RenderTargetTexture {
  56734. /**
  56735. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56736. * 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.
  56737. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56738. */
  56739. refractionPlane: Plane;
  56740. /**
  56741. * Define how deep under the surface we should see.
  56742. */
  56743. depth: number;
  56744. /**
  56745. * Creates a refraction texture used by refraction channel of the standard material.
  56746. * It is like a mirror but to see through a material.
  56747. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56748. * @param name Define the texture name
  56749. * @param size Define the size of the underlying texture
  56750. * @param scene Define the scene the refraction belongs to
  56751. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56752. */
  56753. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56754. /**
  56755. * Clone the refraction texture.
  56756. * @returns the cloned texture
  56757. */
  56758. clone(): RefractionTexture;
  56759. /**
  56760. * Serialize the texture to a JSON representation you could use in Parse later on
  56761. * @returns the serialized JSON representation
  56762. */
  56763. serialize(): any;
  56764. }
  56765. }
  56766. declare module BABYLON {
  56767. /**
  56768. * Defines the options related to the creation of an HtmlElementTexture
  56769. */
  56770. export interface IHtmlElementTextureOptions {
  56771. /**
  56772. * Defines wether mip maps should be created or not.
  56773. */
  56774. generateMipMaps?: boolean;
  56775. /**
  56776. * Defines the sampling mode of the texture.
  56777. */
  56778. samplingMode?: number;
  56779. /**
  56780. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56781. */
  56782. engine: Nullable<ThinEngine>;
  56783. /**
  56784. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56785. */
  56786. scene: Nullable<Scene>;
  56787. }
  56788. /**
  56789. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56790. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56791. * is automatically managed.
  56792. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56793. * in your application.
  56794. *
  56795. * As the update is not automatic, you need to call them manually.
  56796. */
  56797. export class HtmlElementTexture extends BaseTexture {
  56798. /**
  56799. * The texture URL.
  56800. */
  56801. element: HTMLVideoElement | HTMLCanvasElement;
  56802. private static readonly DefaultOptions;
  56803. private _textureMatrix;
  56804. private _engine;
  56805. private _isVideo;
  56806. private _generateMipMaps;
  56807. private _samplingMode;
  56808. /**
  56809. * Instantiates a HtmlElementTexture from the following parameters.
  56810. *
  56811. * @param name Defines the name of the texture
  56812. * @param element Defines the video or canvas the texture is filled with
  56813. * @param options Defines the other none mandatory texture creation options
  56814. */
  56815. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56816. private _createInternalTexture;
  56817. /**
  56818. * Returns the texture matrix used in most of the material.
  56819. */
  56820. getTextureMatrix(): Matrix;
  56821. /**
  56822. * Updates the content of the texture.
  56823. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56824. */
  56825. update(invertY?: Nullable<boolean>): void;
  56826. }
  56827. }
  56828. declare module BABYLON {
  56829. /**
  56830. * Enum used to define the target of a block
  56831. */
  56832. export enum NodeMaterialBlockTargets {
  56833. /** Vertex shader */
  56834. Vertex = 1,
  56835. /** Fragment shader */
  56836. Fragment = 2,
  56837. /** Neutral */
  56838. Neutral = 4,
  56839. /** Vertex and Fragment */
  56840. VertexAndFragment = 3
  56841. }
  56842. }
  56843. declare module BABYLON {
  56844. /**
  56845. * Defines the kind of connection point for node based material
  56846. */
  56847. export enum NodeMaterialBlockConnectionPointTypes {
  56848. /** Float */
  56849. Float = 1,
  56850. /** Int */
  56851. Int = 2,
  56852. /** Vector2 */
  56853. Vector2 = 4,
  56854. /** Vector3 */
  56855. Vector3 = 8,
  56856. /** Vector4 */
  56857. Vector4 = 16,
  56858. /** Color3 */
  56859. Color3 = 32,
  56860. /** Color4 */
  56861. Color4 = 64,
  56862. /** Matrix */
  56863. Matrix = 128,
  56864. /** Detect type based on connection */
  56865. AutoDetect = 1024,
  56866. /** Output type that will be defined by input type */
  56867. BasedOnInput = 2048
  56868. }
  56869. }
  56870. declare module BABYLON {
  56871. /**
  56872. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56873. */
  56874. export enum NodeMaterialBlockConnectionPointMode {
  56875. /** Value is an uniform */
  56876. Uniform = 0,
  56877. /** Value is a mesh attribute */
  56878. Attribute = 1,
  56879. /** Value is a varying between vertex and fragment shaders */
  56880. Varying = 2,
  56881. /** Mode is undefined */
  56882. Undefined = 3
  56883. }
  56884. }
  56885. declare module BABYLON {
  56886. /**
  56887. * Enum used to define system values e.g. values automatically provided by the system
  56888. */
  56889. export enum NodeMaterialSystemValues {
  56890. /** World */
  56891. World = 1,
  56892. /** View */
  56893. View = 2,
  56894. /** Projection */
  56895. Projection = 3,
  56896. /** ViewProjection */
  56897. ViewProjection = 4,
  56898. /** WorldView */
  56899. WorldView = 5,
  56900. /** WorldViewProjection */
  56901. WorldViewProjection = 6,
  56902. /** CameraPosition */
  56903. CameraPosition = 7,
  56904. /** Fog Color */
  56905. FogColor = 8,
  56906. /** Delta time */
  56907. DeltaTime = 9
  56908. }
  56909. }
  56910. declare module BABYLON {
  56911. /**
  56912. * Root class for all node material optimizers
  56913. */
  56914. export class NodeMaterialOptimizer {
  56915. /**
  56916. * Function used to optimize a NodeMaterial graph
  56917. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56918. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56919. */
  56920. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56921. }
  56922. }
  56923. declare module BABYLON {
  56924. /**
  56925. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56926. */
  56927. export class TransformBlock extends NodeMaterialBlock {
  56928. /**
  56929. * Defines the value to use to complement W value to transform it to a Vector4
  56930. */
  56931. complementW: number;
  56932. /**
  56933. * Defines the value to use to complement z value to transform it to a Vector4
  56934. */
  56935. complementZ: number;
  56936. /**
  56937. * Creates a new TransformBlock
  56938. * @param name defines the block name
  56939. */
  56940. constructor(name: string);
  56941. /**
  56942. * Gets the current class name
  56943. * @returns the class name
  56944. */
  56945. getClassName(): string;
  56946. /**
  56947. * Gets the vector input
  56948. */
  56949. get vector(): NodeMaterialConnectionPoint;
  56950. /**
  56951. * Gets the output component
  56952. */
  56953. get output(): NodeMaterialConnectionPoint;
  56954. /**
  56955. * Gets the matrix transform input
  56956. */
  56957. get transform(): NodeMaterialConnectionPoint;
  56958. protected _buildBlock(state: NodeMaterialBuildState): this;
  56959. serialize(): any;
  56960. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56961. protected _dumpPropertiesCode(): string;
  56962. }
  56963. }
  56964. declare module BABYLON {
  56965. /**
  56966. * Block used to output the vertex position
  56967. */
  56968. export class VertexOutputBlock extends NodeMaterialBlock {
  56969. /**
  56970. * Creates a new VertexOutputBlock
  56971. * @param name defines the block name
  56972. */
  56973. constructor(name: string);
  56974. /**
  56975. * Gets the current class name
  56976. * @returns the class name
  56977. */
  56978. getClassName(): string;
  56979. /**
  56980. * Gets the vector input component
  56981. */
  56982. get vector(): NodeMaterialConnectionPoint;
  56983. protected _buildBlock(state: NodeMaterialBuildState): this;
  56984. }
  56985. }
  56986. declare module BABYLON {
  56987. /**
  56988. * Block used to output the final color
  56989. */
  56990. export class FragmentOutputBlock extends NodeMaterialBlock {
  56991. /**
  56992. * Create a new FragmentOutputBlock
  56993. * @param name defines the block name
  56994. */
  56995. constructor(name: string);
  56996. /**
  56997. * Gets the current class name
  56998. * @returns the class name
  56999. */
  57000. getClassName(): string;
  57001. /**
  57002. * Gets the rgba input component
  57003. */
  57004. get rgba(): NodeMaterialConnectionPoint;
  57005. /**
  57006. * Gets the rgb input component
  57007. */
  57008. get rgb(): NodeMaterialConnectionPoint;
  57009. /**
  57010. * Gets the a input component
  57011. */
  57012. get a(): NodeMaterialConnectionPoint;
  57013. protected _buildBlock(state: NodeMaterialBuildState): this;
  57014. }
  57015. }
  57016. declare module BABYLON {
  57017. /**
  57018. * Block used to read a reflection texture from a sampler
  57019. */
  57020. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57021. private _define3DName;
  57022. private _defineCubicName;
  57023. private _defineExplicitName;
  57024. private _defineProjectionName;
  57025. private _defineLocalCubicName;
  57026. private _defineSphericalName;
  57027. private _definePlanarName;
  57028. private _defineEquirectangularName;
  57029. private _defineMirroredEquirectangularFixedName;
  57030. private _defineEquirectangularFixedName;
  57031. private _defineSkyboxName;
  57032. private _cubeSamplerName;
  57033. private _2DSamplerName;
  57034. private _positionUVWName;
  57035. private _directionWName;
  57036. private _reflectionCoordsName;
  57037. private _reflection2DCoordsName;
  57038. private _reflectionColorName;
  57039. private _reflectionMatrixName;
  57040. /**
  57041. * Gets or sets the texture associated with the node
  57042. */
  57043. texture: Nullable<BaseTexture>;
  57044. /**
  57045. * Create a new TextureBlock
  57046. * @param name defines the block name
  57047. */
  57048. constructor(name: string);
  57049. /**
  57050. * Gets the current class name
  57051. * @returns the class name
  57052. */
  57053. getClassName(): string;
  57054. /**
  57055. * Gets the world position input component
  57056. */
  57057. get position(): NodeMaterialConnectionPoint;
  57058. /**
  57059. * Gets the world position input component
  57060. */
  57061. get worldPosition(): NodeMaterialConnectionPoint;
  57062. /**
  57063. * Gets the world normal input component
  57064. */
  57065. get worldNormal(): NodeMaterialConnectionPoint;
  57066. /**
  57067. * Gets the world input component
  57068. */
  57069. get world(): NodeMaterialConnectionPoint;
  57070. /**
  57071. * Gets the camera (or eye) position component
  57072. */
  57073. get cameraPosition(): NodeMaterialConnectionPoint;
  57074. /**
  57075. * Gets the view input component
  57076. */
  57077. get view(): NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the rgb output component
  57080. */
  57081. get rgb(): NodeMaterialConnectionPoint;
  57082. /**
  57083. * Gets the r output component
  57084. */
  57085. get r(): NodeMaterialConnectionPoint;
  57086. /**
  57087. * Gets the g output component
  57088. */
  57089. get g(): NodeMaterialConnectionPoint;
  57090. /**
  57091. * Gets the b output component
  57092. */
  57093. get b(): NodeMaterialConnectionPoint;
  57094. autoConfigure(material: NodeMaterial): void;
  57095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57096. isReady(): boolean;
  57097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57098. private _injectVertexCode;
  57099. private _writeOutput;
  57100. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57101. protected _dumpPropertiesCode(): string;
  57102. serialize(): any;
  57103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57104. }
  57105. }
  57106. declare module BABYLON {
  57107. /**
  57108. * Interface used to configure the node material editor
  57109. */
  57110. export interface INodeMaterialEditorOptions {
  57111. /** Define the URl to load node editor script */
  57112. editorURL?: string;
  57113. }
  57114. /** @hidden */
  57115. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57116. NORMAL: boolean;
  57117. TANGENT: boolean;
  57118. UV1: boolean;
  57119. /** BONES */
  57120. NUM_BONE_INFLUENCERS: number;
  57121. BonesPerMesh: number;
  57122. BONETEXTURE: boolean;
  57123. /** MORPH TARGETS */
  57124. MORPHTARGETS: boolean;
  57125. MORPHTARGETS_NORMAL: boolean;
  57126. MORPHTARGETS_TANGENT: boolean;
  57127. MORPHTARGETS_UV: boolean;
  57128. NUM_MORPH_INFLUENCERS: number;
  57129. /** IMAGE PROCESSING */
  57130. IMAGEPROCESSING: boolean;
  57131. VIGNETTE: boolean;
  57132. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57133. VIGNETTEBLENDMODEOPAQUE: boolean;
  57134. TONEMAPPING: boolean;
  57135. TONEMAPPING_ACES: boolean;
  57136. CONTRAST: boolean;
  57137. EXPOSURE: boolean;
  57138. COLORCURVES: boolean;
  57139. COLORGRADING: boolean;
  57140. COLORGRADING3D: boolean;
  57141. SAMPLER3DGREENDEPTH: boolean;
  57142. SAMPLER3DBGRMAP: boolean;
  57143. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57144. /** MISC. */
  57145. BUMPDIRECTUV: number;
  57146. constructor();
  57147. setValue(name: string, value: boolean): void;
  57148. }
  57149. /**
  57150. * Class used to configure NodeMaterial
  57151. */
  57152. export interface INodeMaterialOptions {
  57153. /**
  57154. * Defines if blocks should emit comments
  57155. */
  57156. emitComments: boolean;
  57157. }
  57158. /**
  57159. * Class used to create a node based material built by assembling shader blocks
  57160. */
  57161. export class NodeMaterial extends PushMaterial {
  57162. private static _BuildIdGenerator;
  57163. private _options;
  57164. private _vertexCompilationState;
  57165. private _fragmentCompilationState;
  57166. private _sharedData;
  57167. private _buildId;
  57168. private _buildWasSuccessful;
  57169. private _cachedWorldViewMatrix;
  57170. private _cachedWorldViewProjectionMatrix;
  57171. private _optimizers;
  57172. private _animationFrame;
  57173. /** Define the Url to load node editor script */
  57174. static EditorURL: string;
  57175. /** Define the Url to load snippets */
  57176. static SnippetUrl: string;
  57177. private BJSNODEMATERIALEDITOR;
  57178. /** Get the inspector from bundle or global */
  57179. private _getGlobalNodeMaterialEditor;
  57180. /**
  57181. * Gets or sets data used by visual editor
  57182. * @see https://nme.babylonjs.com
  57183. */
  57184. editorData: any;
  57185. /**
  57186. * 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)
  57187. */
  57188. ignoreAlpha: boolean;
  57189. /**
  57190. * Defines the maximum number of lights that can be used in the material
  57191. */
  57192. maxSimultaneousLights: number;
  57193. /**
  57194. * Observable raised when the material is built
  57195. */
  57196. onBuildObservable: Observable<NodeMaterial>;
  57197. /**
  57198. * Gets or sets the root nodes of the material vertex shader
  57199. */
  57200. _vertexOutputNodes: NodeMaterialBlock[];
  57201. /**
  57202. * Gets or sets the root nodes of the material fragment (pixel) shader
  57203. */
  57204. _fragmentOutputNodes: NodeMaterialBlock[];
  57205. /** Gets or sets options to control the node material overall behavior */
  57206. get options(): INodeMaterialOptions;
  57207. set options(options: INodeMaterialOptions);
  57208. /**
  57209. * Default configuration related to image processing available in the standard Material.
  57210. */
  57211. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57212. /**
  57213. * Gets the image processing configuration used either in this material.
  57214. */
  57215. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57216. /**
  57217. * Sets the Default image processing configuration used either in the this material.
  57218. *
  57219. * If sets to null, the scene one is in use.
  57220. */
  57221. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57222. /**
  57223. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57224. */
  57225. attachedBlocks: NodeMaterialBlock[];
  57226. /**
  57227. * Create a new node based material
  57228. * @param name defines the material name
  57229. * @param scene defines the hosting scene
  57230. * @param options defines creation option
  57231. */
  57232. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57233. /**
  57234. * Gets the current class name of the material e.g. "NodeMaterial"
  57235. * @returns the class name
  57236. */
  57237. getClassName(): string;
  57238. /**
  57239. * Keep track of the image processing observer to allow dispose and replace.
  57240. */
  57241. private _imageProcessingObserver;
  57242. /**
  57243. * Attaches a new image processing configuration to the Standard Material.
  57244. * @param configuration
  57245. */
  57246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57247. /**
  57248. * Get a block by its name
  57249. * @param name defines the name of the block to retrieve
  57250. * @returns the required block or null if not found
  57251. */
  57252. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57253. /**
  57254. * Get a block by its name
  57255. * @param predicate defines the predicate used to find the good candidate
  57256. * @returns the required block or null if not found
  57257. */
  57258. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57259. /**
  57260. * Get an input block by its name
  57261. * @param predicate defines the predicate used to find the good candidate
  57262. * @returns the required input block or null if not found
  57263. */
  57264. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57265. /**
  57266. * Gets the list of input blocks attached to this material
  57267. * @returns an array of InputBlocks
  57268. */
  57269. getInputBlocks(): InputBlock[];
  57270. /**
  57271. * Adds a new optimizer to the list of optimizers
  57272. * @param optimizer defines the optimizers to add
  57273. * @returns the current material
  57274. */
  57275. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57276. /**
  57277. * Remove an optimizer from the list of optimizers
  57278. * @param optimizer defines the optimizers to remove
  57279. * @returns the current material
  57280. */
  57281. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57282. /**
  57283. * Add a new block to the list of output nodes
  57284. * @param node defines the node to add
  57285. * @returns the current material
  57286. */
  57287. addOutputNode(node: NodeMaterialBlock): this;
  57288. /**
  57289. * Remove a block from the list of root nodes
  57290. * @param node defines the node to remove
  57291. * @returns the current material
  57292. */
  57293. removeOutputNode(node: NodeMaterialBlock): this;
  57294. private _addVertexOutputNode;
  57295. private _removeVertexOutputNode;
  57296. private _addFragmentOutputNode;
  57297. private _removeFragmentOutputNode;
  57298. /**
  57299. * Specifies if the material will require alpha blending
  57300. * @returns a boolean specifying if alpha blending is needed
  57301. */
  57302. needAlphaBlending(): boolean;
  57303. /**
  57304. * Specifies if this material should be rendered in alpha test mode
  57305. * @returns a boolean specifying if an alpha test is needed.
  57306. */
  57307. needAlphaTesting(): boolean;
  57308. private _initializeBlock;
  57309. private _resetDualBlocks;
  57310. /**
  57311. * Remove a block from the current node material
  57312. * @param block defines the block to remove
  57313. */
  57314. removeBlock(block: NodeMaterialBlock): void;
  57315. /**
  57316. * Build the material and generates the inner effect
  57317. * @param verbose defines if the build should log activity
  57318. */
  57319. build(verbose?: boolean): void;
  57320. /**
  57321. * Runs an otpimization phase to try to improve the shader code
  57322. */
  57323. optimize(): void;
  57324. private _prepareDefinesForAttributes;
  57325. /**
  57326. * Get if the submesh is ready to be used and all its information available.
  57327. * Child classes can use it to update shaders
  57328. * @param mesh defines the mesh to check
  57329. * @param subMesh defines which submesh to check
  57330. * @param useInstances specifies that instances should be used
  57331. * @returns a boolean indicating that the submesh is ready or not
  57332. */
  57333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57334. /**
  57335. * Get a string representing the shaders built by the current node graph
  57336. */
  57337. get compiledShaders(): string;
  57338. /**
  57339. * Binds the world matrix to the material
  57340. * @param world defines the world transformation matrix
  57341. */
  57342. bindOnlyWorldMatrix(world: Matrix): void;
  57343. /**
  57344. * Binds the submesh to this material by preparing the effect and shader to draw
  57345. * @param world defines the world transformation matrix
  57346. * @param mesh defines the mesh containing the submesh
  57347. * @param subMesh defines the submesh to bind the material to
  57348. */
  57349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57350. /**
  57351. * Gets the active textures from the material
  57352. * @returns an array of textures
  57353. */
  57354. getActiveTextures(): BaseTexture[];
  57355. /**
  57356. * Gets the list of texture blocks
  57357. * @returns an array of texture blocks
  57358. */
  57359. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57360. /**
  57361. * Specifies if the material uses a texture
  57362. * @param texture defines the texture to check against the material
  57363. * @returns a boolean specifying if the material uses the texture
  57364. */
  57365. hasTexture(texture: BaseTexture): boolean;
  57366. /**
  57367. * Disposes the material
  57368. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57369. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57370. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57371. */
  57372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57373. /** Creates the node editor window. */
  57374. private _createNodeEditor;
  57375. /**
  57376. * Launch the node material editor
  57377. * @param config Define the configuration of the editor
  57378. * @return a promise fulfilled when the node editor is visible
  57379. */
  57380. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57381. /**
  57382. * Clear the current material
  57383. */
  57384. clear(): void;
  57385. /**
  57386. * Clear the current material and set it to a default state
  57387. */
  57388. setToDefault(): void;
  57389. /**
  57390. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57391. * @param url defines the url to load from
  57392. * @returns a promise that will fullfil when the material is fully loaded
  57393. */
  57394. loadAsync(url: string): Promise<void>;
  57395. private _gatherBlocks;
  57396. /**
  57397. * Generate a string containing the code declaration required to create an equivalent of this material
  57398. * @returns a string
  57399. */
  57400. generateCode(): string;
  57401. /**
  57402. * Serializes this material in a JSON representation
  57403. * @returns the serialized material object
  57404. */
  57405. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57406. private _restoreConnections;
  57407. /**
  57408. * Clear the current graph and load a new one from a serialization object
  57409. * @param source defines the JSON representation of the material
  57410. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57411. */
  57412. loadFromSerialization(source: any, rootUrl?: string): void;
  57413. /**
  57414. * Creates a node material from parsed material data
  57415. * @param source defines the JSON representation of the material
  57416. * @param scene defines the hosting scene
  57417. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57418. * @returns a new node material
  57419. */
  57420. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57421. /**
  57422. * Creates a node material from a snippet saved by the node material editor
  57423. * @param snippetId defines the snippet to load
  57424. * @param scene defines the hosting scene
  57425. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57426. * @returns a promise that will resolve to the new node material
  57427. */
  57428. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57429. /**
  57430. * Creates a new node material set to default basic configuration
  57431. * @param name defines the name of the material
  57432. * @param scene defines the hosting scene
  57433. * @returns a new NodeMaterial
  57434. */
  57435. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57436. }
  57437. }
  57438. declare module BABYLON {
  57439. /**
  57440. * Block used to read a texture from a sampler
  57441. */
  57442. export class TextureBlock extends NodeMaterialBlock {
  57443. private _defineName;
  57444. private _linearDefineName;
  57445. private _tempTextureRead;
  57446. private _samplerName;
  57447. private _transformedUVName;
  57448. private _textureTransformName;
  57449. private _textureInfoName;
  57450. private _mainUVName;
  57451. private _mainUVDefineName;
  57452. /**
  57453. * Gets or sets the texture associated with the node
  57454. */
  57455. texture: Nullable<Texture>;
  57456. /**
  57457. * Create a new TextureBlock
  57458. * @param name defines the block name
  57459. */
  57460. constructor(name: string);
  57461. /**
  57462. * Gets the current class name
  57463. * @returns the class name
  57464. */
  57465. getClassName(): string;
  57466. /**
  57467. * Gets the uv input component
  57468. */
  57469. get uv(): NodeMaterialConnectionPoint;
  57470. /**
  57471. * Gets the rgba output component
  57472. */
  57473. get rgba(): NodeMaterialConnectionPoint;
  57474. /**
  57475. * Gets the rgb output component
  57476. */
  57477. get rgb(): NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the r output component
  57480. */
  57481. get r(): NodeMaterialConnectionPoint;
  57482. /**
  57483. * Gets the g output component
  57484. */
  57485. get g(): NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the b output component
  57488. */
  57489. get b(): NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the a output component
  57492. */
  57493. get a(): NodeMaterialConnectionPoint;
  57494. get target(): NodeMaterialBlockTargets;
  57495. autoConfigure(material: NodeMaterial): void;
  57496. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57497. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57498. isReady(): boolean;
  57499. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57500. private get _isMixed();
  57501. private _injectVertexCode;
  57502. private _writeTextureRead;
  57503. private _writeOutput;
  57504. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57505. protected _dumpPropertiesCode(): string;
  57506. serialize(): any;
  57507. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57508. }
  57509. }
  57510. declare module BABYLON {
  57511. /**
  57512. * Class used to store shared data between 2 NodeMaterialBuildState
  57513. */
  57514. export class NodeMaterialBuildStateSharedData {
  57515. /**
  57516. * Gets the list of emitted varyings
  57517. */
  57518. temps: string[];
  57519. /**
  57520. * Gets the list of emitted varyings
  57521. */
  57522. varyings: string[];
  57523. /**
  57524. * Gets the varying declaration string
  57525. */
  57526. varyingDeclaration: string;
  57527. /**
  57528. * Input blocks
  57529. */
  57530. inputBlocks: InputBlock[];
  57531. /**
  57532. * Input blocks
  57533. */
  57534. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57535. /**
  57536. * Bindable blocks (Blocks that need to set data to the effect)
  57537. */
  57538. bindableBlocks: NodeMaterialBlock[];
  57539. /**
  57540. * List of blocks that can provide a compilation fallback
  57541. */
  57542. blocksWithFallbacks: NodeMaterialBlock[];
  57543. /**
  57544. * List of blocks that can provide a define update
  57545. */
  57546. blocksWithDefines: NodeMaterialBlock[];
  57547. /**
  57548. * List of blocks that can provide a repeatable content
  57549. */
  57550. repeatableContentBlocks: NodeMaterialBlock[];
  57551. /**
  57552. * List of blocks that can provide a dynamic list of uniforms
  57553. */
  57554. dynamicUniformBlocks: NodeMaterialBlock[];
  57555. /**
  57556. * List of blocks that can block the isReady function for the material
  57557. */
  57558. blockingBlocks: NodeMaterialBlock[];
  57559. /**
  57560. * Gets the list of animated inputs
  57561. */
  57562. animatedInputs: InputBlock[];
  57563. /**
  57564. * Build Id used to avoid multiple recompilations
  57565. */
  57566. buildId: number;
  57567. /** List of emitted variables */
  57568. variableNames: {
  57569. [key: string]: number;
  57570. };
  57571. /** List of emitted defines */
  57572. defineNames: {
  57573. [key: string]: number;
  57574. };
  57575. /** Should emit comments? */
  57576. emitComments: boolean;
  57577. /** Emit build activity */
  57578. verbose: boolean;
  57579. /** Gets or sets the hosting scene */
  57580. scene: Scene;
  57581. /**
  57582. * Gets the compilation hints emitted at compilation time
  57583. */
  57584. hints: {
  57585. needWorldViewMatrix: boolean;
  57586. needWorldViewProjectionMatrix: boolean;
  57587. needAlphaBlending: boolean;
  57588. needAlphaTesting: boolean;
  57589. };
  57590. /**
  57591. * List of compilation checks
  57592. */
  57593. checks: {
  57594. emitVertex: boolean;
  57595. emitFragment: boolean;
  57596. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57597. };
  57598. /** Creates a new shared data */
  57599. constructor();
  57600. /**
  57601. * Emits console errors and exceptions if there is a failing check
  57602. */
  57603. emitErrors(): void;
  57604. }
  57605. }
  57606. declare module BABYLON {
  57607. /**
  57608. * Class used to store node based material build state
  57609. */
  57610. export class NodeMaterialBuildState {
  57611. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57612. supportUniformBuffers: boolean;
  57613. /**
  57614. * Gets the list of emitted attributes
  57615. */
  57616. attributes: string[];
  57617. /**
  57618. * Gets the list of emitted uniforms
  57619. */
  57620. uniforms: string[];
  57621. /**
  57622. * Gets the list of emitted constants
  57623. */
  57624. constants: string[];
  57625. /**
  57626. * Gets the list of emitted samplers
  57627. */
  57628. samplers: string[];
  57629. /**
  57630. * Gets the list of emitted functions
  57631. */
  57632. functions: {
  57633. [key: string]: string;
  57634. };
  57635. /**
  57636. * Gets the list of emitted extensions
  57637. */
  57638. extensions: {
  57639. [key: string]: string;
  57640. };
  57641. /**
  57642. * Gets the target of the compilation state
  57643. */
  57644. target: NodeMaterialBlockTargets;
  57645. /**
  57646. * Gets the list of emitted counters
  57647. */
  57648. counters: {
  57649. [key: string]: number;
  57650. };
  57651. /**
  57652. * Shared data between multiple NodeMaterialBuildState instances
  57653. */
  57654. sharedData: NodeMaterialBuildStateSharedData;
  57655. /** @hidden */
  57656. _vertexState: NodeMaterialBuildState;
  57657. /** @hidden */
  57658. _attributeDeclaration: string;
  57659. /** @hidden */
  57660. _uniformDeclaration: string;
  57661. /** @hidden */
  57662. _constantDeclaration: string;
  57663. /** @hidden */
  57664. _samplerDeclaration: string;
  57665. /** @hidden */
  57666. _varyingTransfer: string;
  57667. private _repeatableContentAnchorIndex;
  57668. /** @hidden */
  57669. _builtCompilationString: string;
  57670. /**
  57671. * Gets the emitted compilation strings
  57672. */
  57673. compilationString: string;
  57674. /**
  57675. * Finalize the compilation strings
  57676. * @param state defines the current compilation state
  57677. */
  57678. finalize(state: NodeMaterialBuildState): void;
  57679. /** @hidden */
  57680. get _repeatableContentAnchor(): string;
  57681. /** @hidden */
  57682. _getFreeVariableName(prefix: string): string;
  57683. /** @hidden */
  57684. _getFreeDefineName(prefix: string): string;
  57685. /** @hidden */
  57686. _excludeVariableName(name: string): void;
  57687. /** @hidden */
  57688. _emit2DSampler(name: string): void;
  57689. /** @hidden */
  57690. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57691. /** @hidden */
  57692. _emitExtension(name: string, extension: string): void;
  57693. /** @hidden */
  57694. _emitFunction(name: string, code: string, comments: string): void;
  57695. /** @hidden */
  57696. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57697. replaceStrings?: {
  57698. search: RegExp;
  57699. replace: string;
  57700. }[];
  57701. repeatKey?: string;
  57702. }): string;
  57703. /** @hidden */
  57704. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57705. repeatKey?: string;
  57706. removeAttributes?: boolean;
  57707. removeUniforms?: boolean;
  57708. removeVaryings?: boolean;
  57709. removeIfDef?: boolean;
  57710. replaceStrings?: {
  57711. search: RegExp;
  57712. replace: string;
  57713. }[];
  57714. }, storeKey?: string): void;
  57715. /** @hidden */
  57716. _registerTempVariable(name: string): boolean;
  57717. /** @hidden */
  57718. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57719. /** @hidden */
  57720. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57721. /** @hidden */
  57722. _emitFloat(value: number): string;
  57723. }
  57724. }
  57725. declare module BABYLON {
  57726. /**
  57727. * Defines a block that can be used inside a node based material
  57728. */
  57729. export class NodeMaterialBlock {
  57730. private _buildId;
  57731. private _buildTarget;
  57732. private _target;
  57733. private _isFinalMerger;
  57734. private _isInput;
  57735. protected _isUnique: boolean;
  57736. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57737. inputsAreExclusive: boolean;
  57738. /** @hidden */
  57739. _codeVariableName: string;
  57740. /** @hidden */
  57741. _inputs: NodeMaterialConnectionPoint[];
  57742. /** @hidden */
  57743. _outputs: NodeMaterialConnectionPoint[];
  57744. /** @hidden */
  57745. _preparationId: number;
  57746. /**
  57747. * Gets or sets the name of the block
  57748. */
  57749. name: string;
  57750. /**
  57751. * Gets or sets the unique id of the node
  57752. */
  57753. uniqueId: number;
  57754. /**
  57755. * Gets or sets the comments associated with this block
  57756. */
  57757. comments: string;
  57758. /**
  57759. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57760. */
  57761. get isUnique(): boolean;
  57762. /**
  57763. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57764. */
  57765. get isFinalMerger(): boolean;
  57766. /**
  57767. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57768. */
  57769. get isInput(): boolean;
  57770. /**
  57771. * Gets or sets the build Id
  57772. */
  57773. get buildId(): number;
  57774. set buildId(value: number);
  57775. /**
  57776. * Gets or sets the target of the block
  57777. */
  57778. get target(): NodeMaterialBlockTargets;
  57779. set target(value: NodeMaterialBlockTargets);
  57780. /**
  57781. * Gets the list of input points
  57782. */
  57783. get inputs(): NodeMaterialConnectionPoint[];
  57784. /** Gets the list of output points */
  57785. get outputs(): NodeMaterialConnectionPoint[];
  57786. /**
  57787. * Find an input by its name
  57788. * @param name defines the name of the input to look for
  57789. * @returns the input or null if not found
  57790. */
  57791. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57792. /**
  57793. * Find an output by its name
  57794. * @param name defines the name of the outputto look for
  57795. * @returns the output or null if not found
  57796. */
  57797. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57798. /**
  57799. * Creates a new NodeMaterialBlock
  57800. * @param name defines the block name
  57801. * @param target defines the target of that block (Vertex by default)
  57802. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57803. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57804. */
  57805. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57806. /**
  57807. * Initialize the block and prepare the context for build
  57808. * @param state defines the state that will be used for the build
  57809. */
  57810. initialize(state: NodeMaterialBuildState): void;
  57811. /**
  57812. * Bind data to effect. Will only be called for blocks with isBindable === true
  57813. * @param effect defines the effect to bind data to
  57814. * @param nodeMaterial defines the hosting NodeMaterial
  57815. * @param mesh defines the mesh that will be rendered
  57816. */
  57817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57818. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57819. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57820. protected _writeFloat(value: number): string;
  57821. /**
  57822. * Gets the current class name e.g. "NodeMaterialBlock"
  57823. * @returns the class name
  57824. */
  57825. getClassName(): string;
  57826. /**
  57827. * Register a new input. Must be called inside a block constructor
  57828. * @param name defines the connection point name
  57829. * @param type defines the connection point type
  57830. * @param isOptional defines a boolean indicating that this input can be omitted
  57831. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57832. * @returns the current block
  57833. */
  57834. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57835. /**
  57836. * Register a new output. Must be called inside a block constructor
  57837. * @param name defines the connection point name
  57838. * @param type defines the connection point type
  57839. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57840. * @returns the current block
  57841. */
  57842. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57843. /**
  57844. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57845. * @param forOutput defines an optional connection point to check compatibility with
  57846. * @returns the first available input or null
  57847. */
  57848. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57849. /**
  57850. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57851. * @param forBlock defines an optional block to check compatibility with
  57852. * @returns the first available input or null
  57853. */
  57854. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57855. /**
  57856. * Gets the sibling of the given output
  57857. * @param current defines the current output
  57858. * @returns the next output in the list or null
  57859. */
  57860. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57861. /**
  57862. * Connect current block with another block
  57863. * @param other defines the block to connect with
  57864. * @param options define the various options to help pick the right connections
  57865. * @returns the current block
  57866. */
  57867. connectTo(other: NodeMaterialBlock, options?: {
  57868. input?: string;
  57869. output?: string;
  57870. outputSwizzle?: string;
  57871. }): this | undefined;
  57872. protected _buildBlock(state: NodeMaterialBuildState): void;
  57873. /**
  57874. * Add uniforms, samplers and uniform buffers at compilation time
  57875. * @param state defines the state to update
  57876. * @param nodeMaterial defines the node material requesting the update
  57877. * @param defines defines the material defines to update
  57878. * @param uniformBuffers defines the list of uniform buffer names
  57879. */
  57880. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57881. /**
  57882. * Add potential fallbacks if shader compilation fails
  57883. * @param mesh defines the mesh to be rendered
  57884. * @param fallbacks defines the current prioritized list of fallbacks
  57885. */
  57886. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57887. /**
  57888. * Initialize defines for shader compilation
  57889. * @param mesh defines the mesh to be rendered
  57890. * @param nodeMaterial defines the node material requesting the update
  57891. * @param defines defines the material defines to update
  57892. * @param useInstances specifies that instances should be used
  57893. */
  57894. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57895. /**
  57896. * Update defines for shader compilation
  57897. * @param mesh defines the mesh to be rendered
  57898. * @param nodeMaterial defines the node material requesting the update
  57899. * @param defines defines the material defines to update
  57900. * @param useInstances specifies that instances should be used
  57901. */
  57902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57903. /**
  57904. * Lets the block try to connect some inputs automatically
  57905. * @param material defines the hosting NodeMaterial
  57906. */
  57907. autoConfigure(material: NodeMaterial): void;
  57908. /**
  57909. * Function called when a block is declared as repeatable content generator
  57910. * @param vertexShaderState defines the current compilation state for the vertex shader
  57911. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57912. * @param mesh defines the mesh to be rendered
  57913. * @param defines defines the material defines to update
  57914. */
  57915. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57916. /**
  57917. * Checks if the block is ready
  57918. * @param mesh defines the mesh to be rendered
  57919. * @param nodeMaterial defines the node material requesting the update
  57920. * @param defines defines the material defines to update
  57921. * @param useInstances specifies that instances should be used
  57922. * @returns true if the block is ready
  57923. */
  57924. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57925. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57926. private _processBuild;
  57927. /**
  57928. * Compile the current node and generate the shader code
  57929. * @param state defines the current compilation state (uniforms, samplers, current string)
  57930. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57931. * @returns true if already built
  57932. */
  57933. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57934. protected _inputRename(name: string): string;
  57935. protected _outputRename(name: string): string;
  57936. protected _dumpPropertiesCode(): string;
  57937. /** @hidden */
  57938. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57939. /** @hidden */
  57940. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57941. /**
  57942. * Clone the current block to a new identical block
  57943. * @param scene defines the hosting scene
  57944. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57945. * @returns a copy of the current block
  57946. */
  57947. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57948. /**
  57949. * Serializes this block in a JSON representation
  57950. * @returns the serialized block object
  57951. */
  57952. serialize(): any;
  57953. /** @hidden */
  57954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57955. /**
  57956. * Release resources
  57957. */
  57958. dispose(): void;
  57959. }
  57960. }
  57961. declare module BABYLON {
  57962. /**
  57963. * Enum defining the type of animations supported by InputBlock
  57964. */
  57965. export enum AnimatedInputBlockTypes {
  57966. /** No animation */
  57967. None = 0,
  57968. /** Time based animation. Will only work for floats */
  57969. Time = 1
  57970. }
  57971. }
  57972. declare module BABYLON {
  57973. /**
  57974. * Block used to expose an input value
  57975. */
  57976. export class InputBlock extends NodeMaterialBlock {
  57977. private _mode;
  57978. private _associatedVariableName;
  57979. private _storedValue;
  57980. private _valueCallback;
  57981. private _type;
  57982. private _animationType;
  57983. /** Gets or set a value used to limit the range of float values */
  57984. min: number;
  57985. /** Gets or set a value used to limit the range of float values */
  57986. max: number;
  57987. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57988. isBoolean: boolean;
  57989. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57990. matrixMode: number;
  57991. /** @hidden */
  57992. _systemValue: Nullable<NodeMaterialSystemValues>;
  57993. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57994. visibleInInspector: boolean;
  57995. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57996. isConstant: boolean;
  57997. /** Gets or sets the group to use to display this block in the Inspector */
  57998. groupInInspector: string;
  57999. /**
  58000. * Gets or sets the connection point type (default is float)
  58001. */
  58002. get type(): NodeMaterialBlockConnectionPointTypes;
  58003. /**
  58004. * Creates a new InputBlock
  58005. * @param name defines the block name
  58006. * @param target defines the target of that block (Vertex by default)
  58007. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58008. */
  58009. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58010. /**
  58011. * Gets the output component
  58012. */
  58013. get output(): NodeMaterialConnectionPoint;
  58014. /**
  58015. * Set the source of this connection point to a vertex attribute
  58016. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58017. * @returns the current connection point
  58018. */
  58019. setAsAttribute(attributeName?: string): InputBlock;
  58020. /**
  58021. * Set the source of this connection point to a system value
  58022. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58023. * @returns the current connection point
  58024. */
  58025. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58026. /**
  58027. * Gets or sets the value of that point.
  58028. * Please note that this value will be ignored if valueCallback is defined
  58029. */
  58030. get value(): any;
  58031. set value(value: any);
  58032. /**
  58033. * Gets or sets a callback used to get the value of that point.
  58034. * Please note that setting this value will force the connection point to ignore the value property
  58035. */
  58036. get valueCallback(): () => any;
  58037. set valueCallback(value: () => any);
  58038. /**
  58039. * Gets or sets the associated variable name in the shader
  58040. */
  58041. get associatedVariableName(): string;
  58042. set associatedVariableName(value: string);
  58043. /** Gets or sets the type of animation applied to the input */
  58044. get animationType(): AnimatedInputBlockTypes;
  58045. set animationType(value: AnimatedInputBlockTypes);
  58046. /**
  58047. * Gets a boolean indicating that this connection point not defined yet
  58048. */
  58049. get isUndefined(): boolean;
  58050. /**
  58051. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58052. * In this case the connection point name must be the name of the uniform to use.
  58053. * Can only be set on inputs
  58054. */
  58055. get isUniform(): boolean;
  58056. set isUniform(value: boolean);
  58057. /**
  58058. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58059. * In this case the connection point name must be the name of the attribute to use
  58060. * Can only be set on inputs
  58061. */
  58062. get isAttribute(): boolean;
  58063. set isAttribute(value: boolean);
  58064. /**
  58065. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58066. * Can only be set on exit points
  58067. */
  58068. get isVarying(): boolean;
  58069. set isVarying(value: boolean);
  58070. /**
  58071. * Gets a boolean indicating that the current connection point is a system value
  58072. */
  58073. get isSystemValue(): boolean;
  58074. /**
  58075. * Gets or sets the current well known value or null if not defined as a system value
  58076. */
  58077. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58078. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58079. /**
  58080. * Gets the current class name
  58081. * @returns the class name
  58082. */
  58083. getClassName(): string;
  58084. /**
  58085. * Animate the input if animationType !== None
  58086. * @param scene defines the rendering scene
  58087. */
  58088. animate(scene: Scene): void;
  58089. private _emitDefine;
  58090. initialize(state: NodeMaterialBuildState): void;
  58091. /**
  58092. * Set the input block to its default value (based on its type)
  58093. */
  58094. setDefaultValue(): void;
  58095. private _emitConstant;
  58096. private _emit;
  58097. /** @hidden */
  58098. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58099. /** @hidden */
  58100. _transmit(effect: Effect, scene: Scene): void;
  58101. protected _buildBlock(state: NodeMaterialBuildState): void;
  58102. protected _dumpPropertiesCode(): string;
  58103. serialize(): any;
  58104. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58105. }
  58106. }
  58107. declare module BABYLON {
  58108. /**
  58109. * Enum used to define the compatibility state between two connection points
  58110. */
  58111. export enum NodeMaterialConnectionPointCompatibilityStates {
  58112. /** Points are compatibles */
  58113. Compatible = 0,
  58114. /** Points are incompatible because of their types */
  58115. TypeIncompatible = 1,
  58116. /** Points are incompatible because of their targets (vertex vs fragment) */
  58117. TargetIncompatible = 2
  58118. }
  58119. /**
  58120. * Defines the direction of a connection point
  58121. */
  58122. export enum NodeMaterialConnectionPointDirection {
  58123. /** Input */
  58124. Input = 0,
  58125. /** Output */
  58126. Output = 1
  58127. }
  58128. /**
  58129. * Defines a connection point for a block
  58130. */
  58131. export class NodeMaterialConnectionPoint {
  58132. /** @hidden */
  58133. _ownerBlock: NodeMaterialBlock;
  58134. /** @hidden */
  58135. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58136. private _endpoints;
  58137. private _associatedVariableName;
  58138. private _direction;
  58139. /** @hidden */
  58140. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58141. /** @hidden */
  58142. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58143. private _type;
  58144. /** @hidden */
  58145. _enforceAssociatedVariableName: boolean;
  58146. /** Gets the direction of the point */
  58147. get direction(): NodeMaterialConnectionPointDirection;
  58148. /**
  58149. * Gets or sets the additional types supported by this connection point
  58150. */
  58151. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58152. /**
  58153. * Gets or sets the additional types excluded by this connection point
  58154. */
  58155. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58156. /**
  58157. * Observable triggered when this point is connected
  58158. */
  58159. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58160. /**
  58161. * Gets or sets the associated variable name in the shader
  58162. */
  58163. get associatedVariableName(): string;
  58164. set associatedVariableName(value: string);
  58165. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58166. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58167. /**
  58168. * Gets or sets the connection point type (default is float)
  58169. */
  58170. get type(): NodeMaterialBlockConnectionPointTypes;
  58171. set type(value: NodeMaterialBlockConnectionPointTypes);
  58172. /**
  58173. * Gets or sets the connection point name
  58174. */
  58175. name: string;
  58176. /**
  58177. * Gets or sets a boolean indicating that this connection point can be omitted
  58178. */
  58179. isOptional: boolean;
  58180. /**
  58181. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58182. */
  58183. define: string;
  58184. /** @hidden */
  58185. _prioritizeVertex: boolean;
  58186. private _target;
  58187. /** Gets or sets the target of that connection point */
  58188. get target(): NodeMaterialBlockTargets;
  58189. set target(value: NodeMaterialBlockTargets);
  58190. /**
  58191. * Gets a boolean indicating that the current point is connected
  58192. */
  58193. get isConnected(): boolean;
  58194. /**
  58195. * Gets a boolean indicating that the current point is connected to an input block
  58196. */
  58197. get isConnectedToInputBlock(): boolean;
  58198. /**
  58199. * Gets a the connected input block (if any)
  58200. */
  58201. get connectInputBlock(): Nullable<InputBlock>;
  58202. /** Get the other side of the connection (if any) */
  58203. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58204. /** Get the block that owns this connection point */
  58205. get ownerBlock(): NodeMaterialBlock;
  58206. /** Get the block connected on the other side of this connection (if any) */
  58207. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58208. /** Get the block connected on the endpoints of this connection (if any) */
  58209. get connectedBlocks(): Array<NodeMaterialBlock>;
  58210. /** Gets the list of connected endpoints */
  58211. get endpoints(): NodeMaterialConnectionPoint[];
  58212. /** Gets a boolean indicating if that output point is connected to at least one input */
  58213. get hasEndpoints(): boolean;
  58214. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58215. get isConnectedInVertexShader(): boolean;
  58216. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58217. get isConnectedInFragmentShader(): boolean;
  58218. /**
  58219. * Creates a new connection point
  58220. * @param name defines the connection point name
  58221. * @param ownerBlock defines the block hosting this connection point
  58222. * @param direction defines the direction of the connection point
  58223. */
  58224. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58225. /**
  58226. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58227. * @returns the class name
  58228. */
  58229. getClassName(): string;
  58230. /**
  58231. * Gets a boolean indicating if the current point can be connected to another point
  58232. * @param connectionPoint defines the other connection point
  58233. * @returns a boolean
  58234. */
  58235. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58236. /**
  58237. * Gets a number indicating if the current point can be connected to another point
  58238. * @param connectionPoint defines the other connection point
  58239. * @returns a number defining the compatibility state
  58240. */
  58241. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58242. /**
  58243. * Connect this point to another connection point
  58244. * @param connectionPoint defines the other connection point
  58245. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58246. * @returns the current connection point
  58247. */
  58248. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58249. /**
  58250. * Disconnect this point from one of his endpoint
  58251. * @param endpoint defines the other connection point
  58252. * @returns the current connection point
  58253. */
  58254. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58255. /**
  58256. * Serializes this point in a JSON representation
  58257. * @returns the serialized point object
  58258. */
  58259. serialize(): any;
  58260. /**
  58261. * Release resources
  58262. */
  58263. dispose(): void;
  58264. }
  58265. }
  58266. declare module BABYLON {
  58267. /**
  58268. * Block used to add support for vertex skinning (bones)
  58269. */
  58270. export class BonesBlock extends NodeMaterialBlock {
  58271. /**
  58272. * Creates a new BonesBlock
  58273. * @param name defines the block name
  58274. */
  58275. constructor(name: string);
  58276. /**
  58277. * Initialize the block and prepare the context for build
  58278. * @param state defines the state that will be used for the build
  58279. */
  58280. initialize(state: NodeMaterialBuildState): void;
  58281. /**
  58282. * Gets the current class name
  58283. * @returns the class name
  58284. */
  58285. getClassName(): string;
  58286. /**
  58287. * Gets the matrix indices input component
  58288. */
  58289. get matricesIndices(): NodeMaterialConnectionPoint;
  58290. /**
  58291. * Gets the matrix weights input component
  58292. */
  58293. get matricesWeights(): NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the extra matrix indices input component
  58296. */
  58297. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58298. /**
  58299. * Gets the extra matrix weights input component
  58300. */
  58301. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58302. /**
  58303. * Gets the world input component
  58304. */
  58305. get world(): NodeMaterialConnectionPoint;
  58306. /**
  58307. * Gets the output component
  58308. */
  58309. get output(): NodeMaterialConnectionPoint;
  58310. autoConfigure(material: NodeMaterial): void;
  58311. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58314. protected _buildBlock(state: NodeMaterialBuildState): this;
  58315. }
  58316. }
  58317. declare module BABYLON {
  58318. /**
  58319. * Block used to add support for instances
  58320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58321. */
  58322. export class InstancesBlock extends NodeMaterialBlock {
  58323. /**
  58324. * Creates a new InstancesBlock
  58325. * @param name defines the block name
  58326. */
  58327. constructor(name: string);
  58328. /**
  58329. * Gets the current class name
  58330. * @returns the class name
  58331. */
  58332. getClassName(): string;
  58333. /**
  58334. * Gets the first world row input component
  58335. */
  58336. get world0(): NodeMaterialConnectionPoint;
  58337. /**
  58338. * Gets the second world row input component
  58339. */
  58340. get world1(): NodeMaterialConnectionPoint;
  58341. /**
  58342. * Gets the third world row input component
  58343. */
  58344. get world2(): NodeMaterialConnectionPoint;
  58345. /**
  58346. * Gets the forth world row input component
  58347. */
  58348. get world3(): NodeMaterialConnectionPoint;
  58349. /**
  58350. * Gets the world input component
  58351. */
  58352. get world(): NodeMaterialConnectionPoint;
  58353. /**
  58354. * Gets the output component
  58355. */
  58356. get output(): NodeMaterialConnectionPoint;
  58357. /**
  58358. * Gets the isntanceID component
  58359. */
  58360. get instanceID(): NodeMaterialConnectionPoint;
  58361. autoConfigure(material: NodeMaterial): void;
  58362. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58363. protected _buildBlock(state: NodeMaterialBuildState): this;
  58364. }
  58365. }
  58366. declare module BABYLON {
  58367. /**
  58368. * Block used to add morph targets support to vertex shader
  58369. */
  58370. export class MorphTargetsBlock extends NodeMaterialBlock {
  58371. private _repeatableContentAnchor;
  58372. /**
  58373. * Create a new MorphTargetsBlock
  58374. * @param name defines the block name
  58375. */
  58376. constructor(name: string);
  58377. /**
  58378. * Gets the current class name
  58379. * @returns the class name
  58380. */
  58381. getClassName(): string;
  58382. /**
  58383. * Gets the position input component
  58384. */
  58385. get position(): NodeMaterialConnectionPoint;
  58386. /**
  58387. * Gets the normal input component
  58388. */
  58389. get normal(): NodeMaterialConnectionPoint;
  58390. /**
  58391. * Gets the tangent input component
  58392. */
  58393. get tangent(): NodeMaterialConnectionPoint;
  58394. /**
  58395. * Gets the tangent input component
  58396. */
  58397. get uv(): NodeMaterialConnectionPoint;
  58398. /**
  58399. * Gets the position output component
  58400. */
  58401. get positionOutput(): NodeMaterialConnectionPoint;
  58402. /**
  58403. * Gets the normal output component
  58404. */
  58405. get normalOutput(): NodeMaterialConnectionPoint;
  58406. /**
  58407. * Gets the tangent output component
  58408. */
  58409. get tangentOutput(): NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the tangent output component
  58412. */
  58413. get uvOutput(): NodeMaterialConnectionPoint;
  58414. initialize(state: NodeMaterialBuildState): void;
  58415. autoConfigure(material: NodeMaterial): void;
  58416. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58417. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58418. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58419. protected _buildBlock(state: NodeMaterialBuildState): this;
  58420. }
  58421. }
  58422. declare module BABYLON {
  58423. /**
  58424. * Block used to get data information from a light
  58425. */
  58426. export class LightInformationBlock extends NodeMaterialBlock {
  58427. private _lightDataUniformName;
  58428. private _lightColorUniformName;
  58429. private _lightTypeDefineName;
  58430. /**
  58431. * Gets or sets the light associated with this block
  58432. */
  58433. light: Nullable<Light>;
  58434. /**
  58435. * Creates a new LightInformationBlock
  58436. * @param name defines the block name
  58437. */
  58438. constructor(name: string);
  58439. /**
  58440. * Gets the current class name
  58441. * @returns the class name
  58442. */
  58443. getClassName(): string;
  58444. /**
  58445. * Gets the world position input component
  58446. */
  58447. get worldPosition(): NodeMaterialConnectionPoint;
  58448. /**
  58449. * Gets the direction output component
  58450. */
  58451. get direction(): NodeMaterialConnectionPoint;
  58452. /**
  58453. * Gets the direction output component
  58454. */
  58455. get color(): NodeMaterialConnectionPoint;
  58456. /**
  58457. * Gets the direction output component
  58458. */
  58459. get intensity(): NodeMaterialConnectionPoint;
  58460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58462. protected _buildBlock(state: NodeMaterialBuildState): this;
  58463. serialize(): any;
  58464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58465. }
  58466. }
  58467. declare module BABYLON {
  58468. /**
  58469. * Block used to add image processing support to fragment shader
  58470. */
  58471. export class ImageProcessingBlock extends NodeMaterialBlock {
  58472. /**
  58473. * Create a new ImageProcessingBlock
  58474. * @param name defines the block name
  58475. */
  58476. constructor(name: string);
  58477. /**
  58478. * Gets the current class name
  58479. * @returns the class name
  58480. */
  58481. getClassName(): string;
  58482. /**
  58483. * Gets the color input component
  58484. */
  58485. get color(): NodeMaterialConnectionPoint;
  58486. /**
  58487. * Gets the output component
  58488. */
  58489. get output(): NodeMaterialConnectionPoint;
  58490. /**
  58491. * Initialize the block and prepare the context for build
  58492. * @param state defines the state that will be used for the build
  58493. */
  58494. initialize(state: NodeMaterialBuildState): void;
  58495. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58496. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58498. protected _buildBlock(state: NodeMaterialBuildState): this;
  58499. }
  58500. }
  58501. declare module BABYLON {
  58502. /**
  58503. * Block used to pertub normals based on a normal map
  58504. */
  58505. export class PerturbNormalBlock extends NodeMaterialBlock {
  58506. private _tangentSpaceParameterName;
  58507. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58508. invertX: boolean;
  58509. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58510. invertY: boolean;
  58511. /**
  58512. * Create a new PerturbNormalBlock
  58513. * @param name defines the block name
  58514. */
  58515. constructor(name: string);
  58516. /**
  58517. * Gets the current class name
  58518. * @returns the class name
  58519. */
  58520. getClassName(): string;
  58521. /**
  58522. * Gets the world position input component
  58523. */
  58524. get worldPosition(): NodeMaterialConnectionPoint;
  58525. /**
  58526. * Gets the world normal input component
  58527. */
  58528. get worldNormal(): NodeMaterialConnectionPoint;
  58529. /**
  58530. * Gets the uv input component
  58531. */
  58532. get uv(): NodeMaterialConnectionPoint;
  58533. /**
  58534. * Gets the normal map color input component
  58535. */
  58536. get normalMapColor(): NodeMaterialConnectionPoint;
  58537. /**
  58538. * Gets the strength input component
  58539. */
  58540. get strength(): NodeMaterialConnectionPoint;
  58541. /**
  58542. * Gets the output component
  58543. */
  58544. get output(): NodeMaterialConnectionPoint;
  58545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58547. autoConfigure(material: NodeMaterial): void;
  58548. protected _buildBlock(state: NodeMaterialBuildState): this;
  58549. protected _dumpPropertiesCode(): string;
  58550. serialize(): any;
  58551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58552. }
  58553. }
  58554. declare module BABYLON {
  58555. /**
  58556. * Block used to discard a pixel if a value is smaller than a cutoff
  58557. */
  58558. export class DiscardBlock extends NodeMaterialBlock {
  58559. /**
  58560. * Create a new DiscardBlock
  58561. * @param name defines the block name
  58562. */
  58563. constructor(name: string);
  58564. /**
  58565. * Gets the current class name
  58566. * @returns the class name
  58567. */
  58568. getClassName(): string;
  58569. /**
  58570. * Gets the color input component
  58571. */
  58572. get value(): NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the cutoff input component
  58575. */
  58576. get cutoff(): NodeMaterialConnectionPoint;
  58577. protected _buildBlock(state: NodeMaterialBuildState): this;
  58578. }
  58579. }
  58580. declare module BABYLON {
  58581. /**
  58582. * Block used to test if the fragment shader is front facing
  58583. */
  58584. export class FrontFacingBlock extends NodeMaterialBlock {
  58585. /**
  58586. * Creates a new FrontFacingBlock
  58587. * @param name defines the block name
  58588. */
  58589. constructor(name: string);
  58590. /**
  58591. * Gets the current class name
  58592. * @returns the class name
  58593. */
  58594. getClassName(): string;
  58595. /**
  58596. * Gets the output component
  58597. */
  58598. get output(): NodeMaterialConnectionPoint;
  58599. protected _buildBlock(state: NodeMaterialBuildState): this;
  58600. }
  58601. }
  58602. declare module BABYLON {
  58603. /**
  58604. * Block used to get the derivative value on x and y of a given input
  58605. */
  58606. export class DerivativeBlock extends NodeMaterialBlock {
  58607. /**
  58608. * Create a new DerivativeBlock
  58609. * @param name defines the block name
  58610. */
  58611. constructor(name: string);
  58612. /**
  58613. * Gets the current class name
  58614. * @returns the class name
  58615. */
  58616. getClassName(): string;
  58617. /**
  58618. * Gets the input component
  58619. */
  58620. get input(): NodeMaterialConnectionPoint;
  58621. /**
  58622. * Gets the derivative output on x
  58623. */
  58624. get dx(): NodeMaterialConnectionPoint;
  58625. /**
  58626. * Gets the derivative output on y
  58627. */
  58628. get dy(): NodeMaterialConnectionPoint;
  58629. protected _buildBlock(state: NodeMaterialBuildState): this;
  58630. }
  58631. }
  58632. declare module BABYLON {
  58633. /**
  58634. * Block used to add support for scene fog
  58635. */
  58636. export class FogBlock extends NodeMaterialBlock {
  58637. private _fogDistanceName;
  58638. private _fogParameters;
  58639. /**
  58640. * Create a new FogBlock
  58641. * @param name defines the block name
  58642. */
  58643. constructor(name: string);
  58644. /**
  58645. * Gets the current class name
  58646. * @returns the class name
  58647. */
  58648. getClassName(): string;
  58649. /**
  58650. * Gets the world position input component
  58651. */
  58652. get worldPosition(): NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the view input component
  58655. */
  58656. get view(): NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the color input component
  58659. */
  58660. get input(): NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the fog color input component
  58663. */
  58664. get fogColor(): NodeMaterialConnectionPoint;
  58665. /**
  58666. * Gets the output component
  58667. */
  58668. get output(): NodeMaterialConnectionPoint;
  58669. autoConfigure(material: NodeMaterial): void;
  58670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58672. protected _buildBlock(state: NodeMaterialBuildState): this;
  58673. }
  58674. }
  58675. declare module BABYLON {
  58676. /**
  58677. * Block used to add light in the fragment shader
  58678. */
  58679. export class LightBlock extends NodeMaterialBlock {
  58680. private _lightId;
  58681. /**
  58682. * Gets or sets the light associated with this block
  58683. */
  58684. light: Nullable<Light>;
  58685. /**
  58686. * Create a new LightBlock
  58687. * @param name defines the block name
  58688. */
  58689. constructor(name: string);
  58690. /**
  58691. * Gets the current class name
  58692. * @returns the class name
  58693. */
  58694. getClassName(): string;
  58695. /**
  58696. * Gets the world position input component
  58697. */
  58698. get worldPosition(): NodeMaterialConnectionPoint;
  58699. /**
  58700. * Gets the world normal input component
  58701. */
  58702. get worldNormal(): NodeMaterialConnectionPoint;
  58703. /**
  58704. * Gets the camera (or eye) position component
  58705. */
  58706. get cameraPosition(): NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the glossiness component
  58709. */
  58710. get glossiness(): NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the glossinness power component
  58713. */
  58714. get glossPower(): NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the diffuse color component
  58717. */
  58718. get diffuseColor(): NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the specular color component
  58721. */
  58722. get specularColor(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the diffuse output component
  58725. */
  58726. get diffuseOutput(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the specular output component
  58729. */
  58730. get specularOutput(): NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the shadow output component
  58733. */
  58734. get shadow(): NodeMaterialConnectionPoint;
  58735. autoConfigure(material: NodeMaterial): void;
  58736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58737. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58739. private _injectVertexCode;
  58740. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58741. serialize(): any;
  58742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58743. }
  58744. }
  58745. declare module BABYLON {
  58746. /**
  58747. * Block used to multiply 2 values
  58748. */
  58749. export class MultiplyBlock extends NodeMaterialBlock {
  58750. /**
  58751. * Creates a new MultiplyBlock
  58752. * @param name defines the block name
  58753. */
  58754. constructor(name: string);
  58755. /**
  58756. * Gets the current class name
  58757. * @returns the class name
  58758. */
  58759. getClassName(): string;
  58760. /**
  58761. * Gets the left operand input component
  58762. */
  58763. get left(): NodeMaterialConnectionPoint;
  58764. /**
  58765. * Gets the right operand input component
  58766. */
  58767. get right(): NodeMaterialConnectionPoint;
  58768. /**
  58769. * Gets the output component
  58770. */
  58771. get output(): NodeMaterialConnectionPoint;
  58772. protected _buildBlock(state: NodeMaterialBuildState): this;
  58773. }
  58774. }
  58775. declare module BABYLON {
  58776. /**
  58777. * Block used to add 2 vectors
  58778. */
  58779. export class AddBlock extends NodeMaterialBlock {
  58780. /**
  58781. * Creates a new AddBlock
  58782. * @param name defines the block name
  58783. */
  58784. constructor(name: string);
  58785. /**
  58786. * Gets the current class name
  58787. * @returns the class name
  58788. */
  58789. getClassName(): string;
  58790. /**
  58791. * Gets the left operand input component
  58792. */
  58793. get left(): NodeMaterialConnectionPoint;
  58794. /**
  58795. * Gets the right operand input component
  58796. */
  58797. get right(): NodeMaterialConnectionPoint;
  58798. /**
  58799. * Gets the output component
  58800. */
  58801. get output(): NodeMaterialConnectionPoint;
  58802. protected _buildBlock(state: NodeMaterialBuildState): this;
  58803. }
  58804. }
  58805. declare module BABYLON {
  58806. /**
  58807. * Block used to scale a vector by a float
  58808. */
  58809. export class ScaleBlock extends NodeMaterialBlock {
  58810. /**
  58811. * Creates a new ScaleBlock
  58812. * @param name defines the block name
  58813. */
  58814. constructor(name: string);
  58815. /**
  58816. * Gets the current class name
  58817. * @returns the class name
  58818. */
  58819. getClassName(): string;
  58820. /**
  58821. * Gets the input component
  58822. */
  58823. get input(): NodeMaterialConnectionPoint;
  58824. /**
  58825. * Gets the factor input component
  58826. */
  58827. get factor(): NodeMaterialConnectionPoint;
  58828. /**
  58829. * Gets the output component
  58830. */
  58831. get output(): NodeMaterialConnectionPoint;
  58832. protected _buildBlock(state: NodeMaterialBuildState): this;
  58833. }
  58834. }
  58835. declare module BABYLON {
  58836. /**
  58837. * Block used to clamp a float
  58838. */
  58839. export class ClampBlock extends NodeMaterialBlock {
  58840. /** Gets or sets the minimum range */
  58841. minimum: number;
  58842. /** Gets or sets the maximum range */
  58843. maximum: number;
  58844. /**
  58845. * Creates a new ClampBlock
  58846. * @param name defines the block name
  58847. */
  58848. constructor(name: string);
  58849. /**
  58850. * Gets the current class name
  58851. * @returns the class name
  58852. */
  58853. getClassName(): string;
  58854. /**
  58855. * Gets the value input component
  58856. */
  58857. get value(): NodeMaterialConnectionPoint;
  58858. /**
  58859. * Gets the output component
  58860. */
  58861. get output(): NodeMaterialConnectionPoint;
  58862. protected _buildBlock(state: NodeMaterialBuildState): this;
  58863. protected _dumpPropertiesCode(): string;
  58864. serialize(): any;
  58865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58866. }
  58867. }
  58868. declare module BABYLON {
  58869. /**
  58870. * Block used to apply a cross product between 2 vectors
  58871. */
  58872. export class CrossBlock extends NodeMaterialBlock {
  58873. /**
  58874. * Creates a new CrossBlock
  58875. * @param name defines the block name
  58876. */
  58877. constructor(name: string);
  58878. /**
  58879. * Gets the current class name
  58880. * @returns the class name
  58881. */
  58882. getClassName(): string;
  58883. /**
  58884. * Gets the left operand input component
  58885. */
  58886. get left(): NodeMaterialConnectionPoint;
  58887. /**
  58888. * Gets the right operand input component
  58889. */
  58890. get right(): NodeMaterialConnectionPoint;
  58891. /**
  58892. * Gets the output component
  58893. */
  58894. get output(): NodeMaterialConnectionPoint;
  58895. protected _buildBlock(state: NodeMaterialBuildState): this;
  58896. }
  58897. }
  58898. declare module BABYLON {
  58899. /**
  58900. * Block used to apply a dot product between 2 vectors
  58901. */
  58902. export class DotBlock extends NodeMaterialBlock {
  58903. /**
  58904. * Creates a new DotBlock
  58905. * @param name defines the block name
  58906. */
  58907. constructor(name: string);
  58908. /**
  58909. * Gets the current class name
  58910. * @returns the class name
  58911. */
  58912. getClassName(): string;
  58913. /**
  58914. * Gets the left operand input component
  58915. */
  58916. get left(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the right operand input component
  58919. */
  58920. get right(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the output component
  58923. */
  58924. get output(): NodeMaterialConnectionPoint;
  58925. protected _buildBlock(state: NodeMaterialBuildState): this;
  58926. }
  58927. }
  58928. declare module BABYLON {
  58929. /**
  58930. * Block used to remap a float from a range to a new one
  58931. */
  58932. export class RemapBlock extends NodeMaterialBlock {
  58933. /**
  58934. * Gets or sets the source range
  58935. */
  58936. sourceRange: Vector2;
  58937. /**
  58938. * Gets or sets the target range
  58939. */
  58940. targetRange: Vector2;
  58941. /**
  58942. * Creates a new RemapBlock
  58943. * @param name defines the block name
  58944. */
  58945. constructor(name: string);
  58946. /**
  58947. * Gets the current class name
  58948. * @returns the class name
  58949. */
  58950. getClassName(): string;
  58951. /**
  58952. * Gets the input component
  58953. */
  58954. get input(): NodeMaterialConnectionPoint;
  58955. /**
  58956. * Gets the source min input component
  58957. */
  58958. get sourceMin(): NodeMaterialConnectionPoint;
  58959. /**
  58960. * Gets the source max input component
  58961. */
  58962. get sourceMax(): NodeMaterialConnectionPoint;
  58963. /**
  58964. * Gets the target min input component
  58965. */
  58966. get targetMin(): NodeMaterialConnectionPoint;
  58967. /**
  58968. * Gets the target max input component
  58969. */
  58970. get targetMax(): NodeMaterialConnectionPoint;
  58971. /**
  58972. * Gets the output component
  58973. */
  58974. get output(): NodeMaterialConnectionPoint;
  58975. protected _buildBlock(state: NodeMaterialBuildState): this;
  58976. protected _dumpPropertiesCode(): string;
  58977. serialize(): any;
  58978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58979. }
  58980. }
  58981. declare module BABYLON {
  58982. /**
  58983. * Block used to normalize a vector
  58984. */
  58985. export class NormalizeBlock extends NodeMaterialBlock {
  58986. /**
  58987. * Creates a new NormalizeBlock
  58988. * @param name defines the block name
  58989. */
  58990. constructor(name: string);
  58991. /**
  58992. * Gets the current class name
  58993. * @returns the class name
  58994. */
  58995. getClassName(): string;
  58996. /**
  58997. * Gets the input component
  58998. */
  58999. get input(): NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the output component
  59002. */
  59003. get output(): NodeMaterialConnectionPoint;
  59004. protected _buildBlock(state: NodeMaterialBuildState): this;
  59005. }
  59006. }
  59007. declare module BABYLON {
  59008. /**
  59009. * Operations supported by the Trigonometry block
  59010. */
  59011. export enum TrigonometryBlockOperations {
  59012. /** Cos */
  59013. Cos = 0,
  59014. /** Sin */
  59015. Sin = 1,
  59016. /** Abs */
  59017. Abs = 2,
  59018. /** Exp */
  59019. Exp = 3,
  59020. /** Exp2 */
  59021. Exp2 = 4,
  59022. /** Round */
  59023. Round = 5,
  59024. /** Floor */
  59025. Floor = 6,
  59026. /** Ceiling */
  59027. Ceiling = 7,
  59028. /** Square root */
  59029. Sqrt = 8,
  59030. /** Log */
  59031. Log = 9,
  59032. /** Tangent */
  59033. Tan = 10,
  59034. /** Arc tangent */
  59035. ArcTan = 11,
  59036. /** Arc cosinus */
  59037. ArcCos = 12,
  59038. /** Arc sinus */
  59039. ArcSin = 13,
  59040. /** Fraction */
  59041. Fract = 14,
  59042. /** Sign */
  59043. Sign = 15,
  59044. /** To radians (from degrees) */
  59045. Radians = 16,
  59046. /** To degrees (from radians) */
  59047. Degrees = 17
  59048. }
  59049. /**
  59050. * Block used to apply trigonometry operation to floats
  59051. */
  59052. export class TrigonometryBlock extends NodeMaterialBlock {
  59053. /**
  59054. * Gets or sets the operation applied by the block
  59055. */
  59056. operation: TrigonometryBlockOperations;
  59057. /**
  59058. * Creates a new TrigonometryBlock
  59059. * @param name defines the block name
  59060. */
  59061. constructor(name: string);
  59062. /**
  59063. * Gets the current class name
  59064. * @returns the class name
  59065. */
  59066. getClassName(): string;
  59067. /**
  59068. * Gets the input component
  59069. */
  59070. get input(): NodeMaterialConnectionPoint;
  59071. /**
  59072. * Gets the output component
  59073. */
  59074. get output(): NodeMaterialConnectionPoint;
  59075. protected _buildBlock(state: NodeMaterialBuildState): this;
  59076. serialize(): any;
  59077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59078. protected _dumpPropertiesCode(): string;
  59079. }
  59080. }
  59081. declare module BABYLON {
  59082. /**
  59083. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59084. */
  59085. export class ColorMergerBlock extends NodeMaterialBlock {
  59086. /**
  59087. * Create a new ColorMergerBlock
  59088. * @param name defines the block name
  59089. */
  59090. constructor(name: string);
  59091. /**
  59092. * Gets the current class name
  59093. * @returns the class name
  59094. */
  59095. getClassName(): string;
  59096. /**
  59097. * Gets the rgb component (input)
  59098. */
  59099. get rgbIn(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the r component (input)
  59102. */
  59103. get r(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the g component (input)
  59106. */
  59107. get g(): NodeMaterialConnectionPoint;
  59108. /**
  59109. * Gets the b component (input)
  59110. */
  59111. get b(): NodeMaterialConnectionPoint;
  59112. /**
  59113. * Gets the a component (input)
  59114. */
  59115. get a(): NodeMaterialConnectionPoint;
  59116. /**
  59117. * Gets the rgba component (output)
  59118. */
  59119. get rgba(): NodeMaterialConnectionPoint;
  59120. /**
  59121. * Gets the rgb component (output)
  59122. */
  59123. get rgbOut(): NodeMaterialConnectionPoint;
  59124. /**
  59125. * Gets the rgb component (output)
  59126. * @deprecated Please use rgbOut instead.
  59127. */
  59128. get rgb(): NodeMaterialConnectionPoint;
  59129. protected _buildBlock(state: NodeMaterialBuildState): this;
  59130. }
  59131. }
  59132. declare module BABYLON {
  59133. /**
  59134. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59135. */
  59136. export class VectorMergerBlock extends NodeMaterialBlock {
  59137. /**
  59138. * Create a new VectorMergerBlock
  59139. * @param name defines the block name
  59140. */
  59141. constructor(name: string);
  59142. /**
  59143. * Gets the current class name
  59144. * @returns the class name
  59145. */
  59146. getClassName(): string;
  59147. /**
  59148. * Gets the xyz component (input)
  59149. */
  59150. get xyzIn(): NodeMaterialConnectionPoint;
  59151. /**
  59152. * Gets the xy component (input)
  59153. */
  59154. get xyIn(): NodeMaterialConnectionPoint;
  59155. /**
  59156. * Gets the x component (input)
  59157. */
  59158. get x(): NodeMaterialConnectionPoint;
  59159. /**
  59160. * Gets the y component (input)
  59161. */
  59162. get y(): NodeMaterialConnectionPoint;
  59163. /**
  59164. * Gets the z component (input)
  59165. */
  59166. get z(): NodeMaterialConnectionPoint;
  59167. /**
  59168. * Gets the w component (input)
  59169. */
  59170. get w(): NodeMaterialConnectionPoint;
  59171. /**
  59172. * Gets the xyzw component (output)
  59173. */
  59174. get xyzw(): NodeMaterialConnectionPoint;
  59175. /**
  59176. * Gets the xyz component (output)
  59177. */
  59178. get xyzOut(): NodeMaterialConnectionPoint;
  59179. /**
  59180. * Gets the xy component (output)
  59181. */
  59182. get xyOut(): NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the xy component (output)
  59185. * @deprecated Please use xyOut instead.
  59186. */
  59187. get xy(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the xyz component (output)
  59190. * @deprecated Please use xyzOut instead.
  59191. */
  59192. get xyz(): NodeMaterialConnectionPoint;
  59193. protected _buildBlock(state: NodeMaterialBuildState): this;
  59194. }
  59195. }
  59196. declare module BABYLON {
  59197. /**
  59198. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59199. */
  59200. export class ColorSplitterBlock extends NodeMaterialBlock {
  59201. /**
  59202. * Create a new ColorSplitterBlock
  59203. * @param name defines the block name
  59204. */
  59205. constructor(name: string);
  59206. /**
  59207. * Gets the current class name
  59208. * @returns the class name
  59209. */
  59210. getClassName(): string;
  59211. /**
  59212. * Gets the rgba component (input)
  59213. */
  59214. get rgba(): NodeMaterialConnectionPoint;
  59215. /**
  59216. * Gets the rgb component (input)
  59217. */
  59218. get rgbIn(): NodeMaterialConnectionPoint;
  59219. /**
  59220. * Gets the rgb component (output)
  59221. */
  59222. get rgbOut(): NodeMaterialConnectionPoint;
  59223. /**
  59224. * Gets the r component (output)
  59225. */
  59226. get r(): NodeMaterialConnectionPoint;
  59227. /**
  59228. * Gets the g component (output)
  59229. */
  59230. get g(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the b component (output)
  59233. */
  59234. get b(): NodeMaterialConnectionPoint;
  59235. /**
  59236. * Gets the a component (output)
  59237. */
  59238. get a(): NodeMaterialConnectionPoint;
  59239. protected _inputRename(name: string): string;
  59240. protected _outputRename(name: string): string;
  59241. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59242. }
  59243. }
  59244. declare module BABYLON {
  59245. /**
  59246. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59247. */
  59248. export class VectorSplitterBlock extends NodeMaterialBlock {
  59249. /**
  59250. * Create a new VectorSplitterBlock
  59251. * @param name defines the block name
  59252. */
  59253. constructor(name: string);
  59254. /**
  59255. * Gets the current class name
  59256. * @returns the class name
  59257. */
  59258. getClassName(): string;
  59259. /**
  59260. * Gets the xyzw component (input)
  59261. */
  59262. get xyzw(): NodeMaterialConnectionPoint;
  59263. /**
  59264. * Gets the xyz component (input)
  59265. */
  59266. get xyzIn(): NodeMaterialConnectionPoint;
  59267. /**
  59268. * Gets the xy component (input)
  59269. */
  59270. get xyIn(): NodeMaterialConnectionPoint;
  59271. /**
  59272. * Gets the xyz component (output)
  59273. */
  59274. get xyzOut(): NodeMaterialConnectionPoint;
  59275. /**
  59276. * Gets the xy component (output)
  59277. */
  59278. get xyOut(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the x component (output)
  59281. */
  59282. get x(): NodeMaterialConnectionPoint;
  59283. /**
  59284. * Gets the y component (output)
  59285. */
  59286. get y(): NodeMaterialConnectionPoint;
  59287. /**
  59288. * Gets the z component (output)
  59289. */
  59290. get z(): NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the w component (output)
  59293. */
  59294. get w(): NodeMaterialConnectionPoint;
  59295. protected _inputRename(name: string): string;
  59296. protected _outputRename(name: string): string;
  59297. protected _buildBlock(state: NodeMaterialBuildState): this;
  59298. }
  59299. }
  59300. declare module BABYLON {
  59301. /**
  59302. * Block used to lerp between 2 values
  59303. */
  59304. export class LerpBlock extends NodeMaterialBlock {
  59305. /**
  59306. * Creates a new LerpBlock
  59307. * @param name defines the block name
  59308. */
  59309. constructor(name: string);
  59310. /**
  59311. * Gets the current class name
  59312. * @returns the class name
  59313. */
  59314. getClassName(): string;
  59315. /**
  59316. * Gets the left operand input component
  59317. */
  59318. get left(): NodeMaterialConnectionPoint;
  59319. /**
  59320. * Gets the right operand input component
  59321. */
  59322. get right(): NodeMaterialConnectionPoint;
  59323. /**
  59324. * Gets the gradient operand input component
  59325. */
  59326. get gradient(): NodeMaterialConnectionPoint;
  59327. /**
  59328. * Gets the output component
  59329. */
  59330. get output(): NodeMaterialConnectionPoint;
  59331. protected _buildBlock(state: NodeMaterialBuildState): this;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /**
  59336. * Block used to divide 2 vectors
  59337. */
  59338. export class DivideBlock extends NodeMaterialBlock {
  59339. /**
  59340. * Creates a new DivideBlock
  59341. * @param name defines the block name
  59342. */
  59343. constructor(name: string);
  59344. /**
  59345. * Gets the current class name
  59346. * @returns the class name
  59347. */
  59348. getClassName(): string;
  59349. /**
  59350. * Gets the left operand input component
  59351. */
  59352. get left(): NodeMaterialConnectionPoint;
  59353. /**
  59354. * Gets the right operand input component
  59355. */
  59356. get right(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the output component
  59359. */
  59360. get output(): NodeMaterialConnectionPoint;
  59361. protected _buildBlock(state: NodeMaterialBuildState): this;
  59362. }
  59363. }
  59364. declare module BABYLON {
  59365. /**
  59366. * Block used to subtract 2 vectors
  59367. */
  59368. export class SubtractBlock extends NodeMaterialBlock {
  59369. /**
  59370. * Creates a new SubtractBlock
  59371. * @param name defines the block name
  59372. */
  59373. constructor(name: string);
  59374. /**
  59375. * Gets the current class name
  59376. * @returns the class name
  59377. */
  59378. getClassName(): string;
  59379. /**
  59380. * Gets the left operand input component
  59381. */
  59382. get left(): NodeMaterialConnectionPoint;
  59383. /**
  59384. * Gets the right operand input component
  59385. */
  59386. get right(): NodeMaterialConnectionPoint;
  59387. /**
  59388. * Gets the output component
  59389. */
  59390. get output(): NodeMaterialConnectionPoint;
  59391. protected _buildBlock(state: NodeMaterialBuildState): this;
  59392. }
  59393. }
  59394. declare module BABYLON {
  59395. /**
  59396. * Block used to step a value
  59397. */
  59398. export class StepBlock extends NodeMaterialBlock {
  59399. /**
  59400. * Creates a new StepBlock
  59401. * @param name defines the block name
  59402. */
  59403. constructor(name: string);
  59404. /**
  59405. * Gets the current class name
  59406. * @returns the class name
  59407. */
  59408. getClassName(): string;
  59409. /**
  59410. * Gets the value operand input component
  59411. */
  59412. get value(): NodeMaterialConnectionPoint;
  59413. /**
  59414. * Gets the edge operand input component
  59415. */
  59416. get edge(): NodeMaterialConnectionPoint;
  59417. /**
  59418. * Gets the output component
  59419. */
  59420. get output(): NodeMaterialConnectionPoint;
  59421. protected _buildBlock(state: NodeMaterialBuildState): this;
  59422. }
  59423. }
  59424. declare module BABYLON {
  59425. /**
  59426. * Block used to get the opposite (1 - x) of a value
  59427. */
  59428. export class OneMinusBlock extends NodeMaterialBlock {
  59429. /**
  59430. * Creates a new OneMinusBlock
  59431. * @param name defines the block name
  59432. */
  59433. constructor(name: string);
  59434. /**
  59435. * Gets the current class name
  59436. * @returns the class name
  59437. */
  59438. getClassName(): string;
  59439. /**
  59440. * Gets the input component
  59441. */
  59442. get input(): NodeMaterialConnectionPoint;
  59443. /**
  59444. * Gets the output component
  59445. */
  59446. get output(): NodeMaterialConnectionPoint;
  59447. protected _buildBlock(state: NodeMaterialBuildState): this;
  59448. }
  59449. }
  59450. declare module BABYLON {
  59451. /**
  59452. * Block used to get the view direction
  59453. */
  59454. export class ViewDirectionBlock extends NodeMaterialBlock {
  59455. /**
  59456. * Creates a new ViewDirectionBlock
  59457. * @param name defines the block name
  59458. */
  59459. constructor(name: string);
  59460. /**
  59461. * Gets the current class name
  59462. * @returns the class name
  59463. */
  59464. getClassName(): string;
  59465. /**
  59466. * Gets the world position component
  59467. */
  59468. get worldPosition(): NodeMaterialConnectionPoint;
  59469. /**
  59470. * Gets the camera position component
  59471. */
  59472. get cameraPosition(): NodeMaterialConnectionPoint;
  59473. /**
  59474. * Gets the output component
  59475. */
  59476. get output(): NodeMaterialConnectionPoint;
  59477. autoConfigure(material: NodeMaterial): void;
  59478. protected _buildBlock(state: NodeMaterialBuildState): this;
  59479. }
  59480. }
  59481. declare module BABYLON {
  59482. /**
  59483. * Block used to compute fresnel value
  59484. */
  59485. export class FresnelBlock extends NodeMaterialBlock {
  59486. /**
  59487. * Create a new FresnelBlock
  59488. * @param name defines the block name
  59489. */
  59490. constructor(name: string);
  59491. /**
  59492. * Gets the current class name
  59493. * @returns the class name
  59494. */
  59495. getClassName(): string;
  59496. /**
  59497. * Gets the world normal input component
  59498. */
  59499. get worldNormal(): NodeMaterialConnectionPoint;
  59500. /**
  59501. * Gets the view direction input component
  59502. */
  59503. get viewDirection(): NodeMaterialConnectionPoint;
  59504. /**
  59505. * Gets the bias input component
  59506. */
  59507. get bias(): NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the camera (or eye) position component
  59510. */
  59511. get power(): NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the fresnel output component
  59514. */
  59515. get fresnel(): NodeMaterialConnectionPoint;
  59516. autoConfigure(material: NodeMaterial): void;
  59517. protected _buildBlock(state: NodeMaterialBuildState): this;
  59518. }
  59519. }
  59520. declare module BABYLON {
  59521. /**
  59522. * Block used to get the max of 2 values
  59523. */
  59524. export class MaxBlock extends NodeMaterialBlock {
  59525. /**
  59526. * Creates a new MaxBlock
  59527. * @param name defines the block name
  59528. */
  59529. constructor(name: string);
  59530. /**
  59531. * Gets the current class name
  59532. * @returns the class name
  59533. */
  59534. getClassName(): string;
  59535. /**
  59536. * Gets the left operand input component
  59537. */
  59538. get left(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the right operand input component
  59541. */
  59542. get right(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the output component
  59545. */
  59546. get output(): NodeMaterialConnectionPoint;
  59547. protected _buildBlock(state: NodeMaterialBuildState): this;
  59548. }
  59549. }
  59550. declare module BABYLON {
  59551. /**
  59552. * Block used to get the min of 2 values
  59553. */
  59554. export class MinBlock extends NodeMaterialBlock {
  59555. /**
  59556. * Creates a new MinBlock
  59557. * @param name defines the block name
  59558. */
  59559. constructor(name: string);
  59560. /**
  59561. * Gets the current class name
  59562. * @returns the class name
  59563. */
  59564. getClassName(): string;
  59565. /**
  59566. * Gets the left operand input component
  59567. */
  59568. get left(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the right operand input component
  59571. */
  59572. get right(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the output component
  59575. */
  59576. get output(): NodeMaterialConnectionPoint;
  59577. protected _buildBlock(state: NodeMaterialBuildState): this;
  59578. }
  59579. }
  59580. declare module BABYLON {
  59581. /**
  59582. * Block used to get the distance between 2 values
  59583. */
  59584. export class DistanceBlock extends NodeMaterialBlock {
  59585. /**
  59586. * Creates a new DistanceBlock
  59587. * @param name defines the block name
  59588. */
  59589. constructor(name: string);
  59590. /**
  59591. * Gets the current class name
  59592. * @returns the class name
  59593. */
  59594. getClassName(): string;
  59595. /**
  59596. * Gets the left operand input component
  59597. */
  59598. get left(): NodeMaterialConnectionPoint;
  59599. /**
  59600. * Gets the right operand input component
  59601. */
  59602. get right(): NodeMaterialConnectionPoint;
  59603. /**
  59604. * Gets the output component
  59605. */
  59606. get output(): NodeMaterialConnectionPoint;
  59607. protected _buildBlock(state: NodeMaterialBuildState): this;
  59608. }
  59609. }
  59610. declare module BABYLON {
  59611. /**
  59612. * Block used to get the length of a vector
  59613. */
  59614. export class LengthBlock extends NodeMaterialBlock {
  59615. /**
  59616. * Creates a new LengthBlock
  59617. * @param name defines the block name
  59618. */
  59619. constructor(name: string);
  59620. /**
  59621. * Gets the current class name
  59622. * @returns the class name
  59623. */
  59624. getClassName(): string;
  59625. /**
  59626. * Gets the value input component
  59627. */
  59628. get value(): NodeMaterialConnectionPoint;
  59629. /**
  59630. * Gets the output component
  59631. */
  59632. get output(): NodeMaterialConnectionPoint;
  59633. protected _buildBlock(state: NodeMaterialBuildState): this;
  59634. }
  59635. }
  59636. declare module BABYLON {
  59637. /**
  59638. * Block used to get negative version of a value (i.e. x * -1)
  59639. */
  59640. export class NegateBlock extends NodeMaterialBlock {
  59641. /**
  59642. * Creates a new NegateBlock
  59643. * @param name defines the block name
  59644. */
  59645. constructor(name: string);
  59646. /**
  59647. * Gets the current class name
  59648. * @returns the class name
  59649. */
  59650. getClassName(): string;
  59651. /**
  59652. * Gets the value input component
  59653. */
  59654. get value(): NodeMaterialConnectionPoint;
  59655. /**
  59656. * Gets the output component
  59657. */
  59658. get output(): NodeMaterialConnectionPoint;
  59659. protected _buildBlock(state: NodeMaterialBuildState): this;
  59660. }
  59661. }
  59662. declare module BABYLON {
  59663. /**
  59664. * Block used to get the value of the first parameter raised to the power of the second
  59665. */
  59666. export class PowBlock extends NodeMaterialBlock {
  59667. /**
  59668. * Creates a new PowBlock
  59669. * @param name defines the block name
  59670. */
  59671. constructor(name: string);
  59672. /**
  59673. * Gets the current class name
  59674. * @returns the class name
  59675. */
  59676. getClassName(): string;
  59677. /**
  59678. * Gets the value operand input component
  59679. */
  59680. get value(): NodeMaterialConnectionPoint;
  59681. /**
  59682. * Gets the power operand input component
  59683. */
  59684. get power(): NodeMaterialConnectionPoint;
  59685. /**
  59686. * Gets the output component
  59687. */
  59688. get output(): NodeMaterialConnectionPoint;
  59689. protected _buildBlock(state: NodeMaterialBuildState): this;
  59690. }
  59691. }
  59692. declare module BABYLON {
  59693. /**
  59694. * Block used to get a random number
  59695. */
  59696. export class RandomNumberBlock extends NodeMaterialBlock {
  59697. /**
  59698. * Creates a new RandomNumberBlock
  59699. * @param name defines the block name
  59700. */
  59701. constructor(name: string);
  59702. /**
  59703. * Gets the current class name
  59704. * @returns the class name
  59705. */
  59706. getClassName(): string;
  59707. /**
  59708. * Gets the seed input component
  59709. */
  59710. get seed(): NodeMaterialConnectionPoint;
  59711. /**
  59712. * Gets the output component
  59713. */
  59714. get output(): NodeMaterialConnectionPoint;
  59715. protected _buildBlock(state: NodeMaterialBuildState): this;
  59716. }
  59717. }
  59718. declare module BABYLON {
  59719. /**
  59720. * Block used to compute arc tangent of 2 values
  59721. */
  59722. export class ArcTan2Block extends NodeMaterialBlock {
  59723. /**
  59724. * Creates a new ArcTan2Block
  59725. * @param name defines the block name
  59726. */
  59727. constructor(name: string);
  59728. /**
  59729. * Gets the current class name
  59730. * @returns the class name
  59731. */
  59732. getClassName(): string;
  59733. /**
  59734. * Gets the x operand input component
  59735. */
  59736. get x(): NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the y operand input component
  59739. */
  59740. get y(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the output component
  59743. */
  59744. get output(): NodeMaterialConnectionPoint;
  59745. protected _buildBlock(state: NodeMaterialBuildState): this;
  59746. }
  59747. }
  59748. declare module BABYLON {
  59749. /**
  59750. * Block used to smooth step a value
  59751. */
  59752. export class SmoothStepBlock extends NodeMaterialBlock {
  59753. /**
  59754. * Creates a new SmoothStepBlock
  59755. * @param name defines the block name
  59756. */
  59757. constructor(name: string);
  59758. /**
  59759. * Gets the current class name
  59760. * @returns the class name
  59761. */
  59762. getClassName(): string;
  59763. /**
  59764. * Gets the value operand input component
  59765. */
  59766. get value(): NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the first edge operand input component
  59769. */
  59770. get edge0(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the second edge operand input component
  59773. */
  59774. get edge1(): NodeMaterialConnectionPoint;
  59775. /**
  59776. * Gets the output component
  59777. */
  59778. get output(): NodeMaterialConnectionPoint;
  59779. protected _buildBlock(state: NodeMaterialBuildState): this;
  59780. }
  59781. }
  59782. declare module BABYLON {
  59783. /**
  59784. * Block used to get the reciprocal (1 / x) of a value
  59785. */
  59786. export class ReciprocalBlock extends NodeMaterialBlock {
  59787. /**
  59788. * Creates a new ReciprocalBlock
  59789. * @param name defines the block name
  59790. */
  59791. constructor(name: string);
  59792. /**
  59793. * Gets the current class name
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Gets the input component
  59799. */
  59800. get input(): NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the output component
  59803. */
  59804. get output(): NodeMaterialConnectionPoint;
  59805. protected _buildBlock(state: NodeMaterialBuildState): this;
  59806. }
  59807. }
  59808. declare module BABYLON {
  59809. /**
  59810. * Block used to replace a color by another one
  59811. */
  59812. export class ReplaceColorBlock extends NodeMaterialBlock {
  59813. /**
  59814. * Creates a new ReplaceColorBlock
  59815. * @param name defines the block name
  59816. */
  59817. constructor(name: string);
  59818. /**
  59819. * Gets the current class name
  59820. * @returns the class name
  59821. */
  59822. getClassName(): string;
  59823. /**
  59824. * Gets the value input component
  59825. */
  59826. get value(): NodeMaterialConnectionPoint;
  59827. /**
  59828. * Gets the reference input component
  59829. */
  59830. get reference(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the distance input component
  59833. */
  59834. get distance(): NodeMaterialConnectionPoint;
  59835. /**
  59836. * Gets the replacement input component
  59837. */
  59838. get replacement(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the output component
  59841. */
  59842. get output(): NodeMaterialConnectionPoint;
  59843. protected _buildBlock(state: NodeMaterialBuildState): this;
  59844. }
  59845. }
  59846. declare module BABYLON {
  59847. /**
  59848. * Block used to posterize a value
  59849. * @see https://en.wikipedia.org/wiki/Posterization
  59850. */
  59851. export class PosterizeBlock extends NodeMaterialBlock {
  59852. /**
  59853. * Creates a new PosterizeBlock
  59854. * @param name defines the block name
  59855. */
  59856. constructor(name: string);
  59857. /**
  59858. * Gets the current class name
  59859. * @returns the class name
  59860. */
  59861. getClassName(): string;
  59862. /**
  59863. * Gets the value input component
  59864. */
  59865. get value(): NodeMaterialConnectionPoint;
  59866. /**
  59867. * Gets the steps input component
  59868. */
  59869. get steps(): NodeMaterialConnectionPoint;
  59870. /**
  59871. * Gets the output component
  59872. */
  59873. get output(): NodeMaterialConnectionPoint;
  59874. protected _buildBlock(state: NodeMaterialBuildState): this;
  59875. }
  59876. }
  59877. declare module BABYLON {
  59878. /**
  59879. * Operations supported by the Wave block
  59880. */
  59881. export enum WaveBlockKind {
  59882. /** SawTooth */
  59883. SawTooth = 0,
  59884. /** Square */
  59885. Square = 1,
  59886. /** Triangle */
  59887. Triangle = 2
  59888. }
  59889. /**
  59890. * Block used to apply wave operation to floats
  59891. */
  59892. export class WaveBlock extends NodeMaterialBlock {
  59893. /**
  59894. * Gets or sets the kibnd of wave to be applied by the block
  59895. */
  59896. kind: WaveBlockKind;
  59897. /**
  59898. * Creates a new WaveBlock
  59899. * @param name defines the block name
  59900. */
  59901. constructor(name: string);
  59902. /**
  59903. * Gets the current class name
  59904. * @returns the class name
  59905. */
  59906. getClassName(): string;
  59907. /**
  59908. * Gets the input component
  59909. */
  59910. get input(): NodeMaterialConnectionPoint;
  59911. /**
  59912. * Gets the output component
  59913. */
  59914. get output(): NodeMaterialConnectionPoint;
  59915. protected _buildBlock(state: NodeMaterialBuildState): this;
  59916. serialize(): any;
  59917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59918. }
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * Class used to store a color step for the GradientBlock
  59923. */
  59924. export class GradientBlockColorStep {
  59925. /**
  59926. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59927. */
  59928. step: number;
  59929. /**
  59930. * Gets or sets the color associated with this step
  59931. */
  59932. color: Color3;
  59933. /**
  59934. * Creates a new GradientBlockColorStep
  59935. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59936. * @param color defines the color associated with this step
  59937. */
  59938. constructor(
  59939. /**
  59940. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59941. */
  59942. step: number,
  59943. /**
  59944. * Gets or sets the color associated with this step
  59945. */
  59946. color: Color3);
  59947. }
  59948. /**
  59949. * Block used to return a color from a gradient based on an input value between 0 and 1
  59950. */
  59951. export class GradientBlock extends NodeMaterialBlock {
  59952. /**
  59953. * Gets or sets the list of color steps
  59954. */
  59955. colorSteps: GradientBlockColorStep[];
  59956. /**
  59957. * Creates a new GradientBlock
  59958. * @param name defines the block name
  59959. */
  59960. constructor(name: string);
  59961. /**
  59962. * Gets the current class name
  59963. * @returns the class name
  59964. */
  59965. getClassName(): string;
  59966. /**
  59967. * Gets the gradient input component
  59968. */
  59969. get gradient(): NodeMaterialConnectionPoint;
  59970. /**
  59971. * Gets the output component
  59972. */
  59973. get output(): NodeMaterialConnectionPoint;
  59974. private _writeColorConstant;
  59975. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59976. serialize(): any;
  59977. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59978. protected _dumpPropertiesCode(): string;
  59979. }
  59980. }
  59981. declare module BABYLON {
  59982. /**
  59983. * Block used to normalize lerp between 2 values
  59984. */
  59985. export class NLerpBlock extends NodeMaterialBlock {
  59986. /**
  59987. * Creates a new NLerpBlock
  59988. * @param name defines the block name
  59989. */
  59990. constructor(name: string);
  59991. /**
  59992. * Gets the current class name
  59993. * @returns the class name
  59994. */
  59995. getClassName(): string;
  59996. /**
  59997. * Gets the left operand input component
  59998. */
  59999. get left(): NodeMaterialConnectionPoint;
  60000. /**
  60001. * Gets the right operand input component
  60002. */
  60003. get right(): NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the gradient operand input component
  60006. */
  60007. get gradient(): NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the output component
  60010. */
  60011. get output(): NodeMaterialConnectionPoint;
  60012. protected _buildBlock(state: NodeMaterialBuildState): this;
  60013. }
  60014. }
  60015. declare module BABYLON {
  60016. /**
  60017. * block used to Generate a Worley Noise 3D Noise Pattern
  60018. */
  60019. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60020. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60021. manhattanDistance: boolean;
  60022. /**
  60023. * Creates a new WorleyNoise3DBlock
  60024. * @param name defines the block name
  60025. */
  60026. constructor(name: string);
  60027. /**
  60028. * Gets the current class name
  60029. * @returns the class name
  60030. */
  60031. getClassName(): string;
  60032. /**
  60033. * Gets the seed input component
  60034. */
  60035. get seed(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the jitter input component
  60038. */
  60039. get jitter(): NodeMaterialConnectionPoint;
  60040. /**
  60041. * Gets the output component
  60042. */
  60043. get output(): NodeMaterialConnectionPoint;
  60044. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60045. /**
  60046. * Exposes the properties to the UI?
  60047. */
  60048. protected _dumpPropertiesCode(): string;
  60049. /**
  60050. * Exposes the properties to the Seralize?
  60051. */
  60052. serialize(): any;
  60053. /**
  60054. * Exposes the properties to the deseralize?
  60055. */
  60056. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60057. }
  60058. }
  60059. declare module BABYLON {
  60060. /**
  60061. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60062. */
  60063. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60064. /**
  60065. * Creates a new SimplexPerlin3DBlock
  60066. * @param name defines the block name
  60067. */
  60068. constructor(name: string);
  60069. /**
  60070. * Gets the current class name
  60071. * @returns the class name
  60072. */
  60073. getClassName(): string;
  60074. /**
  60075. * Gets the seed operand input component
  60076. */
  60077. get seed(): NodeMaterialConnectionPoint;
  60078. /**
  60079. * Gets the output component
  60080. */
  60081. get output(): NodeMaterialConnectionPoint;
  60082. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60083. }
  60084. }
  60085. declare module BABYLON {
  60086. /**
  60087. * Block used to blend normals
  60088. */
  60089. export class NormalBlendBlock extends NodeMaterialBlock {
  60090. /**
  60091. * Creates a new NormalBlendBlock
  60092. * @param name defines the block name
  60093. */
  60094. constructor(name: string);
  60095. /**
  60096. * Gets the current class name
  60097. * @returns the class name
  60098. */
  60099. getClassName(): string;
  60100. /**
  60101. * Gets the first input component
  60102. */
  60103. get normalMap0(): NodeMaterialConnectionPoint;
  60104. /**
  60105. * Gets the second input component
  60106. */
  60107. get normalMap1(): NodeMaterialConnectionPoint;
  60108. /**
  60109. * Gets the output component
  60110. */
  60111. get output(): NodeMaterialConnectionPoint;
  60112. protected _buildBlock(state: NodeMaterialBuildState): this;
  60113. }
  60114. }
  60115. declare module BABYLON {
  60116. /**
  60117. * Block used to rotate a 2d vector by a given angle
  60118. */
  60119. export class Rotate2dBlock extends NodeMaterialBlock {
  60120. /**
  60121. * Creates a new Rotate2dBlock
  60122. * @param name defines the block name
  60123. */
  60124. constructor(name: string);
  60125. /**
  60126. * Gets the current class name
  60127. * @returns the class name
  60128. */
  60129. getClassName(): string;
  60130. /**
  60131. * Gets the input vector
  60132. */
  60133. get input(): NodeMaterialConnectionPoint;
  60134. /**
  60135. * Gets the input angle
  60136. */
  60137. get angle(): NodeMaterialConnectionPoint;
  60138. /**
  60139. * Gets the output component
  60140. */
  60141. get output(): NodeMaterialConnectionPoint;
  60142. autoConfigure(material: NodeMaterial): void;
  60143. protected _buildBlock(state: NodeMaterialBuildState): this;
  60144. }
  60145. }
  60146. declare module BABYLON {
  60147. /**
  60148. * Block used to get the reflected vector from a direction and a normal
  60149. */
  60150. export class ReflectBlock extends NodeMaterialBlock {
  60151. /**
  60152. * Creates a new ReflectBlock
  60153. * @param name defines the block name
  60154. */
  60155. constructor(name: string);
  60156. /**
  60157. * Gets the current class name
  60158. * @returns the class name
  60159. */
  60160. getClassName(): string;
  60161. /**
  60162. * Gets the incident component
  60163. */
  60164. get incident(): NodeMaterialConnectionPoint;
  60165. /**
  60166. * Gets the normal component
  60167. */
  60168. get normal(): NodeMaterialConnectionPoint;
  60169. /**
  60170. * Gets the output component
  60171. */
  60172. get output(): NodeMaterialConnectionPoint;
  60173. protected _buildBlock(state: NodeMaterialBuildState): this;
  60174. }
  60175. }
  60176. declare module BABYLON {
  60177. /**
  60178. * Block used to get the refracted vector from a direction and a normal
  60179. */
  60180. export class RefractBlock extends NodeMaterialBlock {
  60181. /**
  60182. * Creates a new RefractBlock
  60183. * @param name defines the block name
  60184. */
  60185. constructor(name: string);
  60186. /**
  60187. * Gets the current class name
  60188. * @returns the class name
  60189. */
  60190. getClassName(): string;
  60191. /**
  60192. * Gets the incident component
  60193. */
  60194. get incident(): NodeMaterialConnectionPoint;
  60195. /**
  60196. * Gets the normal component
  60197. */
  60198. get normal(): NodeMaterialConnectionPoint;
  60199. /**
  60200. * Gets the index of refraction component
  60201. */
  60202. get ior(): NodeMaterialConnectionPoint;
  60203. /**
  60204. * Gets the output component
  60205. */
  60206. get output(): NodeMaterialConnectionPoint;
  60207. protected _buildBlock(state: NodeMaterialBuildState): this;
  60208. }
  60209. }
  60210. declare module BABYLON {
  60211. /**
  60212. * Block used to desaturate a color
  60213. */
  60214. export class DesaturateBlock extends NodeMaterialBlock {
  60215. /**
  60216. * Creates a new DesaturateBlock
  60217. * @param name defines the block name
  60218. */
  60219. constructor(name: string);
  60220. /**
  60221. * Gets the current class name
  60222. * @returns the class name
  60223. */
  60224. getClassName(): string;
  60225. /**
  60226. * Gets the color operand input component
  60227. */
  60228. get color(): NodeMaterialConnectionPoint;
  60229. /**
  60230. * Gets the level operand input component
  60231. */
  60232. get level(): NodeMaterialConnectionPoint;
  60233. /**
  60234. * Gets the output component
  60235. */
  60236. get output(): NodeMaterialConnectionPoint;
  60237. protected _buildBlock(state: NodeMaterialBuildState): this;
  60238. }
  60239. }
  60240. declare module BABYLON {
  60241. /**
  60242. * Effect Render Options
  60243. */
  60244. export interface IEffectRendererOptions {
  60245. /**
  60246. * Defines the vertices positions.
  60247. */
  60248. positions?: number[];
  60249. /**
  60250. * Defines the indices.
  60251. */
  60252. indices?: number[];
  60253. }
  60254. /**
  60255. * Helper class to render one or more effects
  60256. */
  60257. export class EffectRenderer {
  60258. private engine;
  60259. private static _DefaultOptions;
  60260. private _vertexBuffers;
  60261. private _indexBuffer;
  60262. private _ringBufferIndex;
  60263. private _ringScreenBuffer;
  60264. private _fullscreenViewport;
  60265. private _getNextFrameBuffer;
  60266. /**
  60267. * Creates an effect renderer
  60268. * @param engine the engine to use for rendering
  60269. * @param options defines the options of the effect renderer
  60270. */
  60271. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60272. /**
  60273. * Sets the current viewport in normalized coordinates 0-1
  60274. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60275. */
  60276. setViewport(viewport?: Viewport): void;
  60277. /**
  60278. * Binds the embedded attributes buffer to the effect.
  60279. * @param effect Defines the effect to bind the attributes for
  60280. */
  60281. bindBuffers(effect: Effect): void;
  60282. /**
  60283. * Sets the current effect wrapper to use during draw.
  60284. * The effect needs to be ready before calling this api.
  60285. * This also sets the default full screen position attribute.
  60286. * @param effectWrapper Defines the effect to draw with
  60287. */
  60288. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60289. /**
  60290. * Draws a full screen quad.
  60291. */
  60292. draw(): void;
  60293. /**
  60294. * renders one or more effects to a specified texture
  60295. * @param effectWrappers list of effects to renderer
  60296. * @param outputTexture texture to draw to, if null it will render to the screen
  60297. */
  60298. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60299. /**
  60300. * Disposes of the effect renderer
  60301. */
  60302. dispose(): void;
  60303. }
  60304. /**
  60305. * Options to create an EffectWrapper
  60306. */
  60307. interface EffectWrapperCreationOptions {
  60308. /**
  60309. * Engine to use to create the effect
  60310. */
  60311. engine: ThinEngine;
  60312. /**
  60313. * Fragment shader for the effect
  60314. */
  60315. fragmentShader: string;
  60316. /**
  60317. * Vertex shader for the effect
  60318. */
  60319. vertexShader?: string;
  60320. /**
  60321. * Attributes to use in the shader
  60322. */
  60323. attributeNames?: Array<string>;
  60324. /**
  60325. * Uniforms to use in the shader
  60326. */
  60327. uniformNames?: Array<string>;
  60328. /**
  60329. * Texture sampler names to use in the shader
  60330. */
  60331. samplerNames?: Array<string>;
  60332. /**
  60333. * The friendly name of the effect displayed in Spector.
  60334. */
  60335. name?: string;
  60336. }
  60337. /**
  60338. * Wraps an effect to be used for rendering
  60339. */
  60340. export class EffectWrapper {
  60341. /**
  60342. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60343. */
  60344. onApplyObservable: Observable<{}>;
  60345. /**
  60346. * The underlying effect
  60347. */
  60348. effect: Effect;
  60349. /**
  60350. * Creates an effect to be renderer
  60351. * @param creationOptions options to create the effect
  60352. */
  60353. constructor(creationOptions: EffectWrapperCreationOptions);
  60354. /**
  60355. * Disposes of the effect wrapper
  60356. */
  60357. dispose(): void;
  60358. }
  60359. }
  60360. declare module BABYLON {
  60361. /**
  60362. * Helper class to push actions to a pool of workers.
  60363. */
  60364. export class WorkerPool implements IDisposable {
  60365. private _workerInfos;
  60366. private _pendingActions;
  60367. /**
  60368. * Constructor
  60369. * @param workers Array of workers to use for actions
  60370. */
  60371. constructor(workers: Array<Worker>);
  60372. /**
  60373. * Terminates all workers and clears any pending actions.
  60374. */
  60375. dispose(): void;
  60376. /**
  60377. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60378. * pended until a worker has completed its action.
  60379. * @param action The action to perform. Call onComplete when the action is complete.
  60380. */
  60381. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60382. private _execute;
  60383. }
  60384. }
  60385. declare module BABYLON {
  60386. /**
  60387. * Configuration for Draco compression
  60388. */
  60389. export interface IDracoCompressionConfiguration {
  60390. /**
  60391. * Configuration for the decoder.
  60392. */
  60393. decoder: {
  60394. /**
  60395. * The url to the WebAssembly module.
  60396. */
  60397. wasmUrl?: string;
  60398. /**
  60399. * The url to the WebAssembly binary.
  60400. */
  60401. wasmBinaryUrl?: string;
  60402. /**
  60403. * The url to the fallback JavaScript module.
  60404. */
  60405. fallbackUrl?: string;
  60406. };
  60407. }
  60408. /**
  60409. * Draco compression (https://google.github.io/draco/)
  60410. *
  60411. * This class wraps the Draco module.
  60412. *
  60413. * **Encoder**
  60414. *
  60415. * The encoder is not currently implemented.
  60416. *
  60417. * **Decoder**
  60418. *
  60419. * 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.
  60420. *
  60421. * To update the configuration, use the following code:
  60422. * ```javascript
  60423. * DracoCompression.Configuration = {
  60424. * decoder: {
  60425. * wasmUrl: "<url to the WebAssembly library>",
  60426. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60427. * fallbackUrl: "<url to the fallback JavaScript library>",
  60428. * }
  60429. * };
  60430. * ```
  60431. *
  60432. * 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.
  60433. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60434. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60435. *
  60436. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60437. * ```javascript
  60438. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60439. * ```
  60440. *
  60441. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60442. */
  60443. export class DracoCompression implements IDisposable {
  60444. private _workerPoolPromise?;
  60445. private _decoderModulePromise?;
  60446. /**
  60447. * The configuration. Defaults to the following urls:
  60448. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60449. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60450. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60451. */
  60452. static Configuration: IDracoCompressionConfiguration;
  60453. /**
  60454. * Returns true if the decoder configuration is available.
  60455. */
  60456. static get DecoderAvailable(): boolean;
  60457. /**
  60458. * Default number of workers to create when creating the draco compression object.
  60459. */
  60460. static DefaultNumWorkers: number;
  60461. private static GetDefaultNumWorkers;
  60462. private static _Default;
  60463. /**
  60464. * Default instance for the draco compression object.
  60465. */
  60466. static get Default(): DracoCompression;
  60467. /**
  60468. * Constructor
  60469. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60470. */
  60471. constructor(numWorkers?: number);
  60472. /**
  60473. * Stop all async operations and release resources.
  60474. */
  60475. dispose(): void;
  60476. /**
  60477. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60478. * @returns a promise that resolves when ready
  60479. */
  60480. whenReadyAsync(): Promise<void>;
  60481. /**
  60482. * Decode Draco compressed mesh data to vertex data.
  60483. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60484. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60485. * @returns A promise that resolves with the decoded vertex data
  60486. */
  60487. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60488. [kind: string]: number;
  60489. }): Promise<VertexData>;
  60490. }
  60491. }
  60492. declare module BABYLON {
  60493. /**
  60494. * Class for building Constructive Solid Geometry
  60495. */
  60496. export class CSG {
  60497. private polygons;
  60498. /**
  60499. * The world matrix
  60500. */
  60501. matrix: Matrix;
  60502. /**
  60503. * Stores the position
  60504. */
  60505. position: Vector3;
  60506. /**
  60507. * Stores the rotation
  60508. */
  60509. rotation: Vector3;
  60510. /**
  60511. * Stores the rotation quaternion
  60512. */
  60513. rotationQuaternion: Nullable<Quaternion>;
  60514. /**
  60515. * Stores the scaling vector
  60516. */
  60517. scaling: Vector3;
  60518. /**
  60519. * Convert the Mesh to CSG
  60520. * @param mesh The Mesh to convert to CSG
  60521. * @returns A new CSG from the Mesh
  60522. */
  60523. static FromMesh(mesh: Mesh): CSG;
  60524. /**
  60525. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60526. * @param polygons Polygons used to construct a CSG solid
  60527. */
  60528. private static FromPolygons;
  60529. /**
  60530. * Clones, or makes a deep copy, of the CSG
  60531. * @returns A new CSG
  60532. */
  60533. clone(): CSG;
  60534. /**
  60535. * Unions this CSG with another CSG
  60536. * @param csg The CSG to union against this CSG
  60537. * @returns The unioned CSG
  60538. */
  60539. union(csg: CSG): CSG;
  60540. /**
  60541. * Unions this CSG with another CSG in place
  60542. * @param csg The CSG to union against this CSG
  60543. */
  60544. unionInPlace(csg: CSG): void;
  60545. /**
  60546. * Subtracts this CSG with another CSG
  60547. * @param csg The CSG to subtract against this CSG
  60548. * @returns A new CSG
  60549. */
  60550. subtract(csg: CSG): CSG;
  60551. /**
  60552. * Subtracts this CSG with another CSG in place
  60553. * @param csg The CSG to subtact against this CSG
  60554. */
  60555. subtractInPlace(csg: CSG): void;
  60556. /**
  60557. * Intersect this CSG with another CSG
  60558. * @param csg The CSG to intersect against this CSG
  60559. * @returns A new CSG
  60560. */
  60561. intersect(csg: CSG): CSG;
  60562. /**
  60563. * Intersects this CSG with another CSG in place
  60564. * @param csg The CSG to intersect against this CSG
  60565. */
  60566. intersectInPlace(csg: CSG): void;
  60567. /**
  60568. * Return a new CSG solid with solid and empty space switched. This solid is
  60569. * not modified.
  60570. * @returns A new CSG solid with solid and empty space switched
  60571. */
  60572. inverse(): CSG;
  60573. /**
  60574. * Inverses the CSG in place
  60575. */
  60576. inverseInPlace(): void;
  60577. /**
  60578. * This is used to keep meshes transformations so they can be restored
  60579. * when we build back a Babylon Mesh
  60580. * NB : All CSG operations are performed in world coordinates
  60581. * @param csg The CSG to copy the transform attributes from
  60582. * @returns This CSG
  60583. */
  60584. copyTransformAttributes(csg: CSG): CSG;
  60585. /**
  60586. * Build Raw mesh from CSG
  60587. * Coordinates here are in world space
  60588. * @param name The name of the mesh geometry
  60589. * @param scene The Scene
  60590. * @param keepSubMeshes Specifies if the submeshes should be kept
  60591. * @returns A new Mesh
  60592. */
  60593. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60594. /**
  60595. * Build Mesh from CSG taking material and transforms into account
  60596. * @param name The name of the Mesh
  60597. * @param material The material of the Mesh
  60598. * @param scene The Scene
  60599. * @param keepSubMeshes Specifies if submeshes should be kept
  60600. * @returns The new Mesh
  60601. */
  60602. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60603. }
  60604. }
  60605. declare module BABYLON {
  60606. /**
  60607. * Class used to create a trail following a mesh
  60608. */
  60609. export class TrailMesh extends Mesh {
  60610. private _generator;
  60611. private _autoStart;
  60612. private _running;
  60613. private _diameter;
  60614. private _length;
  60615. private _sectionPolygonPointsCount;
  60616. private _sectionVectors;
  60617. private _sectionNormalVectors;
  60618. private _beforeRenderObserver;
  60619. /**
  60620. * @constructor
  60621. * @param name The value used by scene.getMeshByName() to do a lookup.
  60622. * @param generator The mesh or transform node to generate a trail.
  60623. * @param scene The scene to add this mesh to.
  60624. * @param diameter Diameter of trailing mesh. Default is 1.
  60625. * @param length Length of trailing mesh. Default is 60.
  60626. * @param autoStart Automatically start trailing mesh. Default true.
  60627. */
  60628. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60629. /**
  60630. * "TrailMesh"
  60631. * @returns "TrailMesh"
  60632. */
  60633. getClassName(): string;
  60634. private _createMesh;
  60635. /**
  60636. * Start trailing mesh.
  60637. */
  60638. start(): void;
  60639. /**
  60640. * Stop trailing mesh.
  60641. */
  60642. stop(): void;
  60643. /**
  60644. * Update trailing mesh geometry.
  60645. */
  60646. update(): void;
  60647. /**
  60648. * Returns a new TrailMesh object.
  60649. * @param name is a string, the name given to the new mesh
  60650. * @param newGenerator use new generator object for cloned trail mesh
  60651. * @returns a new mesh
  60652. */
  60653. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60654. /**
  60655. * Serializes this trail mesh
  60656. * @param serializationObject object to write serialization to
  60657. */
  60658. serialize(serializationObject: any): void;
  60659. /**
  60660. * Parses a serialized trail mesh
  60661. * @param parsedMesh the serialized mesh
  60662. * @param scene the scene to create the trail mesh in
  60663. * @returns the created trail mesh
  60664. */
  60665. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60666. }
  60667. }
  60668. declare module BABYLON {
  60669. /**
  60670. * Class containing static functions to help procedurally build meshes
  60671. */
  60672. export class TiledBoxBuilder {
  60673. /**
  60674. * Creates a box mesh
  60675. * 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)
  60676. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60678. * * 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
  60679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60680. * @param name defines the name of the mesh
  60681. * @param options defines the options used to create the mesh
  60682. * @param scene defines the hosting scene
  60683. * @returns the box mesh
  60684. */
  60685. static CreateTiledBox(name: string, options: {
  60686. pattern?: number;
  60687. width?: number;
  60688. height?: number;
  60689. depth?: number;
  60690. tileSize?: number;
  60691. tileWidth?: number;
  60692. tileHeight?: number;
  60693. alignHorizontal?: number;
  60694. alignVertical?: number;
  60695. faceUV?: Vector4[];
  60696. faceColors?: Color4[];
  60697. sideOrientation?: number;
  60698. updatable?: boolean;
  60699. }, scene?: Nullable<Scene>): Mesh;
  60700. }
  60701. }
  60702. declare module BABYLON {
  60703. /**
  60704. * Class containing static functions to help procedurally build meshes
  60705. */
  60706. export class TorusKnotBuilder {
  60707. /**
  60708. * Creates a torus knot mesh
  60709. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60710. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60711. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60712. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60714. * * 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
  60715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60716. * @param name defines the name of the mesh
  60717. * @param options defines the options used to create the mesh
  60718. * @param scene defines the hosting scene
  60719. * @returns the torus knot mesh
  60720. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60721. */
  60722. static CreateTorusKnot(name: string, options: {
  60723. radius?: number;
  60724. tube?: number;
  60725. radialSegments?: number;
  60726. tubularSegments?: number;
  60727. p?: number;
  60728. q?: number;
  60729. updatable?: boolean;
  60730. sideOrientation?: number;
  60731. frontUVs?: Vector4;
  60732. backUVs?: Vector4;
  60733. }, scene: any): Mesh;
  60734. }
  60735. }
  60736. declare module BABYLON {
  60737. /**
  60738. * Polygon
  60739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60740. */
  60741. export class Polygon {
  60742. /**
  60743. * Creates a rectangle
  60744. * @param xmin bottom X coord
  60745. * @param ymin bottom Y coord
  60746. * @param xmax top X coord
  60747. * @param ymax top Y coord
  60748. * @returns points that make the resulting rectation
  60749. */
  60750. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60751. /**
  60752. * Creates a circle
  60753. * @param radius radius of circle
  60754. * @param cx scale in x
  60755. * @param cy scale in y
  60756. * @param numberOfSides number of sides that make up the circle
  60757. * @returns points that make the resulting circle
  60758. */
  60759. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60760. /**
  60761. * Creates a polygon from input string
  60762. * @param input Input polygon data
  60763. * @returns the parsed points
  60764. */
  60765. static Parse(input: string): Vector2[];
  60766. /**
  60767. * Starts building a polygon from x and y coordinates
  60768. * @param x x coordinate
  60769. * @param y y coordinate
  60770. * @returns the started path2
  60771. */
  60772. static StartingAt(x: number, y: number): Path2;
  60773. }
  60774. /**
  60775. * Builds a polygon
  60776. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60777. */
  60778. export class PolygonMeshBuilder {
  60779. private _points;
  60780. private _outlinepoints;
  60781. private _holes;
  60782. private _name;
  60783. private _scene;
  60784. private _epoints;
  60785. private _eholes;
  60786. private _addToepoint;
  60787. /**
  60788. * Babylon reference to the earcut plugin.
  60789. */
  60790. bjsEarcut: any;
  60791. /**
  60792. * Creates a PolygonMeshBuilder
  60793. * @param name name of the builder
  60794. * @param contours Path of the polygon
  60795. * @param scene scene to add to when creating the mesh
  60796. * @param earcutInjection can be used to inject your own earcut reference
  60797. */
  60798. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60799. /**
  60800. * Adds a whole within the polygon
  60801. * @param hole Array of points defining the hole
  60802. * @returns this
  60803. */
  60804. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60805. /**
  60806. * Creates the polygon
  60807. * @param updatable If the mesh should be updatable
  60808. * @param depth The depth of the mesh created
  60809. * @returns the created mesh
  60810. */
  60811. build(updatable?: boolean, depth?: number): Mesh;
  60812. /**
  60813. * Creates the polygon
  60814. * @param depth The depth of the mesh created
  60815. * @returns the created VertexData
  60816. */
  60817. buildVertexData(depth?: number): VertexData;
  60818. /**
  60819. * Adds a side to the polygon
  60820. * @param positions points that make the polygon
  60821. * @param normals normals of the polygon
  60822. * @param uvs uvs of the polygon
  60823. * @param indices indices of the polygon
  60824. * @param bounds bounds of the polygon
  60825. * @param points points of the polygon
  60826. * @param depth depth of the polygon
  60827. * @param flip flip of the polygon
  60828. */
  60829. private addSide;
  60830. }
  60831. }
  60832. declare module BABYLON {
  60833. /**
  60834. * Class containing static functions to help procedurally build meshes
  60835. */
  60836. export class PolygonBuilder {
  60837. /**
  60838. * Creates a polygon mesh
  60839. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60840. * * 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
  60841. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60843. * * 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)
  60844. * * Remember you can only change the shape positions, not their number when updating a polygon
  60845. * @param name defines the name of the mesh
  60846. * @param options defines the options used to create the mesh
  60847. * @param scene defines the hosting scene
  60848. * @param earcutInjection can be used to inject your own earcut reference
  60849. * @returns the polygon mesh
  60850. */
  60851. static CreatePolygon(name: string, options: {
  60852. shape: Vector3[];
  60853. holes?: Vector3[][];
  60854. depth?: number;
  60855. faceUV?: Vector4[];
  60856. faceColors?: Color4[];
  60857. updatable?: boolean;
  60858. sideOrientation?: number;
  60859. frontUVs?: Vector4;
  60860. backUVs?: Vector4;
  60861. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60862. /**
  60863. * Creates an extruded polygon mesh, with depth in the Y direction.
  60864. * * 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)
  60865. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60866. * @param name defines the name of the mesh
  60867. * @param options defines the options used to create the mesh
  60868. * @param scene defines the hosting scene
  60869. * @param earcutInjection can be used to inject your own earcut reference
  60870. * @returns the polygon mesh
  60871. */
  60872. static ExtrudePolygon(name: string, options: {
  60873. shape: Vector3[];
  60874. holes?: Vector3[][];
  60875. depth?: number;
  60876. faceUV?: Vector4[];
  60877. faceColors?: Color4[];
  60878. updatable?: boolean;
  60879. sideOrientation?: number;
  60880. frontUVs?: Vector4;
  60881. backUVs?: Vector4;
  60882. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60883. }
  60884. }
  60885. declare module BABYLON {
  60886. /**
  60887. * Class containing static functions to help procedurally build meshes
  60888. */
  60889. export class LatheBuilder {
  60890. /**
  60891. * Creates lathe mesh.
  60892. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60893. * * 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
  60894. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60895. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60896. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60897. * * 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
  60898. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60899. * * 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
  60900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60901. * * 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
  60902. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60904. * @param name defines the name of the mesh
  60905. * @param options defines the options used to create the mesh
  60906. * @param scene defines the hosting scene
  60907. * @returns the lathe mesh
  60908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60909. */
  60910. static CreateLathe(name: string, options: {
  60911. shape: Vector3[];
  60912. radius?: number;
  60913. tessellation?: number;
  60914. clip?: number;
  60915. arc?: number;
  60916. closed?: boolean;
  60917. updatable?: boolean;
  60918. sideOrientation?: number;
  60919. frontUVs?: Vector4;
  60920. backUVs?: Vector4;
  60921. cap?: number;
  60922. invertUV?: boolean;
  60923. }, scene?: Nullable<Scene>): Mesh;
  60924. }
  60925. }
  60926. declare module BABYLON {
  60927. /**
  60928. * Class containing static functions to help procedurally build meshes
  60929. */
  60930. export class TiledPlaneBuilder {
  60931. /**
  60932. * Creates a tiled plane mesh
  60933. * * The parameter `pattern` will, depending on value, do nothing or
  60934. * * * flip (reflect about central vertical) alternate tiles across and up
  60935. * * * flip every tile on alternate rows
  60936. * * * rotate (180 degs) alternate tiles across and up
  60937. * * * rotate every tile on alternate rows
  60938. * * * flip and rotate alternate tiles across and up
  60939. * * * flip and rotate every tile on alternate rows
  60940. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60941. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60942. * * 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
  60943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60944. * * 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)
  60945. * * 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)
  60946. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60947. * @param name defines the name of the mesh
  60948. * @param options defines the options used to create the mesh
  60949. * @param scene defines the hosting scene
  60950. * @returns the box mesh
  60951. */
  60952. static CreateTiledPlane(name: string, options: {
  60953. pattern?: number;
  60954. tileSize?: number;
  60955. tileWidth?: number;
  60956. tileHeight?: number;
  60957. size?: number;
  60958. width?: number;
  60959. height?: number;
  60960. alignHorizontal?: number;
  60961. alignVertical?: number;
  60962. sideOrientation?: number;
  60963. frontUVs?: Vector4;
  60964. backUVs?: Vector4;
  60965. updatable?: boolean;
  60966. }, scene?: Nullable<Scene>): Mesh;
  60967. }
  60968. }
  60969. declare module BABYLON {
  60970. /**
  60971. * Class containing static functions to help procedurally build meshes
  60972. */
  60973. export class TubeBuilder {
  60974. /**
  60975. * Creates a tube mesh.
  60976. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60977. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60978. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60979. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60980. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60981. * * 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)
  60982. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60983. * * 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
  60984. * * 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
  60985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60986. * * 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
  60987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60989. * @param name defines the name of the mesh
  60990. * @param options defines the options used to create the mesh
  60991. * @param scene defines the hosting scene
  60992. * @returns the tube mesh
  60993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60994. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60995. */
  60996. static CreateTube(name: string, options: {
  60997. path: Vector3[];
  60998. radius?: number;
  60999. tessellation?: number;
  61000. radiusFunction?: {
  61001. (i: number, distance: number): number;
  61002. };
  61003. cap?: number;
  61004. arc?: number;
  61005. updatable?: boolean;
  61006. sideOrientation?: number;
  61007. frontUVs?: Vector4;
  61008. backUVs?: Vector4;
  61009. instance?: Mesh;
  61010. invertUV?: boolean;
  61011. }, scene?: Nullable<Scene>): Mesh;
  61012. }
  61013. }
  61014. declare module BABYLON {
  61015. /**
  61016. * Class containing static functions to help procedurally build meshes
  61017. */
  61018. export class IcoSphereBuilder {
  61019. /**
  61020. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61021. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61022. * * 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`)
  61023. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61024. * * 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
  61025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61026. * * 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
  61027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61028. * @param name defines the name of the mesh
  61029. * @param options defines the options used to create the mesh
  61030. * @param scene defines the hosting scene
  61031. * @returns the icosahedron mesh
  61032. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61033. */
  61034. static CreateIcoSphere(name: string, options: {
  61035. radius?: number;
  61036. radiusX?: number;
  61037. radiusY?: number;
  61038. radiusZ?: number;
  61039. flat?: boolean;
  61040. subdivisions?: number;
  61041. sideOrientation?: number;
  61042. frontUVs?: Vector4;
  61043. backUVs?: Vector4;
  61044. updatable?: boolean;
  61045. }, scene?: Nullable<Scene>): Mesh;
  61046. }
  61047. }
  61048. declare module BABYLON {
  61049. /**
  61050. * Class containing static functions to help procedurally build meshes
  61051. */
  61052. export class DecalBuilder {
  61053. /**
  61054. * Creates a decal mesh.
  61055. * 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
  61056. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61057. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61058. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61059. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61060. * @param name defines the name of the mesh
  61061. * @param sourceMesh defines the mesh where the decal must be applied
  61062. * @param options defines the options used to create the mesh
  61063. * @param scene defines the hosting scene
  61064. * @returns the decal mesh
  61065. * @see https://doc.babylonjs.com/how_to/decals
  61066. */
  61067. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61068. position?: Vector3;
  61069. normal?: Vector3;
  61070. size?: Vector3;
  61071. angle?: number;
  61072. }): Mesh;
  61073. }
  61074. }
  61075. declare module BABYLON {
  61076. /**
  61077. * Class containing static functions to help procedurally build meshes
  61078. */
  61079. export class MeshBuilder {
  61080. /**
  61081. * Creates a box mesh
  61082. * * The parameter `size` sets the size (float) of each box side (default 1)
  61083. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61084. * * 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)
  61085. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61087. * * 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
  61088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61089. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61090. * @param name defines the name of the mesh
  61091. * @param options defines the options used to create the mesh
  61092. * @param scene defines the hosting scene
  61093. * @returns the box mesh
  61094. */
  61095. static CreateBox(name: string, options: {
  61096. size?: number;
  61097. width?: number;
  61098. height?: number;
  61099. depth?: number;
  61100. faceUV?: Vector4[];
  61101. faceColors?: Color4[];
  61102. sideOrientation?: number;
  61103. frontUVs?: Vector4;
  61104. backUVs?: Vector4;
  61105. updatable?: boolean;
  61106. }, scene?: Nullable<Scene>): Mesh;
  61107. /**
  61108. * Creates a tiled box mesh
  61109. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61111. * @param name defines the name of the mesh
  61112. * @param options defines the options used to create the mesh
  61113. * @param scene defines the hosting scene
  61114. * @returns the tiled box mesh
  61115. */
  61116. static CreateTiledBox(name: string, options: {
  61117. pattern?: number;
  61118. size?: number;
  61119. width?: number;
  61120. height?: number;
  61121. depth: number;
  61122. tileSize?: number;
  61123. tileWidth?: number;
  61124. tileHeight?: number;
  61125. faceUV?: Vector4[];
  61126. faceColors?: Color4[];
  61127. alignHorizontal?: number;
  61128. alignVertical?: number;
  61129. sideOrientation?: number;
  61130. updatable?: boolean;
  61131. }, scene?: Nullable<Scene>): Mesh;
  61132. /**
  61133. * Creates a sphere mesh
  61134. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61135. * * 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`)
  61136. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61137. * * 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
  61138. * * 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)
  61139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61140. * * 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
  61141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61142. * @param name defines the name of the mesh
  61143. * @param options defines the options used to create the mesh
  61144. * @param scene defines the hosting scene
  61145. * @returns the sphere mesh
  61146. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61147. */
  61148. static CreateSphere(name: string, options: {
  61149. segments?: number;
  61150. diameter?: number;
  61151. diameterX?: number;
  61152. diameterY?: number;
  61153. diameterZ?: number;
  61154. arc?: number;
  61155. slice?: number;
  61156. sideOrientation?: number;
  61157. frontUVs?: Vector4;
  61158. backUVs?: Vector4;
  61159. updatable?: boolean;
  61160. }, scene?: Nullable<Scene>): Mesh;
  61161. /**
  61162. * Creates a plane polygonal mesh. By default, this is a disc
  61163. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61164. * * 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
  61165. * * 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
  61166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61167. * * 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
  61168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61169. * @param name defines the name of the mesh
  61170. * @param options defines the options used to create the mesh
  61171. * @param scene defines the hosting scene
  61172. * @returns the plane polygonal mesh
  61173. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61174. */
  61175. static CreateDisc(name: string, options: {
  61176. radius?: number;
  61177. tessellation?: number;
  61178. arc?: number;
  61179. updatable?: boolean;
  61180. sideOrientation?: number;
  61181. frontUVs?: Vector4;
  61182. backUVs?: Vector4;
  61183. }, scene?: Nullable<Scene>): Mesh;
  61184. /**
  61185. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61186. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61187. * * 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`)
  61188. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61189. * * 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
  61190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61191. * * 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
  61192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61193. * @param name defines the name of the mesh
  61194. * @param options defines the options used to create the mesh
  61195. * @param scene defines the hosting scene
  61196. * @returns the icosahedron mesh
  61197. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61198. */
  61199. static CreateIcoSphere(name: string, options: {
  61200. radius?: number;
  61201. radiusX?: number;
  61202. radiusY?: number;
  61203. radiusZ?: number;
  61204. flat?: boolean;
  61205. subdivisions?: number;
  61206. sideOrientation?: number;
  61207. frontUVs?: Vector4;
  61208. backUVs?: Vector4;
  61209. updatable?: boolean;
  61210. }, scene?: Nullable<Scene>): Mesh;
  61211. /**
  61212. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61213. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61214. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61215. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61216. * * 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
  61217. * * 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
  61218. * * 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
  61219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61220. * * 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
  61221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61222. * * 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
  61223. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61224. * * 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
  61225. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61227. * @param name defines the name of the mesh
  61228. * @param options defines the options used to create the mesh
  61229. * @param scene defines the hosting scene
  61230. * @returns the ribbon mesh
  61231. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61233. */
  61234. static CreateRibbon(name: string, options: {
  61235. pathArray: Vector3[][];
  61236. closeArray?: boolean;
  61237. closePath?: boolean;
  61238. offset?: number;
  61239. updatable?: boolean;
  61240. sideOrientation?: number;
  61241. frontUVs?: Vector4;
  61242. backUVs?: Vector4;
  61243. instance?: Mesh;
  61244. invertUV?: boolean;
  61245. uvs?: Vector2[];
  61246. colors?: Color4[];
  61247. }, scene?: Nullable<Scene>): Mesh;
  61248. /**
  61249. * Creates a cylinder or a cone mesh
  61250. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61251. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61252. * * 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.
  61253. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61254. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61255. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61256. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61257. * * 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).
  61258. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61259. * * 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).
  61260. * * 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
  61261. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61262. * * 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
  61263. * * 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.
  61264. * * If `enclose` is false, a ring surface is one element.
  61265. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61266. * * 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
  61267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61268. * * 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
  61269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61270. * @param name defines the name of the mesh
  61271. * @param options defines the options used to create the mesh
  61272. * @param scene defines the hosting scene
  61273. * @returns the cylinder mesh
  61274. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61275. */
  61276. static CreateCylinder(name: string, options: {
  61277. height?: number;
  61278. diameterTop?: number;
  61279. diameterBottom?: number;
  61280. diameter?: number;
  61281. tessellation?: number;
  61282. subdivisions?: number;
  61283. arc?: number;
  61284. faceColors?: Color4[];
  61285. faceUV?: Vector4[];
  61286. updatable?: boolean;
  61287. hasRings?: boolean;
  61288. enclose?: boolean;
  61289. cap?: number;
  61290. sideOrientation?: number;
  61291. frontUVs?: Vector4;
  61292. backUVs?: Vector4;
  61293. }, scene?: Nullable<Scene>): Mesh;
  61294. /**
  61295. * Creates a torus mesh
  61296. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61297. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61298. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61300. * * 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
  61301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61302. * @param name defines the name of the mesh
  61303. * @param options defines the options used to create the mesh
  61304. * @param scene defines the hosting scene
  61305. * @returns the torus mesh
  61306. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61307. */
  61308. static CreateTorus(name: string, options: {
  61309. diameter?: number;
  61310. thickness?: number;
  61311. tessellation?: number;
  61312. updatable?: boolean;
  61313. sideOrientation?: number;
  61314. frontUVs?: Vector4;
  61315. backUVs?: Vector4;
  61316. }, scene?: Nullable<Scene>): Mesh;
  61317. /**
  61318. * Creates a torus knot mesh
  61319. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61320. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61321. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61322. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61324. * * 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
  61325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61326. * @param name defines the name of the mesh
  61327. * @param options defines the options used to create the mesh
  61328. * @param scene defines the hosting scene
  61329. * @returns the torus knot mesh
  61330. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61331. */
  61332. static CreateTorusKnot(name: string, options: {
  61333. radius?: number;
  61334. tube?: number;
  61335. radialSegments?: number;
  61336. tubularSegments?: number;
  61337. p?: number;
  61338. q?: number;
  61339. updatable?: boolean;
  61340. sideOrientation?: number;
  61341. frontUVs?: Vector4;
  61342. backUVs?: Vector4;
  61343. }, scene?: Nullable<Scene>): Mesh;
  61344. /**
  61345. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61346. * * 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
  61347. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61348. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61349. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61350. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61351. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61352. * * 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
  61353. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61355. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61356. * @param name defines the name of the new line system
  61357. * @param options defines the options used to create the line system
  61358. * @param scene defines the hosting scene
  61359. * @returns a new line system mesh
  61360. */
  61361. static CreateLineSystem(name: string, options: {
  61362. lines: Vector3[][];
  61363. updatable?: boolean;
  61364. instance?: Nullable<LinesMesh>;
  61365. colors?: Nullable<Color4[][]>;
  61366. useVertexAlpha?: boolean;
  61367. }, scene: Nullable<Scene>): LinesMesh;
  61368. /**
  61369. * Creates a line mesh
  61370. * 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
  61371. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61372. * * The parameter `points` is an array successive Vector3
  61373. * * 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
  61374. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61375. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61376. * * When updating an instance, remember that only point positions can change, not the number of points
  61377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61379. * @param name defines the name of the new line system
  61380. * @param options defines the options used to create the line system
  61381. * @param scene defines the hosting scene
  61382. * @returns a new line mesh
  61383. */
  61384. static CreateLines(name: string, options: {
  61385. points: Vector3[];
  61386. updatable?: boolean;
  61387. instance?: Nullable<LinesMesh>;
  61388. colors?: Color4[];
  61389. useVertexAlpha?: boolean;
  61390. }, scene?: Nullable<Scene>): LinesMesh;
  61391. /**
  61392. * Creates a dashed line mesh
  61393. * * 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
  61394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61395. * * The parameter `points` is an array successive Vector3
  61396. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61397. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61398. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61399. * * 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
  61400. * * When updating an instance, remember that only point positions can change, not the number of points
  61401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61402. * @param name defines the name of the mesh
  61403. * @param options defines the options used to create the mesh
  61404. * @param scene defines the hosting scene
  61405. * @returns the dashed line mesh
  61406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61407. */
  61408. static CreateDashedLines(name: string, options: {
  61409. points: Vector3[];
  61410. dashSize?: number;
  61411. gapSize?: number;
  61412. dashNb?: number;
  61413. updatable?: boolean;
  61414. instance?: LinesMesh;
  61415. }, scene?: Nullable<Scene>): LinesMesh;
  61416. /**
  61417. * 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.
  61418. * * 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.
  61419. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61420. * * 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.
  61421. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61422. * * 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
  61423. * * 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
  61424. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61426. * * 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
  61427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61429. * @param name defines the name of the mesh
  61430. * @param options defines the options used to create the mesh
  61431. * @param scene defines the hosting scene
  61432. * @returns the extruded shape mesh
  61433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61435. */
  61436. static ExtrudeShape(name: string, options: {
  61437. shape: Vector3[];
  61438. path: Vector3[];
  61439. scale?: number;
  61440. rotation?: number;
  61441. cap?: number;
  61442. updatable?: boolean;
  61443. sideOrientation?: number;
  61444. frontUVs?: Vector4;
  61445. backUVs?: Vector4;
  61446. instance?: Mesh;
  61447. invertUV?: boolean;
  61448. }, scene?: Nullable<Scene>): Mesh;
  61449. /**
  61450. * Creates an custom extruded shape mesh.
  61451. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61452. * * 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.
  61453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61454. * * 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
  61455. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61456. * * 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
  61457. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61458. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61459. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61460. * * 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
  61461. * * 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
  61462. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61464. * * 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
  61465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61467. * @param name defines the name of the mesh
  61468. * @param options defines the options used to create the mesh
  61469. * @param scene defines the hosting scene
  61470. * @returns the custom extruded shape mesh
  61471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61474. */
  61475. static ExtrudeShapeCustom(name: string, options: {
  61476. shape: Vector3[];
  61477. path: Vector3[];
  61478. scaleFunction?: any;
  61479. rotationFunction?: any;
  61480. ribbonCloseArray?: boolean;
  61481. ribbonClosePath?: boolean;
  61482. cap?: number;
  61483. updatable?: boolean;
  61484. sideOrientation?: number;
  61485. frontUVs?: Vector4;
  61486. backUVs?: Vector4;
  61487. instance?: Mesh;
  61488. invertUV?: boolean;
  61489. }, scene?: Nullable<Scene>): Mesh;
  61490. /**
  61491. * Creates lathe mesh.
  61492. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61493. * * 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
  61494. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61495. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61496. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61497. * * 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
  61498. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61499. * * 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
  61500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61501. * * 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
  61502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61504. * @param name defines the name of the mesh
  61505. * @param options defines the options used to create the mesh
  61506. * @param scene defines the hosting scene
  61507. * @returns the lathe mesh
  61508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61509. */
  61510. static CreateLathe(name: string, options: {
  61511. shape: Vector3[];
  61512. radius?: number;
  61513. tessellation?: number;
  61514. clip?: number;
  61515. arc?: number;
  61516. closed?: boolean;
  61517. updatable?: boolean;
  61518. sideOrientation?: number;
  61519. frontUVs?: Vector4;
  61520. backUVs?: Vector4;
  61521. cap?: number;
  61522. invertUV?: boolean;
  61523. }, scene?: Nullable<Scene>): Mesh;
  61524. /**
  61525. * Creates a tiled plane mesh
  61526. * * You can set a limited pattern arrangement with the tiles
  61527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61528. * * 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
  61529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61530. * @param name defines the name of the mesh
  61531. * @param options defines the options used to create the mesh
  61532. * @param scene defines the hosting scene
  61533. * @returns the plane mesh
  61534. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61535. */
  61536. static CreateTiledPlane(name: string, options: {
  61537. pattern?: number;
  61538. tileSize?: number;
  61539. tileWidth?: number;
  61540. tileHeight?: number;
  61541. size?: number;
  61542. width?: number;
  61543. height?: number;
  61544. alignHorizontal?: number;
  61545. alignVertical?: number;
  61546. sideOrientation?: number;
  61547. frontUVs?: Vector4;
  61548. backUVs?: Vector4;
  61549. updatable?: boolean;
  61550. }, scene?: Nullable<Scene>): Mesh;
  61551. /**
  61552. * Creates a plane mesh
  61553. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61554. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61555. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61557. * * 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
  61558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61559. * @param name defines the name of the mesh
  61560. * @param options defines the options used to create the mesh
  61561. * @param scene defines the hosting scene
  61562. * @returns the plane mesh
  61563. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61564. */
  61565. static CreatePlane(name: string, options: {
  61566. size?: number;
  61567. width?: number;
  61568. height?: number;
  61569. sideOrientation?: number;
  61570. frontUVs?: Vector4;
  61571. backUVs?: Vector4;
  61572. updatable?: boolean;
  61573. sourcePlane?: Plane;
  61574. }, scene?: Nullable<Scene>): Mesh;
  61575. /**
  61576. * Creates a ground mesh
  61577. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61578. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61580. * @param name defines the name of the mesh
  61581. * @param options defines the options used to create the mesh
  61582. * @param scene defines the hosting scene
  61583. * @returns the ground mesh
  61584. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61585. */
  61586. static CreateGround(name: string, options: {
  61587. width?: number;
  61588. height?: number;
  61589. subdivisions?: number;
  61590. subdivisionsX?: number;
  61591. subdivisionsY?: number;
  61592. updatable?: boolean;
  61593. }, scene?: Nullable<Scene>): Mesh;
  61594. /**
  61595. * Creates a tiled ground mesh
  61596. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61597. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61598. * * 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
  61599. * * 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
  61600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61601. * @param name defines the name of the mesh
  61602. * @param options defines the options used to create the mesh
  61603. * @param scene defines the hosting scene
  61604. * @returns the tiled ground mesh
  61605. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61606. */
  61607. static CreateTiledGround(name: string, options: {
  61608. xmin: number;
  61609. zmin: number;
  61610. xmax: number;
  61611. zmax: number;
  61612. subdivisions?: {
  61613. w: number;
  61614. h: number;
  61615. };
  61616. precision?: {
  61617. w: number;
  61618. h: number;
  61619. };
  61620. updatable?: boolean;
  61621. }, scene?: Nullable<Scene>): Mesh;
  61622. /**
  61623. * Creates a ground mesh from a height map
  61624. * * The parameter `url` sets the URL of the height map image resource.
  61625. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61626. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61627. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61628. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61629. * * 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.
  61630. * * 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).
  61631. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61633. * @param name defines the name of the mesh
  61634. * @param url defines the url to the height map
  61635. * @param options defines the options used to create the mesh
  61636. * @param scene defines the hosting scene
  61637. * @returns the ground mesh
  61638. * @see https://doc.babylonjs.com/babylon101/height_map
  61639. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61640. */
  61641. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61642. width?: number;
  61643. height?: number;
  61644. subdivisions?: number;
  61645. minHeight?: number;
  61646. maxHeight?: number;
  61647. colorFilter?: Color3;
  61648. alphaFilter?: number;
  61649. updatable?: boolean;
  61650. onReady?: (mesh: GroundMesh) => void;
  61651. }, scene?: Nullable<Scene>): GroundMesh;
  61652. /**
  61653. * Creates a polygon mesh
  61654. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61655. * * 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
  61656. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61658. * * 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)
  61659. * * Remember you can only change the shape positions, not their number when updating a polygon
  61660. * @param name defines the name of the mesh
  61661. * @param options defines the options used to create the mesh
  61662. * @param scene defines the hosting scene
  61663. * @param earcutInjection can be used to inject your own earcut reference
  61664. * @returns the polygon mesh
  61665. */
  61666. static CreatePolygon(name: string, options: {
  61667. shape: Vector3[];
  61668. holes?: Vector3[][];
  61669. depth?: number;
  61670. faceUV?: Vector4[];
  61671. faceColors?: Color4[];
  61672. updatable?: boolean;
  61673. sideOrientation?: number;
  61674. frontUVs?: Vector4;
  61675. backUVs?: Vector4;
  61676. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61677. /**
  61678. * Creates an extruded polygon mesh, with depth in the Y direction.
  61679. * * 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)
  61680. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61681. * @param name defines the name of the mesh
  61682. * @param options defines the options used to create the mesh
  61683. * @param scene defines the hosting scene
  61684. * @param earcutInjection can be used to inject your own earcut reference
  61685. * @returns the polygon mesh
  61686. */
  61687. static ExtrudePolygon(name: string, options: {
  61688. shape: Vector3[];
  61689. holes?: Vector3[][];
  61690. depth?: number;
  61691. faceUV?: Vector4[];
  61692. faceColors?: Color4[];
  61693. updatable?: boolean;
  61694. sideOrientation?: number;
  61695. frontUVs?: Vector4;
  61696. backUVs?: Vector4;
  61697. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61698. /**
  61699. * Creates a tube mesh.
  61700. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61701. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61702. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61703. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61704. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61705. * * 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)
  61706. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61707. * * 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
  61708. * * 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
  61709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61710. * * 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
  61711. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61713. * @param name defines the name of the mesh
  61714. * @param options defines the options used to create the mesh
  61715. * @param scene defines the hosting scene
  61716. * @returns the tube mesh
  61717. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61718. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61719. */
  61720. static CreateTube(name: string, options: {
  61721. path: Vector3[];
  61722. radius?: number;
  61723. tessellation?: number;
  61724. radiusFunction?: {
  61725. (i: number, distance: number): number;
  61726. };
  61727. cap?: number;
  61728. arc?: number;
  61729. updatable?: boolean;
  61730. sideOrientation?: number;
  61731. frontUVs?: Vector4;
  61732. backUVs?: Vector4;
  61733. instance?: Mesh;
  61734. invertUV?: boolean;
  61735. }, scene?: Nullable<Scene>): Mesh;
  61736. /**
  61737. * Creates a polyhedron mesh
  61738. * * 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
  61739. * * The parameter `size` (positive float, default 1) sets the polygon size
  61740. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61741. * * 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`
  61742. * * 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
  61743. * * 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)`)
  61744. * * 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
  61745. * * 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
  61746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61747. * * 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
  61748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61749. * @param name defines the name of the mesh
  61750. * @param options defines the options used to create the mesh
  61751. * @param scene defines the hosting scene
  61752. * @returns the polyhedron mesh
  61753. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61754. */
  61755. static CreatePolyhedron(name: string, options: {
  61756. type?: number;
  61757. size?: number;
  61758. sizeX?: number;
  61759. sizeY?: number;
  61760. sizeZ?: number;
  61761. custom?: any;
  61762. faceUV?: Vector4[];
  61763. faceColors?: Color4[];
  61764. flat?: boolean;
  61765. updatable?: boolean;
  61766. sideOrientation?: number;
  61767. frontUVs?: Vector4;
  61768. backUVs?: Vector4;
  61769. }, scene?: Nullable<Scene>): Mesh;
  61770. /**
  61771. * Creates a decal mesh.
  61772. * 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
  61773. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61774. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61775. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61776. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61777. * @param name defines the name of the mesh
  61778. * @param sourceMesh defines the mesh where the decal must be applied
  61779. * @param options defines the options used to create the mesh
  61780. * @param scene defines the hosting scene
  61781. * @returns the decal mesh
  61782. * @see https://doc.babylonjs.com/how_to/decals
  61783. */
  61784. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61785. position?: Vector3;
  61786. normal?: Vector3;
  61787. size?: Vector3;
  61788. angle?: number;
  61789. }): Mesh;
  61790. }
  61791. }
  61792. declare module BABYLON {
  61793. /**
  61794. * A simplifier interface for future simplification implementations
  61795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61796. */
  61797. export interface ISimplifier {
  61798. /**
  61799. * Simplification of a given mesh according to the given settings.
  61800. * Since this requires computation, it is assumed that the function runs async.
  61801. * @param settings The settings of the simplification, including quality and distance
  61802. * @param successCallback A callback that will be called after the mesh was simplified.
  61803. * @param errorCallback in case of an error, this callback will be called. optional.
  61804. */
  61805. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61806. }
  61807. /**
  61808. * Expected simplification settings.
  61809. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61810. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61811. */
  61812. export interface ISimplificationSettings {
  61813. /**
  61814. * Gets or sets the expected quality
  61815. */
  61816. quality: number;
  61817. /**
  61818. * Gets or sets the distance when this optimized version should be used
  61819. */
  61820. distance: number;
  61821. /**
  61822. * Gets an already optimized mesh
  61823. */
  61824. optimizeMesh?: boolean;
  61825. }
  61826. /**
  61827. * Class used to specify simplification options
  61828. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61829. */
  61830. export class SimplificationSettings implements ISimplificationSettings {
  61831. /** expected quality */
  61832. quality: number;
  61833. /** distance when this optimized version should be used */
  61834. distance: number;
  61835. /** already optimized mesh */
  61836. optimizeMesh?: boolean | undefined;
  61837. /**
  61838. * Creates a SimplificationSettings
  61839. * @param quality expected quality
  61840. * @param distance distance when this optimized version should be used
  61841. * @param optimizeMesh already optimized mesh
  61842. */
  61843. constructor(
  61844. /** expected quality */
  61845. quality: number,
  61846. /** distance when this optimized version should be used */
  61847. distance: number,
  61848. /** already optimized mesh */
  61849. optimizeMesh?: boolean | undefined);
  61850. }
  61851. /**
  61852. * Interface used to define a simplification task
  61853. */
  61854. export interface ISimplificationTask {
  61855. /**
  61856. * Array of settings
  61857. */
  61858. settings: Array<ISimplificationSettings>;
  61859. /**
  61860. * Simplification type
  61861. */
  61862. simplificationType: SimplificationType;
  61863. /**
  61864. * Mesh to simplify
  61865. */
  61866. mesh: Mesh;
  61867. /**
  61868. * Callback called on success
  61869. */
  61870. successCallback?: () => void;
  61871. /**
  61872. * Defines if parallel processing can be used
  61873. */
  61874. parallelProcessing: boolean;
  61875. }
  61876. /**
  61877. * Queue used to order the simplification tasks
  61878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61879. */
  61880. export class SimplificationQueue {
  61881. private _simplificationArray;
  61882. /**
  61883. * Gets a boolean indicating that the process is still running
  61884. */
  61885. running: boolean;
  61886. /**
  61887. * Creates a new queue
  61888. */
  61889. constructor();
  61890. /**
  61891. * Adds a new simplification task
  61892. * @param task defines a task to add
  61893. */
  61894. addTask(task: ISimplificationTask): void;
  61895. /**
  61896. * Execute next task
  61897. */
  61898. executeNext(): void;
  61899. /**
  61900. * Execute a simplification task
  61901. * @param task defines the task to run
  61902. */
  61903. runSimplification(task: ISimplificationTask): void;
  61904. private getSimplifier;
  61905. }
  61906. /**
  61907. * The implemented types of simplification
  61908. * At the moment only Quadratic Error Decimation is implemented
  61909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61910. */
  61911. export enum SimplificationType {
  61912. /** Quadratic error decimation */
  61913. QUADRATIC = 0
  61914. }
  61915. }
  61916. declare module BABYLON {
  61917. interface Scene {
  61918. /** @hidden (Backing field) */
  61919. _simplificationQueue: SimplificationQueue;
  61920. /**
  61921. * Gets or sets the simplification queue attached to the scene
  61922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61923. */
  61924. simplificationQueue: SimplificationQueue;
  61925. }
  61926. interface Mesh {
  61927. /**
  61928. * Simplify the mesh according to the given array of settings.
  61929. * Function will return immediately and will simplify async
  61930. * @param settings a collection of simplification settings
  61931. * @param parallelProcessing should all levels calculate parallel or one after the other
  61932. * @param simplificationType the type of simplification to run
  61933. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61934. * @returns the current mesh
  61935. */
  61936. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61937. }
  61938. /**
  61939. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61940. * created in a scene
  61941. */
  61942. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61943. /**
  61944. * The component name helpfull to identify the component in the list of scene components.
  61945. */
  61946. readonly name: string;
  61947. /**
  61948. * The scene the component belongs to.
  61949. */
  61950. scene: Scene;
  61951. /**
  61952. * Creates a new instance of the component for the given scene
  61953. * @param scene Defines the scene to register the component in
  61954. */
  61955. constructor(scene: Scene);
  61956. /**
  61957. * Registers the component in a given scene
  61958. */
  61959. register(): void;
  61960. /**
  61961. * Rebuilds the elements related to this component in case of
  61962. * context lost for instance.
  61963. */
  61964. rebuild(): void;
  61965. /**
  61966. * Disposes the component and the associated ressources
  61967. */
  61968. dispose(): void;
  61969. private _beforeCameraUpdate;
  61970. }
  61971. }
  61972. declare module BABYLON {
  61973. /**
  61974. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61975. */
  61976. export interface INavigationEnginePlugin {
  61977. /**
  61978. * plugin name
  61979. */
  61980. name: string;
  61981. /**
  61982. * Creates a navigation mesh
  61983. * @param meshes array of all the geometry used to compute the navigatio mesh
  61984. * @param parameters bunch of parameters used to filter geometry
  61985. */
  61986. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61987. /**
  61988. * Create a navigation mesh debug mesh
  61989. * @param scene is where the mesh will be added
  61990. * @returns debug display mesh
  61991. */
  61992. createDebugNavMesh(scene: Scene): Mesh;
  61993. /**
  61994. * Get a navigation mesh constrained position, closest to the parameter position
  61995. * @param position world position
  61996. * @returns the closest point to position constrained by the navigation mesh
  61997. */
  61998. getClosestPoint(position: Vector3): Vector3;
  61999. /**
  62000. * Get a navigation mesh constrained position, within a particular radius
  62001. * @param position world position
  62002. * @param maxRadius the maximum distance to the constrained world position
  62003. * @returns the closest point to position constrained by the navigation mesh
  62004. */
  62005. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62006. /**
  62007. * Compute the final position from a segment made of destination-position
  62008. * @param position world position
  62009. * @param destination world position
  62010. * @returns the resulting point along the navmesh
  62011. */
  62012. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62013. /**
  62014. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62015. * @param start world position
  62016. * @param end world position
  62017. * @returns array containing world position composing the path
  62018. */
  62019. computePath(start: Vector3, end: Vector3): Vector3[];
  62020. /**
  62021. * If this plugin is supported
  62022. * @returns true if plugin is supported
  62023. */
  62024. isSupported(): boolean;
  62025. /**
  62026. * Create a new Crowd so you can add agents
  62027. * @param maxAgents the maximum agent count in the crowd
  62028. * @param maxAgentRadius the maximum radius an agent can have
  62029. * @param scene to attach the crowd to
  62030. * @returns the crowd you can add agents to
  62031. */
  62032. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62033. /**
  62034. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62035. * The queries will try to find a solution within those bounds
  62036. * default is (1,1,1)
  62037. * @param extent x,y,z value that define the extent around the queries point of reference
  62038. */
  62039. setDefaultQueryExtent(extent: Vector3): void;
  62040. /**
  62041. * Get the Bounding box extent specified by setDefaultQueryExtent
  62042. * @returns the box extent values
  62043. */
  62044. getDefaultQueryExtent(): Vector3;
  62045. /**
  62046. * Release all resources
  62047. */
  62048. dispose(): void;
  62049. }
  62050. /**
  62051. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62052. */
  62053. export interface ICrowd {
  62054. /**
  62055. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62056. * You can attach anything to that node. The node position is updated in the scene update tick.
  62057. * @param pos world position that will be constrained by the navigation mesh
  62058. * @param parameters agent parameters
  62059. * @param transform hooked to the agent that will be update by the scene
  62060. * @returns agent index
  62061. */
  62062. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62063. /**
  62064. * Returns the agent position in world space
  62065. * @param index agent index returned by addAgent
  62066. * @returns world space position
  62067. */
  62068. getAgentPosition(index: number): Vector3;
  62069. /**
  62070. * Gets the agent velocity in world space
  62071. * @param index agent index returned by addAgent
  62072. * @returns world space velocity
  62073. */
  62074. getAgentVelocity(index: number): Vector3;
  62075. /**
  62076. * remove a particular agent previously created
  62077. * @param index agent index returned by addAgent
  62078. */
  62079. removeAgent(index: number): void;
  62080. /**
  62081. * get the list of all agents attached to this crowd
  62082. * @returns list of agent indices
  62083. */
  62084. getAgents(): number[];
  62085. /**
  62086. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62087. * @param deltaTime in seconds
  62088. */
  62089. update(deltaTime: number): void;
  62090. /**
  62091. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62092. * @param index agent index returned by addAgent
  62093. * @param destination targeted world position
  62094. */
  62095. agentGoto(index: number, destination: Vector3): void;
  62096. /**
  62097. * Teleport the agent to a new position
  62098. * @param index agent index returned by addAgent
  62099. * @param destination targeted world position
  62100. */
  62101. agentTeleport(index: number, destination: Vector3): void;
  62102. /**
  62103. * Update agent parameters
  62104. * @param index agent index returned by addAgent
  62105. * @param parameters agent parameters
  62106. */
  62107. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62108. /**
  62109. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62110. * The queries will try to find a solution within those bounds
  62111. * default is (1,1,1)
  62112. * @param extent x,y,z value that define the extent around the queries point of reference
  62113. */
  62114. setDefaultQueryExtent(extent: Vector3): void;
  62115. /**
  62116. * Get the Bounding box extent specified by setDefaultQueryExtent
  62117. * @returns the box extent values
  62118. */
  62119. getDefaultQueryExtent(): Vector3;
  62120. /**
  62121. * Release all resources
  62122. */
  62123. dispose(): void;
  62124. }
  62125. /**
  62126. * Configures an agent
  62127. */
  62128. export interface IAgentParameters {
  62129. /**
  62130. * Agent radius. [Limit: >= 0]
  62131. */
  62132. radius: number;
  62133. /**
  62134. * Agent height. [Limit: > 0]
  62135. */
  62136. height: number;
  62137. /**
  62138. * Maximum allowed acceleration. [Limit: >= 0]
  62139. */
  62140. maxAcceleration: number;
  62141. /**
  62142. * Maximum allowed speed. [Limit: >= 0]
  62143. */
  62144. maxSpeed: number;
  62145. /**
  62146. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62147. */
  62148. collisionQueryRange: number;
  62149. /**
  62150. * The path visibility optimization range. [Limit: > 0]
  62151. */
  62152. pathOptimizationRange: number;
  62153. /**
  62154. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62155. */
  62156. separationWeight: number;
  62157. }
  62158. /**
  62159. * Configures the navigation mesh creation
  62160. */
  62161. export interface INavMeshParameters {
  62162. /**
  62163. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62164. */
  62165. cs: number;
  62166. /**
  62167. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62168. */
  62169. ch: number;
  62170. /**
  62171. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62172. */
  62173. walkableSlopeAngle: number;
  62174. /**
  62175. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62176. * be considered walkable. [Limit: >= 3] [Units: vx]
  62177. */
  62178. walkableHeight: number;
  62179. /**
  62180. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62181. */
  62182. walkableClimb: number;
  62183. /**
  62184. * The distance to erode/shrink the walkable area of the heightfield away from
  62185. * obstructions. [Limit: >=0] [Units: vx]
  62186. */
  62187. walkableRadius: number;
  62188. /**
  62189. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62190. */
  62191. maxEdgeLen: number;
  62192. /**
  62193. * The maximum distance a simplfied contour's border edges should deviate
  62194. * the original raw contour. [Limit: >=0] [Units: vx]
  62195. */
  62196. maxSimplificationError: number;
  62197. /**
  62198. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62199. */
  62200. minRegionArea: number;
  62201. /**
  62202. * Any regions with a span count smaller than this value will, if possible,
  62203. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62204. */
  62205. mergeRegionArea: number;
  62206. /**
  62207. * The maximum number of vertices allowed for polygons generated during the
  62208. * contour to polygon conversion process. [Limit: >= 3]
  62209. */
  62210. maxVertsPerPoly: number;
  62211. /**
  62212. * Sets the sampling distance to use when generating the detail mesh.
  62213. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62214. */
  62215. detailSampleDist: number;
  62216. /**
  62217. * The maximum distance the detail mesh surface should deviate from heightfield
  62218. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62219. */
  62220. detailSampleMaxError: number;
  62221. }
  62222. }
  62223. declare module BABYLON {
  62224. /**
  62225. * RecastJS navigation plugin
  62226. */
  62227. export class RecastJSPlugin implements INavigationEnginePlugin {
  62228. /**
  62229. * Reference to the Recast library
  62230. */
  62231. bjsRECAST: any;
  62232. /**
  62233. * plugin name
  62234. */
  62235. name: string;
  62236. /**
  62237. * the first navmesh created. We might extend this to support multiple navmeshes
  62238. */
  62239. navMesh: any;
  62240. /**
  62241. * Initializes the recastJS plugin
  62242. * @param recastInjection can be used to inject your own recast reference
  62243. */
  62244. constructor(recastInjection?: any);
  62245. /**
  62246. * Creates a navigation mesh
  62247. * @param meshes array of all the geometry used to compute the navigatio mesh
  62248. * @param parameters bunch of parameters used to filter geometry
  62249. */
  62250. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62251. /**
  62252. * Create a navigation mesh debug mesh
  62253. * @param scene is where the mesh will be added
  62254. * @returns debug display mesh
  62255. */
  62256. createDebugNavMesh(scene: Scene): Mesh;
  62257. /**
  62258. * Get a navigation mesh constrained position, closest to the parameter position
  62259. * @param position world position
  62260. * @returns the closest point to position constrained by the navigation mesh
  62261. */
  62262. getClosestPoint(position: Vector3): Vector3;
  62263. /**
  62264. * Get a navigation mesh constrained position, within a particular radius
  62265. * @param position world position
  62266. * @param maxRadius the maximum distance to the constrained world position
  62267. * @returns the closest point to position constrained by the navigation mesh
  62268. */
  62269. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62270. /**
  62271. * Compute the final position from a segment made of destination-position
  62272. * @param position world position
  62273. * @param destination world position
  62274. * @returns the resulting point along the navmesh
  62275. */
  62276. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62277. /**
  62278. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62279. * @param start world position
  62280. * @param end world position
  62281. * @returns array containing world position composing the path
  62282. */
  62283. computePath(start: Vector3, end: Vector3): Vector3[];
  62284. /**
  62285. * Create a new Crowd so you can add agents
  62286. * @param maxAgents the maximum agent count in the crowd
  62287. * @param maxAgentRadius the maximum radius an agent can have
  62288. * @param scene to attach the crowd to
  62289. * @returns the crowd you can add agents to
  62290. */
  62291. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62292. /**
  62293. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62294. * The queries will try to find a solution within those bounds
  62295. * default is (1,1,1)
  62296. * @param extent x,y,z value that define the extent around the queries point of reference
  62297. */
  62298. setDefaultQueryExtent(extent: Vector3): void;
  62299. /**
  62300. * Get the Bounding box extent specified by setDefaultQueryExtent
  62301. * @returns the box extent values
  62302. */
  62303. getDefaultQueryExtent(): Vector3;
  62304. /**
  62305. * Disposes
  62306. */
  62307. dispose(): void;
  62308. /**
  62309. * If this plugin is supported
  62310. * @returns true if plugin is supported
  62311. */
  62312. isSupported(): boolean;
  62313. }
  62314. /**
  62315. * Recast detour crowd implementation
  62316. */
  62317. export class RecastJSCrowd implements ICrowd {
  62318. /**
  62319. * Recast/detour plugin
  62320. */
  62321. bjsRECASTPlugin: RecastJSPlugin;
  62322. /**
  62323. * Link to the detour crowd
  62324. */
  62325. recastCrowd: any;
  62326. /**
  62327. * One transform per agent
  62328. */
  62329. transforms: TransformNode[];
  62330. /**
  62331. * All agents created
  62332. */
  62333. agents: number[];
  62334. /**
  62335. * Link to the scene is kept to unregister the crowd from the scene
  62336. */
  62337. private _scene;
  62338. /**
  62339. * Observer for crowd updates
  62340. */
  62341. private _onBeforeAnimationsObserver;
  62342. /**
  62343. * Constructor
  62344. * @param plugin recastJS plugin
  62345. * @param maxAgents the maximum agent count in the crowd
  62346. * @param maxAgentRadius the maximum radius an agent can have
  62347. * @param scene to attach the crowd to
  62348. * @returns the crowd you can add agents to
  62349. */
  62350. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62351. /**
  62352. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62353. * You can attach anything to that node. The node position is updated in the scene update tick.
  62354. * @param pos world position that will be constrained by the navigation mesh
  62355. * @param parameters agent parameters
  62356. * @param transform hooked to the agent that will be update by the scene
  62357. * @returns agent index
  62358. */
  62359. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62360. /**
  62361. * Returns the agent position in world space
  62362. * @param index agent index returned by addAgent
  62363. * @returns world space position
  62364. */
  62365. getAgentPosition(index: number): Vector3;
  62366. /**
  62367. * Returns the agent velocity in world space
  62368. * @param index agent index returned by addAgent
  62369. * @returns world space velocity
  62370. */
  62371. getAgentVelocity(index: number): Vector3;
  62372. /**
  62373. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62374. * @param index agent index returned by addAgent
  62375. * @param destination targeted world position
  62376. */
  62377. agentGoto(index: number, destination: Vector3): void;
  62378. /**
  62379. * Teleport the agent to a new position
  62380. * @param index agent index returned by addAgent
  62381. * @param destination targeted world position
  62382. */
  62383. agentTeleport(index: number, destination: Vector3): void;
  62384. /**
  62385. * Update agent parameters
  62386. * @param index agent index returned by addAgent
  62387. * @param parameters agent parameters
  62388. */
  62389. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62390. /**
  62391. * remove a particular agent previously created
  62392. * @param index agent index returned by addAgent
  62393. */
  62394. removeAgent(index: number): void;
  62395. /**
  62396. * get the list of all agents attached to this crowd
  62397. * @returns list of agent indices
  62398. */
  62399. getAgents(): number[];
  62400. /**
  62401. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62402. * @param deltaTime in seconds
  62403. */
  62404. update(deltaTime: number): void;
  62405. /**
  62406. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62407. * The queries will try to find a solution within those bounds
  62408. * default is (1,1,1)
  62409. * @param extent x,y,z value that define the extent around the queries point of reference
  62410. */
  62411. setDefaultQueryExtent(extent: Vector3): void;
  62412. /**
  62413. * Get the Bounding box extent specified by setDefaultQueryExtent
  62414. * @returns the box extent values
  62415. */
  62416. getDefaultQueryExtent(): Vector3;
  62417. /**
  62418. * Release all resources
  62419. */
  62420. dispose(): void;
  62421. }
  62422. }
  62423. declare module BABYLON {
  62424. /**
  62425. * Class used to enable access to IndexedDB
  62426. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62427. */
  62428. export class Database implements IOfflineProvider {
  62429. private _callbackManifestChecked;
  62430. private _currentSceneUrl;
  62431. private _db;
  62432. private _enableSceneOffline;
  62433. private _enableTexturesOffline;
  62434. private _manifestVersionFound;
  62435. private _mustUpdateRessources;
  62436. private _hasReachedQuota;
  62437. private _isSupported;
  62438. private _idbFactory;
  62439. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62440. private static IsUASupportingBlobStorage;
  62441. /**
  62442. * Gets a boolean indicating if Database storate is enabled (off by default)
  62443. */
  62444. static IDBStorageEnabled: boolean;
  62445. /**
  62446. * Gets a boolean indicating if scene must be saved in the database
  62447. */
  62448. get enableSceneOffline(): boolean;
  62449. /**
  62450. * Gets a boolean indicating if textures must be saved in the database
  62451. */
  62452. get enableTexturesOffline(): boolean;
  62453. /**
  62454. * Creates a new Database
  62455. * @param urlToScene defines the url to load the scene
  62456. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62457. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62458. */
  62459. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62460. private static _ParseURL;
  62461. private static _ReturnFullUrlLocation;
  62462. private _checkManifestFile;
  62463. /**
  62464. * Open the database and make it available
  62465. * @param successCallback defines the callback to call on success
  62466. * @param errorCallback defines the callback to call on error
  62467. */
  62468. open(successCallback: () => void, errorCallback: () => void): void;
  62469. /**
  62470. * Loads an image from the database
  62471. * @param url defines the url to load from
  62472. * @param image defines the target DOM image
  62473. */
  62474. loadImage(url: string, image: HTMLImageElement): void;
  62475. private _loadImageFromDBAsync;
  62476. private _saveImageIntoDBAsync;
  62477. private _checkVersionFromDB;
  62478. private _loadVersionFromDBAsync;
  62479. private _saveVersionIntoDBAsync;
  62480. /**
  62481. * Loads a file from database
  62482. * @param url defines the URL to load from
  62483. * @param sceneLoaded defines a callback to call on success
  62484. * @param progressCallBack defines a callback to call when progress changed
  62485. * @param errorCallback defines a callback to call on error
  62486. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62487. */
  62488. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62489. private _loadFileAsync;
  62490. private _saveFileAsync;
  62491. /**
  62492. * Validates if xhr data is correct
  62493. * @param xhr defines the request to validate
  62494. * @param dataType defines the expected data type
  62495. * @returns true if data is correct
  62496. */
  62497. private static _ValidateXHRData;
  62498. }
  62499. }
  62500. declare module BABYLON {
  62501. /** @hidden */
  62502. export var gpuUpdateParticlesPixelShader: {
  62503. name: string;
  62504. shader: string;
  62505. };
  62506. }
  62507. declare module BABYLON {
  62508. /** @hidden */
  62509. export var gpuUpdateParticlesVertexShader: {
  62510. name: string;
  62511. shader: string;
  62512. };
  62513. }
  62514. declare module BABYLON {
  62515. /** @hidden */
  62516. export var clipPlaneFragmentDeclaration2: {
  62517. name: string;
  62518. shader: string;
  62519. };
  62520. }
  62521. declare module BABYLON {
  62522. /** @hidden */
  62523. export var gpuRenderParticlesPixelShader: {
  62524. name: string;
  62525. shader: string;
  62526. };
  62527. }
  62528. declare module BABYLON {
  62529. /** @hidden */
  62530. export var clipPlaneVertexDeclaration2: {
  62531. name: string;
  62532. shader: string;
  62533. };
  62534. }
  62535. declare module BABYLON {
  62536. /** @hidden */
  62537. export var gpuRenderParticlesVertexShader: {
  62538. name: string;
  62539. shader: string;
  62540. };
  62541. }
  62542. declare module BABYLON {
  62543. /**
  62544. * This represents a GPU particle system in Babylon
  62545. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62546. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62547. */
  62548. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62549. /**
  62550. * The layer mask we are rendering the particles through.
  62551. */
  62552. layerMask: number;
  62553. private _capacity;
  62554. private _activeCount;
  62555. private _currentActiveCount;
  62556. private _accumulatedCount;
  62557. private _renderEffect;
  62558. private _updateEffect;
  62559. private _buffer0;
  62560. private _buffer1;
  62561. private _spriteBuffer;
  62562. private _updateVAO;
  62563. private _renderVAO;
  62564. private _targetIndex;
  62565. private _sourceBuffer;
  62566. private _targetBuffer;
  62567. private _engine;
  62568. private _currentRenderId;
  62569. private _started;
  62570. private _stopped;
  62571. private _timeDelta;
  62572. private _randomTexture;
  62573. private _randomTexture2;
  62574. private _attributesStrideSize;
  62575. private _updateEffectOptions;
  62576. private _randomTextureSize;
  62577. private _actualFrame;
  62578. private readonly _rawTextureWidth;
  62579. /**
  62580. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62581. */
  62582. static get IsSupported(): boolean;
  62583. /**
  62584. * An event triggered when the system is disposed.
  62585. */
  62586. onDisposeObservable: Observable<GPUParticleSystem>;
  62587. /**
  62588. * Gets the maximum number of particles active at the same time.
  62589. * @returns The max number of active particles.
  62590. */
  62591. getCapacity(): number;
  62592. /**
  62593. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62594. * to override the particles.
  62595. */
  62596. forceDepthWrite: boolean;
  62597. /**
  62598. * Gets or set the number of active particles
  62599. */
  62600. get activeParticleCount(): number;
  62601. set activeParticleCount(value: number);
  62602. private _preWarmDone;
  62603. /**
  62604. * Is this system ready to be used/rendered
  62605. * @return true if the system is ready
  62606. */
  62607. isReady(): boolean;
  62608. /**
  62609. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62610. * @returns True if it has been started, otherwise false.
  62611. */
  62612. isStarted(): boolean;
  62613. /**
  62614. * Starts the particle system and begins to emit
  62615. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62616. */
  62617. start(delay?: number): void;
  62618. /**
  62619. * Stops the particle system.
  62620. */
  62621. stop(): void;
  62622. /**
  62623. * Remove all active particles
  62624. */
  62625. reset(): void;
  62626. /**
  62627. * Returns the string "GPUParticleSystem"
  62628. * @returns a string containing the class name
  62629. */
  62630. getClassName(): string;
  62631. private _colorGradientsTexture;
  62632. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62633. /**
  62634. * Adds a new color gradient
  62635. * @param gradient defines the gradient to use (between 0 and 1)
  62636. * @param color1 defines the color to affect to the specified gradient
  62637. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62638. * @returns the current particle system
  62639. */
  62640. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62641. /**
  62642. * Remove a specific color gradient
  62643. * @param gradient defines the gradient to remove
  62644. * @returns the current particle system
  62645. */
  62646. removeColorGradient(gradient: number): GPUParticleSystem;
  62647. private _angularSpeedGradientsTexture;
  62648. private _sizeGradientsTexture;
  62649. private _velocityGradientsTexture;
  62650. private _limitVelocityGradientsTexture;
  62651. private _dragGradientsTexture;
  62652. private _addFactorGradient;
  62653. /**
  62654. * Adds a new size gradient
  62655. * @param gradient defines the gradient to use (between 0 and 1)
  62656. * @param factor defines the size factor to affect to the specified gradient
  62657. * @returns the current particle system
  62658. */
  62659. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62660. /**
  62661. * Remove a specific size gradient
  62662. * @param gradient defines the gradient to remove
  62663. * @returns the current particle system
  62664. */
  62665. removeSizeGradient(gradient: number): GPUParticleSystem;
  62666. /**
  62667. * Adds a new angular speed gradient
  62668. * @param gradient defines the gradient to use (between 0 and 1)
  62669. * @param factor defines the angular speed to affect to the specified gradient
  62670. * @returns the current particle system
  62671. */
  62672. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62673. /**
  62674. * Remove a specific angular speed gradient
  62675. * @param gradient defines the gradient to remove
  62676. * @returns the current particle system
  62677. */
  62678. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62679. /**
  62680. * Adds a new velocity gradient
  62681. * @param gradient defines the gradient to use (between 0 and 1)
  62682. * @param factor defines the velocity to affect to the specified gradient
  62683. * @returns the current particle system
  62684. */
  62685. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62686. /**
  62687. * Remove a specific velocity gradient
  62688. * @param gradient defines the gradient to remove
  62689. * @returns the current particle system
  62690. */
  62691. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62692. /**
  62693. * Adds a new limit velocity gradient
  62694. * @param gradient defines the gradient to use (between 0 and 1)
  62695. * @param factor defines the limit velocity value to affect to the specified gradient
  62696. * @returns the current particle system
  62697. */
  62698. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62699. /**
  62700. * Remove a specific limit velocity gradient
  62701. * @param gradient defines the gradient to remove
  62702. * @returns the current particle system
  62703. */
  62704. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62705. /**
  62706. * Adds a new drag gradient
  62707. * @param gradient defines the gradient to use (between 0 and 1)
  62708. * @param factor defines the drag value to affect to the specified gradient
  62709. * @returns the current particle system
  62710. */
  62711. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62712. /**
  62713. * Remove a specific drag gradient
  62714. * @param gradient defines the gradient to remove
  62715. * @returns the current particle system
  62716. */
  62717. removeDragGradient(gradient: number): GPUParticleSystem;
  62718. /**
  62719. * Not supported by GPUParticleSystem
  62720. * @param gradient defines the gradient to use (between 0 and 1)
  62721. * @param factor defines the emit rate value to affect to the specified gradient
  62722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62723. * @returns the current particle system
  62724. */
  62725. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62726. /**
  62727. * Not supported by GPUParticleSystem
  62728. * @param gradient defines the gradient to remove
  62729. * @returns the current particle system
  62730. */
  62731. removeEmitRateGradient(gradient: number): IParticleSystem;
  62732. /**
  62733. * Not supported by GPUParticleSystem
  62734. * @param gradient defines the gradient to use (between 0 and 1)
  62735. * @param factor defines the start size value to affect to the specified gradient
  62736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62737. * @returns the current particle system
  62738. */
  62739. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62740. /**
  62741. * Not supported by GPUParticleSystem
  62742. * @param gradient defines the gradient to remove
  62743. * @returns the current particle system
  62744. */
  62745. removeStartSizeGradient(gradient: number): IParticleSystem;
  62746. /**
  62747. * Not supported by GPUParticleSystem
  62748. * @param gradient defines the gradient to use (between 0 and 1)
  62749. * @param min defines the color remap minimal range
  62750. * @param max defines the color remap maximal range
  62751. * @returns the current particle system
  62752. */
  62753. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62754. /**
  62755. * Not supported by GPUParticleSystem
  62756. * @param gradient defines the gradient to remove
  62757. * @returns the current particle system
  62758. */
  62759. removeColorRemapGradient(): IParticleSystem;
  62760. /**
  62761. * Not supported by GPUParticleSystem
  62762. * @param gradient defines the gradient to use (between 0 and 1)
  62763. * @param min defines the alpha remap minimal range
  62764. * @param max defines the alpha remap maximal range
  62765. * @returns the current particle system
  62766. */
  62767. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62768. /**
  62769. * Not supported by GPUParticleSystem
  62770. * @param gradient defines the gradient to remove
  62771. * @returns the current particle system
  62772. */
  62773. removeAlphaRemapGradient(): IParticleSystem;
  62774. /**
  62775. * Not supported by GPUParticleSystem
  62776. * @param gradient defines the gradient to use (between 0 and 1)
  62777. * @param color defines the color to affect to the specified gradient
  62778. * @returns the current particle system
  62779. */
  62780. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62781. /**
  62782. * Not supported by GPUParticleSystem
  62783. * @param gradient defines the gradient to remove
  62784. * @returns the current particle system
  62785. */
  62786. removeRampGradient(): IParticleSystem;
  62787. /**
  62788. * Not supported by GPUParticleSystem
  62789. * @returns the list of ramp gradients
  62790. */
  62791. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62792. /**
  62793. * Not supported by GPUParticleSystem
  62794. * Gets or sets a boolean indicating that ramp gradients must be used
  62795. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62796. */
  62797. get useRampGradients(): boolean;
  62798. set useRampGradients(value: boolean);
  62799. /**
  62800. * Not supported by GPUParticleSystem
  62801. * @param gradient defines the gradient to use (between 0 and 1)
  62802. * @param factor defines the life time factor to affect to the specified gradient
  62803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62804. * @returns the current particle system
  62805. */
  62806. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62807. /**
  62808. * Not supported by GPUParticleSystem
  62809. * @param gradient defines the gradient to remove
  62810. * @returns the current particle system
  62811. */
  62812. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62813. /**
  62814. * Instantiates a GPU particle system.
  62815. * 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.
  62816. * @param name The name of the particle system
  62817. * @param options The options used to create the system
  62818. * @param scene The scene the particle system belongs to
  62819. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62820. */
  62821. constructor(name: string, options: Partial<{
  62822. capacity: number;
  62823. randomTextureSize: number;
  62824. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62825. protected _reset(): void;
  62826. private _createUpdateVAO;
  62827. private _createRenderVAO;
  62828. private _initialize;
  62829. /** @hidden */
  62830. _recreateUpdateEffect(): void;
  62831. /** @hidden */
  62832. _recreateRenderEffect(): void;
  62833. /**
  62834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62835. * @param preWarm defines if we are in the pre-warmimg phase
  62836. */
  62837. animate(preWarm?: boolean): void;
  62838. private _createFactorGradientTexture;
  62839. private _createSizeGradientTexture;
  62840. private _createAngularSpeedGradientTexture;
  62841. private _createVelocityGradientTexture;
  62842. private _createLimitVelocityGradientTexture;
  62843. private _createDragGradientTexture;
  62844. private _createColorGradientTexture;
  62845. /**
  62846. * Renders the particle system in its current state
  62847. * @param preWarm defines if the system should only update the particles but not render them
  62848. * @returns the current number of particles
  62849. */
  62850. render(preWarm?: boolean): number;
  62851. /**
  62852. * Rebuilds the particle system
  62853. */
  62854. rebuild(): void;
  62855. private _releaseBuffers;
  62856. private _releaseVAOs;
  62857. /**
  62858. * Disposes the particle system and free the associated resources
  62859. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62860. */
  62861. dispose(disposeTexture?: boolean): void;
  62862. /**
  62863. * Clones the particle system.
  62864. * @param name The name of the cloned object
  62865. * @param newEmitter The new emitter to use
  62866. * @returns the cloned particle system
  62867. */
  62868. clone(name: string, newEmitter: any): GPUParticleSystem;
  62869. /**
  62870. * Serializes the particle system to a JSON object.
  62871. * @returns the JSON object
  62872. */
  62873. serialize(): any;
  62874. /**
  62875. * Parses a JSON object to create a GPU particle system.
  62876. * @param parsedParticleSystem The JSON object to parse
  62877. * @param scene The scene to create the particle system in
  62878. * @param rootUrl The root url to use to load external dependencies like texture
  62879. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62880. * @returns the parsed GPU particle system
  62881. */
  62882. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62883. }
  62884. }
  62885. declare module BABYLON {
  62886. /**
  62887. * Represents a set of particle systems working together to create a specific effect
  62888. */
  62889. export class ParticleSystemSet implements IDisposable {
  62890. /**
  62891. * Gets or sets base Assets URL
  62892. */
  62893. static BaseAssetsUrl: string;
  62894. private _emitterCreationOptions;
  62895. private _emitterNode;
  62896. /**
  62897. * Gets the particle system list
  62898. */
  62899. systems: IParticleSystem[];
  62900. /**
  62901. * Gets the emitter node used with this set
  62902. */
  62903. get emitterNode(): Nullable<TransformNode>;
  62904. /**
  62905. * Creates a new emitter mesh as a sphere
  62906. * @param options defines the options used to create the sphere
  62907. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62908. * @param scene defines the hosting scene
  62909. */
  62910. setEmitterAsSphere(options: {
  62911. diameter: number;
  62912. segments: number;
  62913. color: Color3;
  62914. }, renderingGroupId: number, scene: Scene): void;
  62915. /**
  62916. * Starts all particle systems of the set
  62917. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62918. */
  62919. start(emitter?: AbstractMesh): void;
  62920. /**
  62921. * Release all associated resources
  62922. */
  62923. dispose(): void;
  62924. /**
  62925. * Serialize the set into a JSON compatible object
  62926. * @returns a JSON compatible representation of the set
  62927. */
  62928. serialize(): any;
  62929. /**
  62930. * Parse a new ParticleSystemSet from a serialized source
  62931. * @param data defines a JSON compatible representation of the set
  62932. * @param scene defines the hosting scene
  62933. * @param gpu defines if we want GPU particles or CPU particles
  62934. * @returns a new ParticleSystemSet
  62935. */
  62936. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62937. }
  62938. }
  62939. declare module BABYLON {
  62940. /**
  62941. * This class is made for on one-liner static method to help creating particle system set.
  62942. */
  62943. export class ParticleHelper {
  62944. /**
  62945. * Gets or sets base Assets URL
  62946. */
  62947. static BaseAssetsUrl: string;
  62948. /**
  62949. * Create a default particle system that you can tweak
  62950. * @param emitter defines the emitter to use
  62951. * @param capacity defines the system capacity (default is 500 particles)
  62952. * @param scene defines the hosting scene
  62953. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62954. * @returns the new Particle system
  62955. */
  62956. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62957. /**
  62958. * This is the main static method (one-liner) of this helper to create different particle systems
  62959. * @param type This string represents the type to the particle system to create
  62960. * @param scene The scene where the particle system should live
  62961. * @param gpu If the system will use gpu
  62962. * @returns the ParticleSystemSet created
  62963. */
  62964. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62965. /**
  62966. * Static function used to export a particle system to a ParticleSystemSet variable.
  62967. * Please note that the emitter shape is not exported
  62968. * @param systems defines the particle systems to export
  62969. * @returns the created particle system set
  62970. */
  62971. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. interface Engine {
  62976. /**
  62977. * Create an effect to use with particle systems.
  62978. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62979. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62980. * @param uniformsNames defines a list of attribute names
  62981. * @param samplers defines an array of string used to represent textures
  62982. * @param defines defines the string containing the defines to use to compile the shaders
  62983. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62984. * @param onCompiled defines a function to call when the effect creation is successful
  62985. * @param onError defines a function to call when the effect creation has failed
  62986. * @returns the new Effect
  62987. */
  62988. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62989. }
  62990. interface Mesh {
  62991. /**
  62992. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62993. * @returns an array of IParticleSystem
  62994. */
  62995. getEmittedParticleSystems(): IParticleSystem[];
  62996. /**
  62997. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62998. * @returns an array of IParticleSystem
  62999. */
  63000. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63001. }
  63002. /**
  63003. * @hidden
  63004. */
  63005. export var _IDoNeedToBeInTheBuild: number;
  63006. }
  63007. declare module BABYLON {
  63008. /** Defines the 4 color options */
  63009. export enum PointColor {
  63010. /** color value */
  63011. Color = 2,
  63012. /** uv value */
  63013. UV = 1,
  63014. /** random value */
  63015. Random = 0,
  63016. /** stated value */
  63017. Stated = 3
  63018. }
  63019. /**
  63020. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63021. * 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.
  63022. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63023. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63024. *
  63025. * Full documentation here : TO BE ENTERED
  63026. */
  63027. export class PointsCloudSystem implements IDisposable {
  63028. /**
  63029. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63030. * Example : var p = SPS.particles[i];
  63031. */
  63032. particles: CloudPoint[];
  63033. /**
  63034. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63035. */
  63036. nbParticles: number;
  63037. /**
  63038. * This a counter for your own usage. It's not set by any SPS functions.
  63039. */
  63040. counter: number;
  63041. /**
  63042. * The PCS name. This name is also given to the underlying mesh.
  63043. */
  63044. name: string;
  63045. /**
  63046. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63047. */
  63048. mesh: Mesh;
  63049. /**
  63050. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63051. * Please read :
  63052. */
  63053. vars: any;
  63054. /**
  63055. * @hidden
  63056. */
  63057. _size: number;
  63058. private _scene;
  63059. private _promises;
  63060. private _positions;
  63061. private _indices;
  63062. private _normals;
  63063. private _colors;
  63064. private _uvs;
  63065. private _indices32;
  63066. private _positions32;
  63067. private _colors32;
  63068. private _uvs32;
  63069. private _updatable;
  63070. private _isVisibilityBoxLocked;
  63071. private _alwaysVisible;
  63072. private _groups;
  63073. private _groupCounter;
  63074. private _computeParticleColor;
  63075. private _computeParticleTexture;
  63076. private _computeParticleRotation;
  63077. private _computeBoundingBox;
  63078. private _isReady;
  63079. /**
  63080. * Creates a PCS (Points Cloud System) object
  63081. * @param name (String) is the PCS name, this will be the underlying mesh name
  63082. * @param pointSize (number) is the size for each point
  63083. * @param scene (Scene) is the scene in which the PCS is added
  63084. * @param options defines the options of the PCS e.g.
  63085. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63086. */
  63087. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63088. updatable?: boolean;
  63089. });
  63090. /**
  63091. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63092. * If no points were added to the PCS, the returned mesh is just a single point.
  63093. * @returns a promise for the created mesh
  63094. */
  63095. buildMeshAsync(): Promise<Mesh>;
  63096. /**
  63097. * @hidden
  63098. */
  63099. private _buildMesh;
  63100. private _addParticle;
  63101. private _randomUnitVector;
  63102. private _getColorIndicesForCoord;
  63103. private _setPointsColorOrUV;
  63104. private _colorFromTexture;
  63105. private _calculateDensity;
  63106. /**
  63107. * Adds points to the PCS in random positions within a unit sphere
  63108. * @param nb (positive integer) the number of particles to be created from this model
  63109. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63110. * @returns the number of groups in the system
  63111. */
  63112. addPoints(nb: number, pointFunction?: any): number;
  63113. /**
  63114. * Adds points to the PCS from the surface of the model shape
  63115. * @param mesh is any Mesh object that will be used as a surface model for the points
  63116. * @param nb (positive integer) the number of particles to be created from this model
  63117. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63118. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63119. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63120. * @returns the number of groups in the system
  63121. */
  63122. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63123. /**
  63124. * Adds points to the PCS inside the model shape
  63125. * @param mesh is any Mesh object that will be used as a surface model for the points
  63126. * @param nb (positive integer) the number of particles to be created from this model
  63127. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63128. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63129. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63130. * @returns the number of groups in the system
  63131. */
  63132. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63133. /**
  63134. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63135. * This method calls `updateParticle()` for each particle of the SPS.
  63136. * For an animated SPS, it is usually called within the render loop.
  63137. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63138. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63139. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63140. * @returns the PCS.
  63141. */
  63142. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63143. /**
  63144. * Disposes the PCS.
  63145. */
  63146. dispose(): void;
  63147. /**
  63148. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63149. * doc :
  63150. * @returns the PCS.
  63151. */
  63152. refreshVisibleSize(): PointsCloudSystem;
  63153. /**
  63154. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63155. * @param size the size (float) of the visibility box
  63156. * note : this doesn't lock the PCS mesh bounding box.
  63157. * doc :
  63158. */
  63159. setVisibilityBox(size: number): void;
  63160. /**
  63161. * Gets whether the PCS is always visible or not
  63162. * doc :
  63163. */
  63164. get isAlwaysVisible(): boolean;
  63165. /**
  63166. * Sets the PCS as always visible or not
  63167. * doc :
  63168. */
  63169. set isAlwaysVisible(val: boolean);
  63170. /**
  63171. * Tells to `setParticles()` to compute the particle rotations or not
  63172. * Default value : false. The PCS is faster when it's set to false
  63173. * Note : particle rotations are only applied to parent particles
  63174. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63175. */
  63176. set computeParticleRotation(val: boolean);
  63177. /**
  63178. * Tells to `setParticles()` to compute the particle colors or not.
  63179. * Default value : true. The PCS is faster when it's set to false.
  63180. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63181. */
  63182. set computeParticleColor(val: boolean);
  63183. set computeParticleTexture(val: boolean);
  63184. /**
  63185. * Gets if `setParticles()` computes the particle colors or not.
  63186. * Default value : false. The PCS is faster when it's set to false.
  63187. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63188. */
  63189. get computeParticleColor(): boolean;
  63190. /**
  63191. * Gets if `setParticles()` computes the particle textures or not.
  63192. * Default value : false. The PCS is faster when it's set to false.
  63193. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63194. */
  63195. get computeParticleTexture(): boolean;
  63196. /**
  63197. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63198. */
  63199. set computeBoundingBox(val: boolean);
  63200. /**
  63201. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63202. */
  63203. get computeBoundingBox(): boolean;
  63204. /**
  63205. * This function does nothing. It may be overwritten to set all the particle first values.
  63206. * The PCS doesn't call this function, you may have to call it by your own.
  63207. * doc :
  63208. */
  63209. initParticles(): void;
  63210. /**
  63211. * This function does nothing. It may be overwritten to recycle a particle
  63212. * The PCS doesn't call this function, you can to call it
  63213. * doc :
  63214. * @param particle The particle to recycle
  63215. * @returns the recycled particle
  63216. */
  63217. recycleParticle(particle: CloudPoint): CloudPoint;
  63218. /**
  63219. * Updates a particle : this function should be overwritten by the user.
  63220. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63221. * doc :
  63222. * @example : just set a particle position or velocity and recycle conditions
  63223. * @param particle The particle to update
  63224. * @returns the updated particle
  63225. */
  63226. updateParticle(particle: CloudPoint): CloudPoint;
  63227. /**
  63228. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63229. * This does nothing and may be overwritten by the user.
  63230. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63231. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63232. * @param update the boolean update value actually passed to setParticles()
  63233. */
  63234. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63235. /**
  63236. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63237. * This will be passed three parameters.
  63238. * This does nothing and may be overwritten by the user.
  63239. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63240. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63241. * @param update the boolean update value actually passed to setParticles()
  63242. */
  63243. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63244. }
  63245. }
  63246. declare module BABYLON {
  63247. /**
  63248. * Represents one particle of a points cloud system.
  63249. */
  63250. export class CloudPoint {
  63251. /**
  63252. * particle global index
  63253. */
  63254. idx: number;
  63255. /**
  63256. * The color of the particle
  63257. */
  63258. color: Nullable<Color4>;
  63259. /**
  63260. * The world space position of the particle.
  63261. */
  63262. position: Vector3;
  63263. /**
  63264. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63265. */
  63266. rotation: Vector3;
  63267. /**
  63268. * The world space rotation quaternion of the particle.
  63269. */
  63270. rotationQuaternion: Nullable<Quaternion>;
  63271. /**
  63272. * The uv of the particle.
  63273. */
  63274. uv: Nullable<Vector2>;
  63275. /**
  63276. * The current speed of the particle.
  63277. */
  63278. velocity: Vector3;
  63279. /**
  63280. * The pivot point in the particle local space.
  63281. */
  63282. pivot: Vector3;
  63283. /**
  63284. * Must the particle be translated from its pivot point in its local space ?
  63285. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63286. * Default : false
  63287. */
  63288. translateFromPivot: boolean;
  63289. /**
  63290. * Index of this particle in the global "positions" array (Internal use)
  63291. * @hidden
  63292. */
  63293. _pos: number;
  63294. /**
  63295. * @hidden Index of this particle in the global "indices" array (Internal use)
  63296. */
  63297. _ind: number;
  63298. /**
  63299. * Group this particle belongs to
  63300. */
  63301. _group: PointsGroup;
  63302. /**
  63303. * Group id of this particle
  63304. */
  63305. groupId: number;
  63306. /**
  63307. * Index of the particle in its group id (Internal use)
  63308. */
  63309. idxInGroup: number;
  63310. /**
  63311. * @hidden Particle BoundingInfo object (Internal use)
  63312. */
  63313. _boundingInfo: BoundingInfo;
  63314. /**
  63315. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63316. */
  63317. _pcs: PointsCloudSystem;
  63318. /**
  63319. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63320. */
  63321. _stillInvisible: boolean;
  63322. /**
  63323. * @hidden Last computed particle rotation matrix
  63324. */
  63325. _rotationMatrix: number[];
  63326. /**
  63327. * Parent particle Id, if any.
  63328. * Default null.
  63329. */
  63330. parentId: Nullable<number>;
  63331. /**
  63332. * @hidden Internal global position in the PCS.
  63333. */
  63334. _globalPosition: Vector3;
  63335. /**
  63336. * Creates a Point Cloud object.
  63337. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63338. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63339. * @param group (PointsGroup) is the group the particle belongs to
  63340. * @param groupId (integer) is the group identifier in the PCS.
  63341. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63342. * @param pcs defines the PCS it is associated to
  63343. */
  63344. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63345. /**
  63346. * get point size
  63347. */
  63348. get size(): Vector3;
  63349. /**
  63350. * Set point size
  63351. */
  63352. set size(scale: Vector3);
  63353. /**
  63354. * Legacy support, changed quaternion to rotationQuaternion
  63355. */
  63356. get quaternion(): Nullable<Quaternion>;
  63357. /**
  63358. * Legacy support, changed quaternion to rotationQuaternion
  63359. */
  63360. set quaternion(q: Nullable<Quaternion>);
  63361. /**
  63362. * Returns a boolean. True if the particle intersects a mesh, else false
  63363. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63364. * @param target is the object (point or mesh) what the intersection is computed against
  63365. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63366. * @returns true if it intersects
  63367. */
  63368. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63369. /**
  63370. * get the rotation matrix of the particle
  63371. * @hidden
  63372. */
  63373. getRotationMatrix(m: Matrix): void;
  63374. }
  63375. /**
  63376. * Represents a group of points in a points cloud system
  63377. * * PCS internal tool, don't use it manually.
  63378. */
  63379. export class PointsGroup {
  63380. /**
  63381. * The group id
  63382. * @hidden
  63383. */
  63384. groupID: number;
  63385. /**
  63386. * image data for group (internal use)
  63387. * @hidden
  63388. */
  63389. _groupImageData: Nullable<ArrayBufferView>;
  63390. /**
  63391. * Image Width (internal use)
  63392. * @hidden
  63393. */
  63394. _groupImgWidth: number;
  63395. /**
  63396. * Image Height (internal use)
  63397. * @hidden
  63398. */
  63399. _groupImgHeight: number;
  63400. /**
  63401. * Custom position function (internal use)
  63402. * @hidden
  63403. */
  63404. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63405. /**
  63406. * density per facet for surface points
  63407. * @hidden
  63408. */
  63409. _groupDensity: number[];
  63410. /**
  63411. * Only when points are colored by texture carries pointer to texture list array
  63412. * @hidden
  63413. */
  63414. _textureNb: number;
  63415. /**
  63416. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63417. * PCS internal tool, don't use it manually.
  63418. * @hidden
  63419. */
  63420. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63421. }
  63422. }
  63423. declare module BABYLON {
  63424. interface Scene {
  63425. /** @hidden (Backing field) */
  63426. _physicsEngine: Nullable<IPhysicsEngine>;
  63427. /** @hidden */
  63428. _physicsTimeAccumulator: number;
  63429. /**
  63430. * Gets the current physics engine
  63431. * @returns a IPhysicsEngine or null if none attached
  63432. */
  63433. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63434. /**
  63435. * Enables physics to the current scene
  63436. * @param gravity defines the scene's gravity for the physics engine
  63437. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63438. * @return a boolean indicating if the physics engine was initialized
  63439. */
  63440. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63441. /**
  63442. * Disables and disposes the physics engine associated with the scene
  63443. */
  63444. disablePhysicsEngine(): void;
  63445. /**
  63446. * Gets a boolean indicating if there is an active physics engine
  63447. * @returns a boolean indicating if there is an active physics engine
  63448. */
  63449. isPhysicsEnabled(): boolean;
  63450. /**
  63451. * Deletes a physics compound impostor
  63452. * @param compound defines the compound to delete
  63453. */
  63454. deleteCompoundImpostor(compound: any): void;
  63455. /**
  63456. * An event triggered when physic simulation is about to be run
  63457. */
  63458. onBeforePhysicsObservable: Observable<Scene>;
  63459. /**
  63460. * An event triggered when physic simulation has been done
  63461. */
  63462. onAfterPhysicsObservable: Observable<Scene>;
  63463. }
  63464. interface AbstractMesh {
  63465. /** @hidden */
  63466. _physicsImpostor: Nullable<PhysicsImpostor>;
  63467. /**
  63468. * Gets or sets impostor used for physic simulation
  63469. * @see http://doc.babylonjs.com/features/physics_engine
  63470. */
  63471. physicsImpostor: Nullable<PhysicsImpostor>;
  63472. /**
  63473. * Gets the current physics impostor
  63474. * @see http://doc.babylonjs.com/features/physics_engine
  63475. * @returns a physics impostor or null
  63476. */
  63477. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63478. /** Apply a physic impulse to the mesh
  63479. * @param force defines the force to apply
  63480. * @param contactPoint defines where to apply the force
  63481. * @returns the current mesh
  63482. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63483. */
  63484. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63485. /**
  63486. * Creates a physic joint between two meshes
  63487. * @param otherMesh defines the other mesh to use
  63488. * @param pivot1 defines the pivot to use on this mesh
  63489. * @param pivot2 defines the pivot to use on the other mesh
  63490. * @param options defines additional options (can be plugin dependent)
  63491. * @returns the current mesh
  63492. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63493. */
  63494. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63495. /** @hidden */
  63496. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63497. }
  63498. /**
  63499. * Defines the physics engine scene component responsible to manage a physics engine
  63500. */
  63501. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63502. /**
  63503. * The component name helpful to identify the component in the list of scene components.
  63504. */
  63505. readonly name: string;
  63506. /**
  63507. * The scene the component belongs to.
  63508. */
  63509. scene: Scene;
  63510. /**
  63511. * Creates a new instance of the component for the given scene
  63512. * @param scene Defines the scene to register the component in
  63513. */
  63514. constructor(scene: Scene);
  63515. /**
  63516. * Registers the component in a given scene
  63517. */
  63518. register(): void;
  63519. /**
  63520. * Rebuilds the elements related to this component in case of
  63521. * context lost for instance.
  63522. */
  63523. rebuild(): void;
  63524. /**
  63525. * Disposes the component and the associated ressources
  63526. */
  63527. dispose(): void;
  63528. }
  63529. }
  63530. declare module BABYLON {
  63531. /**
  63532. * A helper for physics simulations
  63533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63534. */
  63535. export class PhysicsHelper {
  63536. private _scene;
  63537. private _physicsEngine;
  63538. /**
  63539. * Initializes the Physics helper
  63540. * @param scene Babylon.js scene
  63541. */
  63542. constructor(scene: Scene);
  63543. /**
  63544. * Applies a radial explosion impulse
  63545. * @param origin the origin of the explosion
  63546. * @param radiusOrEventOptions the radius or the options of radial explosion
  63547. * @param strength the explosion strength
  63548. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63549. * @returns A physics radial explosion event, or null
  63550. */
  63551. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63552. /**
  63553. * Applies a radial explosion force
  63554. * @param origin the origin of the explosion
  63555. * @param radiusOrEventOptions the radius or the options of radial explosion
  63556. * @param strength the explosion strength
  63557. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63558. * @returns A physics radial explosion event, or null
  63559. */
  63560. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63561. /**
  63562. * Creates a gravitational field
  63563. * @param origin the origin of the explosion
  63564. * @param radiusOrEventOptions the radius or the options of radial explosion
  63565. * @param strength the explosion strength
  63566. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63567. * @returns A physics gravitational field event, or null
  63568. */
  63569. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63570. /**
  63571. * Creates a physics updraft event
  63572. * @param origin the origin of the updraft
  63573. * @param radiusOrEventOptions the radius or the options of the updraft
  63574. * @param strength the strength of the updraft
  63575. * @param height the height of the updraft
  63576. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63577. * @returns A physics updraft event, or null
  63578. */
  63579. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63580. /**
  63581. * Creates a physics vortex event
  63582. * @param origin the of the vortex
  63583. * @param radiusOrEventOptions the radius or the options of the vortex
  63584. * @param strength the strength of the vortex
  63585. * @param height the height of the vortex
  63586. * @returns a Physics vortex event, or null
  63587. * A physics vortex event or null
  63588. */
  63589. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63590. }
  63591. /**
  63592. * Represents a physics radial explosion event
  63593. */
  63594. class PhysicsRadialExplosionEvent {
  63595. private _scene;
  63596. private _options;
  63597. private _sphere;
  63598. private _dataFetched;
  63599. /**
  63600. * Initializes a radial explosioin event
  63601. * @param _scene BabylonJS scene
  63602. * @param _options The options for the vortex event
  63603. */
  63604. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63605. /**
  63606. * Returns the data related to the radial explosion event (sphere).
  63607. * @returns The radial explosion event data
  63608. */
  63609. getData(): PhysicsRadialExplosionEventData;
  63610. /**
  63611. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63612. * @param impostor A physics imposter
  63613. * @param origin the origin of the explosion
  63614. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63615. */
  63616. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63617. /**
  63618. * Triggers affecterd impostors callbacks
  63619. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63620. */
  63621. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63622. /**
  63623. * Disposes the sphere.
  63624. * @param force Specifies if the sphere should be disposed by force
  63625. */
  63626. dispose(force?: boolean): void;
  63627. /*** Helpers ***/
  63628. private _prepareSphere;
  63629. private _intersectsWithSphere;
  63630. }
  63631. /**
  63632. * Represents a gravitational field event
  63633. */
  63634. class PhysicsGravitationalFieldEvent {
  63635. private _physicsHelper;
  63636. private _scene;
  63637. private _origin;
  63638. private _options;
  63639. private _tickCallback;
  63640. private _sphere;
  63641. private _dataFetched;
  63642. /**
  63643. * Initializes the physics gravitational field event
  63644. * @param _physicsHelper A physics helper
  63645. * @param _scene BabylonJS scene
  63646. * @param _origin The origin position of the gravitational field event
  63647. * @param _options The options for the vortex event
  63648. */
  63649. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63650. /**
  63651. * Returns the data related to the gravitational field event (sphere).
  63652. * @returns A gravitational field event
  63653. */
  63654. getData(): PhysicsGravitationalFieldEventData;
  63655. /**
  63656. * Enables the gravitational field.
  63657. */
  63658. enable(): void;
  63659. /**
  63660. * Disables the gravitational field.
  63661. */
  63662. disable(): void;
  63663. /**
  63664. * Disposes the sphere.
  63665. * @param force The force to dispose from the gravitational field event
  63666. */
  63667. dispose(force?: boolean): void;
  63668. private _tick;
  63669. }
  63670. /**
  63671. * Represents a physics updraft event
  63672. */
  63673. class PhysicsUpdraftEvent {
  63674. private _scene;
  63675. private _origin;
  63676. private _options;
  63677. private _physicsEngine;
  63678. private _originTop;
  63679. private _originDirection;
  63680. private _tickCallback;
  63681. private _cylinder;
  63682. private _cylinderPosition;
  63683. private _dataFetched;
  63684. /**
  63685. * Initializes the physics updraft event
  63686. * @param _scene BabylonJS scene
  63687. * @param _origin The origin position of the updraft
  63688. * @param _options The options for the updraft event
  63689. */
  63690. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63691. /**
  63692. * Returns the data related to the updraft event (cylinder).
  63693. * @returns A physics updraft event
  63694. */
  63695. getData(): PhysicsUpdraftEventData;
  63696. /**
  63697. * Enables the updraft.
  63698. */
  63699. enable(): void;
  63700. /**
  63701. * Disables the updraft.
  63702. */
  63703. disable(): void;
  63704. /**
  63705. * Disposes the cylinder.
  63706. * @param force Specifies if the updraft should be disposed by force
  63707. */
  63708. dispose(force?: boolean): void;
  63709. private getImpostorHitData;
  63710. private _tick;
  63711. /*** Helpers ***/
  63712. private _prepareCylinder;
  63713. private _intersectsWithCylinder;
  63714. }
  63715. /**
  63716. * Represents a physics vortex event
  63717. */
  63718. class PhysicsVortexEvent {
  63719. private _scene;
  63720. private _origin;
  63721. private _options;
  63722. private _physicsEngine;
  63723. private _originTop;
  63724. private _tickCallback;
  63725. private _cylinder;
  63726. private _cylinderPosition;
  63727. private _dataFetched;
  63728. /**
  63729. * Initializes the physics vortex event
  63730. * @param _scene The BabylonJS scene
  63731. * @param _origin The origin position of the vortex
  63732. * @param _options The options for the vortex event
  63733. */
  63734. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63735. /**
  63736. * Returns the data related to the vortex event (cylinder).
  63737. * @returns The physics vortex event data
  63738. */
  63739. getData(): PhysicsVortexEventData;
  63740. /**
  63741. * Enables the vortex.
  63742. */
  63743. enable(): void;
  63744. /**
  63745. * Disables the cortex.
  63746. */
  63747. disable(): void;
  63748. /**
  63749. * Disposes the sphere.
  63750. * @param force
  63751. */
  63752. dispose(force?: boolean): void;
  63753. private getImpostorHitData;
  63754. private _tick;
  63755. /*** Helpers ***/
  63756. private _prepareCylinder;
  63757. private _intersectsWithCylinder;
  63758. }
  63759. /**
  63760. * Options fot the radial explosion event
  63761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63762. */
  63763. export class PhysicsRadialExplosionEventOptions {
  63764. /**
  63765. * The radius of the sphere for the radial explosion.
  63766. */
  63767. radius: number;
  63768. /**
  63769. * The strenth of the explosion.
  63770. */
  63771. strength: number;
  63772. /**
  63773. * The strenght of the force in correspondence to the distance of the affected object
  63774. */
  63775. falloff: PhysicsRadialImpulseFalloff;
  63776. /**
  63777. * Sphere options for the radial explosion.
  63778. */
  63779. sphere: {
  63780. segments: number;
  63781. diameter: number;
  63782. };
  63783. /**
  63784. * Sphere options for the radial explosion.
  63785. */
  63786. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63787. }
  63788. /**
  63789. * Options fot the updraft event
  63790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63791. */
  63792. export class PhysicsUpdraftEventOptions {
  63793. /**
  63794. * The radius of the cylinder for the vortex
  63795. */
  63796. radius: number;
  63797. /**
  63798. * The strenth of the updraft.
  63799. */
  63800. strength: number;
  63801. /**
  63802. * The height of the cylinder for the updraft.
  63803. */
  63804. height: number;
  63805. /**
  63806. * The mode for the the updraft.
  63807. */
  63808. updraftMode: PhysicsUpdraftMode;
  63809. }
  63810. /**
  63811. * Options fot the vortex event
  63812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63813. */
  63814. export class PhysicsVortexEventOptions {
  63815. /**
  63816. * The radius of the cylinder for the vortex
  63817. */
  63818. radius: number;
  63819. /**
  63820. * The strenth of the vortex.
  63821. */
  63822. strength: number;
  63823. /**
  63824. * The height of the cylinder for the vortex.
  63825. */
  63826. height: number;
  63827. /**
  63828. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63829. */
  63830. centripetalForceThreshold: number;
  63831. /**
  63832. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63833. */
  63834. centripetalForceMultiplier: number;
  63835. /**
  63836. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63837. */
  63838. centrifugalForceMultiplier: number;
  63839. /**
  63840. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63841. */
  63842. updraftForceMultiplier: number;
  63843. }
  63844. /**
  63845. * The strenght of the force in correspondence to the distance of the affected object
  63846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63847. */
  63848. export enum PhysicsRadialImpulseFalloff {
  63849. /** Defines that impulse is constant in strength across it's whole radius */
  63850. Constant = 0,
  63851. /** Defines that impulse gets weaker if it's further from the origin */
  63852. Linear = 1
  63853. }
  63854. /**
  63855. * The strength of the force in correspondence to the distance of the affected object
  63856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63857. */
  63858. export enum PhysicsUpdraftMode {
  63859. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63860. Center = 0,
  63861. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63862. Perpendicular = 1
  63863. }
  63864. /**
  63865. * Interface for a physics hit data
  63866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63867. */
  63868. export interface PhysicsHitData {
  63869. /**
  63870. * The force applied at the contact point
  63871. */
  63872. force: Vector3;
  63873. /**
  63874. * The contact point
  63875. */
  63876. contactPoint: Vector3;
  63877. /**
  63878. * The distance from the origin to the contact point
  63879. */
  63880. distanceFromOrigin: number;
  63881. }
  63882. /**
  63883. * Interface for radial explosion event data
  63884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63885. */
  63886. export interface PhysicsRadialExplosionEventData {
  63887. /**
  63888. * A sphere used for the radial explosion event
  63889. */
  63890. sphere: Mesh;
  63891. }
  63892. /**
  63893. * Interface for gravitational field event data
  63894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63895. */
  63896. export interface PhysicsGravitationalFieldEventData {
  63897. /**
  63898. * A sphere mesh used for the gravitational field event
  63899. */
  63900. sphere: Mesh;
  63901. }
  63902. /**
  63903. * Interface for updraft event data
  63904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63905. */
  63906. export interface PhysicsUpdraftEventData {
  63907. /**
  63908. * A cylinder used for the updraft event
  63909. */
  63910. cylinder: Mesh;
  63911. }
  63912. /**
  63913. * Interface for vortex event data
  63914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63915. */
  63916. export interface PhysicsVortexEventData {
  63917. /**
  63918. * A cylinder used for the vortex event
  63919. */
  63920. cylinder: Mesh;
  63921. }
  63922. /**
  63923. * Interface for an affected physics impostor
  63924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63925. */
  63926. export interface PhysicsAffectedImpostorWithData {
  63927. /**
  63928. * The impostor affected by the effect
  63929. */
  63930. impostor: PhysicsImpostor;
  63931. /**
  63932. * The data about the hit/horce from the explosion
  63933. */
  63934. hitData: PhysicsHitData;
  63935. }
  63936. }
  63937. declare module BABYLON {
  63938. /** @hidden */
  63939. export var blackAndWhitePixelShader: {
  63940. name: string;
  63941. shader: string;
  63942. };
  63943. }
  63944. declare module BABYLON {
  63945. /**
  63946. * Post process used to render in black and white
  63947. */
  63948. export class BlackAndWhitePostProcess extends PostProcess {
  63949. /**
  63950. * Linear about to convert he result to black and white (default: 1)
  63951. */
  63952. degree: number;
  63953. /**
  63954. * Creates a black and white post process
  63955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63956. * @param name The name of the effect.
  63957. * @param options The required width/height ratio to downsize to before computing the render pass.
  63958. * @param camera The camera to apply the render pass to.
  63959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63960. * @param engine The engine which the post process will be applied. (default: current engine)
  63961. * @param reusable If the post process can be reused on the same frame. (default: false)
  63962. */
  63963. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63964. }
  63965. }
  63966. declare module BABYLON {
  63967. /**
  63968. * This represents a set of one or more post processes in Babylon.
  63969. * A post process can be used to apply a shader to a texture after it is rendered.
  63970. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63971. */
  63972. export class PostProcessRenderEffect {
  63973. private _postProcesses;
  63974. private _getPostProcesses;
  63975. private _singleInstance;
  63976. private _cameras;
  63977. private _indicesForCamera;
  63978. /**
  63979. * Name of the effect
  63980. * @hidden
  63981. */
  63982. _name: string;
  63983. /**
  63984. * Instantiates a post process render effect.
  63985. * A post process can be used to apply a shader to a texture after it is rendered.
  63986. * @param engine The engine the effect is tied to
  63987. * @param name The name of the effect
  63988. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63989. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63990. */
  63991. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63992. /**
  63993. * Checks if all the post processes in the effect are supported.
  63994. */
  63995. get isSupported(): boolean;
  63996. /**
  63997. * Updates the current state of the effect
  63998. * @hidden
  63999. */
  64000. _update(): void;
  64001. /**
  64002. * Attaches the effect on cameras
  64003. * @param cameras The camera to attach to.
  64004. * @hidden
  64005. */
  64006. _attachCameras(cameras: Camera): void;
  64007. /**
  64008. * Attaches the effect on cameras
  64009. * @param cameras The camera to attach to.
  64010. * @hidden
  64011. */
  64012. _attachCameras(cameras: Camera[]): void;
  64013. /**
  64014. * Detaches the effect on cameras
  64015. * @param cameras The camera to detatch from.
  64016. * @hidden
  64017. */
  64018. _detachCameras(cameras: Camera): void;
  64019. /**
  64020. * Detatches the effect on cameras
  64021. * @param cameras The camera to detatch from.
  64022. * @hidden
  64023. */
  64024. _detachCameras(cameras: Camera[]): void;
  64025. /**
  64026. * Enables the effect on given cameras
  64027. * @param cameras The camera to enable.
  64028. * @hidden
  64029. */
  64030. _enable(cameras: Camera): void;
  64031. /**
  64032. * Enables the effect on given cameras
  64033. * @param cameras The camera to enable.
  64034. * @hidden
  64035. */
  64036. _enable(cameras: Nullable<Camera[]>): void;
  64037. /**
  64038. * Disables the effect on the given cameras
  64039. * @param cameras The camera to disable.
  64040. * @hidden
  64041. */
  64042. _disable(cameras: Camera): void;
  64043. /**
  64044. * Disables the effect on the given cameras
  64045. * @param cameras The camera to disable.
  64046. * @hidden
  64047. */
  64048. _disable(cameras: Nullable<Camera[]>): void;
  64049. /**
  64050. * Gets a list of the post processes contained in the effect.
  64051. * @param camera The camera to get the post processes on.
  64052. * @returns The list of the post processes in the effect.
  64053. */
  64054. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64055. }
  64056. }
  64057. declare module BABYLON {
  64058. /** @hidden */
  64059. export var extractHighlightsPixelShader: {
  64060. name: string;
  64061. shader: string;
  64062. };
  64063. }
  64064. declare module BABYLON {
  64065. /**
  64066. * 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.
  64067. */
  64068. export class ExtractHighlightsPostProcess extends PostProcess {
  64069. /**
  64070. * The luminance threshold, pixels below this value will be set to black.
  64071. */
  64072. threshold: number;
  64073. /** @hidden */
  64074. _exposure: number;
  64075. /**
  64076. * Post process which has the input texture to be used when performing highlight extraction
  64077. * @hidden
  64078. */
  64079. _inputPostProcess: Nullable<PostProcess>;
  64080. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64081. }
  64082. }
  64083. declare module BABYLON {
  64084. /** @hidden */
  64085. export var bloomMergePixelShader: {
  64086. name: string;
  64087. shader: string;
  64088. };
  64089. }
  64090. declare module BABYLON {
  64091. /**
  64092. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64093. */
  64094. export class BloomMergePostProcess extends PostProcess {
  64095. /** Weight of the bloom to be added to the original input. */
  64096. weight: number;
  64097. /**
  64098. * Creates a new instance of @see BloomMergePostProcess
  64099. * @param name The name of the effect.
  64100. * @param originalFromInput Post process which's input will be used for the merge.
  64101. * @param blurred Blurred highlights post process which's output will be used.
  64102. * @param weight Weight of the bloom to be added to the original input.
  64103. * @param options The required width/height ratio to downsize to before computing the render pass.
  64104. * @param camera The camera to apply the render pass to.
  64105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64106. * @param engine The engine which the post process will be applied. (default: current engine)
  64107. * @param reusable If the post process can be reused on the same frame. (default: false)
  64108. * @param textureType Type of textures used when performing the post process. (default: 0)
  64109. * @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)
  64110. */
  64111. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64112. /** Weight of the bloom to be added to the original input. */
  64113. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64114. }
  64115. }
  64116. declare module BABYLON {
  64117. /**
  64118. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64119. */
  64120. export class BloomEffect extends PostProcessRenderEffect {
  64121. private bloomScale;
  64122. /**
  64123. * @hidden Internal
  64124. */
  64125. _effects: Array<PostProcess>;
  64126. /**
  64127. * @hidden Internal
  64128. */
  64129. _downscale: ExtractHighlightsPostProcess;
  64130. private _blurX;
  64131. private _blurY;
  64132. private _merge;
  64133. /**
  64134. * The luminance threshold to find bright areas of the image to bloom.
  64135. */
  64136. get threshold(): number;
  64137. set threshold(value: number);
  64138. /**
  64139. * The strength of the bloom.
  64140. */
  64141. get weight(): number;
  64142. set weight(value: number);
  64143. /**
  64144. * Specifies the size of the bloom blur kernel, relative to the final output size
  64145. */
  64146. get kernel(): number;
  64147. set kernel(value: number);
  64148. /**
  64149. * Creates a new instance of @see BloomEffect
  64150. * @param scene The scene the effect belongs to.
  64151. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64152. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64153. * @param bloomWeight The the strength of bloom.
  64154. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64155. * @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)
  64156. */
  64157. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64158. /**
  64159. * Disposes each of the internal effects for a given camera.
  64160. * @param camera The camera to dispose the effect on.
  64161. */
  64162. disposeEffects(camera: Camera): void;
  64163. /**
  64164. * @hidden Internal
  64165. */
  64166. _updateEffects(): void;
  64167. /**
  64168. * Internal
  64169. * @returns if all the contained post processes are ready.
  64170. * @hidden
  64171. */
  64172. _isReady(): boolean;
  64173. }
  64174. }
  64175. declare module BABYLON {
  64176. /** @hidden */
  64177. export var chromaticAberrationPixelShader: {
  64178. name: string;
  64179. shader: string;
  64180. };
  64181. }
  64182. declare module BABYLON {
  64183. /**
  64184. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64185. */
  64186. export class ChromaticAberrationPostProcess extends PostProcess {
  64187. /**
  64188. * The amount of seperation of rgb channels (default: 30)
  64189. */
  64190. aberrationAmount: number;
  64191. /**
  64192. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64193. */
  64194. radialIntensity: number;
  64195. /**
  64196. * 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))
  64197. */
  64198. direction: Vector2;
  64199. /**
  64200. * 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))
  64201. */
  64202. centerPosition: Vector2;
  64203. /**
  64204. * Creates a new instance ChromaticAberrationPostProcess
  64205. * @param name The name of the effect.
  64206. * @param screenWidth The width of the screen to apply the effect on.
  64207. * @param screenHeight The height of the screen to apply the effect on.
  64208. * @param options The required width/height ratio to downsize to before computing the render pass.
  64209. * @param camera The camera to apply the render pass to.
  64210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64211. * @param engine The engine which the post process will be applied. (default: current engine)
  64212. * @param reusable If the post process can be reused on the same frame. (default: false)
  64213. * @param textureType Type of textures used when performing the post process. (default: 0)
  64214. * @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)
  64215. */
  64216. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64217. }
  64218. }
  64219. declare module BABYLON {
  64220. /** @hidden */
  64221. export var circleOfConfusionPixelShader: {
  64222. name: string;
  64223. shader: string;
  64224. };
  64225. }
  64226. declare module BABYLON {
  64227. /**
  64228. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64229. */
  64230. export class CircleOfConfusionPostProcess extends PostProcess {
  64231. /**
  64232. * 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.
  64233. */
  64234. lensSize: number;
  64235. /**
  64236. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64237. */
  64238. fStop: number;
  64239. /**
  64240. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64241. */
  64242. focusDistance: number;
  64243. /**
  64244. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64245. */
  64246. focalLength: number;
  64247. private _depthTexture;
  64248. /**
  64249. * Creates a new instance CircleOfConfusionPostProcess
  64250. * @param name The name of the effect.
  64251. * @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.
  64252. * @param options The required width/height ratio to downsize to before computing the render pass.
  64253. * @param camera The camera to apply the render pass to.
  64254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64255. * @param engine The engine which the post process will be applied. (default: current engine)
  64256. * @param reusable If the post process can be reused on the same frame. (default: false)
  64257. * @param textureType Type of textures used when performing the post process. (default: 0)
  64258. * @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)
  64259. */
  64260. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64261. /**
  64262. * 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.
  64263. */
  64264. set depthTexture(value: RenderTargetTexture);
  64265. }
  64266. }
  64267. declare module BABYLON {
  64268. /** @hidden */
  64269. export var colorCorrectionPixelShader: {
  64270. name: string;
  64271. shader: string;
  64272. };
  64273. }
  64274. declare module BABYLON {
  64275. /**
  64276. *
  64277. * This post-process allows the modification of rendered colors by using
  64278. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64279. *
  64280. * The object needs to be provided an url to a texture containing the color
  64281. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64282. * Use an image editing software to tweak the LUT to match your needs.
  64283. *
  64284. * For an example of a color LUT, see here:
  64285. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64286. * For explanations on color grading, see here:
  64287. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64288. *
  64289. */
  64290. export class ColorCorrectionPostProcess extends PostProcess {
  64291. private _colorTableTexture;
  64292. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64293. }
  64294. }
  64295. declare module BABYLON {
  64296. /** @hidden */
  64297. export var convolutionPixelShader: {
  64298. name: string;
  64299. shader: string;
  64300. };
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64305. * input texture to perform effects such as edge detection or sharpening
  64306. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64307. */
  64308. export class ConvolutionPostProcess extends PostProcess {
  64309. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64310. kernel: number[];
  64311. /**
  64312. * Creates a new instance ConvolutionPostProcess
  64313. * @param name The name of the effect.
  64314. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64315. * @param options The required width/height ratio to downsize to before computing the render pass.
  64316. * @param camera The camera to apply the render pass to.
  64317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64318. * @param engine The engine which the post process will be applied. (default: current engine)
  64319. * @param reusable If the post process can be reused on the same frame. (default: false)
  64320. * @param textureType Type of textures used when performing the post process. (default: 0)
  64321. */
  64322. constructor(name: string,
  64323. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64324. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64325. /**
  64326. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64327. */
  64328. static EdgeDetect0Kernel: number[];
  64329. /**
  64330. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64331. */
  64332. static EdgeDetect1Kernel: number[];
  64333. /**
  64334. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64335. */
  64336. static EdgeDetect2Kernel: number[];
  64337. /**
  64338. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64339. */
  64340. static SharpenKernel: number[];
  64341. /**
  64342. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64343. */
  64344. static EmbossKernel: number[];
  64345. /**
  64346. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64347. */
  64348. static GaussianKernel: number[];
  64349. }
  64350. }
  64351. declare module BABYLON {
  64352. /**
  64353. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64354. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64355. * based on samples that have a large difference in distance than the center pixel.
  64356. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64357. */
  64358. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64359. direction: Vector2;
  64360. /**
  64361. * Creates a new instance CircleOfConfusionPostProcess
  64362. * @param name The name of the effect.
  64363. * @param scene The scene the effect belongs to.
  64364. * @param direction The direction the blur should be applied.
  64365. * @param kernel The size of the kernel used to blur.
  64366. * @param options The required width/height ratio to downsize to before computing the render pass.
  64367. * @param camera The camera to apply the render pass to.
  64368. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64369. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64371. * @param engine The engine which the post process will be applied. (default: current engine)
  64372. * @param reusable If the post process can be reused on the same frame. (default: false)
  64373. * @param textureType Type of textures used when performing the post process. (default: 0)
  64374. * @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)
  64375. */
  64376. 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);
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /** @hidden */
  64381. export var depthOfFieldMergePixelShader: {
  64382. name: string;
  64383. shader: string;
  64384. };
  64385. }
  64386. declare module BABYLON {
  64387. /**
  64388. * Options to be set when merging outputs from the default pipeline.
  64389. */
  64390. export class DepthOfFieldMergePostProcessOptions {
  64391. /**
  64392. * The original image to merge on top of
  64393. */
  64394. originalFromInput: PostProcess;
  64395. /**
  64396. * Parameters to perform the merge of the depth of field effect
  64397. */
  64398. depthOfField?: {
  64399. circleOfConfusion: PostProcess;
  64400. blurSteps: Array<PostProcess>;
  64401. };
  64402. /**
  64403. * Parameters to perform the merge of bloom effect
  64404. */
  64405. bloom?: {
  64406. blurred: PostProcess;
  64407. weight: number;
  64408. };
  64409. }
  64410. /**
  64411. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64412. */
  64413. export class DepthOfFieldMergePostProcess extends PostProcess {
  64414. private blurSteps;
  64415. /**
  64416. * Creates a new instance of DepthOfFieldMergePostProcess
  64417. * @param name The name of the effect.
  64418. * @param originalFromInput Post process which's input will be used for the merge.
  64419. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64420. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64421. * @param options The required width/height ratio to downsize to before computing the render pass.
  64422. * @param camera The camera to apply the render pass to.
  64423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64424. * @param engine The engine which the post process will be applied. (default: current engine)
  64425. * @param reusable If the post process can be reused on the same frame. (default: false)
  64426. * @param textureType Type of textures used when performing the post process. (default: 0)
  64427. * @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)
  64428. */
  64429. 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);
  64430. /**
  64431. * Updates the effect with the current post process compile time values and recompiles the shader.
  64432. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64433. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64434. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64435. * @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
  64436. * @param onCompiled Called when the shader has been compiled.
  64437. * @param onError Called if there is an error when compiling a shader.
  64438. */
  64439. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64440. }
  64441. }
  64442. declare module BABYLON {
  64443. /**
  64444. * Specifies the level of max blur that should be applied when using the depth of field effect
  64445. */
  64446. export enum DepthOfFieldEffectBlurLevel {
  64447. /**
  64448. * Subtle blur
  64449. */
  64450. Low = 0,
  64451. /**
  64452. * Medium blur
  64453. */
  64454. Medium = 1,
  64455. /**
  64456. * Large blur
  64457. */
  64458. High = 2
  64459. }
  64460. /**
  64461. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64462. */
  64463. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64464. private _circleOfConfusion;
  64465. /**
  64466. * @hidden Internal, blurs from high to low
  64467. */
  64468. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64469. private _depthOfFieldBlurY;
  64470. private _dofMerge;
  64471. /**
  64472. * @hidden Internal post processes in depth of field effect
  64473. */
  64474. _effects: Array<PostProcess>;
  64475. /**
  64476. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64477. */
  64478. set focalLength(value: number);
  64479. get focalLength(): number;
  64480. /**
  64481. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64482. */
  64483. set fStop(value: number);
  64484. get fStop(): number;
  64485. /**
  64486. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64487. */
  64488. set focusDistance(value: number);
  64489. get focusDistance(): number;
  64490. /**
  64491. * 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.
  64492. */
  64493. set lensSize(value: number);
  64494. get lensSize(): number;
  64495. /**
  64496. * Creates a new instance DepthOfFieldEffect
  64497. * @param scene The scene the effect belongs to.
  64498. * @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.
  64499. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64500. * @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)
  64501. */
  64502. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64503. /**
  64504. * Get the current class name of the current effet
  64505. * @returns "DepthOfFieldEffect"
  64506. */
  64507. getClassName(): string;
  64508. /**
  64509. * 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.
  64510. */
  64511. set depthTexture(value: RenderTargetTexture);
  64512. /**
  64513. * Disposes each of the internal effects for a given camera.
  64514. * @param camera The camera to dispose the effect on.
  64515. */
  64516. disposeEffects(camera: Camera): void;
  64517. /**
  64518. * @hidden Internal
  64519. */
  64520. _updateEffects(): void;
  64521. /**
  64522. * Internal
  64523. * @returns if all the contained post processes are ready.
  64524. * @hidden
  64525. */
  64526. _isReady(): boolean;
  64527. }
  64528. }
  64529. declare module BABYLON {
  64530. /** @hidden */
  64531. export var displayPassPixelShader: {
  64532. name: string;
  64533. shader: string;
  64534. };
  64535. }
  64536. declare module BABYLON {
  64537. /**
  64538. * DisplayPassPostProcess which produces an output the same as it's input
  64539. */
  64540. export class DisplayPassPostProcess extends PostProcess {
  64541. /**
  64542. * Creates the DisplayPassPostProcess
  64543. * @param name The name of the effect.
  64544. * @param options The required width/height ratio to downsize to before computing the render pass.
  64545. * @param camera The camera to apply the render pass to.
  64546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64547. * @param engine The engine which the post process will be applied. (default: current engine)
  64548. * @param reusable If the post process can be reused on the same frame. (default: false)
  64549. */
  64550. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64551. }
  64552. }
  64553. declare module BABYLON {
  64554. /** @hidden */
  64555. export var filterPixelShader: {
  64556. name: string;
  64557. shader: string;
  64558. };
  64559. }
  64560. declare module BABYLON {
  64561. /**
  64562. * Applies a kernel filter to the image
  64563. */
  64564. export class FilterPostProcess extends PostProcess {
  64565. /** The matrix to be applied to the image */
  64566. kernelMatrix: Matrix;
  64567. /**
  64568. *
  64569. * @param name The name of the effect.
  64570. * @param kernelMatrix The matrix to be applied to the image
  64571. * @param options The required width/height ratio to downsize to before computing the render pass.
  64572. * @param camera The camera to apply the render pass to.
  64573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64574. * @param engine The engine which the post process will be applied. (default: current engine)
  64575. * @param reusable If the post process can be reused on the same frame. (default: false)
  64576. */
  64577. constructor(name: string,
  64578. /** The matrix to be applied to the image */
  64579. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64580. }
  64581. }
  64582. declare module BABYLON {
  64583. /** @hidden */
  64584. export var fxaaPixelShader: {
  64585. name: string;
  64586. shader: string;
  64587. };
  64588. }
  64589. declare module BABYLON {
  64590. /** @hidden */
  64591. export var fxaaVertexShader: {
  64592. name: string;
  64593. shader: string;
  64594. };
  64595. }
  64596. declare module BABYLON {
  64597. /**
  64598. * Fxaa post process
  64599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64600. */
  64601. export class FxaaPostProcess extends PostProcess {
  64602. /** @hidden */
  64603. texelWidth: number;
  64604. /** @hidden */
  64605. texelHeight: number;
  64606. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64607. private _getDefines;
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /** @hidden */
  64612. export var grainPixelShader: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module BABYLON {
  64618. /**
  64619. * The GrainPostProcess adds noise to the image at mid luminance levels
  64620. */
  64621. export class GrainPostProcess extends PostProcess {
  64622. /**
  64623. * The intensity of the grain added (default: 30)
  64624. */
  64625. intensity: number;
  64626. /**
  64627. * If the grain should be randomized on every frame
  64628. */
  64629. animated: boolean;
  64630. /**
  64631. * Creates a new instance of @see GrainPostProcess
  64632. * @param name The name of the effect.
  64633. * @param options The required width/height ratio to downsize to before computing the render pass.
  64634. * @param camera The camera to apply the render pass to.
  64635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64636. * @param engine The engine which the post process will be applied. (default: current engine)
  64637. * @param reusable If the post process can be reused on the same frame. (default: false)
  64638. * @param textureType Type of textures used when performing the post process. (default: 0)
  64639. * @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)
  64640. */
  64641. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64642. }
  64643. }
  64644. declare module BABYLON {
  64645. /** @hidden */
  64646. export var highlightsPixelShader: {
  64647. name: string;
  64648. shader: string;
  64649. };
  64650. }
  64651. declare module BABYLON {
  64652. /**
  64653. * Extracts highlights from the image
  64654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64655. */
  64656. export class HighlightsPostProcess extends PostProcess {
  64657. /**
  64658. * Extracts highlights from the image
  64659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64660. * @param name The name of the effect.
  64661. * @param options The required width/height ratio to downsize to before computing the render pass.
  64662. * @param camera The camera to apply the render pass to.
  64663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64664. * @param engine The engine which the post process will be applied. (default: current engine)
  64665. * @param reusable If the post process can be reused on the same frame. (default: false)
  64666. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64667. */
  64668. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64669. }
  64670. }
  64671. declare module BABYLON {
  64672. /** @hidden */
  64673. export var mrtFragmentDeclaration: {
  64674. name: string;
  64675. shader: string;
  64676. };
  64677. }
  64678. declare module BABYLON {
  64679. /** @hidden */
  64680. export var geometryPixelShader: {
  64681. name: string;
  64682. shader: string;
  64683. };
  64684. }
  64685. declare module BABYLON {
  64686. /** @hidden */
  64687. export var geometryVertexShader: {
  64688. name: string;
  64689. shader: string;
  64690. };
  64691. }
  64692. declare module BABYLON {
  64693. /** @hidden */
  64694. interface ISavedTransformationMatrix {
  64695. world: Matrix;
  64696. viewProjection: Matrix;
  64697. }
  64698. /**
  64699. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64700. */
  64701. export class GeometryBufferRenderer {
  64702. /**
  64703. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64704. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64705. */
  64706. static readonly POSITION_TEXTURE_TYPE: number;
  64707. /**
  64708. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64709. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64710. */
  64711. static readonly VELOCITY_TEXTURE_TYPE: number;
  64712. /**
  64713. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64714. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64715. */
  64716. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64717. /**
  64718. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64719. * in order to compute objects velocities when enableVelocity is set to "true"
  64720. * @hidden
  64721. */
  64722. _previousTransformationMatrices: {
  64723. [index: number]: ISavedTransformationMatrix;
  64724. };
  64725. /**
  64726. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64727. * in order to compute objects velocities when enableVelocity is set to "true"
  64728. * @hidden
  64729. */
  64730. _previousBonesTransformationMatrices: {
  64731. [index: number]: Float32Array;
  64732. };
  64733. /**
  64734. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64735. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64736. */
  64737. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64738. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64739. renderTransparentMeshes: boolean;
  64740. private _scene;
  64741. private _multiRenderTarget;
  64742. private _ratio;
  64743. private _enablePosition;
  64744. private _enableVelocity;
  64745. private _enableReflectivity;
  64746. private _positionIndex;
  64747. private _velocityIndex;
  64748. private _reflectivityIndex;
  64749. protected _effect: Effect;
  64750. protected _cachedDefines: string;
  64751. /**
  64752. * Set the render list (meshes to be rendered) used in the G buffer.
  64753. */
  64754. set renderList(meshes: Mesh[]);
  64755. /**
  64756. * Gets wether or not G buffer are supported by the running hardware.
  64757. * This requires draw buffer supports
  64758. */
  64759. get isSupported(): boolean;
  64760. /**
  64761. * Returns the index of the given texture type in the G-Buffer textures array
  64762. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64763. * @returns the index of the given texture type in the G-Buffer textures array
  64764. */
  64765. getTextureIndex(textureType: number): number;
  64766. /**
  64767. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64768. */
  64769. get enablePosition(): boolean;
  64770. /**
  64771. * Sets whether or not objects positions are enabled for the G buffer.
  64772. */
  64773. set enablePosition(enable: boolean);
  64774. /**
  64775. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64776. */
  64777. get enableVelocity(): boolean;
  64778. /**
  64779. * Sets wether or not objects velocities are enabled for the G buffer.
  64780. */
  64781. set enableVelocity(enable: boolean);
  64782. /**
  64783. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64784. */
  64785. get enableReflectivity(): boolean;
  64786. /**
  64787. * Sets wether or not objects roughness are enabled for the G buffer.
  64788. */
  64789. set enableReflectivity(enable: boolean);
  64790. /**
  64791. * Gets the scene associated with the buffer.
  64792. */
  64793. get scene(): Scene;
  64794. /**
  64795. * Gets the ratio used by the buffer during its creation.
  64796. * How big is the buffer related to the main canvas.
  64797. */
  64798. get ratio(): number;
  64799. /** @hidden */
  64800. static _SceneComponentInitialization: (scene: Scene) => void;
  64801. /**
  64802. * Creates a new G Buffer for the scene
  64803. * @param scene The scene the buffer belongs to
  64804. * @param ratio How big is the buffer related to the main canvas.
  64805. */
  64806. constructor(scene: Scene, ratio?: number);
  64807. /**
  64808. * Checks wether everything is ready to render a submesh to the G buffer.
  64809. * @param subMesh the submesh to check readiness for
  64810. * @param useInstances is the mesh drawn using instance or not
  64811. * @returns true if ready otherwise false
  64812. */
  64813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64814. /**
  64815. * Gets the current underlying G Buffer.
  64816. * @returns the buffer
  64817. */
  64818. getGBuffer(): MultiRenderTarget;
  64819. /**
  64820. * Gets the number of samples used to render the buffer (anti aliasing).
  64821. */
  64822. get samples(): number;
  64823. /**
  64824. * Sets the number of samples used to render the buffer (anti aliasing).
  64825. */
  64826. set samples(value: number);
  64827. /**
  64828. * Disposes the renderer and frees up associated resources.
  64829. */
  64830. dispose(): void;
  64831. protected _createRenderTargets(): void;
  64832. private _copyBonesTransformationMatrices;
  64833. }
  64834. }
  64835. declare module BABYLON {
  64836. interface Scene {
  64837. /** @hidden (Backing field) */
  64838. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64839. /**
  64840. * Gets or Sets the current geometry buffer associated to the scene.
  64841. */
  64842. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64843. /**
  64844. * Enables a GeometryBufferRender and associates it with the scene
  64845. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64846. * @returns the GeometryBufferRenderer
  64847. */
  64848. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64849. /**
  64850. * Disables the GeometryBufferRender associated with the scene
  64851. */
  64852. disableGeometryBufferRenderer(): void;
  64853. }
  64854. /**
  64855. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64856. * in several rendering techniques.
  64857. */
  64858. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64859. /**
  64860. * The component name helpful to identify the component in the list of scene components.
  64861. */
  64862. readonly name: string;
  64863. /**
  64864. * The scene the component belongs to.
  64865. */
  64866. scene: Scene;
  64867. /**
  64868. * Creates a new instance of the component for the given scene
  64869. * @param scene Defines the scene to register the component in
  64870. */
  64871. constructor(scene: Scene);
  64872. /**
  64873. * Registers the component in a given scene
  64874. */
  64875. register(): void;
  64876. /**
  64877. * Rebuilds the elements related to this component in case of
  64878. * context lost for instance.
  64879. */
  64880. rebuild(): void;
  64881. /**
  64882. * Disposes the component and the associated ressources
  64883. */
  64884. dispose(): void;
  64885. private _gatherRenderTargets;
  64886. }
  64887. }
  64888. declare module BABYLON {
  64889. /** @hidden */
  64890. export var motionBlurPixelShader: {
  64891. name: string;
  64892. shader: string;
  64893. };
  64894. }
  64895. declare module BABYLON {
  64896. /**
  64897. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64898. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64899. * As an example, all you have to do is to create the post-process:
  64900. * var mb = new BABYLON.MotionBlurPostProcess(
  64901. * 'mb', // The name of the effect.
  64902. * scene, // The scene containing the objects to blur according to their velocity.
  64903. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64904. * camera // The camera to apply the render pass to.
  64905. * );
  64906. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64907. */
  64908. export class MotionBlurPostProcess extends PostProcess {
  64909. /**
  64910. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64911. */
  64912. motionStrength: number;
  64913. /**
  64914. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64915. */
  64916. get motionBlurSamples(): number;
  64917. /**
  64918. * Sets the number of iterations to be used for motion blur quality
  64919. */
  64920. set motionBlurSamples(samples: number);
  64921. private _motionBlurSamples;
  64922. private _geometryBufferRenderer;
  64923. /**
  64924. * Creates a new instance MotionBlurPostProcess
  64925. * @param name The name of the effect.
  64926. * @param scene The scene containing the objects to blur according to their velocity.
  64927. * @param options The required width/height ratio to downsize to before computing the render pass.
  64928. * @param camera The camera to apply the render pass to.
  64929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64930. * @param engine The engine which the post process will be applied. (default: current engine)
  64931. * @param reusable If the post process can be reused on the same frame. (default: false)
  64932. * @param textureType Type of textures used when performing the post process. (default: 0)
  64933. * @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)
  64934. */
  64935. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64936. /**
  64937. * Excludes the given skinned mesh from computing bones velocities.
  64938. * 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.
  64939. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64940. */
  64941. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64942. /**
  64943. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64944. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64945. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64946. */
  64947. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64948. /**
  64949. * Disposes the post process.
  64950. * @param camera The camera to dispose the post process on.
  64951. */
  64952. dispose(camera?: Camera): void;
  64953. }
  64954. }
  64955. declare module BABYLON {
  64956. /** @hidden */
  64957. export var refractionPixelShader: {
  64958. name: string;
  64959. shader: string;
  64960. };
  64961. }
  64962. declare module BABYLON {
  64963. /**
  64964. * Post process which applies a refractin texture
  64965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64966. */
  64967. export class RefractionPostProcess extends PostProcess {
  64968. /** the base color of the refraction (used to taint the rendering) */
  64969. color: Color3;
  64970. /** simulated refraction depth */
  64971. depth: number;
  64972. /** the coefficient of the base color (0 to remove base color tainting) */
  64973. colorLevel: number;
  64974. private _refTexture;
  64975. private _ownRefractionTexture;
  64976. /**
  64977. * Gets or sets the refraction texture
  64978. * Please note that you are responsible for disposing the texture if you set it manually
  64979. */
  64980. get refractionTexture(): Texture;
  64981. set refractionTexture(value: Texture);
  64982. /**
  64983. * Initializes the RefractionPostProcess
  64984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64985. * @param name The name of the effect.
  64986. * @param refractionTextureUrl Url of the refraction texture to use
  64987. * @param color the base color of the refraction (used to taint the rendering)
  64988. * @param depth simulated refraction depth
  64989. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64990. * @param camera The camera to apply the render pass to.
  64991. * @param options The required width/height ratio to downsize to before computing the render pass.
  64992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64993. * @param engine The engine which the post process will be applied. (default: current engine)
  64994. * @param reusable If the post process can be reused on the same frame. (default: false)
  64995. */
  64996. constructor(name: string, refractionTextureUrl: string,
  64997. /** the base color of the refraction (used to taint the rendering) */
  64998. color: Color3,
  64999. /** simulated refraction depth */
  65000. depth: number,
  65001. /** the coefficient of the base color (0 to remove base color tainting) */
  65002. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65003. /**
  65004. * Disposes of the post process
  65005. * @param camera Camera to dispose post process on
  65006. */
  65007. dispose(camera: Camera): void;
  65008. }
  65009. }
  65010. declare module BABYLON {
  65011. /** @hidden */
  65012. export var sharpenPixelShader: {
  65013. name: string;
  65014. shader: string;
  65015. };
  65016. }
  65017. declare module BABYLON {
  65018. /**
  65019. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65020. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65021. */
  65022. export class SharpenPostProcess extends PostProcess {
  65023. /**
  65024. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65025. */
  65026. colorAmount: number;
  65027. /**
  65028. * How much sharpness should be applied (default: 0.3)
  65029. */
  65030. edgeAmount: number;
  65031. /**
  65032. * Creates a new instance ConvolutionPostProcess
  65033. * @param name The name of the effect.
  65034. * @param options The required width/height ratio to downsize to before computing the render pass.
  65035. * @param camera The camera to apply the render pass to.
  65036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65037. * @param engine The engine which the post process will be applied. (default: current engine)
  65038. * @param reusable If the post process can be reused on the same frame. (default: false)
  65039. * @param textureType Type of textures used when performing the post process. (default: 0)
  65040. * @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)
  65041. */
  65042. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65043. }
  65044. }
  65045. declare module BABYLON {
  65046. /**
  65047. * PostProcessRenderPipeline
  65048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65049. */
  65050. export class PostProcessRenderPipeline {
  65051. private engine;
  65052. private _renderEffects;
  65053. private _renderEffectsForIsolatedPass;
  65054. /**
  65055. * List of inspectable custom properties (used by the Inspector)
  65056. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65057. */
  65058. inspectableCustomProperties: IInspectable[];
  65059. /**
  65060. * @hidden
  65061. */
  65062. protected _cameras: Camera[];
  65063. /** @hidden */
  65064. _name: string;
  65065. /**
  65066. * Gets pipeline name
  65067. */
  65068. get name(): string;
  65069. /** Gets the list of attached cameras */
  65070. get cameras(): Camera[];
  65071. /**
  65072. * Initializes a PostProcessRenderPipeline
  65073. * @param engine engine to add the pipeline to
  65074. * @param name name of the pipeline
  65075. */
  65076. constructor(engine: Engine, name: string);
  65077. /**
  65078. * Gets the class name
  65079. * @returns "PostProcessRenderPipeline"
  65080. */
  65081. getClassName(): string;
  65082. /**
  65083. * If all the render effects in the pipeline are supported
  65084. */
  65085. get isSupported(): boolean;
  65086. /**
  65087. * Adds an effect to the pipeline
  65088. * @param renderEffect the effect to add
  65089. */
  65090. addEffect(renderEffect: PostProcessRenderEffect): void;
  65091. /** @hidden */
  65092. _rebuild(): void;
  65093. /** @hidden */
  65094. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65095. /** @hidden */
  65096. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65097. /** @hidden */
  65098. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65099. /** @hidden */
  65100. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65101. /** @hidden */
  65102. _attachCameras(cameras: Camera, unique: boolean): void;
  65103. /** @hidden */
  65104. _attachCameras(cameras: Camera[], unique: boolean): void;
  65105. /** @hidden */
  65106. _detachCameras(cameras: Camera): void;
  65107. /** @hidden */
  65108. _detachCameras(cameras: Nullable<Camera[]>): void;
  65109. /** @hidden */
  65110. _update(): void;
  65111. /** @hidden */
  65112. _reset(): void;
  65113. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65114. /**
  65115. * Disposes of the pipeline
  65116. */
  65117. dispose(): void;
  65118. }
  65119. }
  65120. declare module BABYLON {
  65121. /**
  65122. * PostProcessRenderPipelineManager class
  65123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65124. */
  65125. export class PostProcessRenderPipelineManager {
  65126. private _renderPipelines;
  65127. /**
  65128. * Initializes a PostProcessRenderPipelineManager
  65129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65130. */
  65131. constructor();
  65132. /**
  65133. * Gets the list of supported render pipelines
  65134. */
  65135. get supportedPipelines(): PostProcessRenderPipeline[];
  65136. /**
  65137. * Adds a pipeline to the manager
  65138. * @param renderPipeline The pipeline to add
  65139. */
  65140. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65141. /**
  65142. * Attaches a camera to the pipeline
  65143. * @param renderPipelineName The name of the pipeline to attach to
  65144. * @param cameras the camera to attach
  65145. * @param unique if the camera can be attached multiple times to the pipeline
  65146. */
  65147. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65148. /**
  65149. * Detaches a camera from the pipeline
  65150. * @param renderPipelineName The name of the pipeline to detach from
  65151. * @param cameras the camera to detach
  65152. */
  65153. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65154. /**
  65155. * Enables an effect by name on a pipeline
  65156. * @param renderPipelineName the name of the pipeline to enable the effect in
  65157. * @param renderEffectName the name of the effect to enable
  65158. * @param cameras the cameras that the effect should be enabled on
  65159. */
  65160. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65161. /**
  65162. * Disables an effect by name on a pipeline
  65163. * @param renderPipelineName the name of the pipeline to disable the effect in
  65164. * @param renderEffectName the name of the effect to disable
  65165. * @param cameras the cameras that the effect should be disabled on
  65166. */
  65167. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65168. /**
  65169. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65170. */
  65171. update(): void;
  65172. /** @hidden */
  65173. _rebuild(): void;
  65174. /**
  65175. * Disposes of the manager and pipelines
  65176. */
  65177. dispose(): void;
  65178. }
  65179. }
  65180. declare module BABYLON {
  65181. interface Scene {
  65182. /** @hidden (Backing field) */
  65183. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65184. /**
  65185. * Gets the postprocess render pipeline manager
  65186. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65187. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65188. */
  65189. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65190. }
  65191. /**
  65192. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65193. */
  65194. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65195. /**
  65196. * The component name helpfull to identify the component in the list of scene components.
  65197. */
  65198. readonly name: string;
  65199. /**
  65200. * The scene the component belongs to.
  65201. */
  65202. scene: Scene;
  65203. /**
  65204. * Creates a new instance of the component for the given scene
  65205. * @param scene Defines the scene to register the component in
  65206. */
  65207. constructor(scene: Scene);
  65208. /**
  65209. * Registers the component in a given scene
  65210. */
  65211. register(): void;
  65212. /**
  65213. * Rebuilds the elements related to this component in case of
  65214. * context lost for instance.
  65215. */
  65216. rebuild(): void;
  65217. /**
  65218. * Disposes the component and the associated ressources
  65219. */
  65220. dispose(): void;
  65221. private _gatherRenderTargets;
  65222. }
  65223. }
  65224. declare module BABYLON {
  65225. /**
  65226. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65227. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65228. */
  65229. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65230. private _scene;
  65231. private _camerasToBeAttached;
  65232. /**
  65233. * ID of the sharpen post process,
  65234. */
  65235. private readonly SharpenPostProcessId;
  65236. /**
  65237. * @ignore
  65238. * ID of the image processing post process;
  65239. */
  65240. readonly ImageProcessingPostProcessId: string;
  65241. /**
  65242. * @ignore
  65243. * ID of the Fast Approximate Anti-Aliasing post process;
  65244. */
  65245. readonly FxaaPostProcessId: string;
  65246. /**
  65247. * ID of the chromatic aberration post process,
  65248. */
  65249. private readonly ChromaticAberrationPostProcessId;
  65250. /**
  65251. * ID of the grain post process
  65252. */
  65253. private readonly GrainPostProcessId;
  65254. /**
  65255. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65256. */
  65257. sharpen: SharpenPostProcess;
  65258. private _sharpenEffect;
  65259. private bloom;
  65260. /**
  65261. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65262. */
  65263. depthOfField: DepthOfFieldEffect;
  65264. /**
  65265. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65266. */
  65267. fxaa: FxaaPostProcess;
  65268. /**
  65269. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65270. */
  65271. imageProcessing: ImageProcessingPostProcess;
  65272. /**
  65273. * Chromatic aberration post process which will shift rgb colors in the image
  65274. */
  65275. chromaticAberration: ChromaticAberrationPostProcess;
  65276. private _chromaticAberrationEffect;
  65277. /**
  65278. * Grain post process which add noise to the image
  65279. */
  65280. grain: GrainPostProcess;
  65281. private _grainEffect;
  65282. /**
  65283. * Glow post process which adds a glow to emissive areas of the image
  65284. */
  65285. private _glowLayer;
  65286. /**
  65287. * Animations which can be used to tweak settings over a period of time
  65288. */
  65289. animations: Animation[];
  65290. private _imageProcessingConfigurationObserver;
  65291. private _sharpenEnabled;
  65292. private _bloomEnabled;
  65293. private _depthOfFieldEnabled;
  65294. private _depthOfFieldBlurLevel;
  65295. private _fxaaEnabled;
  65296. private _imageProcessingEnabled;
  65297. private _defaultPipelineTextureType;
  65298. private _bloomScale;
  65299. private _chromaticAberrationEnabled;
  65300. private _grainEnabled;
  65301. private _buildAllowed;
  65302. /**
  65303. * Gets active scene
  65304. */
  65305. get scene(): Scene;
  65306. /**
  65307. * Enable or disable the sharpen process from the pipeline
  65308. */
  65309. set sharpenEnabled(enabled: boolean);
  65310. get sharpenEnabled(): boolean;
  65311. private _resizeObserver;
  65312. private _hardwareScaleLevel;
  65313. private _bloomKernel;
  65314. /**
  65315. * Specifies the size of the bloom blur kernel, relative to the final output size
  65316. */
  65317. get bloomKernel(): number;
  65318. set bloomKernel(value: number);
  65319. /**
  65320. * Specifies the weight of the bloom in the final rendering
  65321. */
  65322. private _bloomWeight;
  65323. /**
  65324. * Specifies the luma threshold for the area that will be blurred by the bloom
  65325. */
  65326. private _bloomThreshold;
  65327. private _hdr;
  65328. /**
  65329. * The strength of the bloom.
  65330. */
  65331. set bloomWeight(value: number);
  65332. get bloomWeight(): number;
  65333. /**
  65334. * The strength of the bloom.
  65335. */
  65336. set bloomThreshold(value: number);
  65337. get bloomThreshold(): number;
  65338. /**
  65339. * The scale of the bloom, lower value will provide better performance.
  65340. */
  65341. set bloomScale(value: number);
  65342. get bloomScale(): number;
  65343. /**
  65344. * Enable or disable the bloom from the pipeline
  65345. */
  65346. set bloomEnabled(enabled: boolean);
  65347. get bloomEnabled(): boolean;
  65348. private _rebuildBloom;
  65349. /**
  65350. * If the depth of field is enabled.
  65351. */
  65352. get depthOfFieldEnabled(): boolean;
  65353. set depthOfFieldEnabled(enabled: boolean);
  65354. /**
  65355. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65356. */
  65357. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65358. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65359. /**
  65360. * If the anti aliasing is enabled.
  65361. */
  65362. set fxaaEnabled(enabled: boolean);
  65363. get fxaaEnabled(): boolean;
  65364. private _samples;
  65365. /**
  65366. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65367. */
  65368. set samples(sampleCount: number);
  65369. get samples(): number;
  65370. /**
  65371. * If image processing is enabled.
  65372. */
  65373. set imageProcessingEnabled(enabled: boolean);
  65374. get imageProcessingEnabled(): boolean;
  65375. /**
  65376. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65377. */
  65378. set glowLayerEnabled(enabled: boolean);
  65379. get glowLayerEnabled(): boolean;
  65380. /**
  65381. * Gets the glow layer (or null if not defined)
  65382. */
  65383. get glowLayer(): Nullable<GlowLayer>;
  65384. /**
  65385. * Enable or disable the chromaticAberration process from the pipeline
  65386. */
  65387. set chromaticAberrationEnabled(enabled: boolean);
  65388. get chromaticAberrationEnabled(): boolean;
  65389. /**
  65390. * Enable or disable the grain process from the pipeline
  65391. */
  65392. set grainEnabled(enabled: boolean);
  65393. get grainEnabled(): boolean;
  65394. /**
  65395. * @constructor
  65396. * @param name - The rendering pipeline name (default: "")
  65397. * @param hdr - If high dynamic range textures should be used (default: true)
  65398. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65399. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65400. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65401. */
  65402. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65403. /**
  65404. * Get the class name
  65405. * @returns "DefaultRenderingPipeline"
  65406. */
  65407. getClassName(): string;
  65408. /**
  65409. * Force the compilation of the entire pipeline.
  65410. */
  65411. prepare(): void;
  65412. private _hasCleared;
  65413. private _prevPostProcess;
  65414. private _prevPrevPostProcess;
  65415. private _setAutoClearAndTextureSharing;
  65416. private _depthOfFieldSceneObserver;
  65417. private _buildPipeline;
  65418. private _disposePostProcesses;
  65419. /**
  65420. * Adds a camera to the pipeline
  65421. * @param camera the camera to be added
  65422. */
  65423. addCamera(camera: Camera): void;
  65424. /**
  65425. * Removes a camera from the pipeline
  65426. * @param camera the camera to remove
  65427. */
  65428. removeCamera(camera: Camera): void;
  65429. /**
  65430. * Dispose of the pipeline and stop all post processes
  65431. */
  65432. dispose(): void;
  65433. /**
  65434. * Serialize the rendering pipeline (Used when exporting)
  65435. * @returns the serialized object
  65436. */
  65437. serialize(): any;
  65438. /**
  65439. * Parse the serialized pipeline
  65440. * @param source Source pipeline.
  65441. * @param scene The scene to load the pipeline to.
  65442. * @param rootUrl The URL of the serialized pipeline.
  65443. * @returns An instantiated pipeline from the serialized object.
  65444. */
  65445. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65446. }
  65447. }
  65448. declare module BABYLON {
  65449. /** @hidden */
  65450. export var lensHighlightsPixelShader: {
  65451. name: string;
  65452. shader: string;
  65453. };
  65454. }
  65455. declare module BABYLON {
  65456. /** @hidden */
  65457. export var depthOfFieldPixelShader: {
  65458. name: string;
  65459. shader: string;
  65460. };
  65461. }
  65462. declare module BABYLON {
  65463. /**
  65464. * BABYLON.JS Chromatic Aberration GLSL Shader
  65465. * Author: Olivier Guyot
  65466. * Separates very slightly R, G and B colors on the edges of the screen
  65467. * Inspired by Francois Tarlier & Martins Upitis
  65468. */
  65469. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65470. /**
  65471. * @ignore
  65472. * The chromatic aberration PostProcess id in the pipeline
  65473. */
  65474. LensChromaticAberrationEffect: string;
  65475. /**
  65476. * @ignore
  65477. * The highlights enhancing PostProcess id in the pipeline
  65478. */
  65479. HighlightsEnhancingEffect: string;
  65480. /**
  65481. * @ignore
  65482. * The depth-of-field PostProcess id in the pipeline
  65483. */
  65484. LensDepthOfFieldEffect: string;
  65485. private _scene;
  65486. private _depthTexture;
  65487. private _grainTexture;
  65488. private _chromaticAberrationPostProcess;
  65489. private _highlightsPostProcess;
  65490. private _depthOfFieldPostProcess;
  65491. private _edgeBlur;
  65492. private _grainAmount;
  65493. private _chromaticAberration;
  65494. private _distortion;
  65495. private _highlightsGain;
  65496. private _highlightsThreshold;
  65497. private _dofDistance;
  65498. private _dofAperture;
  65499. private _dofDarken;
  65500. private _dofPentagon;
  65501. private _blurNoise;
  65502. /**
  65503. * @constructor
  65504. *
  65505. * Effect parameters are as follow:
  65506. * {
  65507. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65508. * edge_blur: number; // from 0 to x (1 for realism)
  65509. * distortion: number; // from 0 to x (1 for realism)
  65510. * grain_amount: number; // from 0 to 1
  65511. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65512. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65513. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65514. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65515. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65516. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65517. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65518. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65519. * }
  65520. * Note: if an effect parameter is unset, effect is disabled
  65521. *
  65522. * @param name The rendering pipeline name
  65523. * @param parameters - An object containing all parameters (see above)
  65524. * @param scene The scene linked to this pipeline
  65525. * @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)
  65526. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65527. */
  65528. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65529. /**
  65530. * Get the class name
  65531. * @returns "LensRenderingPipeline"
  65532. */
  65533. getClassName(): string;
  65534. /**
  65535. * Gets associated scene
  65536. */
  65537. get scene(): Scene;
  65538. /**
  65539. * Gets or sets the edge blur
  65540. */
  65541. get edgeBlur(): number;
  65542. set edgeBlur(value: number);
  65543. /**
  65544. * Gets or sets the grain amount
  65545. */
  65546. get grainAmount(): number;
  65547. set grainAmount(value: number);
  65548. /**
  65549. * Gets or sets the chromatic aberration amount
  65550. */
  65551. get chromaticAberration(): number;
  65552. set chromaticAberration(value: number);
  65553. /**
  65554. * Gets or sets the depth of field aperture
  65555. */
  65556. get dofAperture(): number;
  65557. set dofAperture(value: number);
  65558. /**
  65559. * Gets or sets the edge distortion
  65560. */
  65561. get edgeDistortion(): number;
  65562. set edgeDistortion(value: number);
  65563. /**
  65564. * Gets or sets the depth of field distortion
  65565. */
  65566. get dofDistortion(): number;
  65567. set dofDistortion(value: number);
  65568. /**
  65569. * Gets or sets the darken out of focus amount
  65570. */
  65571. get darkenOutOfFocus(): number;
  65572. set darkenOutOfFocus(value: number);
  65573. /**
  65574. * Gets or sets a boolean indicating if blur noise is enabled
  65575. */
  65576. get blurNoise(): boolean;
  65577. set blurNoise(value: boolean);
  65578. /**
  65579. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65580. */
  65581. get pentagonBokeh(): boolean;
  65582. set pentagonBokeh(value: boolean);
  65583. /**
  65584. * Gets or sets the highlight grain amount
  65585. */
  65586. get highlightsGain(): number;
  65587. set highlightsGain(value: number);
  65588. /**
  65589. * Gets or sets the highlight threshold
  65590. */
  65591. get highlightsThreshold(): number;
  65592. set highlightsThreshold(value: number);
  65593. /**
  65594. * Sets the amount of blur at the edges
  65595. * @param amount blur amount
  65596. */
  65597. setEdgeBlur(amount: number): void;
  65598. /**
  65599. * Sets edge blur to 0
  65600. */
  65601. disableEdgeBlur(): void;
  65602. /**
  65603. * Sets the amout of grain
  65604. * @param amount Amount of grain
  65605. */
  65606. setGrainAmount(amount: number): void;
  65607. /**
  65608. * Set grain amount to 0
  65609. */
  65610. disableGrain(): void;
  65611. /**
  65612. * Sets the chromatic aberration amount
  65613. * @param amount amount of chromatic aberration
  65614. */
  65615. setChromaticAberration(amount: number): void;
  65616. /**
  65617. * Sets chromatic aberration amount to 0
  65618. */
  65619. disableChromaticAberration(): void;
  65620. /**
  65621. * Sets the EdgeDistortion amount
  65622. * @param amount amount of EdgeDistortion
  65623. */
  65624. setEdgeDistortion(amount: number): void;
  65625. /**
  65626. * Sets edge distortion to 0
  65627. */
  65628. disableEdgeDistortion(): void;
  65629. /**
  65630. * Sets the FocusDistance amount
  65631. * @param amount amount of FocusDistance
  65632. */
  65633. setFocusDistance(amount: number): void;
  65634. /**
  65635. * Disables depth of field
  65636. */
  65637. disableDepthOfField(): void;
  65638. /**
  65639. * Sets the Aperture amount
  65640. * @param amount amount of Aperture
  65641. */
  65642. setAperture(amount: number): void;
  65643. /**
  65644. * Sets the DarkenOutOfFocus amount
  65645. * @param amount amount of DarkenOutOfFocus
  65646. */
  65647. setDarkenOutOfFocus(amount: number): void;
  65648. private _pentagonBokehIsEnabled;
  65649. /**
  65650. * Creates a pentagon bokeh effect
  65651. */
  65652. enablePentagonBokeh(): void;
  65653. /**
  65654. * Disables the pentagon bokeh effect
  65655. */
  65656. disablePentagonBokeh(): void;
  65657. /**
  65658. * Enables noise blur
  65659. */
  65660. enableNoiseBlur(): void;
  65661. /**
  65662. * Disables noise blur
  65663. */
  65664. disableNoiseBlur(): void;
  65665. /**
  65666. * Sets the HighlightsGain amount
  65667. * @param amount amount of HighlightsGain
  65668. */
  65669. setHighlightsGain(amount: number): void;
  65670. /**
  65671. * Sets the HighlightsThreshold amount
  65672. * @param amount amount of HighlightsThreshold
  65673. */
  65674. setHighlightsThreshold(amount: number): void;
  65675. /**
  65676. * Disables highlights
  65677. */
  65678. disableHighlights(): void;
  65679. /**
  65680. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65681. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65682. */
  65683. dispose(disableDepthRender?: boolean): void;
  65684. private _createChromaticAberrationPostProcess;
  65685. private _createHighlightsPostProcess;
  65686. private _createDepthOfFieldPostProcess;
  65687. private _createGrainTexture;
  65688. }
  65689. }
  65690. declare module BABYLON {
  65691. /** @hidden */
  65692. export var ssao2PixelShader: {
  65693. name: string;
  65694. shader: string;
  65695. };
  65696. }
  65697. declare module BABYLON {
  65698. /** @hidden */
  65699. export var ssaoCombinePixelShader: {
  65700. name: string;
  65701. shader: string;
  65702. };
  65703. }
  65704. declare module BABYLON {
  65705. /**
  65706. * Render pipeline to produce ssao effect
  65707. */
  65708. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65709. /**
  65710. * @ignore
  65711. * The PassPostProcess id in the pipeline that contains the original scene color
  65712. */
  65713. SSAOOriginalSceneColorEffect: string;
  65714. /**
  65715. * @ignore
  65716. * The SSAO PostProcess id in the pipeline
  65717. */
  65718. SSAORenderEffect: string;
  65719. /**
  65720. * @ignore
  65721. * The horizontal blur PostProcess id in the pipeline
  65722. */
  65723. SSAOBlurHRenderEffect: string;
  65724. /**
  65725. * @ignore
  65726. * The vertical blur PostProcess id in the pipeline
  65727. */
  65728. SSAOBlurVRenderEffect: string;
  65729. /**
  65730. * @ignore
  65731. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65732. */
  65733. SSAOCombineRenderEffect: string;
  65734. /**
  65735. * The output strength of the SSAO post-process. Default value is 1.0.
  65736. */
  65737. totalStrength: number;
  65738. /**
  65739. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65740. */
  65741. maxZ: number;
  65742. /**
  65743. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65744. */
  65745. minZAspect: number;
  65746. private _samples;
  65747. /**
  65748. * Number of samples used for the SSAO calculations. Default value is 8
  65749. */
  65750. set samples(n: number);
  65751. get samples(): number;
  65752. private _textureSamples;
  65753. /**
  65754. * Number of samples to use for antialiasing
  65755. */
  65756. set textureSamples(n: number);
  65757. get textureSamples(): number;
  65758. /**
  65759. * Ratio object used for SSAO ratio and blur ratio
  65760. */
  65761. private _ratio;
  65762. /**
  65763. * Dynamically generated sphere sampler.
  65764. */
  65765. private _sampleSphere;
  65766. /**
  65767. * Blur filter offsets
  65768. */
  65769. private _samplerOffsets;
  65770. private _expensiveBlur;
  65771. /**
  65772. * If bilateral blur should be used
  65773. */
  65774. set expensiveBlur(b: boolean);
  65775. get expensiveBlur(): boolean;
  65776. /**
  65777. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65778. */
  65779. radius: number;
  65780. /**
  65781. * The base color of the SSAO post-process
  65782. * The final result is "base + ssao" between [0, 1]
  65783. */
  65784. base: number;
  65785. /**
  65786. * Support test.
  65787. */
  65788. static get IsSupported(): boolean;
  65789. private _scene;
  65790. private _depthTexture;
  65791. private _normalTexture;
  65792. private _randomTexture;
  65793. private _originalColorPostProcess;
  65794. private _ssaoPostProcess;
  65795. private _blurHPostProcess;
  65796. private _blurVPostProcess;
  65797. private _ssaoCombinePostProcess;
  65798. /**
  65799. * Gets active scene
  65800. */
  65801. get scene(): Scene;
  65802. /**
  65803. * @constructor
  65804. * @param name The rendering pipeline name
  65805. * @param scene The scene linked to this pipeline
  65806. * @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 }
  65807. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65808. */
  65809. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65810. /**
  65811. * Get the class name
  65812. * @returns "SSAO2RenderingPipeline"
  65813. */
  65814. getClassName(): string;
  65815. /**
  65816. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65817. */
  65818. dispose(disableGeometryBufferRenderer?: boolean): void;
  65819. private _createBlurPostProcess;
  65820. /** @hidden */
  65821. _rebuild(): void;
  65822. private _bits;
  65823. private _radicalInverse_VdC;
  65824. private _hammersley;
  65825. private _hemisphereSample_uniform;
  65826. private _generateHemisphere;
  65827. private _createSSAOPostProcess;
  65828. private _createSSAOCombinePostProcess;
  65829. private _createRandomTexture;
  65830. /**
  65831. * Serialize the rendering pipeline (Used when exporting)
  65832. * @returns the serialized object
  65833. */
  65834. serialize(): any;
  65835. /**
  65836. * Parse the serialized pipeline
  65837. * @param source Source pipeline.
  65838. * @param scene The scene to load the pipeline to.
  65839. * @param rootUrl The URL of the serialized pipeline.
  65840. * @returns An instantiated pipeline from the serialized object.
  65841. */
  65842. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65843. }
  65844. }
  65845. declare module BABYLON {
  65846. /** @hidden */
  65847. export var ssaoPixelShader: {
  65848. name: string;
  65849. shader: string;
  65850. };
  65851. }
  65852. declare module BABYLON {
  65853. /**
  65854. * Render pipeline to produce ssao effect
  65855. */
  65856. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65857. /**
  65858. * @ignore
  65859. * The PassPostProcess id in the pipeline that contains the original scene color
  65860. */
  65861. SSAOOriginalSceneColorEffect: string;
  65862. /**
  65863. * @ignore
  65864. * The SSAO PostProcess id in the pipeline
  65865. */
  65866. SSAORenderEffect: string;
  65867. /**
  65868. * @ignore
  65869. * The horizontal blur PostProcess id in the pipeline
  65870. */
  65871. SSAOBlurHRenderEffect: string;
  65872. /**
  65873. * @ignore
  65874. * The vertical blur PostProcess id in the pipeline
  65875. */
  65876. SSAOBlurVRenderEffect: string;
  65877. /**
  65878. * @ignore
  65879. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65880. */
  65881. SSAOCombineRenderEffect: string;
  65882. /**
  65883. * The output strength of the SSAO post-process. Default value is 1.0.
  65884. */
  65885. totalStrength: number;
  65886. /**
  65887. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65888. */
  65889. radius: number;
  65890. /**
  65891. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65892. * Must not be equal to fallOff and superior to fallOff.
  65893. * Default value is 0.0075
  65894. */
  65895. area: number;
  65896. /**
  65897. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65898. * Must not be equal to area and inferior to area.
  65899. * Default value is 0.000001
  65900. */
  65901. fallOff: number;
  65902. /**
  65903. * The base color of the SSAO post-process
  65904. * The final result is "base + ssao" between [0, 1]
  65905. */
  65906. base: number;
  65907. private _scene;
  65908. private _depthTexture;
  65909. private _randomTexture;
  65910. private _originalColorPostProcess;
  65911. private _ssaoPostProcess;
  65912. private _blurHPostProcess;
  65913. private _blurVPostProcess;
  65914. private _ssaoCombinePostProcess;
  65915. private _firstUpdate;
  65916. /**
  65917. * Gets active scene
  65918. */
  65919. get scene(): Scene;
  65920. /**
  65921. * @constructor
  65922. * @param name - The rendering pipeline name
  65923. * @param scene - The scene linked to this pipeline
  65924. * @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 }
  65925. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65926. */
  65927. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65928. /**
  65929. * Get the class name
  65930. * @returns "SSAORenderingPipeline"
  65931. */
  65932. getClassName(): string;
  65933. /**
  65934. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65935. */
  65936. dispose(disableDepthRender?: boolean): void;
  65937. private _createBlurPostProcess;
  65938. /** @hidden */
  65939. _rebuild(): void;
  65940. private _createSSAOPostProcess;
  65941. private _createSSAOCombinePostProcess;
  65942. private _createRandomTexture;
  65943. }
  65944. }
  65945. declare module BABYLON {
  65946. /** @hidden */
  65947. export var screenSpaceReflectionPixelShader: {
  65948. name: string;
  65949. shader: string;
  65950. };
  65951. }
  65952. declare module BABYLON {
  65953. /**
  65954. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65955. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65956. */
  65957. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65958. /**
  65959. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65960. */
  65961. threshold: number;
  65962. /**
  65963. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65964. */
  65965. strength: number;
  65966. /**
  65967. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65968. */
  65969. reflectionSpecularFalloffExponent: number;
  65970. /**
  65971. * 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]
  65972. */
  65973. step: number;
  65974. /**
  65975. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65976. */
  65977. roughnessFactor: number;
  65978. private _geometryBufferRenderer;
  65979. private _enableSmoothReflections;
  65980. private _reflectionSamples;
  65981. private _smoothSteps;
  65982. /**
  65983. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65984. * @param name The name of the effect.
  65985. * @param scene The scene containing the objects to calculate reflections.
  65986. * @param options The required width/height ratio to downsize to before computing the render pass.
  65987. * @param camera The camera to apply the render pass to.
  65988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65989. * @param engine The engine which the post process will be applied. (default: current engine)
  65990. * @param reusable If the post process can be reused on the same frame. (default: false)
  65991. * @param textureType Type of textures used when performing the post process. (default: 0)
  65992. * @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)
  65993. */
  65994. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65995. /**
  65996. * Gets wether or not smoothing reflections is enabled.
  65997. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65998. */
  65999. get enableSmoothReflections(): boolean;
  66000. /**
  66001. * Sets wether or not smoothing reflections is enabled.
  66002. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66003. */
  66004. set enableSmoothReflections(enabled: boolean);
  66005. /**
  66006. * Gets the number of samples taken while computing reflections. More samples count is high,
  66007. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66008. */
  66009. get reflectionSamples(): number;
  66010. /**
  66011. * Sets the number of samples taken while computing reflections. More samples count is high,
  66012. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66013. */
  66014. set reflectionSamples(samples: number);
  66015. /**
  66016. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66017. * more the post-process will require GPU power and can generate a drop in FPS.
  66018. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66019. */
  66020. get smoothSteps(): number;
  66021. set smoothSteps(steps: number);
  66022. private _updateEffectDefines;
  66023. }
  66024. }
  66025. declare module BABYLON {
  66026. /** @hidden */
  66027. export var standardPixelShader: {
  66028. name: string;
  66029. shader: string;
  66030. };
  66031. }
  66032. declare module BABYLON {
  66033. /**
  66034. * Standard rendering pipeline
  66035. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66036. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66037. */
  66038. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66039. /**
  66040. * Public members
  66041. */
  66042. /**
  66043. * Post-process which contains the original scene color before the pipeline applies all the effects
  66044. */
  66045. originalPostProcess: Nullable<PostProcess>;
  66046. /**
  66047. * Post-process used to down scale an image x4
  66048. */
  66049. downSampleX4PostProcess: Nullable<PostProcess>;
  66050. /**
  66051. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66052. */
  66053. brightPassPostProcess: Nullable<PostProcess>;
  66054. /**
  66055. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66056. */
  66057. blurHPostProcesses: PostProcess[];
  66058. /**
  66059. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66060. */
  66061. blurVPostProcesses: PostProcess[];
  66062. /**
  66063. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66064. */
  66065. textureAdderPostProcess: Nullable<PostProcess>;
  66066. /**
  66067. * Post-process used to create volumetric lighting effect
  66068. */
  66069. volumetricLightPostProcess: Nullable<PostProcess>;
  66070. /**
  66071. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66072. */
  66073. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66074. /**
  66075. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66076. */
  66077. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66078. /**
  66079. * Post-process used to merge the volumetric light effect and the real scene color
  66080. */
  66081. volumetricLightMergePostProces: Nullable<PostProcess>;
  66082. /**
  66083. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66084. */
  66085. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66086. /**
  66087. * Base post-process used to calculate the average luminance of the final image for HDR
  66088. */
  66089. luminancePostProcess: Nullable<PostProcess>;
  66090. /**
  66091. * Post-processes used to create down sample post-processes in order to get
  66092. * the average luminance of the final image for HDR
  66093. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66094. */
  66095. luminanceDownSamplePostProcesses: PostProcess[];
  66096. /**
  66097. * Post-process used to create a HDR effect (light adaptation)
  66098. */
  66099. hdrPostProcess: Nullable<PostProcess>;
  66100. /**
  66101. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66102. */
  66103. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66104. /**
  66105. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66106. */
  66107. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66108. /**
  66109. * Post-process used to merge the final HDR post-process and the real scene color
  66110. */
  66111. hdrFinalPostProcess: Nullable<PostProcess>;
  66112. /**
  66113. * Post-process used to create a lens flare effect
  66114. */
  66115. lensFlarePostProcess: Nullable<PostProcess>;
  66116. /**
  66117. * Post-process that merges the result of the lens flare post-process and the real scene color
  66118. */
  66119. lensFlareComposePostProcess: Nullable<PostProcess>;
  66120. /**
  66121. * Post-process used to create a motion blur effect
  66122. */
  66123. motionBlurPostProcess: Nullable<PostProcess>;
  66124. /**
  66125. * Post-process used to create a depth of field effect
  66126. */
  66127. depthOfFieldPostProcess: Nullable<PostProcess>;
  66128. /**
  66129. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66130. */
  66131. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66132. /**
  66133. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66134. */
  66135. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66136. /**
  66137. * Represents the brightness threshold in order to configure the illuminated surfaces
  66138. */
  66139. brightThreshold: number;
  66140. /**
  66141. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66142. */
  66143. blurWidth: number;
  66144. /**
  66145. * Sets if the blur for highlighted surfaces must be only horizontal
  66146. */
  66147. horizontalBlur: boolean;
  66148. /**
  66149. * Gets the overall exposure used by the pipeline
  66150. */
  66151. get exposure(): number;
  66152. /**
  66153. * Sets the overall exposure used by the pipeline
  66154. */
  66155. set exposure(value: number);
  66156. /**
  66157. * Texture used typically to simulate "dirty" on camera lens
  66158. */
  66159. lensTexture: Nullable<Texture>;
  66160. /**
  66161. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66162. */
  66163. volumetricLightCoefficient: number;
  66164. /**
  66165. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66166. */
  66167. volumetricLightPower: number;
  66168. /**
  66169. * Used the set the blur intensity to smooth the volumetric lights
  66170. */
  66171. volumetricLightBlurScale: number;
  66172. /**
  66173. * Light (spot or directional) used to generate the volumetric lights rays
  66174. * The source light must have a shadow generate so the pipeline can get its
  66175. * depth map
  66176. */
  66177. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66178. /**
  66179. * For eye adaptation, represents the minimum luminance the eye can see
  66180. */
  66181. hdrMinimumLuminance: number;
  66182. /**
  66183. * For eye adaptation, represents the decrease luminance speed
  66184. */
  66185. hdrDecreaseRate: number;
  66186. /**
  66187. * For eye adaptation, represents the increase luminance speed
  66188. */
  66189. hdrIncreaseRate: number;
  66190. /**
  66191. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66192. */
  66193. get hdrAutoExposure(): boolean;
  66194. /**
  66195. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66196. */
  66197. set hdrAutoExposure(value: boolean);
  66198. /**
  66199. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66200. */
  66201. lensColorTexture: Nullable<Texture>;
  66202. /**
  66203. * The overall strengh for the lens flare effect
  66204. */
  66205. lensFlareStrength: number;
  66206. /**
  66207. * Dispersion coefficient for lens flare ghosts
  66208. */
  66209. lensFlareGhostDispersal: number;
  66210. /**
  66211. * Main lens flare halo width
  66212. */
  66213. lensFlareHaloWidth: number;
  66214. /**
  66215. * Based on the lens distortion effect, defines how much the lens flare result
  66216. * is distorted
  66217. */
  66218. lensFlareDistortionStrength: number;
  66219. /**
  66220. * Configures the blur intensity used for for lens flare (halo)
  66221. */
  66222. lensFlareBlurWidth: number;
  66223. /**
  66224. * Lens star texture must be used to simulate rays on the flares and is available
  66225. * in the documentation
  66226. */
  66227. lensStarTexture: Nullable<Texture>;
  66228. /**
  66229. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66230. * flare effect by taking account of the dirt texture
  66231. */
  66232. lensFlareDirtTexture: Nullable<Texture>;
  66233. /**
  66234. * Represents the focal length for the depth of field effect
  66235. */
  66236. depthOfFieldDistance: number;
  66237. /**
  66238. * Represents the blur intensity for the blurred part of the depth of field effect
  66239. */
  66240. depthOfFieldBlurWidth: number;
  66241. /**
  66242. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66243. */
  66244. get motionStrength(): number;
  66245. /**
  66246. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66247. */
  66248. set motionStrength(strength: number);
  66249. /**
  66250. * Gets wether or not the motion blur post-process is object based or screen based.
  66251. */
  66252. get objectBasedMotionBlur(): boolean;
  66253. /**
  66254. * Sets wether or not the motion blur post-process should be object based or screen based
  66255. */
  66256. set objectBasedMotionBlur(value: boolean);
  66257. /**
  66258. * List of animations for the pipeline (IAnimatable implementation)
  66259. */
  66260. animations: Animation[];
  66261. /**
  66262. * Private members
  66263. */
  66264. private _scene;
  66265. private _currentDepthOfFieldSource;
  66266. private _basePostProcess;
  66267. private _fixedExposure;
  66268. private _currentExposure;
  66269. private _hdrAutoExposure;
  66270. private _hdrCurrentLuminance;
  66271. private _motionStrength;
  66272. private _isObjectBasedMotionBlur;
  66273. private _floatTextureType;
  66274. private _camerasToBeAttached;
  66275. private _ratio;
  66276. private _bloomEnabled;
  66277. private _depthOfFieldEnabled;
  66278. private _vlsEnabled;
  66279. private _lensFlareEnabled;
  66280. private _hdrEnabled;
  66281. private _motionBlurEnabled;
  66282. private _fxaaEnabled;
  66283. private _screenSpaceReflectionsEnabled;
  66284. private _motionBlurSamples;
  66285. private _volumetricLightStepsCount;
  66286. private _samples;
  66287. /**
  66288. * @ignore
  66289. * Specifies if the bloom pipeline is enabled
  66290. */
  66291. get BloomEnabled(): boolean;
  66292. set BloomEnabled(enabled: boolean);
  66293. /**
  66294. * @ignore
  66295. * Specifies if the depth of field pipeline is enabed
  66296. */
  66297. get DepthOfFieldEnabled(): boolean;
  66298. set DepthOfFieldEnabled(enabled: boolean);
  66299. /**
  66300. * @ignore
  66301. * Specifies if the lens flare pipeline is enabed
  66302. */
  66303. get LensFlareEnabled(): boolean;
  66304. set LensFlareEnabled(enabled: boolean);
  66305. /**
  66306. * @ignore
  66307. * Specifies if the HDR pipeline is enabled
  66308. */
  66309. get HDREnabled(): boolean;
  66310. set HDREnabled(enabled: boolean);
  66311. /**
  66312. * @ignore
  66313. * Specifies if the volumetric lights scattering effect is enabled
  66314. */
  66315. get VLSEnabled(): boolean;
  66316. set VLSEnabled(enabled: boolean);
  66317. /**
  66318. * @ignore
  66319. * Specifies if the motion blur effect is enabled
  66320. */
  66321. get MotionBlurEnabled(): boolean;
  66322. set MotionBlurEnabled(enabled: boolean);
  66323. /**
  66324. * Specifies if anti-aliasing is enabled
  66325. */
  66326. get fxaaEnabled(): boolean;
  66327. set fxaaEnabled(enabled: boolean);
  66328. /**
  66329. * Specifies if screen space reflections are enabled.
  66330. */
  66331. get screenSpaceReflectionsEnabled(): boolean;
  66332. set screenSpaceReflectionsEnabled(enabled: boolean);
  66333. /**
  66334. * Specifies the number of steps used to calculate the volumetric lights
  66335. * Typically in interval [50, 200]
  66336. */
  66337. get volumetricLightStepsCount(): number;
  66338. set volumetricLightStepsCount(count: number);
  66339. /**
  66340. * Specifies the number of samples used for the motion blur effect
  66341. * Typically in interval [16, 64]
  66342. */
  66343. get motionBlurSamples(): number;
  66344. set motionBlurSamples(samples: number);
  66345. /**
  66346. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66347. */
  66348. get samples(): number;
  66349. set samples(sampleCount: number);
  66350. /**
  66351. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66352. * @constructor
  66353. * @param name The rendering pipeline name
  66354. * @param scene The scene linked to this pipeline
  66355. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  66356. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66357. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66358. */
  66359. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66360. private _buildPipeline;
  66361. private _createDownSampleX4PostProcess;
  66362. private _createBrightPassPostProcess;
  66363. private _createBlurPostProcesses;
  66364. private _createTextureAdderPostProcess;
  66365. private _createVolumetricLightPostProcess;
  66366. private _createLuminancePostProcesses;
  66367. private _createHdrPostProcess;
  66368. private _createLensFlarePostProcess;
  66369. private _createDepthOfFieldPostProcess;
  66370. private _createMotionBlurPostProcess;
  66371. private _getDepthTexture;
  66372. private _disposePostProcesses;
  66373. /**
  66374. * Dispose of the pipeline and stop all post processes
  66375. */
  66376. dispose(): void;
  66377. /**
  66378. * Serialize the rendering pipeline (Used when exporting)
  66379. * @returns the serialized object
  66380. */
  66381. serialize(): any;
  66382. /**
  66383. * Parse the serialized pipeline
  66384. * @param source Source pipeline.
  66385. * @param scene The scene to load the pipeline to.
  66386. * @param rootUrl The URL of the serialized pipeline.
  66387. * @returns An instantiated pipeline from the serialized object.
  66388. */
  66389. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66390. /**
  66391. * Luminance steps
  66392. */
  66393. static LuminanceSteps: number;
  66394. }
  66395. }
  66396. declare module BABYLON {
  66397. /** @hidden */
  66398. export var tonemapPixelShader: {
  66399. name: string;
  66400. shader: string;
  66401. };
  66402. }
  66403. declare module BABYLON {
  66404. /** Defines operator used for tonemapping */
  66405. export enum TonemappingOperator {
  66406. /** Hable */
  66407. Hable = 0,
  66408. /** Reinhard */
  66409. Reinhard = 1,
  66410. /** HejiDawson */
  66411. HejiDawson = 2,
  66412. /** Photographic */
  66413. Photographic = 3
  66414. }
  66415. /**
  66416. * Defines a post process to apply tone mapping
  66417. */
  66418. export class TonemapPostProcess extends PostProcess {
  66419. private _operator;
  66420. /** Defines the required exposure adjustement */
  66421. exposureAdjustment: number;
  66422. /**
  66423. * Creates a new TonemapPostProcess
  66424. * @param name defines the name of the postprocess
  66425. * @param _operator defines the operator to use
  66426. * @param exposureAdjustment defines the required exposure adjustement
  66427. * @param camera defines the camera to use (can be null)
  66428. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66429. * @param engine defines the hosting engine (can be ignore if camera is set)
  66430. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66431. */
  66432. constructor(name: string, _operator: TonemappingOperator,
  66433. /** Defines the required exposure adjustement */
  66434. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66435. }
  66436. }
  66437. declare module BABYLON {
  66438. /** @hidden */
  66439. export var volumetricLightScatteringPixelShader: {
  66440. name: string;
  66441. shader: string;
  66442. };
  66443. }
  66444. declare module BABYLON {
  66445. /** @hidden */
  66446. export var volumetricLightScatteringPassVertexShader: {
  66447. name: string;
  66448. shader: string;
  66449. };
  66450. }
  66451. declare module BABYLON {
  66452. /** @hidden */
  66453. export var volumetricLightScatteringPassPixelShader: {
  66454. name: string;
  66455. shader: string;
  66456. };
  66457. }
  66458. declare module BABYLON {
  66459. /**
  66460. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66461. */
  66462. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66463. private _volumetricLightScatteringPass;
  66464. private _volumetricLightScatteringRTT;
  66465. private _viewPort;
  66466. private _screenCoordinates;
  66467. private _cachedDefines;
  66468. /**
  66469. * If not undefined, the mesh position is computed from the attached node position
  66470. */
  66471. attachedNode: {
  66472. position: Vector3;
  66473. };
  66474. /**
  66475. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66476. */
  66477. customMeshPosition: Vector3;
  66478. /**
  66479. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66480. */
  66481. useCustomMeshPosition: boolean;
  66482. /**
  66483. * If the post-process should inverse the light scattering direction
  66484. */
  66485. invert: boolean;
  66486. /**
  66487. * The internal mesh used by the post-process
  66488. */
  66489. mesh: Mesh;
  66490. /**
  66491. * @hidden
  66492. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66493. */
  66494. get useDiffuseColor(): boolean;
  66495. set useDiffuseColor(useDiffuseColor: boolean);
  66496. /**
  66497. * Array containing the excluded meshes not rendered in the internal pass
  66498. */
  66499. excludedMeshes: AbstractMesh[];
  66500. /**
  66501. * Controls the overall intensity of the post-process
  66502. */
  66503. exposure: number;
  66504. /**
  66505. * Dissipates each sample's contribution in range [0, 1]
  66506. */
  66507. decay: number;
  66508. /**
  66509. * Controls the overall intensity of each sample
  66510. */
  66511. weight: number;
  66512. /**
  66513. * Controls the density of each sample
  66514. */
  66515. density: number;
  66516. /**
  66517. * @constructor
  66518. * @param name The post-process name
  66519. * @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)
  66520. * @param camera The camera that the post-process will be attached to
  66521. * @param mesh The mesh used to create the light scattering
  66522. * @param samples The post-process quality, default 100
  66523. * @param samplingModeThe post-process filtering mode
  66524. * @param engine The babylon engine
  66525. * @param reusable If the post-process is reusable
  66526. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66527. */
  66528. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66529. /**
  66530. * Returns the string "VolumetricLightScatteringPostProcess"
  66531. * @returns "VolumetricLightScatteringPostProcess"
  66532. */
  66533. getClassName(): string;
  66534. private _isReady;
  66535. /**
  66536. * Sets the new light position for light scattering effect
  66537. * @param position The new custom light position
  66538. */
  66539. setCustomMeshPosition(position: Vector3): void;
  66540. /**
  66541. * Returns the light position for light scattering effect
  66542. * @return Vector3 The custom light position
  66543. */
  66544. getCustomMeshPosition(): Vector3;
  66545. /**
  66546. * Disposes the internal assets and detaches the post-process from the camera
  66547. */
  66548. dispose(camera: Camera): void;
  66549. /**
  66550. * Returns the render target texture used by the post-process
  66551. * @return the render target texture used by the post-process
  66552. */
  66553. getPass(): RenderTargetTexture;
  66554. private _meshExcluded;
  66555. private _createPass;
  66556. private _updateMeshScreenCoordinates;
  66557. /**
  66558. * Creates a default mesh for the Volumeric Light Scattering post-process
  66559. * @param name The mesh name
  66560. * @param scene The scene where to create the mesh
  66561. * @return the default mesh
  66562. */
  66563. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66564. }
  66565. }
  66566. declare module BABYLON {
  66567. interface Scene {
  66568. /** @hidden (Backing field) */
  66569. _boundingBoxRenderer: BoundingBoxRenderer;
  66570. /** @hidden (Backing field) */
  66571. _forceShowBoundingBoxes: boolean;
  66572. /**
  66573. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66574. */
  66575. forceShowBoundingBoxes: boolean;
  66576. /**
  66577. * Gets the bounding box renderer associated with the scene
  66578. * @returns a BoundingBoxRenderer
  66579. */
  66580. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66581. }
  66582. interface AbstractMesh {
  66583. /** @hidden (Backing field) */
  66584. _showBoundingBox: boolean;
  66585. /**
  66586. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66587. */
  66588. showBoundingBox: boolean;
  66589. }
  66590. /**
  66591. * Component responsible of rendering the bounding box of the meshes in a scene.
  66592. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66593. */
  66594. export class BoundingBoxRenderer implements ISceneComponent {
  66595. /**
  66596. * The component name helpfull to identify the component in the list of scene components.
  66597. */
  66598. readonly name: string;
  66599. /**
  66600. * The scene the component belongs to.
  66601. */
  66602. scene: Scene;
  66603. /**
  66604. * Color of the bounding box lines placed in front of an object
  66605. */
  66606. frontColor: Color3;
  66607. /**
  66608. * Color of the bounding box lines placed behind an object
  66609. */
  66610. backColor: Color3;
  66611. /**
  66612. * Defines if the renderer should show the back lines or not
  66613. */
  66614. showBackLines: boolean;
  66615. /**
  66616. * @hidden
  66617. */
  66618. renderList: SmartArray<BoundingBox>;
  66619. private _colorShader;
  66620. private _vertexBuffers;
  66621. private _indexBuffer;
  66622. private _fillIndexBuffer;
  66623. private _fillIndexData;
  66624. /**
  66625. * Instantiates a new bounding box renderer in a scene.
  66626. * @param scene the scene the renderer renders in
  66627. */
  66628. constructor(scene: Scene);
  66629. /**
  66630. * Registers the component in a given scene
  66631. */
  66632. register(): void;
  66633. private _evaluateSubMesh;
  66634. private _activeMesh;
  66635. private _prepareRessources;
  66636. private _createIndexBuffer;
  66637. /**
  66638. * Rebuilds the elements related to this component in case of
  66639. * context lost for instance.
  66640. */
  66641. rebuild(): void;
  66642. /**
  66643. * @hidden
  66644. */
  66645. reset(): void;
  66646. /**
  66647. * Render the bounding boxes of a specific rendering group
  66648. * @param renderingGroupId defines the rendering group to render
  66649. */
  66650. render(renderingGroupId: number): void;
  66651. /**
  66652. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66653. * @param mesh Define the mesh to render the occlusion bounding box for
  66654. */
  66655. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66656. /**
  66657. * Dispose and release the resources attached to this renderer.
  66658. */
  66659. dispose(): void;
  66660. }
  66661. }
  66662. declare module BABYLON {
  66663. interface Scene {
  66664. /** @hidden (Backing field) */
  66665. _depthRenderer: {
  66666. [id: string]: DepthRenderer;
  66667. };
  66668. /**
  66669. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66670. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66671. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66672. * @returns the created depth renderer
  66673. */
  66674. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66675. /**
  66676. * Disables a depth renderer for a given camera
  66677. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66678. */
  66679. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66680. }
  66681. /**
  66682. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66683. * in several rendering techniques.
  66684. */
  66685. export class DepthRendererSceneComponent implements ISceneComponent {
  66686. /**
  66687. * The component name helpfull to identify the component in the list of scene components.
  66688. */
  66689. readonly name: string;
  66690. /**
  66691. * The scene the component belongs to.
  66692. */
  66693. scene: Scene;
  66694. /**
  66695. * Creates a new instance of the component for the given scene
  66696. * @param scene Defines the scene to register the component in
  66697. */
  66698. constructor(scene: Scene);
  66699. /**
  66700. * Registers the component in a given scene
  66701. */
  66702. register(): void;
  66703. /**
  66704. * Rebuilds the elements related to this component in case of
  66705. * context lost for instance.
  66706. */
  66707. rebuild(): void;
  66708. /**
  66709. * Disposes the component and the associated ressources
  66710. */
  66711. dispose(): void;
  66712. private _gatherRenderTargets;
  66713. private _gatherActiveCameraRenderTargets;
  66714. }
  66715. }
  66716. declare module BABYLON {
  66717. /** @hidden */
  66718. export var outlinePixelShader: {
  66719. name: string;
  66720. shader: string;
  66721. };
  66722. }
  66723. declare module BABYLON {
  66724. /** @hidden */
  66725. export var outlineVertexShader: {
  66726. name: string;
  66727. shader: string;
  66728. };
  66729. }
  66730. declare module BABYLON {
  66731. interface Scene {
  66732. /** @hidden */
  66733. _outlineRenderer: OutlineRenderer;
  66734. /**
  66735. * Gets the outline renderer associated with the scene
  66736. * @returns a OutlineRenderer
  66737. */
  66738. getOutlineRenderer(): OutlineRenderer;
  66739. }
  66740. interface AbstractMesh {
  66741. /** @hidden (Backing field) */
  66742. _renderOutline: boolean;
  66743. /**
  66744. * Gets or sets a boolean indicating if the outline must be rendered as well
  66745. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66746. */
  66747. renderOutline: boolean;
  66748. /** @hidden (Backing field) */
  66749. _renderOverlay: boolean;
  66750. /**
  66751. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66752. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66753. */
  66754. renderOverlay: boolean;
  66755. }
  66756. /**
  66757. * This class is responsible to draw bothe outline/overlay of meshes.
  66758. * It should not be used directly but through the available method on mesh.
  66759. */
  66760. export class OutlineRenderer implements ISceneComponent {
  66761. /**
  66762. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66763. */
  66764. private static _StencilReference;
  66765. /**
  66766. * The name of the component. Each component must have a unique name.
  66767. */
  66768. name: string;
  66769. /**
  66770. * The scene the component belongs to.
  66771. */
  66772. scene: Scene;
  66773. /**
  66774. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66775. */
  66776. zOffset: number;
  66777. private _engine;
  66778. private _effect;
  66779. private _cachedDefines;
  66780. private _savedDepthWrite;
  66781. /**
  66782. * Instantiates a new outline renderer. (There could be only one per scene).
  66783. * @param scene Defines the scene it belongs to
  66784. */
  66785. constructor(scene: Scene);
  66786. /**
  66787. * Register the component to one instance of a scene.
  66788. */
  66789. register(): void;
  66790. /**
  66791. * Rebuilds the elements related to this component in case of
  66792. * context lost for instance.
  66793. */
  66794. rebuild(): void;
  66795. /**
  66796. * Disposes the component and the associated ressources.
  66797. */
  66798. dispose(): void;
  66799. /**
  66800. * Renders the outline in the canvas.
  66801. * @param subMesh Defines the sumesh to render
  66802. * @param batch Defines the batch of meshes in case of instances
  66803. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66804. */
  66805. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66806. /**
  66807. * Returns whether or not the outline renderer is ready for a given submesh.
  66808. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66809. * @param subMesh Defines the submesh to check readyness for
  66810. * @param useInstances Defines wheter wee are trying to render instances or not
  66811. * @returns true if ready otherwise false
  66812. */
  66813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66814. private _beforeRenderingMesh;
  66815. private _afterRenderingMesh;
  66816. }
  66817. }
  66818. declare module BABYLON {
  66819. /**
  66820. * Defines the basic options interface of a Sprite Frame Source Size.
  66821. */
  66822. export interface ISpriteJSONSpriteSourceSize {
  66823. /**
  66824. * number of the original width of the Frame
  66825. */
  66826. w: number;
  66827. /**
  66828. * number of the original height of the Frame
  66829. */
  66830. h: number;
  66831. }
  66832. /**
  66833. * Defines the basic options interface of a Sprite Frame Data.
  66834. */
  66835. export interface ISpriteJSONSpriteFrameData {
  66836. /**
  66837. * number of the x offset of the Frame
  66838. */
  66839. x: number;
  66840. /**
  66841. * number of the y offset of the Frame
  66842. */
  66843. y: number;
  66844. /**
  66845. * number of the width of the Frame
  66846. */
  66847. w: number;
  66848. /**
  66849. * number of the height of the Frame
  66850. */
  66851. h: number;
  66852. }
  66853. /**
  66854. * Defines the basic options interface of a JSON Sprite.
  66855. */
  66856. export interface ISpriteJSONSprite {
  66857. /**
  66858. * string name of the Frame
  66859. */
  66860. filename: string;
  66861. /**
  66862. * ISpriteJSONSpriteFrame basic object of the frame data
  66863. */
  66864. frame: ISpriteJSONSpriteFrameData;
  66865. /**
  66866. * boolean to flag is the frame was rotated.
  66867. */
  66868. rotated: boolean;
  66869. /**
  66870. * boolean to flag is the frame was trimmed.
  66871. */
  66872. trimmed: boolean;
  66873. /**
  66874. * ISpriteJSONSpriteFrame basic object of the source data
  66875. */
  66876. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66877. /**
  66878. * ISpriteJSONSpriteFrame basic object of the source data
  66879. */
  66880. sourceSize: ISpriteJSONSpriteSourceSize;
  66881. }
  66882. /**
  66883. * Defines the basic options interface of a JSON atlas.
  66884. */
  66885. export interface ISpriteJSONAtlas {
  66886. /**
  66887. * Array of objects that contain the frame data.
  66888. */
  66889. frames: Array<ISpriteJSONSprite>;
  66890. /**
  66891. * object basic object containing the sprite meta data.
  66892. */
  66893. meta?: object;
  66894. }
  66895. }
  66896. declare module BABYLON {
  66897. /** @hidden */
  66898. export var spriteMapPixelShader: {
  66899. name: string;
  66900. shader: string;
  66901. };
  66902. }
  66903. declare module BABYLON {
  66904. /** @hidden */
  66905. export var spriteMapVertexShader: {
  66906. name: string;
  66907. shader: string;
  66908. };
  66909. }
  66910. declare module BABYLON {
  66911. /**
  66912. * Defines the basic options interface of a SpriteMap
  66913. */
  66914. export interface ISpriteMapOptions {
  66915. /**
  66916. * Vector2 of the number of cells in the grid.
  66917. */
  66918. stageSize?: Vector2;
  66919. /**
  66920. * Vector2 of the size of the output plane in World Units.
  66921. */
  66922. outputSize?: Vector2;
  66923. /**
  66924. * Vector3 of the position of the output plane in World Units.
  66925. */
  66926. outputPosition?: Vector3;
  66927. /**
  66928. * Vector3 of the rotation of the output plane.
  66929. */
  66930. outputRotation?: Vector3;
  66931. /**
  66932. * number of layers that the system will reserve in resources.
  66933. */
  66934. layerCount?: number;
  66935. /**
  66936. * number of max animation frames a single cell will reserve in resources.
  66937. */
  66938. maxAnimationFrames?: number;
  66939. /**
  66940. * number cell index of the base tile when the system compiles.
  66941. */
  66942. baseTile?: number;
  66943. /**
  66944. * boolean flip the sprite after its been repositioned by the framing data.
  66945. */
  66946. flipU?: boolean;
  66947. /**
  66948. * Vector3 scalar of the global RGB values of the SpriteMap.
  66949. */
  66950. colorMultiply?: Vector3;
  66951. }
  66952. /**
  66953. * Defines the IDisposable interface in order to be cleanable from resources.
  66954. */
  66955. export interface ISpriteMap extends IDisposable {
  66956. /**
  66957. * String name of the SpriteMap.
  66958. */
  66959. name: string;
  66960. /**
  66961. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66962. */
  66963. atlasJSON: ISpriteJSONAtlas;
  66964. /**
  66965. * Texture of the SpriteMap.
  66966. */
  66967. spriteSheet: Texture;
  66968. /**
  66969. * The parameters to initialize the SpriteMap with.
  66970. */
  66971. options: ISpriteMapOptions;
  66972. }
  66973. /**
  66974. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66975. */
  66976. export class SpriteMap implements ISpriteMap {
  66977. /** The Name of the spriteMap */
  66978. name: string;
  66979. /** The JSON file with the frame and meta data */
  66980. atlasJSON: ISpriteJSONAtlas;
  66981. /** The systems Sprite Sheet Texture */
  66982. spriteSheet: Texture;
  66983. /** Arguments passed with the Constructor */
  66984. options: ISpriteMapOptions;
  66985. /** Public Sprite Storage array, parsed from atlasJSON */
  66986. sprites: Array<ISpriteJSONSprite>;
  66987. /** Returns the Number of Sprites in the System */
  66988. get spriteCount(): number;
  66989. /** Returns the Position of Output Plane*/
  66990. get position(): Vector3;
  66991. /** Returns the Position of Output Plane*/
  66992. set position(v: Vector3);
  66993. /** Returns the Rotation of Output Plane*/
  66994. get rotation(): Vector3;
  66995. /** Returns the Rotation of Output Plane*/
  66996. set rotation(v: Vector3);
  66997. /** Sets the AnimationMap*/
  66998. get animationMap(): RawTexture;
  66999. /** Sets the AnimationMap*/
  67000. set animationMap(v: RawTexture);
  67001. /** Scene that the SpriteMap was created in */
  67002. private _scene;
  67003. /** Texture Buffer of Float32 that holds tile frame data*/
  67004. private _frameMap;
  67005. /** Texture Buffers of Float32 that holds tileMap data*/
  67006. private _tileMaps;
  67007. /** Texture Buffer of Float32 that holds Animation Data*/
  67008. private _animationMap;
  67009. /** Custom ShaderMaterial Central to the System*/
  67010. private _material;
  67011. /** Custom ShaderMaterial Central to the System*/
  67012. private _output;
  67013. /** Systems Time Ticker*/
  67014. private _time;
  67015. /**
  67016. * Creates a new SpriteMap
  67017. * @param name defines the SpriteMaps Name
  67018. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67019. * @param spriteSheet is the Texture that the Sprites are on.
  67020. * @param options a basic deployment configuration
  67021. * @param scene The Scene that the map is deployed on
  67022. */
  67023. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67024. /**
  67025. * Returns tileID location
  67026. * @returns Vector2 the cell position ID
  67027. */
  67028. getTileID(): Vector2;
  67029. /**
  67030. * Gets the UV location of the mouse over the SpriteMap.
  67031. * @returns Vector2 the UV position of the mouse interaction
  67032. */
  67033. getMousePosition(): Vector2;
  67034. /**
  67035. * Creates the "frame" texture Buffer
  67036. * -------------------------------------
  67037. * Structure of frames
  67038. * "filename": "Falling-Water-2.png",
  67039. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67040. * "rotated": true,
  67041. * "trimmed": true,
  67042. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67043. * "sourceSize": {"w":32,"h":32}
  67044. * @returns RawTexture of the frameMap
  67045. */
  67046. private _createFrameBuffer;
  67047. /**
  67048. * Creates the tileMap texture Buffer
  67049. * @param buffer normally and array of numbers, or a false to generate from scratch
  67050. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67051. * @returns RawTexture of the tileMap
  67052. */
  67053. private _createTileBuffer;
  67054. /**
  67055. * Modifies the data of the tileMaps
  67056. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67057. * @param pos is the iVector2 Coordinates of the Tile
  67058. * @param tile The SpriteIndex of the new Tile
  67059. */
  67060. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67061. /**
  67062. * Creates the animationMap texture Buffer
  67063. * @param buffer normally and array of numbers, or a false to generate from scratch
  67064. * @returns RawTexture of the animationMap
  67065. */
  67066. private _createTileAnimationBuffer;
  67067. /**
  67068. * Modifies the data of the animationMap
  67069. * @param cellID is the Index of the Sprite
  67070. * @param _frame is the target Animation frame
  67071. * @param toCell is the Target Index of the next frame of the animation
  67072. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67073. * @param speed is a global scalar of the time variable on the map.
  67074. */
  67075. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67076. /**
  67077. * Exports the .tilemaps file
  67078. */
  67079. saveTileMaps(): void;
  67080. /**
  67081. * Imports the .tilemaps file
  67082. * @param url of the .tilemaps file
  67083. */
  67084. loadTileMaps(url: string): void;
  67085. /**
  67086. * Release associated resources
  67087. */
  67088. dispose(): void;
  67089. }
  67090. }
  67091. declare module BABYLON {
  67092. /**
  67093. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67094. * @see http://doc.babylonjs.com/babylon101/sprites
  67095. */
  67096. export class SpritePackedManager extends SpriteManager {
  67097. /** defines the packed manager's name */
  67098. name: string;
  67099. /**
  67100. * Creates a new sprite manager from a packed sprite sheet
  67101. * @param name defines the manager's name
  67102. * @param imgUrl defines the sprite sheet url
  67103. * @param capacity defines the maximum allowed number of sprites
  67104. * @param scene defines the hosting scene
  67105. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67106. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67107. * @param samplingMode defines the smapling mode to use with spritesheet
  67108. * @param fromPacked set to true; do not alter
  67109. */
  67110. constructor(
  67111. /** defines the packed manager's name */
  67112. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67113. }
  67114. }
  67115. declare module BABYLON {
  67116. /**
  67117. * Defines the list of states available for a task inside a AssetsManager
  67118. */
  67119. export enum AssetTaskState {
  67120. /**
  67121. * Initialization
  67122. */
  67123. INIT = 0,
  67124. /**
  67125. * Running
  67126. */
  67127. RUNNING = 1,
  67128. /**
  67129. * Done
  67130. */
  67131. DONE = 2,
  67132. /**
  67133. * Error
  67134. */
  67135. ERROR = 3
  67136. }
  67137. /**
  67138. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67139. */
  67140. export abstract class AbstractAssetTask {
  67141. /**
  67142. * Task name
  67143. */ name: string;
  67144. /**
  67145. * Callback called when the task is successful
  67146. */
  67147. onSuccess: (task: any) => void;
  67148. /**
  67149. * Callback called when the task is not successful
  67150. */
  67151. onError: (task: any, message?: string, exception?: any) => void;
  67152. /**
  67153. * Creates a new AssetsManager
  67154. * @param name defines the name of the task
  67155. */
  67156. constructor(
  67157. /**
  67158. * Task name
  67159. */ name: string);
  67160. private _isCompleted;
  67161. private _taskState;
  67162. private _errorObject;
  67163. /**
  67164. * Get if the task is completed
  67165. */
  67166. get isCompleted(): boolean;
  67167. /**
  67168. * Gets the current state of the task
  67169. */
  67170. get taskState(): AssetTaskState;
  67171. /**
  67172. * Gets the current error object (if task is in error)
  67173. */
  67174. get errorObject(): {
  67175. message?: string;
  67176. exception?: any;
  67177. };
  67178. /**
  67179. * Internal only
  67180. * @hidden
  67181. */
  67182. _setErrorObject(message?: string, exception?: any): void;
  67183. /**
  67184. * Execute the current task
  67185. * @param scene defines the scene where you want your assets to be loaded
  67186. * @param onSuccess is a callback called when the task is successfully executed
  67187. * @param onError is a callback called if an error occurs
  67188. */
  67189. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67190. /**
  67191. * Execute the current task
  67192. * @param scene defines the scene where you want your assets to be loaded
  67193. * @param onSuccess is a callback called when the task is successfully executed
  67194. * @param onError is a callback called if an error occurs
  67195. */
  67196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67197. /**
  67198. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67199. * This can be used with failed tasks that have the reason for failure fixed.
  67200. */
  67201. reset(): void;
  67202. private onErrorCallback;
  67203. private onDoneCallback;
  67204. }
  67205. /**
  67206. * Define the interface used by progress events raised during assets loading
  67207. */
  67208. export interface IAssetsProgressEvent {
  67209. /**
  67210. * Defines the number of remaining tasks to process
  67211. */
  67212. remainingCount: number;
  67213. /**
  67214. * Defines the total number of tasks
  67215. */
  67216. totalCount: number;
  67217. /**
  67218. * Defines the task that was just processed
  67219. */
  67220. task: AbstractAssetTask;
  67221. }
  67222. /**
  67223. * Class used to share progress information about assets loading
  67224. */
  67225. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67226. /**
  67227. * Defines the number of remaining tasks to process
  67228. */
  67229. remainingCount: number;
  67230. /**
  67231. * Defines the total number of tasks
  67232. */
  67233. totalCount: number;
  67234. /**
  67235. * Defines the task that was just processed
  67236. */
  67237. task: AbstractAssetTask;
  67238. /**
  67239. * Creates a AssetsProgressEvent
  67240. * @param remainingCount defines the number of remaining tasks to process
  67241. * @param totalCount defines the total number of tasks
  67242. * @param task defines the task that was just processed
  67243. */
  67244. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67245. }
  67246. /**
  67247. * Define a task used by AssetsManager to load meshes
  67248. */
  67249. export class MeshAssetTask extends AbstractAssetTask {
  67250. /**
  67251. * Defines the name of the task
  67252. */
  67253. name: string;
  67254. /**
  67255. * Defines the list of mesh's names you want to load
  67256. */
  67257. meshesNames: any;
  67258. /**
  67259. * Defines the root url to use as a base to load your meshes and associated resources
  67260. */
  67261. rootUrl: string;
  67262. /**
  67263. * Defines the filename of the scene to load from
  67264. */
  67265. sceneFilename: string;
  67266. /**
  67267. * Gets the list of loaded meshes
  67268. */
  67269. loadedMeshes: Array<AbstractMesh>;
  67270. /**
  67271. * Gets the list of loaded particle systems
  67272. */
  67273. loadedParticleSystems: Array<IParticleSystem>;
  67274. /**
  67275. * Gets the list of loaded skeletons
  67276. */
  67277. loadedSkeletons: Array<Skeleton>;
  67278. /**
  67279. * Gets the list of loaded animation groups
  67280. */
  67281. loadedAnimationGroups: Array<AnimationGroup>;
  67282. /**
  67283. * Callback called when the task is successful
  67284. */
  67285. onSuccess: (task: MeshAssetTask) => void;
  67286. /**
  67287. * Callback called when the task is successful
  67288. */
  67289. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67290. /**
  67291. * Creates a new MeshAssetTask
  67292. * @param name defines the name of the task
  67293. * @param meshesNames defines the list of mesh's names you want to load
  67294. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67295. * @param sceneFilename defines the filename of the scene to load from
  67296. */
  67297. constructor(
  67298. /**
  67299. * Defines the name of the task
  67300. */
  67301. name: string,
  67302. /**
  67303. * Defines the list of mesh's names you want to load
  67304. */
  67305. meshesNames: any,
  67306. /**
  67307. * Defines the root url to use as a base to load your meshes and associated resources
  67308. */
  67309. rootUrl: string,
  67310. /**
  67311. * Defines the filename of the scene to load from
  67312. */
  67313. sceneFilename: string);
  67314. /**
  67315. * Execute the current task
  67316. * @param scene defines the scene where you want your assets to be loaded
  67317. * @param onSuccess is a callback called when the task is successfully executed
  67318. * @param onError is a callback called if an error occurs
  67319. */
  67320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67321. }
  67322. /**
  67323. * Define a task used by AssetsManager to load text content
  67324. */
  67325. export class TextFileAssetTask extends AbstractAssetTask {
  67326. /**
  67327. * Defines the name of the task
  67328. */
  67329. name: string;
  67330. /**
  67331. * Defines the location of the file to load
  67332. */
  67333. url: string;
  67334. /**
  67335. * Gets the loaded text string
  67336. */
  67337. text: string;
  67338. /**
  67339. * Callback called when the task is successful
  67340. */
  67341. onSuccess: (task: TextFileAssetTask) => void;
  67342. /**
  67343. * Callback called when the task is successful
  67344. */
  67345. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67346. /**
  67347. * Creates a new TextFileAssetTask object
  67348. * @param name defines the name of the task
  67349. * @param url defines the location of the file to load
  67350. */
  67351. constructor(
  67352. /**
  67353. * Defines the name of the task
  67354. */
  67355. name: string,
  67356. /**
  67357. * Defines the location of the file to load
  67358. */
  67359. url: string);
  67360. /**
  67361. * Execute the current task
  67362. * @param scene defines the scene where you want your assets to be loaded
  67363. * @param onSuccess is a callback called when the task is successfully executed
  67364. * @param onError is a callback called if an error occurs
  67365. */
  67366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67367. }
  67368. /**
  67369. * Define a task used by AssetsManager to load binary data
  67370. */
  67371. export class BinaryFileAssetTask extends AbstractAssetTask {
  67372. /**
  67373. * Defines the name of the task
  67374. */
  67375. name: string;
  67376. /**
  67377. * Defines the location of the file to load
  67378. */
  67379. url: string;
  67380. /**
  67381. * Gets the lodaded data (as an array buffer)
  67382. */
  67383. data: ArrayBuffer;
  67384. /**
  67385. * Callback called when the task is successful
  67386. */
  67387. onSuccess: (task: BinaryFileAssetTask) => void;
  67388. /**
  67389. * Callback called when the task is successful
  67390. */
  67391. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67392. /**
  67393. * Creates a new BinaryFileAssetTask object
  67394. * @param name defines the name of the new task
  67395. * @param url defines the location of the file to load
  67396. */
  67397. constructor(
  67398. /**
  67399. * Defines the name of the task
  67400. */
  67401. name: string,
  67402. /**
  67403. * Defines the location of the file to load
  67404. */
  67405. url: string);
  67406. /**
  67407. * Execute the current task
  67408. * @param scene defines the scene where you want your assets to be loaded
  67409. * @param onSuccess is a callback called when the task is successfully executed
  67410. * @param onError is a callback called if an error occurs
  67411. */
  67412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67413. }
  67414. /**
  67415. * Define a task used by AssetsManager to load images
  67416. */
  67417. export class ImageAssetTask extends AbstractAssetTask {
  67418. /**
  67419. * Defines the name of the task
  67420. */
  67421. name: string;
  67422. /**
  67423. * Defines the location of the image to load
  67424. */
  67425. url: string;
  67426. /**
  67427. * Gets the loaded images
  67428. */
  67429. image: HTMLImageElement;
  67430. /**
  67431. * Callback called when the task is successful
  67432. */
  67433. onSuccess: (task: ImageAssetTask) => void;
  67434. /**
  67435. * Callback called when the task is successful
  67436. */
  67437. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67438. /**
  67439. * Creates a new ImageAssetTask
  67440. * @param name defines the name of the task
  67441. * @param url defines the location of the image to load
  67442. */
  67443. constructor(
  67444. /**
  67445. * Defines the name of the task
  67446. */
  67447. name: string,
  67448. /**
  67449. * Defines the location of the image to load
  67450. */
  67451. url: string);
  67452. /**
  67453. * Execute the current task
  67454. * @param scene defines the scene where you want your assets to be loaded
  67455. * @param onSuccess is a callback called when the task is successfully executed
  67456. * @param onError is a callback called if an error occurs
  67457. */
  67458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67459. }
  67460. /**
  67461. * Defines the interface used by texture loading tasks
  67462. */
  67463. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67464. /**
  67465. * Gets the loaded texture
  67466. */
  67467. texture: TEX;
  67468. }
  67469. /**
  67470. * Define a task used by AssetsManager to load 2D textures
  67471. */
  67472. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67473. /**
  67474. * Defines the name of the task
  67475. */
  67476. name: string;
  67477. /**
  67478. * Defines the location of the file to load
  67479. */
  67480. url: string;
  67481. /**
  67482. * Defines if mipmap should not be generated (default is false)
  67483. */
  67484. noMipmap?: boolean | undefined;
  67485. /**
  67486. * Defines if texture must be inverted on Y axis (default is false)
  67487. */
  67488. invertY?: boolean | undefined;
  67489. /**
  67490. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67491. */
  67492. samplingMode: number;
  67493. /**
  67494. * Gets the loaded texture
  67495. */
  67496. texture: Texture;
  67497. /**
  67498. * Callback called when the task is successful
  67499. */
  67500. onSuccess: (task: TextureAssetTask) => void;
  67501. /**
  67502. * Callback called when the task is successful
  67503. */
  67504. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67505. /**
  67506. * Creates a new TextureAssetTask object
  67507. * @param name defines the name of the task
  67508. * @param url defines the location of the file to load
  67509. * @param noMipmap defines if mipmap should not be generated (default is false)
  67510. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67511. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67512. */
  67513. constructor(
  67514. /**
  67515. * Defines the name of the task
  67516. */
  67517. name: string,
  67518. /**
  67519. * Defines the location of the file to load
  67520. */
  67521. url: string,
  67522. /**
  67523. * Defines if mipmap should not be generated (default is false)
  67524. */
  67525. noMipmap?: boolean | undefined,
  67526. /**
  67527. * Defines if texture must be inverted on Y axis (default is false)
  67528. */
  67529. invertY?: boolean | undefined,
  67530. /**
  67531. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67532. */
  67533. samplingMode?: number);
  67534. /**
  67535. * Execute the current task
  67536. * @param scene defines the scene where you want your assets to be loaded
  67537. * @param onSuccess is a callback called when the task is successfully executed
  67538. * @param onError is a callback called if an error occurs
  67539. */
  67540. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67541. }
  67542. /**
  67543. * Define a task used by AssetsManager to load cube textures
  67544. */
  67545. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67546. /**
  67547. * Defines the name of the task
  67548. */
  67549. name: string;
  67550. /**
  67551. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67552. */
  67553. url: string;
  67554. /**
  67555. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67556. */
  67557. extensions?: string[] | undefined;
  67558. /**
  67559. * Defines if mipmaps should not be generated (default is false)
  67560. */
  67561. noMipmap?: boolean | undefined;
  67562. /**
  67563. * Defines the explicit list of files (undefined by default)
  67564. */
  67565. files?: string[] | undefined;
  67566. /**
  67567. * Gets the loaded texture
  67568. */
  67569. texture: CubeTexture;
  67570. /**
  67571. * Callback called when the task is successful
  67572. */
  67573. onSuccess: (task: CubeTextureAssetTask) => void;
  67574. /**
  67575. * Callback called when the task is successful
  67576. */
  67577. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67578. /**
  67579. * Creates a new CubeTextureAssetTask
  67580. * @param name defines the name of the task
  67581. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67582. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67583. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67584. * @param files defines the explicit list of files (undefined by default)
  67585. */
  67586. constructor(
  67587. /**
  67588. * Defines the name of the task
  67589. */
  67590. name: string,
  67591. /**
  67592. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67593. */
  67594. url: string,
  67595. /**
  67596. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67597. */
  67598. extensions?: string[] | undefined,
  67599. /**
  67600. * Defines if mipmaps should not be generated (default is false)
  67601. */
  67602. noMipmap?: boolean | undefined,
  67603. /**
  67604. * Defines the explicit list of files (undefined by default)
  67605. */
  67606. files?: string[] | undefined);
  67607. /**
  67608. * Execute the current task
  67609. * @param scene defines the scene where you want your assets to be loaded
  67610. * @param onSuccess is a callback called when the task is successfully executed
  67611. * @param onError is a callback called if an error occurs
  67612. */
  67613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67614. }
  67615. /**
  67616. * Define a task used by AssetsManager to load HDR cube textures
  67617. */
  67618. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67619. /**
  67620. * Defines the name of the task
  67621. */
  67622. name: string;
  67623. /**
  67624. * Defines the location of the file to load
  67625. */
  67626. url: string;
  67627. /**
  67628. * Defines the desired size (the more it increases the longer the generation will be)
  67629. */
  67630. size: number;
  67631. /**
  67632. * Defines if mipmaps should not be generated (default is false)
  67633. */
  67634. noMipmap: boolean;
  67635. /**
  67636. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67637. */
  67638. generateHarmonics: boolean;
  67639. /**
  67640. * 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)
  67641. */
  67642. gammaSpace: boolean;
  67643. /**
  67644. * Internal Use Only
  67645. */
  67646. reserved: boolean;
  67647. /**
  67648. * Gets the loaded texture
  67649. */
  67650. texture: HDRCubeTexture;
  67651. /**
  67652. * Callback called when the task is successful
  67653. */
  67654. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67655. /**
  67656. * Callback called when the task is successful
  67657. */
  67658. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67659. /**
  67660. * Creates a new HDRCubeTextureAssetTask object
  67661. * @param name defines the name of the task
  67662. * @param url defines the location of the file to load
  67663. * @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.
  67664. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67665. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67666. * @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)
  67667. * @param reserved Internal use only
  67668. */
  67669. constructor(
  67670. /**
  67671. * Defines the name of the task
  67672. */
  67673. name: string,
  67674. /**
  67675. * Defines the location of the file to load
  67676. */
  67677. url: string,
  67678. /**
  67679. * Defines the desired size (the more it increases the longer the generation will be)
  67680. */
  67681. size: number,
  67682. /**
  67683. * Defines if mipmaps should not be generated (default is false)
  67684. */
  67685. noMipmap?: boolean,
  67686. /**
  67687. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67688. */
  67689. generateHarmonics?: boolean,
  67690. /**
  67691. * 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)
  67692. */
  67693. gammaSpace?: boolean,
  67694. /**
  67695. * Internal Use Only
  67696. */
  67697. reserved?: boolean);
  67698. /**
  67699. * Execute the current task
  67700. * @param scene defines the scene where you want your assets to be loaded
  67701. * @param onSuccess is a callback called when the task is successfully executed
  67702. * @param onError is a callback called if an error occurs
  67703. */
  67704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67705. }
  67706. /**
  67707. * Define a task used by AssetsManager to load Equirectangular cube textures
  67708. */
  67709. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67710. /**
  67711. * Defines the name of the task
  67712. */
  67713. name: string;
  67714. /**
  67715. * Defines the location of the file to load
  67716. */
  67717. url: string;
  67718. /**
  67719. * Defines the desired size (the more it increases the longer the generation will be)
  67720. */
  67721. size: number;
  67722. /**
  67723. * Defines if mipmaps should not be generated (default is false)
  67724. */
  67725. noMipmap: boolean;
  67726. /**
  67727. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67728. * but the standard material would require them in Gamma space) (default is true)
  67729. */
  67730. gammaSpace: boolean;
  67731. /**
  67732. * Gets the loaded texture
  67733. */
  67734. texture: EquiRectangularCubeTexture;
  67735. /**
  67736. * Callback called when the task is successful
  67737. */
  67738. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67739. /**
  67740. * Callback called when the task is successful
  67741. */
  67742. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67743. /**
  67744. * Creates a new EquiRectangularCubeTextureAssetTask object
  67745. * @param name defines the name of the task
  67746. * @param url defines the location of the file to load
  67747. * @param size defines the desired size (the more it increases the longer the generation will be)
  67748. * If the size is omitted this implies you are using a preprocessed cubemap.
  67749. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67750. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67751. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67752. * (default is true)
  67753. */
  67754. constructor(
  67755. /**
  67756. * Defines the name of the task
  67757. */
  67758. name: string,
  67759. /**
  67760. * Defines the location of the file to load
  67761. */
  67762. url: string,
  67763. /**
  67764. * Defines the desired size (the more it increases the longer the generation will be)
  67765. */
  67766. size: number,
  67767. /**
  67768. * Defines if mipmaps should not be generated (default is false)
  67769. */
  67770. noMipmap?: boolean,
  67771. /**
  67772. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67773. * but the standard material would require them in Gamma space) (default is true)
  67774. */
  67775. gammaSpace?: boolean);
  67776. /**
  67777. * Execute the current task
  67778. * @param scene defines the scene where you want your assets to be loaded
  67779. * @param onSuccess is a callback called when the task is successfully executed
  67780. * @param onError is a callback called if an error occurs
  67781. */
  67782. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67783. }
  67784. /**
  67785. * This class can be used to easily import assets into a scene
  67786. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67787. */
  67788. export class AssetsManager {
  67789. private _scene;
  67790. private _isLoading;
  67791. protected _tasks: AbstractAssetTask[];
  67792. protected _waitingTasksCount: number;
  67793. protected _totalTasksCount: number;
  67794. /**
  67795. * Callback called when all tasks are processed
  67796. */
  67797. onFinish: (tasks: AbstractAssetTask[]) => void;
  67798. /**
  67799. * Callback called when a task is successful
  67800. */
  67801. onTaskSuccess: (task: AbstractAssetTask) => void;
  67802. /**
  67803. * Callback called when a task had an error
  67804. */
  67805. onTaskError: (task: AbstractAssetTask) => void;
  67806. /**
  67807. * Callback called when a task is done (whatever the result is)
  67808. */
  67809. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67810. /**
  67811. * Observable called when all tasks are processed
  67812. */
  67813. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67814. /**
  67815. * Observable called when a task had an error
  67816. */
  67817. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67818. /**
  67819. * Observable called when all tasks were executed
  67820. */
  67821. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67822. /**
  67823. * Observable called when a task is done (whatever the result is)
  67824. */
  67825. onProgressObservable: Observable<IAssetsProgressEvent>;
  67826. /**
  67827. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67828. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67829. */
  67830. useDefaultLoadingScreen: boolean;
  67831. /**
  67832. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67833. * when all assets have been downloaded.
  67834. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67835. */
  67836. autoHideLoadingUI: boolean;
  67837. /**
  67838. * Creates a new AssetsManager
  67839. * @param scene defines the scene to work on
  67840. */
  67841. constructor(scene: Scene);
  67842. /**
  67843. * Add a MeshAssetTask to the list of active tasks
  67844. * @param taskName defines the name of the new task
  67845. * @param meshesNames defines the name of meshes to load
  67846. * @param rootUrl defines the root url to use to locate files
  67847. * @param sceneFilename defines the filename of the scene file
  67848. * @returns a new MeshAssetTask object
  67849. */
  67850. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67851. /**
  67852. * Add a TextFileAssetTask to the list of active tasks
  67853. * @param taskName defines the name of the new task
  67854. * @param url defines the url of the file to load
  67855. * @returns a new TextFileAssetTask object
  67856. */
  67857. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67858. /**
  67859. * Add a BinaryFileAssetTask to the list of active tasks
  67860. * @param taskName defines the name of the new task
  67861. * @param url defines the url of the file to load
  67862. * @returns a new BinaryFileAssetTask object
  67863. */
  67864. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67865. /**
  67866. * Add a ImageAssetTask to the list of active tasks
  67867. * @param taskName defines the name of the new task
  67868. * @param url defines the url of the file to load
  67869. * @returns a new ImageAssetTask object
  67870. */
  67871. addImageTask(taskName: string, url: string): ImageAssetTask;
  67872. /**
  67873. * Add a TextureAssetTask to the list of active tasks
  67874. * @param taskName defines the name of the new task
  67875. * @param url defines the url of the file to load
  67876. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67877. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67878. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67879. * @returns a new TextureAssetTask object
  67880. */
  67881. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67882. /**
  67883. * Add a CubeTextureAssetTask to the list of active tasks
  67884. * @param taskName defines the name of the new task
  67885. * @param url defines the url of the file to load
  67886. * @param extensions defines the extension to use to load the cube map (can be null)
  67887. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67888. * @param files defines the list of files to load (can be null)
  67889. * @returns a new CubeTextureAssetTask object
  67890. */
  67891. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67892. /**
  67893. *
  67894. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67895. * @param taskName defines the name of the new task
  67896. * @param url defines the url of the file to load
  67897. * @param size defines the size you want for the cubemap (can be null)
  67898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67899. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67900. * @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)
  67901. * @param reserved Internal use only
  67902. * @returns a new HDRCubeTextureAssetTask object
  67903. */
  67904. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67905. /**
  67906. *
  67907. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67908. * @param taskName defines the name of the new task
  67909. * @param url defines the url of the file to load
  67910. * @param size defines the size you want for the cubemap (can be null)
  67911. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67912. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67913. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67914. * @returns a new EquiRectangularCubeTextureAssetTask object
  67915. */
  67916. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67917. /**
  67918. * Remove a task from the assets manager.
  67919. * @param task the task to remove
  67920. */
  67921. removeTask(task: AbstractAssetTask): void;
  67922. private _decreaseWaitingTasksCount;
  67923. private _runTask;
  67924. /**
  67925. * Reset the AssetsManager and remove all tasks
  67926. * @return the current instance of the AssetsManager
  67927. */
  67928. reset(): AssetsManager;
  67929. /**
  67930. * Start the loading process
  67931. * @return the current instance of the AssetsManager
  67932. */
  67933. load(): AssetsManager;
  67934. /**
  67935. * Start the loading process as an async operation
  67936. * @return a promise returning the list of failed tasks
  67937. */
  67938. loadAsync(): Promise<void>;
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. /**
  67943. * Wrapper class for promise with external resolve and reject.
  67944. */
  67945. export class Deferred<T> {
  67946. /**
  67947. * The promise associated with this deferred object.
  67948. */
  67949. readonly promise: Promise<T>;
  67950. private _resolve;
  67951. private _reject;
  67952. /**
  67953. * The resolve method of the promise associated with this deferred object.
  67954. */
  67955. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67956. /**
  67957. * The reject method of the promise associated with this deferred object.
  67958. */
  67959. get reject(): (reason?: any) => void;
  67960. /**
  67961. * Constructor for this deferred object.
  67962. */
  67963. constructor();
  67964. }
  67965. }
  67966. declare module BABYLON {
  67967. /**
  67968. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67969. */
  67970. export class MeshExploder {
  67971. private _centerMesh;
  67972. private _meshes;
  67973. private _meshesOrigins;
  67974. private _toCenterVectors;
  67975. private _scaledDirection;
  67976. private _newPosition;
  67977. private _centerPosition;
  67978. /**
  67979. * Explodes meshes from a center mesh.
  67980. * @param meshes The meshes to explode.
  67981. * @param centerMesh The mesh to be center of explosion.
  67982. */
  67983. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67984. private _setCenterMesh;
  67985. /**
  67986. * Get class name
  67987. * @returns "MeshExploder"
  67988. */
  67989. getClassName(): string;
  67990. /**
  67991. * "Exploded meshes"
  67992. * @returns Array of meshes with the centerMesh at index 0.
  67993. */
  67994. getMeshes(): Array<Mesh>;
  67995. /**
  67996. * Explodes meshes giving a specific direction
  67997. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67998. */
  67999. explode(direction?: number): void;
  68000. }
  68001. }
  68002. declare module BABYLON {
  68003. /**
  68004. * Class used to help managing file picking and drag'n'drop
  68005. */
  68006. export class FilesInput {
  68007. /**
  68008. * List of files ready to be loaded
  68009. */
  68010. static get FilesToLoad(): {
  68011. [key: string]: File;
  68012. };
  68013. /**
  68014. * Callback called when a file is processed
  68015. */
  68016. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68017. private _engine;
  68018. private _currentScene;
  68019. private _sceneLoadedCallback;
  68020. private _progressCallback;
  68021. private _additionalRenderLoopLogicCallback;
  68022. private _textureLoadingCallback;
  68023. private _startingProcessingFilesCallback;
  68024. private _onReloadCallback;
  68025. private _errorCallback;
  68026. private _elementToMonitor;
  68027. private _sceneFileToLoad;
  68028. private _filesToLoad;
  68029. /**
  68030. * Creates a new FilesInput
  68031. * @param engine defines the rendering engine
  68032. * @param scene defines the hosting scene
  68033. * @param sceneLoadedCallback callback called when scene is loaded
  68034. * @param progressCallback callback called to track progress
  68035. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68036. * @param textureLoadingCallback callback called when a texture is loading
  68037. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68038. * @param onReloadCallback callback called when a reload is requested
  68039. * @param errorCallback callback call if an error occurs
  68040. */
  68041. 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);
  68042. private _dragEnterHandler;
  68043. private _dragOverHandler;
  68044. private _dropHandler;
  68045. /**
  68046. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68047. * @param elementToMonitor defines the DOM element to track
  68048. */
  68049. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68050. /**
  68051. * Release all associated resources
  68052. */
  68053. dispose(): void;
  68054. private renderFunction;
  68055. private drag;
  68056. private drop;
  68057. private _traverseFolder;
  68058. private _processFiles;
  68059. /**
  68060. * Load files from a drop event
  68061. * @param event defines the drop event to use as source
  68062. */
  68063. loadFiles(event: any): void;
  68064. private _processReload;
  68065. /**
  68066. * Reload the current scene from the loaded files
  68067. */
  68068. reload(): void;
  68069. }
  68070. }
  68071. declare module BABYLON {
  68072. /**
  68073. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68075. */
  68076. export class SceneOptimization {
  68077. /**
  68078. * Defines the priority of this optimization (0 by default which means first in the list)
  68079. */
  68080. priority: number;
  68081. /**
  68082. * Gets a string describing the action executed by the current optimization
  68083. * @returns description string
  68084. */
  68085. getDescription(): string;
  68086. /**
  68087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68088. * @param scene defines the current scene where to apply this optimization
  68089. * @param optimizer defines the current optimizer
  68090. * @returns true if everything that can be done was applied
  68091. */
  68092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68093. /**
  68094. * Creates the SceneOptimization object
  68095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68096. * @param desc defines the description associated with the optimization
  68097. */
  68098. constructor(
  68099. /**
  68100. * Defines the priority of this optimization (0 by default which means first in the list)
  68101. */
  68102. priority?: number);
  68103. }
  68104. /**
  68105. * Defines an optimization used to reduce the size of render target textures
  68106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68107. */
  68108. export class TextureOptimization extends SceneOptimization {
  68109. /**
  68110. * Defines the priority of this optimization (0 by default which means first in the list)
  68111. */
  68112. priority: number;
  68113. /**
  68114. * 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
  68115. */
  68116. maximumSize: number;
  68117. /**
  68118. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68119. */
  68120. step: number;
  68121. /**
  68122. * Gets a string describing the action executed by the current optimization
  68123. * @returns description string
  68124. */
  68125. getDescription(): string;
  68126. /**
  68127. * Creates the TextureOptimization object
  68128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68129. * @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
  68130. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68131. */
  68132. constructor(
  68133. /**
  68134. * Defines the priority of this optimization (0 by default which means first in the list)
  68135. */
  68136. priority?: number,
  68137. /**
  68138. * 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
  68139. */
  68140. maximumSize?: number,
  68141. /**
  68142. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68143. */
  68144. step?: number);
  68145. /**
  68146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68147. * @param scene defines the current scene where to apply this optimization
  68148. * @param optimizer defines the current optimizer
  68149. * @returns true if everything that can be done was applied
  68150. */
  68151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68152. }
  68153. /**
  68154. * Defines an optimization used to increase or decrease the rendering resolution
  68155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68156. */
  68157. export class HardwareScalingOptimization extends SceneOptimization {
  68158. /**
  68159. * Defines the priority of this optimization (0 by default which means first in the list)
  68160. */
  68161. priority: number;
  68162. /**
  68163. * Defines the maximum scale to use (2 by default)
  68164. */
  68165. maximumScale: number;
  68166. /**
  68167. * Defines the step to use between two passes (0.5 by default)
  68168. */
  68169. step: number;
  68170. private _currentScale;
  68171. private _directionOffset;
  68172. /**
  68173. * Gets a string describing the action executed by the current optimization
  68174. * @return description string
  68175. */
  68176. getDescription(): string;
  68177. /**
  68178. * Creates the HardwareScalingOptimization object
  68179. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68180. * @param maximumScale defines the maximum scale to use (2 by default)
  68181. * @param step defines the step to use between two passes (0.5 by default)
  68182. */
  68183. constructor(
  68184. /**
  68185. * Defines the priority of this optimization (0 by default which means first in the list)
  68186. */
  68187. priority?: number,
  68188. /**
  68189. * Defines the maximum scale to use (2 by default)
  68190. */
  68191. maximumScale?: number,
  68192. /**
  68193. * Defines the step to use between two passes (0.5 by default)
  68194. */
  68195. step?: number);
  68196. /**
  68197. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68198. * @param scene defines the current scene where to apply this optimization
  68199. * @param optimizer defines the current optimizer
  68200. * @returns true if everything that can be done was applied
  68201. */
  68202. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68203. }
  68204. /**
  68205. * Defines an optimization used to remove shadows
  68206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68207. */
  68208. export class ShadowsOptimization extends SceneOptimization {
  68209. /**
  68210. * Gets a string describing the action executed by the current optimization
  68211. * @return description string
  68212. */
  68213. getDescription(): string;
  68214. /**
  68215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68216. * @param scene defines the current scene where to apply this optimization
  68217. * @param optimizer defines the current optimizer
  68218. * @returns true if everything that can be done was applied
  68219. */
  68220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68221. }
  68222. /**
  68223. * Defines an optimization used to turn post-processes off
  68224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68225. */
  68226. export class PostProcessesOptimization extends SceneOptimization {
  68227. /**
  68228. * Gets a string describing the action executed by the current optimization
  68229. * @return description string
  68230. */
  68231. getDescription(): string;
  68232. /**
  68233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68234. * @param scene defines the current scene where to apply this optimization
  68235. * @param optimizer defines the current optimizer
  68236. * @returns true if everything that can be done was applied
  68237. */
  68238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68239. }
  68240. /**
  68241. * Defines an optimization used to turn lens flares off
  68242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68243. */
  68244. export class LensFlaresOptimization extends SceneOptimization {
  68245. /**
  68246. * Gets a string describing the action executed by the current optimization
  68247. * @return description string
  68248. */
  68249. getDescription(): string;
  68250. /**
  68251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68252. * @param scene defines the current scene where to apply this optimization
  68253. * @param optimizer defines the current optimizer
  68254. * @returns true if everything that can be done was applied
  68255. */
  68256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68257. }
  68258. /**
  68259. * Defines an optimization based on user defined callback.
  68260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68261. */
  68262. export class CustomOptimization extends SceneOptimization {
  68263. /**
  68264. * Callback called to apply the custom optimization.
  68265. */
  68266. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68267. /**
  68268. * Callback called to get custom description
  68269. */
  68270. onGetDescription: () => string;
  68271. /**
  68272. * Gets a string describing the action executed by the current optimization
  68273. * @returns description string
  68274. */
  68275. getDescription(): string;
  68276. /**
  68277. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68278. * @param scene defines the current scene where to apply this optimization
  68279. * @param optimizer defines the current optimizer
  68280. * @returns true if everything that can be done was applied
  68281. */
  68282. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68283. }
  68284. /**
  68285. * Defines an optimization used to turn particles off
  68286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68287. */
  68288. export class ParticlesOptimization extends SceneOptimization {
  68289. /**
  68290. * Gets a string describing the action executed by the current optimization
  68291. * @return description string
  68292. */
  68293. getDescription(): string;
  68294. /**
  68295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68296. * @param scene defines the current scene where to apply this optimization
  68297. * @param optimizer defines the current optimizer
  68298. * @returns true if everything that can be done was applied
  68299. */
  68300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68301. }
  68302. /**
  68303. * Defines an optimization used to turn render targets off
  68304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68305. */
  68306. export class RenderTargetsOptimization extends SceneOptimization {
  68307. /**
  68308. * Gets a string describing the action executed by the current optimization
  68309. * @return description string
  68310. */
  68311. getDescription(): string;
  68312. /**
  68313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68314. * @param scene defines the current scene where to apply this optimization
  68315. * @param optimizer defines the current optimizer
  68316. * @returns true if everything that can be done was applied
  68317. */
  68318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68319. }
  68320. /**
  68321. * Defines an optimization used to merge meshes with compatible materials
  68322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68323. */
  68324. export class MergeMeshesOptimization extends SceneOptimization {
  68325. private static _UpdateSelectionTree;
  68326. /**
  68327. * Gets or sets a boolean which defines if optimization octree has to be updated
  68328. */
  68329. static get UpdateSelectionTree(): boolean;
  68330. /**
  68331. * Gets or sets a boolean which defines if optimization octree has to be updated
  68332. */
  68333. static set UpdateSelectionTree(value: boolean);
  68334. /**
  68335. * Gets a string describing the action executed by the current optimization
  68336. * @return description string
  68337. */
  68338. getDescription(): string;
  68339. private _canBeMerged;
  68340. /**
  68341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68342. * @param scene defines the current scene where to apply this optimization
  68343. * @param optimizer defines the current optimizer
  68344. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68345. * @returns true if everything that can be done was applied
  68346. */
  68347. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68348. }
  68349. /**
  68350. * Defines a list of options used by SceneOptimizer
  68351. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68352. */
  68353. export class SceneOptimizerOptions {
  68354. /**
  68355. * Defines the target frame rate to reach (60 by default)
  68356. */
  68357. targetFrameRate: number;
  68358. /**
  68359. * Defines the interval between two checkes (2000ms by default)
  68360. */
  68361. trackerDuration: number;
  68362. /**
  68363. * Gets the list of optimizations to apply
  68364. */
  68365. optimizations: SceneOptimization[];
  68366. /**
  68367. * Creates a new list of options used by SceneOptimizer
  68368. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68369. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68370. */
  68371. constructor(
  68372. /**
  68373. * Defines the target frame rate to reach (60 by default)
  68374. */
  68375. targetFrameRate?: number,
  68376. /**
  68377. * Defines the interval between two checkes (2000ms by default)
  68378. */
  68379. trackerDuration?: number);
  68380. /**
  68381. * Add a new optimization
  68382. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68383. * @returns the current SceneOptimizerOptions
  68384. */
  68385. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68386. /**
  68387. * Add a new custom optimization
  68388. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68389. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68391. * @returns the current SceneOptimizerOptions
  68392. */
  68393. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68394. /**
  68395. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68396. * @param targetFrameRate defines the target frame rate (60 by default)
  68397. * @returns a SceneOptimizerOptions object
  68398. */
  68399. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68400. /**
  68401. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68402. * @param targetFrameRate defines the target frame rate (60 by default)
  68403. * @returns a SceneOptimizerOptions object
  68404. */
  68405. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68406. /**
  68407. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68408. * @param targetFrameRate defines the target frame rate (60 by default)
  68409. * @returns a SceneOptimizerOptions object
  68410. */
  68411. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68412. }
  68413. /**
  68414. * Class used to run optimizations in order to reach a target frame rate
  68415. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68416. */
  68417. export class SceneOptimizer implements IDisposable {
  68418. private _isRunning;
  68419. private _options;
  68420. private _scene;
  68421. private _currentPriorityLevel;
  68422. private _targetFrameRate;
  68423. private _trackerDuration;
  68424. private _currentFrameRate;
  68425. private _sceneDisposeObserver;
  68426. private _improvementMode;
  68427. /**
  68428. * Defines an observable called when the optimizer reaches the target frame rate
  68429. */
  68430. onSuccessObservable: Observable<SceneOptimizer>;
  68431. /**
  68432. * Defines an observable called when the optimizer enables an optimization
  68433. */
  68434. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68435. /**
  68436. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68437. */
  68438. onFailureObservable: Observable<SceneOptimizer>;
  68439. /**
  68440. * Gets a boolean indicating if the optimizer is in improvement mode
  68441. */
  68442. get isInImprovementMode(): boolean;
  68443. /**
  68444. * Gets the current priority level (0 at start)
  68445. */
  68446. get currentPriorityLevel(): number;
  68447. /**
  68448. * Gets the current frame rate checked by the SceneOptimizer
  68449. */
  68450. get currentFrameRate(): number;
  68451. /**
  68452. * Gets or sets the current target frame rate (60 by default)
  68453. */
  68454. get targetFrameRate(): number;
  68455. /**
  68456. * Gets or sets the current target frame rate (60 by default)
  68457. */
  68458. set targetFrameRate(value: number);
  68459. /**
  68460. * Gets or sets the current interval between two checks (every 2000ms by default)
  68461. */
  68462. get trackerDuration(): number;
  68463. /**
  68464. * Gets or sets the current interval between two checks (every 2000ms by default)
  68465. */
  68466. set trackerDuration(value: number);
  68467. /**
  68468. * Gets the list of active optimizations
  68469. */
  68470. get optimizations(): SceneOptimization[];
  68471. /**
  68472. * Creates a new SceneOptimizer
  68473. * @param scene defines the scene to work on
  68474. * @param options defines the options to use with the SceneOptimizer
  68475. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68476. * @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)
  68477. */
  68478. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68479. /**
  68480. * Stops the current optimizer
  68481. */
  68482. stop(): void;
  68483. /**
  68484. * Reset the optimizer to initial step (current priority level = 0)
  68485. */
  68486. reset(): void;
  68487. /**
  68488. * Start the optimizer. By default it will try to reach a specific framerate
  68489. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68490. */
  68491. start(): void;
  68492. private _checkCurrentState;
  68493. /**
  68494. * Release all resources
  68495. */
  68496. dispose(): void;
  68497. /**
  68498. * Helper function to create a SceneOptimizer with one single line of code
  68499. * @param scene defines the scene to work on
  68500. * @param options defines the options to use with the SceneOptimizer
  68501. * @param onSuccess defines a callback to call on success
  68502. * @param onFailure defines a callback to call on failure
  68503. * @returns the new SceneOptimizer object
  68504. */
  68505. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68506. }
  68507. }
  68508. declare module BABYLON {
  68509. /**
  68510. * Class used to serialize a scene into a string
  68511. */
  68512. export class SceneSerializer {
  68513. /**
  68514. * Clear cache used by a previous serialization
  68515. */
  68516. static ClearCache(): void;
  68517. /**
  68518. * Serialize a scene into a JSON compatible object
  68519. * @param scene defines the scene to serialize
  68520. * @returns a JSON compatible object
  68521. */
  68522. static Serialize(scene: Scene): any;
  68523. /**
  68524. * Serialize a mesh into a JSON compatible object
  68525. * @param toSerialize defines the mesh to serialize
  68526. * @param withParents defines if parents must be serialized as well
  68527. * @param withChildren defines if children must be serialized as well
  68528. * @returns a JSON compatible object
  68529. */
  68530. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68531. }
  68532. }
  68533. declare module BABYLON {
  68534. /**
  68535. * Class used to host texture specific utilities
  68536. */
  68537. export class TextureTools {
  68538. /**
  68539. * Uses the GPU to create a copy texture rescaled at a given size
  68540. * @param texture Texture to copy from
  68541. * @param width defines the desired width
  68542. * @param height defines the desired height
  68543. * @param useBilinearMode defines if bilinear mode has to be used
  68544. * @return the generated texture
  68545. */
  68546. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68547. }
  68548. }
  68549. declare module BABYLON {
  68550. /**
  68551. * This represents the different options available for the video capture.
  68552. */
  68553. export interface VideoRecorderOptions {
  68554. /** Defines the mime type of the video. */
  68555. mimeType: string;
  68556. /** Defines the FPS the video should be recorded at. */
  68557. fps: number;
  68558. /** Defines the chunk size for the recording data. */
  68559. recordChunckSize: number;
  68560. /** The audio tracks to attach to the recording. */
  68561. audioTracks?: MediaStreamTrack[];
  68562. }
  68563. /**
  68564. * This can help with recording videos from BabylonJS.
  68565. * This is based on the available WebRTC functionalities of the browser.
  68566. *
  68567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68568. */
  68569. export class VideoRecorder {
  68570. private static readonly _defaultOptions;
  68571. /**
  68572. * Returns whether or not the VideoRecorder is available in your browser.
  68573. * @param engine Defines the Babylon Engine.
  68574. * @returns true if supported otherwise false.
  68575. */
  68576. static IsSupported(engine: Engine): boolean;
  68577. private readonly _options;
  68578. private _canvas;
  68579. private _mediaRecorder;
  68580. private _recordedChunks;
  68581. private _fileName;
  68582. private _resolve;
  68583. private _reject;
  68584. /**
  68585. * True when a recording is already in progress.
  68586. */
  68587. get isRecording(): boolean;
  68588. /**
  68589. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68590. * @param engine Defines the BabylonJS Engine you wish to record.
  68591. * @param options Defines options that can be used to customize the capture.
  68592. */
  68593. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68594. /**
  68595. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68596. */
  68597. stopRecording(): void;
  68598. /**
  68599. * Starts recording the canvas for a max duration specified in parameters.
  68600. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68601. * If null no automatic download will start and you can rely on the promise to get the data back.
  68602. * @param maxDuration Defines the maximum recording time in seconds.
  68603. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68604. * @return A promise callback at the end of the recording with the video data in Blob.
  68605. */
  68606. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68607. /**
  68608. * Releases internal resources used during the recording.
  68609. */
  68610. dispose(): void;
  68611. private _handleDataAvailable;
  68612. private _handleError;
  68613. private _handleStop;
  68614. }
  68615. }
  68616. declare module BABYLON {
  68617. /**
  68618. * Class containing a set of static utilities functions for screenshots
  68619. */
  68620. export class ScreenshotTools {
  68621. /**
  68622. * Captures a screenshot of the current rendering
  68623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68624. * @param engine defines the rendering engine
  68625. * @param camera defines the source camera
  68626. * @param size This parameter can be set to a single number or to an object with the
  68627. * following (optional) properties: precision, width, height. If a single number is passed,
  68628. * it will be used for both width and height. If an object is passed, the screenshot size
  68629. * will be derived from the parameters. The precision property is a multiplier allowing
  68630. * rendering at a higher or lower resolution
  68631. * @param successCallback defines the callback receives a single parameter which contains the
  68632. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68633. * src parameter of an <img> to display it
  68634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68635. * Check your browser for supported MIME types
  68636. */
  68637. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68638. /**
  68639. * Captures a screenshot of the current rendering
  68640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68641. * @param engine defines the rendering engine
  68642. * @param camera defines the source camera
  68643. * @param size This parameter can be set to a single number or to an object with the
  68644. * following (optional) properties: precision, width, height. If a single number is passed,
  68645. * it will be used for both width and height. If an object is passed, the screenshot size
  68646. * will be derived from the parameters. The precision property is a multiplier allowing
  68647. * rendering at a higher or lower resolution
  68648. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68649. * Check your browser for supported MIME types
  68650. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68651. * to the src parameter of an <img> to display it
  68652. */
  68653. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68654. /**
  68655. * Generates an image screenshot from the specified camera.
  68656. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68657. * @param engine The engine to use for rendering
  68658. * @param camera The camera to use for rendering
  68659. * @param size This parameter can be set to a single number or to an object with the
  68660. * following (optional) properties: precision, width, height. If a single number is passed,
  68661. * it will be used for both width and height. If an object is passed, the screenshot size
  68662. * will be derived from the parameters. The precision property is a multiplier allowing
  68663. * rendering at a higher or lower resolution
  68664. * @param successCallback The callback receives a single parameter which contains the
  68665. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68666. * src parameter of an <img> to display it
  68667. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68668. * Check your browser for supported MIME types
  68669. * @param samples Texture samples (default: 1)
  68670. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68671. * @param fileName A name for for the downloaded file.
  68672. */
  68673. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68674. /**
  68675. * Generates an image screenshot from the specified camera.
  68676. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68677. * @param engine The engine to use for rendering
  68678. * @param camera The camera to use for rendering
  68679. * @param size This parameter can be set to a single number or to an object with the
  68680. * following (optional) properties: precision, width, height. If a single number is passed,
  68681. * it will be used for both width and height. If an object is passed, the screenshot size
  68682. * will be derived from the parameters. The precision property is a multiplier allowing
  68683. * rendering at a higher or lower resolution
  68684. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68685. * Check your browser for supported MIME types
  68686. * @param samples Texture samples (default: 1)
  68687. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68688. * @param fileName A name for for the downloaded file.
  68689. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68690. * to the src parameter of an <img> to display it
  68691. */
  68692. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68693. /**
  68694. * Gets height and width for screenshot size
  68695. * @private
  68696. */
  68697. private static _getScreenshotSize;
  68698. }
  68699. }
  68700. declare module BABYLON {
  68701. /**
  68702. * Interface for a data buffer
  68703. */
  68704. export interface IDataBuffer {
  68705. /**
  68706. * Reads bytes from the data buffer.
  68707. * @param byteOffset The byte offset to read
  68708. * @param byteLength The byte length to read
  68709. * @returns A promise that resolves when the bytes are read
  68710. */
  68711. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68712. /**
  68713. * The byte length of the buffer.
  68714. */
  68715. readonly byteLength: number;
  68716. }
  68717. /**
  68718. * Utility class for reading from a data buffer
  68719. */
  68720. export class DataReader {
  68721. /**
  68722. * The data buffer associated with this data reader.
  68723. */
  68724. readonly buffer: IDataBuffer;
  68725. /**
  68726. * The current byte offset from the beginning of the data buffer.
  68727. */
  68728. byteOffset: number;
  68729. private _dataView;
  68730. private _dataByteOffset;
  68731. /**
  68732. * Constructor
  68733. * @param buffer The buffer to read
  68734. */
  68735. constructor(buffer: IDataBuffer);
  68736. /**
  68737. * Loads the given byte length.
  68738. * @param byteLength The byte length to load
  68739. * @returns A promise that resolves when the load is complete
  68740. */
  68741. loadAsync(byteLength: number): Promise<void>;
  68742. /**
  68743. * Read a unsigned 32-bit integer from the currently loaded data range.
  68744. * @returns The 32-bit integer read
  68745. */
  68746. readUint32(): number;
  68747. /**
  68748. * Read a byte array from the currently loaded data range.
  68749. * @param byteLength The byte length to read
  68750. * @returns The byte array read
  68751. */
  68752. readUint8Array(byteLength: number): Uint8Array;
  68753. /**
  68754. * Read a string from the currently loaded data range.
  68755. * @param byteLength The byte length to read
  68756. * @returns The string read
  68757. */
  68758. readString(byteLength: number): string;
  68759. /**
  68760. * Skips the given byte length the currently loaded data range.
  68761. * @param byteLength The byte length to skip
  68762. */
  68763. skipBytes(byteLength: number): void;
  68764. }
  68765. }
  68766. declare module BABYLON {
  68767. /**
  68768. * A cursor which tracks a point on a path
  68769. */
  68770. export class PathCursor {
  68771. private path;
  68772. /**
  68773. * Stores path cursor callbacks for when an onchange event is triggered
  68774. */
  68775. private _onchange;
  68776. /**
  68777. * The value of the path cursor
  68778. */
  68779. value: number;
  68780. /**
  68781. * The animation array of the path cursor
  68782. */
  68783. animations: Animation[];
  68784. /**
  68785. * Initializes the path cursor
  68786. * @param path The path to track
  68787. */
  68788. constructor(path: Path2);
  68789. /**
  68790. * Gets the cursor point on the path
  68791. * @returns A point on the path cursor at the cursor location
  68792. */
  68793. getPoint(): Vector3;
  68794. /**
  68795. * Moves the cursor ahead by the step amount
  68796. * @param step The amount to move the cursor forward
  68797. * @returns This path cursor
  68798. */
  68799. moveAhead(step?: number): PathCursor;
  68800. /**
  68801. * Moves the cursor behind by the step amount
  68802. * @param step The amount to move the cursor back
  68803. * @returns This path cursor
  68804. */
  68805. moveBack(step?: number): PathCursor;
  68806. /**
  68807. * Moves the cursor by the step amount
  68808. * If the step amount is greater than one, an exception is thrown
  68809. * @param step The amount to move the cursor
  68810. * @returns This path cursor
  68811. */
  68812. move(step: number): PathCursor;
  68813. /**
  68814. * Ensures that the value is limited between zero and one
  68815. * @returns This path cursor
  68816. */
  68817. private ensureLimits;
  68818. /**
  68819. * Runs onchange callbacks on change (used by the animation engine)
  68820. * @returns This path cursor
  68821. */
  68822. private raiseOnChange;
  68823. /**
  68824. * Executes a function on change
  68825. * @param f A path cursor onchange callback
  68826. * @returns This path cursor
  68827. */
  68828. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68829. }
  68830. }
  68831. declare module BABYLON {
  68832. /** @hidden */
  68833. export var blurPixelShader: {
  68834. name: string;
  68835. shader: string;
  68836. };
  68837. }
  68838. declare module BABYLON {
  68839. /** @hidden */
  68840. export var pointCloudVertexDeclaration: {
  68841. name: string;
  68842. shader: string;
  68843. };
  68844. }
  68845. // Mixins
  68846. interface Window {
  68847. mozIndexedDB: IDBFactory;
  68848. webkitIndexedDB: IDBFactory;
  68849. msIndexedDB: IDBFactory;
  68850. webkitURL: typeof URL;
  68851. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  68852. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  68853. WebGLRenderingContext: WebGLRenderingContext;
  68854. MSGesture: MSGesture;
  68855. CANNON: any;
  68856. AudioContext: AudioContext;
  68857. webkitAudioContext: AudioContext;
  68858. PointerEvent: any;
  68859. Math: Math;
  68860. Uint8Array: Uint8ArrayConstructor;
  68861. Float32Array: Float32ArrayConstructor;
  68862. mozURL: typeof URL;
  68863. msURL: typeof URL;
  68864. VRFrameData: any; // WebVR, from specs 1.1
  68865. DracoDecoderModule: any;
  68866. setImmediate(handler: (...args: any[]) => void): number;
  68867. }
  68868. interface HTMLCanvasElement {
  68869. requestPointerLock(): void;
  68870. msRequestPointerLock?(): void;
  68871. mozRequestPointerLock?(): void;
  68872. webkitRequestPointerLock?(): void;
  68873. /** Track wether a record is in progress */
  68874. isRecording: boolean;
  68875. /** Capture Stream method defined by some browsers */
  68876. captureStream(fps?: number): MediaStream;
  68877. }
  68878. interface CanvasRenderingContext2D {
  68879. msImageSmoothingEnabled: boolean;
  68880. }
  68881. interface MouseEvent {
  68882. mozMovementX: number;
  68883. mozMovementY: number;
  68884. webkitMovementX: number;
  68885. webkitMovementY: number;
  68886. msMovementX: number;
  68887. msMovementY: number;
  68888. }
  68889. interface Navigator {
  68890. mozGetVRDevices: (any: any) => any;
  68891. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68892. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68893. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68894. webkitGetGamepads(): Gamepad[];
  68895. msGetGamepads(): Gamepad[];
  68896. webkitGamepads(): Gamepad[];
  68897. }
  68898. interface HTMLVideoElement {
  68899. mozSrcObject: any;
  68900. }
  68901. interface Math {
  68902. fround(x: number): number;
  68903. imul(a: number, b: number): number;
  68904. }
  68905. interface WebGLRenderingContext {
  68906. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  68907. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  68908. vertexAttribDivisor(index: number, divisor: number): void;
  68909. createVertexArray(): any;
  68910. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  68911. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  68912. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  68913. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  68914. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  68915. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  68916. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  68917. // Queries
  68918. createQuery(): WebGLQuery;
  68919. deleteQuery(query: WebGLQuery): void;
  68920. beginQuery(target: number, query: WebGLQuery): void;
  68921. endQuery(target: number): void;
  68922. getQueryParameter(query: WebGLQuery, pname: number): any;
  68923. getQuery(target: number, pname: number): any;
  68924. MAX_SAMPLES: number;
  68925. RGBA8: number;
  68926. READ_FRAMEBUFFER: number;
  68927. DRAW_FRAMEBUFFER: number;
  68928. UNIFORM_BUFFER: number;
  68929. HALF_FLOAT_OES: number;
  68930. RGBA16F: number;
  68931. RGBA32F: number;
  68932. R32F: number;
  68933. RG32F: number;
  68934. RGB32F: number;
  68935. R16F: number;
  68936. RG16F: number;
  68937. RGB16F: number;
  68938. RED: number;
  68939. RG: number;
  68940. R8: number;
  68941. RG8: number;
  68942. UNSIGNED_INT_24_8: number;
  68943. DEPTH24_STENCIL8: number;
  68944. MIN: number;
  68945. MAX: number;
  68946. /* Multiple Render Targets */
  68947. drawBuffers(buffers: number[]): void;
  68948. readBuffer(src: number): void;
  68949. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  68950. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  68951. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  68952. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  68953. // Occlusion Query
  68954. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  68955. ANY_SAMPLES_PASSED: number;
  68956. QUERY_RESULT_AVAILABLE: number;
  68957. QUERY_RESULT: number;
  68958. }
  68959. interface WebGLProgram {
  68960. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  68961. }
  68962. interface EXT_disjoint_timer_query {
  68963. QUERY_COUNTER_BITS_EXT: number;
  68964. TIME_ELAPSED_EXT: number;
  68965. TIMESTAMP_EXT: number;
  68966. GPU_DISJOINT_EXT: number;
  68967. QUERY_RESULT_EXT: number;
  68968. QUERY_RESULT_AVAILABLE_EXT: number;
  68969. queryCounterEXT(query: WebGLQuery, target: number): void;
  68970. createQueryEXT(): WebGLQuery;
  68971. beginQueryEXT(target: number, query: WebGLQuery): void;
  68972. endQueryEXT(target: number): void;
  68973. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  68974. deleteQueryEXT(query: WebGLQuery): void;
  68975. }
  68976. interface WebGLUniformLocation {
  68977. _currentState: any;
  68978. }
  68979. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  68980. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  68981. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  68982. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  68983. interface WebGLRenderingContext {
  68984. readonly RASTERIZER_DISCARD: number;
  68985. readonly DEPTH_COMPONENT24: number;
  68986. readonly TEXTURE_3D: number;
  68987. readonly TEXTURE_2D_ARRAY: number;
  68988. readonly TEXTURE_COMPARE_FUNC: number;
  68989. readonly TEXTURE_COMPARE_MODE: number;
  68990. readonly COMPARE_REF_TO_TEXTURE: number;
  68991. readonly TEXTURE_WRAP_R: number;
  68992. readonly HALF_FLOAT: number;
  68993. readonly RGB8: number;
  68994. readonly RED_INTEGER: number;
  68995. readonly RG_INTEGER: number;
  68996. readonly RGB_INTEGER: number;
  68997. readonly RGBA_INTEGER: number;
  68998. readonly R8_SNORM: number;
  68999. readonly RG8_SNORM: number;
  69000. readonly RGB8_SNORM: number;
  69001. readonly RGBA8_SNORM: number;
  69002. readonly R8I: number;
  69003. readonly RG8I: number;
  69004. readonly RGB8I: number;
  69005. readonly RGBA8I: number;
  69006. readonly R8UI: number;
  69007. readonly RG8UI: number;
  69008. readonly RGB8UI: number;
  69009. readonly RGBA8UI: number;
  69010. readonly R16I: number;
  69011. readonly RG16I: number;
  69012. readonly RGB16I: number;
  69013. readonly RGBA16I: number;
  69014. readonly R16UI: number;
  69015. readonly RG16UI: number;
  69016. readonly RGB16UI: number;
  69017. readonly RGBA16UI: number;
  69018. readonly R32I: number;
  69019. readonly RG32I: number;
  69020. readonly RGB32I: number;
  69021. readonly RGBA32I: number;
  69022. readonly R32UI: number;
  69023. readonly RG32UI: number;
  69024. readonly RGB32UI: number;
  69025. readonly RGBA32UI: number;
  69026. readonly RGB10_A2UI: number;
  69027. readonly R11F_G11F_B10F: number;
  69028. readonly RGB9_E5: number;
  69029. readonly RGB10_A2: number;
  69030. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69031. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69032. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69033. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69034. readonly DEPTH_COMPONENT32F: number;
  69035. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69036. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69037. 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;
  69038. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69039. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69040. readonly TRANSFORM_FEEDBACK: number;
  69041. readonly INTERLEAVED_ATTRIBS: number;
  69042. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69043. createTransformFeedback(): WebGLTransformFeedback;
  69044. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69045. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69046. beginTransformFeedback(primitiveMode: number): void;
  69047. endTransformFeedback(): void;
  69048. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69049. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69050. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69051. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69052. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69053. }
  69054. interface ImageBitmap {
  69055. readonly width: number;
  69056. readonly height: number;
  69057. close(): void;
  69058. }
  69059. interface WebGLQuery extends WebGLObject {
  69060. }
  69061. declare var WebGLQuery: {
  69062. prototype: WebGLQuery;
  69063. new(): WebGLQuery;
  69064. };
  69065. interface WebGLSampler extends WebGLObject {
  69066. }
  69067. declare var WebGLSampler: {
  69068. prototype: WebGLSampler;
  69069. new(): WebGLSampler;
  69070. };
  69071. interface WebGLSync extends WebGLObject {
  69072. }
  69073. declare var WebGLSync: {
  69074. prototype: WebGLSync;
  69075. new(): WebGLSync;
  69076. };
  69077. interface WebGLTransformFeedback extends WebGLObject {
  69078. }
  69079. declare var WebGLTransformFeedback: {
  69080. prototype: WebGLTransformFeedback;
  69081. new(): WebGLTransformFeedback;
  69082. };
  69083. interface WebGLVertexArrayObject extends WebGLObject {
  69084. }
  69085. declare var WebGLVertexArrayObject: {
  69086. prototype: WebGLVertexArrayObject;
  69087. new(): WebGLVertexArrayObject;
  69088. };
  69089. // Type definitions for WebVR API
  69090. // Project: https://w3c.github.io/webvr/
  69091. // Definitions by: six a <https://github.com/lostfictions>
  69092. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69093. interface VRDisplay extends EventTarget {
  69094. /**
  69095. * Dictionary of capabilities describing the VRDisplay.
  69096. */
  69097. readonly capabilities: VRDisplayCapabilities;
  69098. /**
  69099. * z-depth defining the far plane of the eye view frustum
  69100. * enables mapping of values in the render target depth
  69101. * attachment to scene coordinates. Initially set to 10000.0.
  69102. */
  69103. depthFar: number;
  69104. /**
  69105. * z-depth defining the near plane of the eye view frustum
  69106. * enables mapping of values in the render target depth
  69107. * attachment to scene coordinates. Initially set to 0.01.
  69108. */
  69109. depthNear: number;
  69110. /**
  69111. * An identifier for this distinct VRDisplay. Used as an
  69112. * association point in the Gamepad API.
  69113. */
  69114. readonly displayId: number;
  69115. /**
  69116. * A display name, a user-readable name identifying it.
  69117. */
  69118. readonly displayName: string;
  69119. readonly isConnected: boolean;
  69120. readonly isPresenting: boolean;
  69121. /**
  69122. * If this VRDisplay supports room-scale experiences, the optional
  69123. * stage attribute contains details on the room-scale parameters.
  69124. */
  69125. readonly stageParameters: VRStageParameters | null;
  69126. /**
  69127. * Passing the value returned by `requestAnimationFrame` to
  69128. * `cancelAnimationFrame` will unregister the callback.
  69129. * @param handle Define the hanle of the request to cancel
  69130. */
  69131. cancelAnimationFrame(handle: number): void;
  69132. /**
  69133. * Stops presenting to the VRDisplay.
  69134. * @returns a promise to know when it stopped
  69135. */
  69136. exitPresent(): Promise<void>;
  69137. /**
  69138. * Return the current VREyeParameters for the given eye.
  69139. * @param whichEye Define the eye we want the parameter for
  69140. * @returns the eye parameters
  69141. */
  69142. getEyeParameters(whichEye: string): VREyeParameters;
  69143. /**
  69144. * Populates the passed VRFrameData with the information required to render
  69145. * the current frame.
  69146. * @param frameData Define the data structure to populate
  69147. * @returns true if ok otherwise false
  69148. */
  69149. getFrameData(frameData: VRFrameData): boolean;
  69150. /**
  69151. * Get the layers currently being presented.
  69152. * @returns the list of VR layers
  69153. */
  69154. getLayers(): VRLayer[];
  69155. /**
  69156. * Return a VRPose containing the future predicted pose of the VRDisplay
  69157. * when the current frame will be presented. The value returned will not
  69158. * change until JavaScript has returned control to the browser.
  69159. *
  69160. * The VRPose will contain the position, orientation, velocity,
  69161. * and acceleration of each of these properties.
  69162. * @returns the pose object
  69163. */
  69164. getPose(): VRPose;
  69165. /**
  69166. * Return the current instantaneous pose of the VRDisplay, with no
  69167. * prediction applied.
  69168. * @returns the current instantaneous pose
  69169. */
  69170. getImmediatePose(): VRPose;
  69171. /**
  69172. * The callback passed to `requestAnimationFrame` will be called
  69173. * any time a new frame should be rendered. When the VRDisplay is
  69174. * presenting the callback will be called at the native refresh
  69175. * rate of the HMD. When not presenting this function acts
  69176. * identically to how window.requestAnimationFrame acts. Content should
  69177. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69178. * asynchronously from other displays and at differing refresh rates.
  69179. * @param callback Define the eaction to run next frame
  69180. * @returns the request handle it
  69181. */
  69182. requestAnimationFrame(callback: FrameRequestCallback): number;
  69183. /**
  69184. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69185. * Repeat calls while already presenting will update the VRLayers being displayed.
  69186. * @param layers Define the list of layer to present
  69187. * @returns a promise to know when the request has been fulfilled
  69188. */
  69189. requestPresent(layers: VRLayer[]): Promise<void>;
  69190. /**
  69191. * Reset the pose for this display, treating its current position and
  69192. * orientation as the "origin/zero" values. VRPose.position,
  69193. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69194. * updated when calling resetPose(). This should be called in only
  69195. * sitting-space experiences.
  69196. */
  69197. resetPose(): void;
  69198. /**
  69199. * The VRLayer provided to the VRDisplay will be captured and presented
  69200. * in the HMD. Calling this function has the same effect on the source
  69201. * canvas as any other operation that uses its source image, and canvases
  69202. * created without preserveDrawingBuffer set to true will be cleared.
  69203. * @param pose Define the pose to submit
  69204. */
  69205. submitFrame(pose?: VRPose): void;
  69206. }
  69207. declare var VRDisplay: {
  69208. prototype: VRDisplay;
  69209. new(): VRDisplay;
  69210. };
  69211. interface VRLayer {
  69212. leftBounds?: number[] | Float32Array | null;
  69213. rightBounds?: number[] | Float32Array | null;
  69214. source?: HTMLCanvasElement | null;
  69215. }
  69216. interface VRDisplayCapabilities {
  69217. readonly canPresent: boolean;
  69218. readonly hasExternalDisplay: boolean;
  69219. readonly hasOrientation: boolean;
  69220. readonly hasPosition: boolean;
  69221. readonly maxLayers: number;
  69222. }
  69223. interface VREyeParameters {
  69224. /** @deprecated */
  69225. readonly fieldOfView: VRFieldOfView;
  69226. readonly offset: Float32Array;
  69227. readonly renderHeight: number;
  69228. readonly renderWidth: number;
  69229. }
  69230. interface VRFieldOfView {
  69231. readonly downDegrees: number;
  69232. readonly leftDegrees: number;
  69233. readonly rightDegrees: number;
  69234. readonly upDegrees: number;
  69235. }
  69236. interface VRFrameData {
  69237. readonly leftProjectionMatrix: Float32Array;
  69238. readonly leftViewMatrix: Float32Array;
  69239. readonly pose: VRPose;
  69240. readonly rightProjectionMatrix: Float32Array;
  69241. readonly rightViewMatrix: Float32Array;
  69242. readonly timestamp: number;
  69243. }
  69244. interface VRPose {
  69245. readonly angularAcceleration: Float32Array | null;
  69246. readonly angularVelocity: Float32Array | null;
  69247. readonly linearAcceleration: Float32Array | null;
  69248. readonly linearVelocity: Float32Array | null;
  69249. readonly orientation: Float32Array | null;
  69250. readonly position: Float32Array | null;
  69251. readonly timestamp: number;
  69252. }
  69253. interface VRStageParameters {
  69254. sittingToStandingTransform?: Float32Array;
  69255. sizeX?: number;
  69256. sizeY?: number;
  69257. }
  69258. interface Navigator {
  69259. getVRDisplays(): Promise<VRDisplay[]>;
  69260. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69261. }
  69262. interface Window {
  69263. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69264. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69265. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69266. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69267. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69268. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69269. }
  69270. interface Gamepad {
  69271. readonly displayId: number;
  69272. }
  69273. type XRSessionMode =
  69274. | "inline"
  69275. | "immersive-vr"
  69276. | "immersive-ar";
  69277. type XRReferenceSpaceType =
  69278. | "viewer"
  69279. | "local"
  69280. | "local-floor"
  69281. | "bounded-floor"
  69282. | "unbounded";
  69283. type XREnvironmentBlendMode =
  69284. | "opaque"
  69285. | "additive"
  69286. | "alpha-blend";
  69287. type XRVisibilityState =
  69288. | "visible"
  69289. | "visible-blurred"
  69290. | "hidden";
  69291. type XRHandedness =
  69292. | "none"
  69293. | "left"
  69294. | "right";
  69295. type XRTargetRayMode =
  69296. | "gaze"
  69297. | "tracked-pointer"
  69298. | "screen";
  69299. type XREye =
  69300. | "none"
  69301. | "left"
  69302. | "right";
  69303. interface XRSpace extends EventTarget {
  69304. }
  69305. interface XRRenderState {
  69306. depthNear?: number;
  69307. depthFar?: number;
  69308. inlineVerticalFieldOfView?: number;
  69309. baseLayer?: XRWebGLLayer;
  69310. }
  69311. interface XRInputSource {
  69312. handedness: XRHandedness;
  69313. targetRayMode: XRTargetRayMode;
  69314. targetRaySpace: XRSpace;
  69315. gripSpace: XRSpace | undefined;
  69316. gamepad: Gamepad | undefined;
  69317. profiles: Array<string>;
  69318. }
  69319. interface XRSessionInit {
  69320. optionalFeatures?: XRReferenceSpaceType[];
  69321. requiredFeatures?: XRReferenceSpaceType[];
  69322. }
  69323. interface XRSession extends XRAnchorCreator {
  69324. addEventListener: Function;
  69325. removeEventListener: Function;
  69326. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69327. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69328. requestAnimationFrame: Function;
  69329. end(): Promise<void>;
  69330. renderState: XRRenderState;
  69331. inputSources: Array<XRInputSource>;
  69332. // AR hit test
  69333. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69334. updateWorldTrackingState(options: {
  69335. planeDetectionState?: { enabled: boolean; }
  69336. }): void;
  69337. }
  69338. interface XRReferenceSpace extends XRSpace {
  69339. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69340. onreset: any;
  69341. }
  69342. type XRPlaneSet = Set<XRPlane>;
  69343. type XRAnchorSet = Set<XRAnchor>;
  69344. interface XRFrame {
  69345. session: XRSession;
  69346. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69347. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69348. // Anchors
  69349. trackedAnchors?: XRAnchorSet;
  69350. // Planes
  69351. worldInformation: {
  69352. detectedPlanes?: XRPlaneSet;
  69353. };
  69354. }
  69355. interface XRViewerPose extends XRPose {
  69356. views: Array<XRView>;
  69357. }
  69358. interface XRPose {
  69359. transform: XRRigidTransform;
  69360. emulatedPosition: boolean;
  69361. }
  69362. interface XRWebGLLayerOptions {
  69363. antialias?: boolean;
  69364. depth?: boolean;
  69365. stencil?: boolean;
  69366. alpha?: boolean;
  69367. multiview?: boolean;
  69368. framebufferScaleFactor?: number;
  69369. }
  69370. declare var XRWebGLLayer: {
  69371. prototype: XRWebGLLayer;
  69372. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69373. };
  69374. interface XRWebGLLayer {
  69375. framebuffer: WebGLFramebuffer;
  69376. framebufferWidth: number;
  69377. framebufferHeight: number;
  69378. getViewport: Function;
  69379. }
  69380. declare class XRRigidTransform {
  69381. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69382. position: DOMPointReadOnly;
  69383. orientation: DOMPointReadOnly;
  69384. matrix: Float32Array;
  69385. inverse: XRRigidTransform;
  69386. }
  69387. interface XRView {
  69388. eye: XREye;
  69389. projectionMatrix: Float32Array;
  69390. transform: XRRigidTransform;
  69391. }
  69392. interface XRInputSourceChangeEvent {
  69393. session: XRSession;
  69394. removed: Array<XRInputSource>;
  69395. added: Array<XRInputSource>;
  69396. }
  69397. interface XRInputSourceEvent extends Event {
  69398. readonly frame: XRFrame;
  69399. readonly inputSource: XRInputSource;
  69400. }
  69401. // Experimental(er) features
  69402. declare class XRRay {
  69403. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69404. origin: DOMPointReadOnly;
  69405. direction: DOMPointReadOnly;
  69406. matrix: Float32Array;
  69407. }
  69408. interface XRHitResult {
  69409. hitMatrix: Float32Array;
  69410. }
  69411. interface XRAnchor {
  69412. // remove?
  69413. id?: string;
  69414. anchorSpace: XRSpace;
  69415. lastChangedTime: number;
  69416. detach(): void;
  69417. }
  69418. interface XRPlane extends XRAnchorCreator {
  69419. orientation: "Horizontal" | "Vertical";
  69420. planeSpace: XRSpace;
  69421. polygon: Array<DOMPointReadOnly>;
  69422. lastChangedTime: number;
  69423. }
  69424. interface XRAnchorCreator {
  69425. // AR Anchors
  69426. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69427. }
  69428. /**
  69429. * @ignore
  69430. */
  69431. declare module BABYLON.GLTF2.Exporter {
  69432. }
  69433. /**
  69434. * @ignore
  69435. */
  69436. declare module BABYLON.GLTF1 {
  69437. }
  69438. declare module BABYLON.GUI {
  69439. /**
  69440. * Class used to specific a value and its associated unit
  69441. */
  69442. export class ValueAndUnit {
  69443. /** defines the unit to store */
  69444. unit: number;
  69445. /** defines a boolean indicating if the value can be negative */
  69446. negativeValueAllowed: boolean;
  69447. private _value;
  69448. private _originalUnit;
  69449. /**
  69450. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69451. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69452. */
  69453. ignoreAdaptiveScaling: boolean;
  69454. /**
  69455. * Creates a new ValueAndUnit
  69456. * @param value defines the value to store
  69457. * @param unit defines the unit to store
  69458. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69459. */
  69460. constructor(value: number,
  69461. /** defines the unit to store */
  69462. unit?: number,
  69463. /** defines a boolean indicating if the value can be negative */
  69464. negativeValueAllowed?: boolean);
  69465. /** Gets a boolean indicating if the value is a percentage */
  69466. get isPercentage(): boolean;
  69467. /** Gets a boolean indicating if the value is store as pixel */
  69468. get isPixel(): boolean;
  69469. /** Gets direct internal value */
  69470. get internalValue(): number;
  69471. /**
  69472. * Gets value as pixel
  69473. * @param host defines the root host
  69474. * @param refValue defines the reference value for percentages
  69475. * @returns the value as pixel
  69476. */
  69477. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  69478. /**
  69479. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  69480. * @param value defines the value to store
  69481. * @param unit defines the unit to store
  69482. * @returns the current ValueAndUnit
  69483. */
  69484. updateInPlace(value: number, unit?: number): ValueAndUnit;
  69485. /**
  69486. * Gets the value accordingly to its unit
  69487. * @param host defines the root host
  69488. * @returns the value
  69489. */
  69490. getValue(host: AdvancedDynamicTexture): number;
  69491. /**
  69492. * Gets a string representation of the value
  69493. * @param host defines the root host
  69494. * @param decimals defines an optional number of decimals to display
  69495. * @returns a string
  69496. */
  69497. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  69498. /**
  69499. * Store a value parsed from a string
  69500. * @param source defines the source string
  69501. * @returns true if the value was successfully parsed
  69502. */
  69503. fromString(source: string | number): boolean;
  69504. private static _Regex;
  69505. private static _UNITMODE_PERCENTAGE;
  69506. private static _UNITMODE_PIXEL;
  69507. /** UNITMODE_PERCENTAGE */
  69508. static get UNITMODE_PERCENTAGE(): number;
  69509. /** UNITMODE_PIXEL */
  69510. static get UNITMODE_PIXEL(): number;
  69511. }
  69512. }
  69513. declare module BABYLON.GUI {
  69514. /**
  69515. * Define a style used by control to automatically setup properties based on a template.
  69516. * Only support font related properties so far
  69517. */
  69518. export class Style implements BABYLON.IDisposable {
  69519. private _fontFamily;
  69520. private _fontStyle;
  69521. private _fontWeight;
  69522. /** @hidden */
  69523. _host: AdvancedDynamicTexture;
  69524. /** @hidden */
  69525. _fontSize: ValueAndUnit;
  69526. /**
  69527. * BABYLON.Observable raised when the style values are changed
  69528. */
  69529. onChangedObservable: BABYLON.Observable<Style>;
  69530. /**
  69531. * Creates a new style object
  69532. * @param host defines the AdvancedDynamicTexture which hosts this style
  69533. */
  69534. constructor(host: AdvancedDynamicTexture);
  69535. /**
  69536. * Gets or sets the font size
  69537. */
  69538. get fontSize(): string | number;
  69539. set fontSize(value: string | number);
  69540. /**
  69541. * Gets or sets the font family
  69542. */
  69543. get fontFamily(): string;
  69544. set fontFamily(value: string);
  69545. /**
  69546. * Gets or sets the font style
  69547. */
  69548. get fontStyle(): string;
  69549. set fontStyle(value: string);
  69550. /** Gets or sets font weight */
  69551. get fontWeight(): string;
  69552. set fontWeight(value: string);
  69553. /** Dispose all associated resources */
  69554. dispose(): void;
  69555. }
  69556. }
  69557. declare module BABYLON.GUI {
  69558. /**
  69559. * Class used to transport BABYLON.Vector2 information for pointer events
  69560. */
  69561. export class Vector2WithInfo extends BABYLON.Vector2 {
  69562. /** defines the current mouse button index */
  69563. buttonIndex: number;
  69564. /**
  69565. * Creates a new Vector2WithInfo
  69566. * @param source defines the vector2 data to transport
  69567. * @param buttonIndex defines the current mouse button index
  69568. */
  69569. constructor(source: BABYLON.Vector2,
  69570. /** defines the current mouse button index */
  69571. buttonIndex?: number);
  69572. }
  69573. /** Class used to provide 2D matrix features */
  69574. export class Matrix2D {
  69575. /** Gets the internal array of 6 floats used to store matrix data */
  69576. m: Float32Array;
  69577. /**
  69578. * Creates a new matrix
  69579. * @param m00 defines value for (0, 0)
  69580. * @param m01 defines value for (0, 1)
  69581. * @param m10 defines value for (1, 0)
  69582. * @param m11 defines value for (1, 1)
  69583. * @param m20 defines value for (2, 0)
  69584. * @param m21 defines value for (2, 1)
  69585. */
  69586. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  69587. /**
  69588. * Fills the matrix from direct values
  69589. * @param m00 defines value for (0, 0)
  69590. * @param m01 defines value for (0, 1)
  69591. * @param m10 defines value for (1, 0)
  69592. * @param m11 defines value for (1, 1)
  69593. * @param m20 defines value for (2, 0)
  69594. * @param m21 defines value for (2, 1)
  69595. * @returns the current modified matrix
  69596. */
  69597. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  69598. /**
  69599. * Gets matrix determinant
  69600. * @returns the determinant
  69601. */
  69602. determinant(): number;
  69603. /**
  69604. * Inverses the matrix and stores it in a target matrix
  69605. * @param result defines the target matrix
  69606. * @returns the current matrix
  69607. */
  69608. invertToRef(result: Matrix2D): Matrix2D;
  69609. /**
  69610. * Multiplies the current matrix with another one
  69611. * @param other defines the second operand
  69612. * @param result defines the target matrix
  69613. * @returns the current matrix
  69614. */
  69615. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  69616. /**
  69617. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  69618. * @param x defines the x coordinate to transform
  69619. * @param y defines the x coordinate to transform
  69620. * @param result defines the target vector2
  69621. * @returns the current matrix
  69622. */
  69623. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  69624. /**
  69625. * Creates an identity matrix
  69626. * @returns a new matrix
  69627. */
  69628. static Identity(): Matrix2D;
  69629. /**
  69630. * Creates a translation matrix and stores it in a target matrix
  69631. * @param x defines the x coordinate of the translation
  69632. * @param y defines the y coordinate of the translation
  69633. * @param result defines the target matrix
  69634. */
  69635. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  69636. /**
  69637. * Creates a scaling matrix and stores it in a target matrix
  69638. * @param x defines the x coordinate of the scaling
  69639. * @param y defines the y coordinate of the scaling
  69640. * @param result defines the target matrix
  69641. */
  69642. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  69643. /**
  69644. * Creates a rotation matrix and stores it in a target matrix
  69645. * @param angle defines the rotation angle
  69646. * @param result defines the target matrix
  69647. */
  69648. static RotationToRef(angle: number, result: Matrix2D): void;
  69649. private static _TempPreTranslationMatrix;
  69650. private static _TempPostTranslationMatrix;
  69651. private static _TempRotationMatrix;
  69652. private static _TempScalingMatrix;
  69653. private static _TempCompose0;
  69654. private static _TempCompose1;
  69655. private static _TempCompose2;
  69656. /**
  69657. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  69658. * @param tx defines the x coordinate of the translation
  69659. * @param ty defines the y coordinate of the translation
  69660. * @param angle defines the rotation angle
  69661. * @param scaleX defines the x coordinate of the scaling
  69662. * @param scaleY defines the y coordinate of the scaling
  69663. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  69664. * @param result defines the target matrix
  69665. */
  69666. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  69667. }
  69668. }
  69669. declare module BABYLON.GUI {
  69670. /**
  69671. * Class used to store 2D control sizes
  69672. */
  69673. export class Measure {
  69674. /** defines left coordinate */
  69675. left: number;
  69676. /** defines top coordinate */
  69677. top: number;
  69678. /** defines width dimension */
  69679. width: number;
  69680. /** defines height dimension */
  69681. height: number;
  69682. /**
  69683. * Creates a new measure
  69684. * @param left defines left coordinate
  69685. * @param top defines top coordinate
  69686. * @param width defines width dimension
  69687. * @param height defines height dimension
  69688. */
  69689. constructor(
  69690. /** defines left coordinate */
  69691. left: number,
  69692. /** defines top coordinate */
  69693. top: number,
  69694. /** defines width dimension */
  69695. width: number,
  69696. /** defines height dimension */
  69697. height: number);
  69698. /**
  69699. * Copy from another measure
  69700. * @param other defines the other measure to copy from
  69701. */
  69702. copyFrom(other: Measure): void;
  69703. /**
  69704. * Copy from a group of 4 floats
  69705. * @param left defines left coordinate
  69706. * @param top defines top coordinate
  69707. * @param width defines width dimension
  69708. * @param height defines height dimension
  69709. */
  69710. copyFromFloats(left: number, top: number, width: number, height: number): void;
  69711. /**
  69712. * Computes the axis aligned bounding box measure for two given measures
  69713. * @param a Input measure
  69714. * @param b Input measure
  69715. * @param result the resulting bounding measure
  69716. */
  69717. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  69718. /**
  69719. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  69720. * @param transform the matrix to transform the measure before computing the AABB
  69721. * @param result the resulting AABB
  69722. */
  69723. transformToRef(transform: Matrix2D, result: Measure): void;
  69724. /**
  69725. * Check equality between this measure and another one
  69726. * @param other defines the other measures
  69727. * @returns true if both measures are equals
  69728. */
  69729. isEqualsTo(other: Measure): boolean;
  69730. /**
  69731. * Creates an empty measure
  69732. * @returns a new measure
  69733. */
  69734. static Empty(): Measure;
  69735. }
  69736. }
  69737. declare module BABYLON.GUI {
  69738. /**
  69739. * Interface used to define a control that can receive focus
  69740. */
  69741. export interface IFocusableControl {
  69742. /**
  69743. * Function called when the control receives the focus
  69744. */
  69745. onFocus(): void;
  69746. /**
  69747. * Function called when the control loses the focus
  69748. */
  69749. onBlur(): void;
  69750. /**
  69751. * Function called to let the control handle keyboard events
  69752. * @param evt defines the current keyboard event
  69753. */
  69754. processKeyboard(evt: KeyboardEvent): void;
  69755. /**
  69756. * Function called to get the list of controls that should not steal the focus from this control
  69757. * @returns an array of controls
  69758. */
  69759. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69760. }
  69761. /**
  69762. * Class used to create texture to support 2D GUI elements
  69763. * @see http://doc.babylonjs.com/how_to/gui
  69764. */
  69765. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  69766. private _isDirty;
  69767. private _renderObserver;
  69768. private _resizeObserver;
  69769. private _preKeyboardObserver;
  69770. private _pointerMoveObserver;
  69771. private _pointerObserver;
  69772. private _canvasPointerOutObserver;
  69773. private _background;
  69774. /** @hidden */
  69775. _rootContainer: Container;
  69776. /** @hidden */
  69777. _lastPickedControl: Control;
  69778. /** @hidden */
  69779. _lastControlOver: {
  69780. [pointerId: number]: Control;
  69781. };
  69782. /** @hidden */
  69783. _lastControlDown: {
  69784. [pointerId: number]: Control;
  69785. };
  69786. /** @hidden */
  69787. _capturingControl: {
  69788. [pointerId: number]: Control;
  69789. };
  69790. /** @hidden */
  69791. _shouldBlockPointer: boolean;
  69792. /** @hidden */
  69793. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  69794. /** @hidden */
  69795. _linkedControls: Control[];
  69796. private _isFullscreen;
  69797. private _fullscreenViewport;
  69798. private _idealWidth;
  69799. private _idealHeight;
  69800. private _useSmallestIdeal;
  69801. private _renderAtIdealSize;
  69802. private _focusedControl;
  69803. private _blockNextFocusCheck;
  69804. private _renderScale;
  69805. private _rootElement;
  69806. private _cursorChanged;
  69807. /**
  69808. * Define type to string to ensure compatibility across browsers
  69809. * Safari doesn't support DataTransfer constructor
  69810. */
  69811. private _clipboardData;
  69812. /**
  69813. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  69814. */
  69815. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  69816. /**
  69817. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  69818. */
  69819. onControlPickedObservable: BABYLON.Observable<Control>;
  69820. /**
  69821. * BABYLON.Observable event triggered before layout is evaluated
  69822. */
  69823. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69824. /**
  69825. * BABYLON.Observable event triggered after the layout was evaluated
  69826. */
  69827. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69828. /**
  69829. * BABYLON.Observable event triggered before the texture is rendered
  69830. */
  69831. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69832. /**
  69833. * BABYLON.Observable event triggered after the texture was rendered
  69834. */
  69835. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69836. /**
  69837. * Gets or sets a boolean defining if alpha is stored as premultiplied
  69838. */
  69839. premulAlpha: boolean;
  69840. /**
  69841. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  69842. * Useful when you want more antialiasing
  69843. */
  69844. get renderScale(): number;
  69845. set renderScale(value: number);
  69846. /** Gets or sets the background color */
  69847. get background(): string;
  69848. set background(value: string);
  69849. /**
  69850. * Gets or sets the ideal width used to design controls.
  69851. * The GUI will then rescale everything accordingly
  69852. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69853. */
  69854. get idealWidth(): number;
  69855. set idealWidth(value: number);
  69856. /**
  69857. * Gets or sets the ideal height used to design controls.
  69858. * The GUI will then rescale everything accordingly
  69859. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69860. */
  69861. get idealHeight(): number;
  69862. set idealHeight(value: number);
  69863. /**
  69864. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  69865. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69866. */
  69867. get useSmallestIdeal(): boolean;
  69868. set useSmallestIdeal(value: boolean);
  69869. /**
  69870. * Gets or sets a boolean indicating if adaptive scaling must be used
  69871. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69872. */
  69873. get renderAtIdealSize(): boolean;
  69874. set renderAtIdealSize(value: boolean);
  69875. /**
  69876. * Gets the underlying layer used to render the texture when in fullscreen mode
  69877. */
  69878. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  69879. /**
  69880. * Gets the root container control
  69881. */
  69882. get rootContainer(): Container;
  69883. /**
  69884. * Returns an array containing the root container.
  69885. * This is mostly used to let the Inspector introspects the ADT
  69886. * @returns an array containing the rootContainer
  69887. */
  69888. getChildren(): Array<Container>;
  69889. /**
  69890. * Will return all controls that are inside this texture
  69891. * @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
  69892. * @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
  69893. * @return all child controls
  69894. */
  69895. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  69896. /**
  69897. * Gets or sets the current focused control
  69898. */
  69899. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  69900. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  69901. /**
  69902. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  69903. */
  69904. get isForeground(): boolean;
  69905. set isForeground(value: boolean);
  69906. /**
  69907. * Gets or set information about clipboardData
  69908. */
  69909. get clipboardData(): string;
  69910. set clipboardData(value: string);
  69911. /**
  69912. * Creates a new AdvancedDynamicTexture
  69913. * @param name defines the name of the texture
  69914. * @param width defines the width of the texture
  69915. * @param height defines the height of the texture
  69916. * @param scene defines the hosting scene
  69917. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  69918. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  69919. */
  69920. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  69921. /**
  69922. * Get the current class name of the texture useful for serialization or dynamic coding.
  69923. * @returns "AdvancedDynamicTexture"
  69924. */
  69925. getClassName(): string;
  69926. /**
  69927. * Function used to execute a function on all controls
  69928. * @param func defines the function to execute
  69929. * @param container defines the container where controls belong. If null the root container will be used
  69930. */
  69931. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  69932. private _useInvalidateRectOptimization;
  69933. /**
  69934. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  69935. */
  69936. get useInvalidateRectOptimization(): boolean;
  69937. set useInvalidateRectOptimization(value: boolean);
  69938. private _invalidatedRectangle;
  69939. /**
  69940. * Invalidates a rectangle area on the gui texture
  69941. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  69942. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  69943. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  69944. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  69945. */
  69946. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  69947. /**
  69948. * Marks the texture as dirty forcing a complete update
  69949. */
  69950. markAsDirty(): void;
  69951. /**
  69952. * Helper function used to create a new style
  69953. * @returns a new style
  69954. * @see http://doc.babylonjs.com/how_to/gui#styles
  69955. */
  69956. createStyle(): Style;
  69957. /**
  69958. * Adds a new control to the root container
  69959. * @param control defines the control to add
  69960. * @returns the current texture
  69961. */
  69962. addControl(control: Control): AdvancedDynamicTexture;
  69963. /**
  69964. * Removes a control from the root container
  69965. * @param control defines the control to remove
  69966. * @returns the current texture
  69967. */
  69968. removeControl(control: Control): AdvancedDynamicTexture;
  69969. /**
  69970. * Release all resources
  69971. */
  69972. dispose(): void;
  69973. private _onResize;
  69974. /** @hidden */
  69975. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  69976. /**
  69977. * Get screen coordinates for a vector3
  69978. * @param position defines the position to project
  69979. * @param worldMatrix defines the world matrix to use
  69980. * @returns the projected position
  69981. */
  69982. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  69983. private _checkUpdate;
  69984. private _clearMeasure;
  69985. private _render;
  69986. /** @hidden */
  69987. _changeCursor(cursor: string): void;
  69988. /** @hidden */
  69989. _registerLastControlDown(control: Control, pointerId: number): void;
  69990. private _doPicking;
  69991. /** @hidden */
  69992. _cleanControlAfterRemovalFromList(list: {
  69993. [pointerId: number]: Control;
  69994. }, control: Control): void;
  69995. /** @hidden */
  69996. _cleanControlAfterRemoval(control: Control): void;
  69997. /** Attach to all scene events required to support pointer events */
  69998. attach(): void;
  69999. /** @hidden */
  70000. private onClipboardCopy;
  70001. /** @hidden */
  70002. private onClipboardCut;
  70003. /** @hidden */
  70004. private onClipboardPaste;
  70005. /**
  70006. * Register the clipboard Events onto the canvas
  70007. */
  70008. registerClipboardEvents(): void;
  70009. /**
  70010. * Unregister the clipboard Events from the canvas
  70011. */
  70012. unRegisterClipboardEvents(): void;
  70013. /**
  70014. * Connect the texture to a hosting mesh to enable interactions
  70015. * @param mesh defines the mesh to attach to
  70016. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70017. */
  70018. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70019. /**
  70020. * Move the focus to a specific control
  70021. * @param control defines the control which will receive the focus
  70022. */
  70023. moveFocusToControl(control: IFocusableControl): void;
  70024. private _manageFocus;
  70025. private _attachToOnPointerOut;
  70026. /**
  70027. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70028. * @param mesh defines the mesh which will receive the texture
  70029. * @param width defines the texture width (1024 by default)
  70030. * @param height defines the texture height (1024 by default)
  70031. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70032. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70033. * @returns a new AdvancedDynamicTexture
  70034. */
  70035. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70036. /**
  70037. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70038. * In this mode the texture will rely on a layer for its rendering.
  70039. * This allows it to be treated like any other layer.
  70040. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70041. * LayerMask is set through advancedTexture.layer.layerMask
  70042. * @param name defines name for the texture
  70043. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70044. * @param scene defines the hsoting scene
  70045. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70046. * @returns a new AdvancedDynamicTexture
  70047. */
  70048. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70049. }
  70050. }
  70051. declare module BABYLON.GUI {
  70052. /**
  70053. * Root class used for all 2D controls
  70054. * @see http://doc.babylonjs.com/how_to/gui#controls
  70055. */
  70056. export class Control {
  70057. /** defines the name of the control */
  70058. name?: string | undefined;
  70059. /**
  70060. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70061. */
  70062. static AllowAlphaInheritance: boolean;
  70063. private _alpha;
  70064. private _alphaSet;
  70065. private _zIndex;
  70066. /** @hidden */
  70067. _host: AdvancedDynamicTexture;
  70068. /** Gets or sets the control parent */
  70069. parent: BABYLON.Nullable<Container>;
  70070. /** @hidden */
  70071. _currentMeasure: Measure;
  70072. private _fontFamily;
  70073. private _fontStyle;
  70074. private _fontWeight;
  70075. private _fontSize;
  70076. private _font;
  70077. /** @hidden */
  70078. _width: ValueAndUnit;
  70079. /** @hidden */
  70080. _height: ValueAndUnit;
  70081. /** @hidden */
  70082. protected _fontOffset: {
  70083. ascent: number;
  70084. height: number;
  70085. descent: number;
  70086. };
  70087. private _color;
  70088. private _style;
  70089. private _styleObserver;
  70090. /** @hidden */
  70091. protected _horizontalAlignment: number;
  70092. /** @hidden */
  70093. protected _verticalAlignment: number;
  70094. /** @hidden */
  70095. protected _isDirty: boolean;
  70096. /** @hidden */
  70097. protected _wasDirty: boolean;
  70098. /** @hidden */
  70099. _tempParentMeasure: Measure;
  70100. /** @hidden */
  70101. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70102. /** @hidden */
  70103. protected _cachedParentMeasure: Measure;
  70104. private _paddingLeft;
  70105. private _paddingRight;
  70106. private _paddingTop;
  70107. private _paddingBottom;
  70108. /** @hidden */
  70109. _left: ValueAndUnit;
  70110. /** @hidden */
  70111. _top: ValueAndUnit;
  70112. private _scaleX;
  70113. private _scaleY;
  70114. private _rotation;
  70115. private _transformCenterX;
  70116. private _transformCenterY;
  70117. /** @hidden */
  70118. _transformMatrix: Matrix2D;
  70119. /** @hidden */
  70120. protected _invertTransformMatrix: Matrix2D;
  70121. /** @hidden */
  70122. protected _transformedPosition: BABYLON.Vector2;
  70123. private _isMatrixDirty;
  70124. private _cachedOffsetX;
  70125. private _cachedOffsetY;
  70126. private _isVisible;
  70127. private _isHighlighted;
  70128. /** @hidden */
  70129. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70130. private _fontSet;
  70131. private _dummyVector2;
  70132. private _downCount;
  70133. private _enterCount;
  70134. private _doNotRender;
  70135. private _downPointerIds;
  70136. protected _isEnabled: boolean;
  70137. protected _disabledColor: string;
  70138. /** @hidden */
  70139. protected _rebuildLayout: boolean;
  70140. /** @hidden */
  70141. _isClipped: boolean;
  70142. /** @hidden */
  70143. _automaticSize: boolean;
  70144. /** @hidden */
  70145. _tag: any;
  70146. /**
  70147. * 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
  70148. */
  70149. uniqueId: number;
  70150. /**
  70151. * Gets or sets an object used to store user defined information for the node
  70152. */
  70153. metadata: any;
  70154. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70155. isHitTestVisible: boolean;
  70156. /** Gets or sets a boolean indicating if the control can block pointer events */
  70157. isPointerBlocker: boolean;
  70158. /** Gets or sets a boolean indicating if the control can be focusable */
  70159. isFocusInvisible: boolean;
  70160. /**
  70161. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70162. * 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
  70163. */
  70164. clipChildren: boolean;
  70165. /**
  70166. * Gets or sets a boolean indicating that control content must be clipped
  70167. * 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
  70168. */
  70169. clipContent: boolean;
  70170. /**
  70171. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70172. */
  70173. useBitmapCache: boolean;
  70174. private _cacheData;
  70175. private _shadowOffsetX;
  70176. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70177. get shadowOffsetX(): number;
  70178. set shadowOffsetX(value: number);
  70179. private _shadowOffsetY;
  70180. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70181. get shadowOffsetY(): number;
  70182. set shadowOffsetY(value: number);
  70183. private _shadowBlur;
  70184. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70185. get shadowBlur(): number;
  70186. set shadowBlur(value: number);
  70187. private _shadowColor;
  70188. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70189. get shadowColor(): string;
  70190. set shadowColor(value: string);
  70191. /** Gets or sets the cursor to use when the control is hovered */
  70192. hoverCursor: string;
  70193. /** @hidden */
  70194. protected _linkOffsetX: ValueAndUnit;
  70195. /** @hidden */
  70196. protected _linkOffsetY: ValueAndUnit;
  70197. /** Gets the control type name */
  70198. get typeName(): string;
  70199. /**
  70200. * Get the current class name of the control.
  70201. * @returns current class name
  70202. */
  70203. getClassName(): string;
  70204. /**
  70205. * An event triggered when the pointer move over the control.
  70206. */
  70207. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70208. /**
  70209. * An event triggered when the pointer move out of the control.
  70210. */
  70211. onPointerOutObservable: BABYLON.Observable<Control>;
  70212. /**
  70213. * An event triggered when the pointer taps the control
  70214. */
  70215. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70216. /**
  70217. * An event triggered when pointer up
  70218. */
  70219. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70220. /**
  70221. * An event triggered when a control is clicked on
  70222. */
  70223. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70224. /**
  70225. * An event triggered when pointer enters the control
  70226. */
  70227. onPointerEnterObservable: BABYLON.Observable<Control>;
  70228. /**
  70229. * An event triggered when the control is marked as dirty
  70230. */
  70231. onDirtyObservable: BABYLON.Observable<Control>;
  70232. /**
  70233. * An event triggered before drawing the control
  70234. */
  70235. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70236. /**
  70237. * An event triggered after the control was drawn
  70238. */
  70239. onAfterDrawObservable: BABYLON.Observable<Control>;
  70240. /**
  70241. * Get the hosting AdvancedDynamicTexture
  70242. */
  70243. get host(): AdvancedDynamicTexture;
  70244. /** Gets or set information about font offsets (used to render and align text) */
  70245. get fontOffset(): {
  70246. ascent: number;
  70247. height: number;
  70248. descent: number;
  70249. };
  70250. set fontOffset(offset: {
  70251. ascent: number;
  70252. height: number;
  70253. descent: number;
  70254. });
  70255. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70256. get alpha(): number;
  70257. set alpha(value: number);
  70258. /**
  70259. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70260. */
  70261. get isHighlighted(): boolean;
  70262. set isHighlighted(value: boolean);
  70263. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70264. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70265. */
  70266. get scaleX(): number;
  70267. set scaleX(value: number);
  70268. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70269. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70270. */
  70271. get scaleY(): number;
  70272. set scaleY(value: number);
  70273. /** Gets or sets the rotation angle (0 by default)
  70274. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70275. */
  70276. get rotation(): number;
  70277. set rotation(value: number);
  70278. /** Gets or sets the transformation center on Y axis (0 by default)
  70279. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70280. */
  70281. get transformCenterY(): number;
  70282. set transformCenterY(value: number);
  70283. /** Gets or sets the transformation center on X axis (0 by default)
  70284. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70285. */
  70286. get transformCenterX(): number;
  70287. set transformCenterX(value: number);
  70288. /**
  70289. * Gets or sets the horizontal alignment
  70290. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70291. */
  70292. get horizontalAlignment(): number;
  70293. set horizontalAlignment(value: number);
  70294. /**
  70295. * Gets or sets the vertical alignment
  70296. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70297. */
  70298. get verticalAlignment(): number;
  70299. set verticalAlignment(value: number);
  70300. /**
  70301. * Gets or sets control width
  70302. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70303. */
  70304. get width(): string | number;
  70305. set width(value: string | number);
  70306. /**
  70307. * Gets or sets the control width in pixel
  70308. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70309. */
  70310. get widthInPixels(): number;
  70311. set widthInPixels(value: number);
  70312. /**
  70313. * Gets or sets control height
  70314. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70315. */
  70316. get height(): string | number;
  70317. set height(value: string | number);
  70318. /**
  70319. * Gets or sets control height in pixel
  70320. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70321. */
  70322. get heightInPixels(): number;
  70323. set heightInPixels(value: number);
  70324. /** Gets or set font family */
  70325. get fontFamily(): string;
  70326. set fontFamily(value: string);
  70327. /** Gets or sets font style */
  70328. get fontStyle(): string;
  70329. set fontStyle(value: string);
  70330. /** Gets or sets font weight */
  70331. get fontWeight(): string;
  70332. set fontWeight(value: string);
  70333. /**
  70334. * Gets or sets style
  70335. * @see http://doc.babylonjs.com/how_to/gui#styles
  70336. */
  70337. get style(): BABYLON.Nullable<Style>;
  70338. set style(value: BABYLON.Nullable<Style>);
  70339. /** @hidden */
  70340. get _isFontSizeInPercentage(): boolean;
  70341. /** Gets or sets font size in pixels */
  70342. get fontSizeInPixels(): number;
  70343. set fontSizeInPixels(value: number);
  70344. /** Gets or sets font size */
  70345. get fontSize(): string | number;
  70346. set fontSize(value: string | number);
  70347. /** Gets or sets foreground color */
  70348. get color(): string;
  70349. set color(value: string);
  70350. /** Gets or sets z index which is used to reorder controls on the z axis */
  70351. get zIndex(): number;
  70352. set zIndex(value: number);
  70353. /** Gets or sets a boolean indicating if the control can be rendered */
  70354. get notRenderable(): boolean;
  70355. set notRenderable(value: boolean);
  70356. /** Gets or sets a boolean indicating if the control is visible */
  70357. get isVisible(): boolean;
  70358. set isVisible(value: boolean);
  70359. /** Gets a boolean indicating that the control needs to update its rendering */
  70360. get isDirty(): boolean;
  70361. /**
  70362. * Gets the current linked mesh (or null if none)
  70363. */
  70364. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70365. /**
  70366. * Gets or sets a value indicating the padding to use on the left of the control
  70367. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70368. */
  70369. get paddingLeft(): string | number;
  70370. set paddingLeft(value: string | number);
  70371. /**
  70372. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70373. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70374. */
  70375. get paddingLeftInPixels(): number;
  70376. set paddingLeftInPixels(value: number);
  70377. /**
  70378. * Gets or sets a value indicating the padding to use on the right of the control
  70379. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70380. */
  70381. get paddingRight(): string | number;
  70382. set paddingRight(value: string | number);
  70383. /**
  70384. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70385. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70386. */
  70387. get paddingRightInPixels(): number;
  70388. set paddingRightInPixels(value: number);
  70389. /**
  70390. * Gets or sets a value indicating the padding to use on the top of the control
  70391. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70392. */
  70393. get paddingTop(): string | number;
  70394. set paddingTop(value: string | number);
  70395. /**
  70396. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70397. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70398. */
  70399. get paddingTopInPixels(): number;
  70400. set paddingTopInPixels(value: number);
  70401. /**
  70402. * Gets or sets a value indicating the padding to use on the bottom of the control
  70403. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70404. */
  70405. get paddingBottom(): string | number;
  70406. set paddingBottom(value: string | number);
  70407. /**
  70408. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70409. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70410. */
  70411. get paddingBottomInPixels(): number;
  70412. set paddingBottomInPixels(value: number);
  70413. /**
  70414. * Gets or sets a value indicating the left coordinate of the control
  70415. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70416. */
  70417. get left(): string | number;
  70418. set left(value: string | number);
  70419. /**
  70420. * Gets or sets a value indicating the left coordinate in pixels of the control
  70421. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70422. */
  70423. get leftInPixels(): number;
  70424. set leftInPixels(value: number);
  70425. /**
  70426. * Gets or sets a value indicating the top coordinate of the control
  70427. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70428. */
  70429. get top(): string | number;
  70430. set top(value: string | number);
  70431. /**
  70432. * Gets or sets a value indicating the top coordinate in pixels of the control
  70433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70434. */
  70435. get topInPixels(): number;
  70436. set topInPixels(value: number);
  70437. /**
  70438. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70439. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70440. */
  70441. get linkOffsetX(): string | number;
  70442. set linkOffsetX(value: string | number);
  70443. /**
  70444. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70445. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70446. */
  70447. get linkOffsetXInPixels(): number;
  70448. set linkOffsetXInPixels(value: number);
  70449. /**
  70450. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70451. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70452. */
  70453. get linkOffsetY(): string | number;
  70454. set linkOffsetY(value: string | number);
  70455. /**
  70456. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70457. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70458. */
  70459. get linkOffsetYInPixels(): number;
  70460. set linkOffsetYInPixels(value: number);
  70461. /** Gets the center coordinate on X axis */
  70462. get centerX(): number;
  70463. /** Gets the center coordinate on Y axis */
  70464. get centerY(): number;
  70465. /** Gets or sets if control is Enabled*/
  70466. get isEnabled(): boolean;
  70467. set isEnabled(value: boolean);
  70468. /** Gets or sets background color of control if it's disabled*/
  70469. get disabledColor(): string;
  70470. set disabledColor(value: string);
  70471. /**
  70472. * Creates a new control
  70473. * @param name defines the name of the control
  70474. */
  70475. constructor(
  70476. /** defines the name of the control */
  70477. name?: string | undefined);
  70478. /** @hidden */
  70479. protected _getTypeName(): string;
  70480. /**
  70481. * Gets the first ascendant in the hierarchy of the given type
  70482. * @param className defines the required type
  70483. * @returns the ascendant or null if not found
  70484. */
  70485. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  70486. /** @hidden */
  70487. _resetFontCache(): void;
  70488. /**
  70489. * Determines if a container is an ascendant of the current control
  70490. * @param container defines the container to look for
  70491. * @returns true if the container is one of the ascendant of the control
  70492. */
  70493. isAscendant(container: Control): boolean;
  70494. /**
  70495. * Gets coordinates in local control space
  70496. * @param globalCoordinates defines the coordinates to transform
  70497. * @returns the new coordinates in local space
  70498. */
  70499. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70500. /**
  70501. * Gets coordinates in local control space
  70502. * @param globalCoordinates defines the coordinates to transform
  70503. * @param result defines the target vector2 where to store the result
  70504. * @returns the current control
  70505. */
  70506. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  70507. /**
  70508. * Gets coordinates in parent local control space
  70509. * @param globalCoordinates defines the coordinates to transform
  70510. * @returns the new coordinates in parent local space
  70511. */
  70512. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70513. /**
  70514. * Move the current control to a vector3 position projected onto the screen.
  70515. * @param position defines the target position
  70516. * @param scene defines the hosting scene
  70517. */
  70518. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  70519. /**
  70520. * Will store all controls that have this control as ascendant in a given array
  70521. * @param results defines the array where to store the descendants
  70522. * @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
  70523. * @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
  70524. */
  70525. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70526. /**
  70527. * Will return all controls that have this control as ascendant
  70528. * @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
  70529. * @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
  70530. * @return all child controls
  70531. */
  70532. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70533. /**
  70534. * Link current control with a target mesh
  70535. * @param mesh defines the mesh to link with
  70536. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70537. */
  70538. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  70539. /** @hidden */
  70540. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  70541. /** @hidden */
  70542. _offsetLeft(offset: number): void;
  70543. /** @hidden */
  70544. _offsetTop(offset: number): void;
  70545. /** @hidden */
  70546. _markMatrixAsDirty(): void;
  70547. /** @hidden */
  70548. _flagDescendantsAsMatrixDirty(): void;
  70549. /** @hidden */
  70550. _intersectsRect(rect: Measure): boolean;
  70551. /** @hidden */
  70552. protected invalidateRect(): void;
  70553. /** @hidden */
  70554. _markAsDirty(force?: boolean): void;
  70555. /** @hidden */
  70556. _markAllAsDirty(): void;
  70557. /** @hidden */
  70558. _link(host: AdvancedDynamicTexture): void;
  70559. /** @hidden */
  70560. protected _transform(context?: CanvasRenderingContext2D): void;
  70561. /** @hidden */
  70562. _renderHighlight(context: CanvasRenderingContext2D): void;
  70563. /** @hidden */
  70564. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70565. /** @hidden */
  70566. protected _applyStates(context: CanvasRenderingContext2D): void;
  70567. /** @hidden */
  70568. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70569. /** @hidden */
  70570. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70571. protected _evaluateClippingState(parentMeasure: Measure): void;
  70572. /** @hidden */
  70573. _measure(): void;
  70574. /** @hidden */
  70575. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70576. /** @hidden */
  70577. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70578. /** @hidden */
  70579. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70580. /** @hidden */
  70581. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70582. private static _ClipMeasure;
  70583. private _tmpMeasureA;
  70584. private _clip;
  70585. /** @hidden */
  70586. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  70587. /** @hidden */
  70588. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70589. /**
  70590. * Tests if a given coordinates belong to the current control
  70591. * @param x defines x coordinate to test
  70592. * @param y defines y coordinate to test
  70593. * @returns true if the coordinates are inside the control
  70594. */
  70595. contains(x: number, y: number): boolean;
  70596. /** @hidden */
  70597. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70598. /** @hidden */
  70599. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70600. /** @hidden */
  70601. _onPointerEnter(target: Control): boolean;
  70602. /** @hidden */
  70603. _onPointerOut(target: Control, force?: boolean): void;
  70604. /** @hidden */
  70605. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70606. /** @hidden */
  70607. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70608. /** @hidden */
  70609. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70610. /** @hidden */
  70611. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  70612. private _prepareFont;
  70613. /** Releases associated resources */
  70614. dispose(): void;
  70615. private static _HORIZONTAL_ALIGNMENT_LEFT;
  70616. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  70617. private static _HORIZONTAL_ALIGNMENT_CENTER;
  70618. private static _VERTICAL_ALIGNMENT_TOP;
  70619. private static _VERTICAL_ALIGNMENT_BOTTOM;
  70620. private static _VERTICAL_ALIGNMENT_CENTER;
  70621. /** HORIZONTAL_ALIGNMENT_LEFT */
  70622. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  70623. /** HORIZONTAL_ALIGNMENT_RIGHT */
  70624. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  70625. /** HORIZONTAL_ALIGNMENT_CENTER */
  70626. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  70627. /** VERTICAL_ALIGNMENT_TOP */
  70628. static get VERTICAL_ALIGNMENT_TOP(): number;
  70629. /** VERTICAL_ALIGNMENT_BOTTOM */
  70630. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  70631. /** VERTICAL_ALIGNMENT_CENTER */
  70632. static get VERTICAL_ALIGNMENT_CENTER(): number;
  70633. private static _FontHeightSizes;
  70634. /** @hidden */
  70635. static _GetFontOffset(font: string): {
  70636. ascent: number;
  70637. height: number;
  70638. descent: number;
  70639. };
  70640. /**
  70641. * Creates a stack panel that can be used to render headers
  70642. * @param control defines the control to associate with the header
  70643. * @param text defines the text of the header
  70644. * @param size defines the size of the header
  70645. * @param options defines options used to configure the header
  70646. * @returns a new StackPanel
  70647. * @ignore
  70648. * @hidden
  70649. */
  70650. static AddHeader: (control: Control, text: string, size: string | number, options: {
  70651. isHorizontal: boolean;
  70652. controlFirst: boolean;
  70653. }) => any;
  70654. /** @hidden */
  70655. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  70656. }
  70657. }
  70658. declare module BABYLON.GUI {
  70659. /**
  70660. * Root class for 2D containers
  70661. * @see http://doc.babylonjs.com/how_to/gui#containers
  70662. */
  70663. export class Container extends Control {
  70664. name?: string | undefined;
  70665. /** @hidden */
  70666. protected _children: Control[];
  70667. /** @hidden */
  70668. protected _measureForChildren: Measure;
  70669. /** @hidden */
  70670. protected _background: string;
  70671. /** @hidden */
  70672. protected _adaptWidthToChildren: boolean;
  70673. /** @hidden */
  70674. protected _adaptHeightToChildren: boolean;
  70675. /**
  70676. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  70677. */
  70678. logLayoutCycleErrors: boolean;
  70679. /**
  70680. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  70681. */
  70682. maxLayoutCycle: number;
  70683. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  70684. get adaptHeightToChildren(): boolean;
  70685. set adaptHeightToChildren(value: boolean);
  70686. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  70687. get adaptWidthToChildren(): boolean;
  70688. set adaptWidthToChildren(value: boolean);
  70689. /** Gets or sets background color */
  70690. get background(): string;
  70691. set background(value: string);
  70692. /** Gets the list of children */
  70693. get children(): Control[];
  70694. /**
  70695. * Creates a new Container
  70696. * @param name defines the name of the container
  70697. */
  70698. constructor(name?: string | undefined);
  70699. protected _getTypeName(): string;
  70700. _flagDescendantsAsMatrixDirty(): void;
  70701. /**
  70702. * Gets a child using its name
  70703. * @param name defines the child name to look for
  70704. * @returns the child control if found
  70705. */
  70706. getChildByName(name: string): BABYLON.Nullable<Control>;
  70707. /**
  70708. * Gets a child using its type and its name
  70709. * @param name defines the child name to look for
  70710. * @param type defines the child type to look for
  70711. * @returns the child control if found
  70712. */
  70713. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  70714. /**
  70715. * Search for a specific control in children
  70716. * @param control defines the control to look for
  70717. * @returns true if the control is in child list
  70718. */
  70719. containsControl(control: Control): boolean;
  70720. /**
  70721. * Adds a new control to the current container
  70722. * @param control defines the control to add
  70723. * @returns the current container
  70724. */
  70725. addControl(control: BABYLON.Nullable<Control>): Container;
  70726. /**
  70727. * Removes all controls from the current container
  70728. * @returns the current container
  70729. */
  70730. clearControls(): Container;
  70731. /**
  70732. * Removes a control from the current container
  70733. * @param control defines the control to remove
  70734. * @returns the current container
  70735. */
  70736. removeControl(control: Control): Container;
  70737. /** @hidden */
  70738. _reOrderControl(control: Control): void;
  70739. /** @hidden */
  70740. _offsetLeft(offset: number): void;
  70741. /** @hidden */
  70742. _offsetTop(offset: number): void;
  70743. /** @hidden */
  70744. _markAllAsDirty(): void;
  70745. /** @hidden */
  70746. protected _localDraw(context: CanvasRenderingContext2D): void;
  70747. /** @hidden */
  70748. _link(host: AdvancedDynamicTexture): void;
  70749. /** @hidden */
  70750. protected _beforeLayout(): void;
  70751. /** @hidden */
  70752. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70753. /** @hidden */
  70754. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70755. protected _postMeasure(): void;
  70756. /** @hidden */
  70757. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  70758. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70759. /** @hidden */
  70760. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70761. /** @hidden */
  70762. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70763. /** Releases associated resources */
  70764. dispose(): void;
  70765. }
  70766. }
  70767. declare module BABYLON.GUI {
  70768. /** Class used to create rectangle container */
  70769. export class Rectangle extends Container {
  70770. name?: string | undefined;
  70771. private _thickness;
  70772. private _cornerRadius;
  70773. /** Gets or sets border thickness */
  70774. get thickness(): number;
  70775. set thickness(value: number);
  70776. /** Gets or sets the corner radius angle */
  70777. get cornerRadius(): number;
  70778. set cornerRadius(value: number);
  70779. /**
  70780. * Creates a new Rectangle
  70781. * @param name defines the control name
  70782. */
  70783. constructor(name?: string | undefined);
  70784. protected _getTypeName(): string;
  70785. protected _localDraw(context: CanvasRenderingContext2D): void;
  70786. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70787. private _drawRoundedRect;
  70788. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70789. }
  70790. }
  70791. declare module BABYLON.GUI {
  70792. /**
  70793. * Enum that determines the text-wrapping mode to use.
  70794. */
  70795. export enum TextWrapping {
  70796. /**
  70797. * Clip the text when it's larger than Control.width; this is the default mode.
  70798. */
  70799. Clip = 0,
  70800. /**
  70801. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  70802. */
  70803. WordWrap = 1,
  70804. /**
  70805. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  70806. */
  70807. Ellipsis = 2
  70808. }
  70809. /**
  70810. * Class used to create text block control
  70811. */
  70812. export class TextBlock extends Control {
  70813. /**
  70814. * Defines the name of the control
  70815. */
  70816. name?: string | undefined;
  70817. private _text;
  70818. private _textWrapping;
  70819. private _textHorizontalAlignment;
  70820. private _textVerticalAlignment;
  70821. private _lines;
  70822. private _resizeToFit;
  70823. private _lineSpacing;
  70824. private _outlineWidth;
  70825. private _outlineColor;
  70826. /**
  70827. * An event triggered after the text is changed
  70828. */
  70829. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  70830. /**
  70831. * An event triggered after the text was broken up into lines
  70832. */
  70833. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  70834. /**
  70835. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  70836. */
  70837. get lines(): any[];
  70838. /**
  70839. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70840. */
  70841. get resizeToFit(): boolean;
  70842. /**
  70843. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70844. */
  70845. set resizeToFit(value: boolean);
  70846. /**
  70847. * Gets or sets a boolean indicating if text must be wrapped
  70848. */
  70849. get textWrapping(): TextWrapping | boolean;
  70850. /**
  70851. * Gets or sets a boolean indicating if text must be wrapped
  70852. */
  70853. set textWrapping(value: TextWrapping | boolean);
  70854. /**
  70855. * Gets or sets text to display
  70856. */
  70857. get text(): string;
  70858. /**
  70859. * Gets or sets text to display
  70860. */
  70861. set text(value: string);
  70862. /**
  70863. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70864. */
  70865. get textHorizontalAlignment(): number;
  70866. /**
  70867. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70868. */
  70869. set textHorizontalAlignment(value: number);
  70870. /**
  70871. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70872. */
  70873. get textVerticalAlignment(): number;
  70874. /**
  70875. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70876. */
  70877. set textVerticalAlignment(value: number);
  70878. /**
  70879. * Gets or sets line spacing value
  70880. */
  70881. set lineSpacing(value: string | number);
  70882. /**
  70883. * Gets or sets line spacing value
  70884. */
  70885. get lineSpacing(): string | number;
  70886. /**
  70887. * Gets or sets outlineWidth of the text to display
  70888. */
  70889. get outlineWidth(): number;
  70890. /**
  70891. * Gets or sets outlineWidth of the text to display
  70892. */
  70893. set outlineWidth(value: number);
  70894. /**
  70895. * Gets or sets outlineColor of the text to display
  70896. */
  70897. get outlineColor(): string;
  70898. /**
  70899. * Gets or sets outlineColor of the text to display
  70900. */
  70901. set outlineColor(value: string);
  70902. /**
  70903. * Creates a new TextBlock object
  70904. * @param name defines the name of the control
  70905. * @param text defines the text to display (emptry string by default)
  70906. */
  70907. constructor(
  70908. /**
  70909. * Defines the name of the control
  70910. */
  70911. name?: string | undefined, text?: string);
  70912. protected _getTypeName(): string;
  70913. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70914. private _drawText;
  70915. /** @hidden */
  70916. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70917. protected _applyStates(context: CanvasRenderingContext2D): void;
  70918. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  70919. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  70920. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  70921. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  70922. protected _renderLines(context: CanvasRenderingContext2D): void;
  70923. /**
  70924. * Given a width constraint applied on the text block, find the expected height
  70925. * @returns expected height
  70926. */
  70927. computeExpectedHeight(): number;
  70928. dispose(): void;
  70929. }
  70930. }
  70931. declare module BABYLON.GUI {
  70932. /**
  70933. * Class used to create 2D images
  70934. */
  70935. export class Image extends Control {
  70936. name?: string | undefined;
  70937. private _workingCanvas;
  70938. private _domImage;
  70939. private _imageWidth;
  70940. private _imageHeight;
  70941. private _loaded;
  70942. private _stretch;
  70943. private _source;
  70944. private _autoScale;
  70945. private _sourceLeft;
  70946. private _sourceTop;
  70947. private _sourceWidth;
  70948. private _sourceHeight;
  70949. private _cellWidth;
  70950. private _cellHeight;
  70951. private _cellId;
  70952. private _populateNinePatchSlicesFromImage;
  70953. private _sliceLeft;
  70954. private _sliceRight;
  70955. private _sliceTop;
  70956. private _sliceBottom;
  70957. private _detectPointerOnOpaqueOnly;
  70958. /**
  70959. * BABYLON.Observable notified when the content is loaded
  70960. */
  70961. onImageLoadedObservable: BABYLON.Observable<Image>;
  70962. /**
  70963. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  70964. */
  70965. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  70966. /**
  70967. * Gets a boolean indicating that the content is loaded
  70968. */
  70969. get isLoaded(): boolean;
  70970. /**
  70971. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  70972. */
  70973. get populateNinePatchSlicesFromImage(): boolean;
  70974. set populateNinePatchSlicesFromImage(value: boolean);
  70975. /**
  70976. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  70977. * Beware using this as this will comsume more memory as the image has to be stored twice
  70978. */
  70979. get detectPointerOnOpaqueOnly(): boolean;
  70980. set detectPointerOnOpaqueOnly(value: boolean);
  70981. /**
  70982. * Gets or sets the left value for slicing (9-patch)
  70983. */
  70984. get sliceLeft(): number;
  70985. set sliceLeft(value: number);
  70986. /**
  70987. * Gets or sets the right value for slicing (9-patch)
  70988. */
  70989. get sliceRight(): number;
  70990. set sliceRight(value: number);
  70991. /**
  70992. * Gets or sets the top value for slicing (9-patch)
  70993. */
  70994. get sliceTop(): number;
  70995. set sliceTop(value: number);
  70996. /**
  70997. * Gets or sets the bottom value for slicing (9-patch)
  70998. */
  70999. get sliceBottom(): number;
  71000. set sliceBottom(value: number);
  71001. /**
  71002. * Gets or sets the left coordinate in the source image
  71003. */
  71004. get sourceLeft(): number;
  71005. set sourceLeft(value: number);
  71006. /**
  71007. * Gets or sets the top coordinate in the source image
  71008. */
  71009. get sourceTop(): number;
  71010. set sourceTop(value: number);
  71011. /**
  71012. * Gets or sets the width to capture in the source image
  71013. */
  71014. get sourceWidth(): number;
  71015. set sourceWidth(value: number);
  71016. /**
  71017. * Gets or sets the height to capture in the source image
  71018. */
  71019. get sourceHeight(): number;
  71020. set sourceHeight(value: number);
  71021. /**
  71022. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71023. * @see http://doc.babylonjs.com/how_to/gui#image
  71024. */
  71025. get autoScale(): boolean;
  71026. set autoScale(value: boolean);
  71027. /** Gets or sets the streching mode used by the image */
  71028. get stretch(): number;
  71029. set stretch(value: number);
  71030. /** @hidden */
  71031. _rotate90(n: number): Image;
  71032. /**
  71033. * Gets or sets the internal DOM image used to render the control
  71034. */
  71035. set domImage(value: HTMLImageElement);
  71036. get domImage(): HTMLImageElement;
  71037. private _onImageLoaded;
  71038. private _extractNinePatchSliceDataFromImage;
  71039. /**
  71040. * Gets or sets image source url
  71041. */
  71042. set source(value: BABYLON.Nullable<string>);
  71043. /**
  71044. * Checks for svg document with icon id present
  71045. */
  71046. private _svgCheck;
  71047. /**
  71048. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71049. * given external svg file and icon id
  71050. */
  71051. private _getSVGAttribs;
  71052. /**
  71053. * Gets or sets the cell width to use when animation sheet is enabled
  71054. * @see http://doc.babylonjs.com/how_to/gui#image
  71055. */
  71056. get cellWidth(): number;
  71057. set cellWidth(value: number);
  71058. /**
  71059. * Gets or sets the cell height to use when animation sheet is enabled
  71060. * @see http://doc.babylonjs.com/how_to/gui#image
  71061. */
  71062. get cellHeight(): number;
  71063. set cellHeight(value: number);
  71064. /**
  71065. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71066. * @see http://doc.babylonjs.com/how_to/gui#image
  71067. */
  71068. get cellId(): number;
  71069. set cellId(value: number);
  71070. /**
  71071. * Creates a new Image
  71072. * @param name defines the control name
  71073. * @param url defines the image url
  71074. */
  71075. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71076. /**
  71077. * Tests if a given coordinates belong to the current control
  71078. * @param x defines x coordinate to test
  71079. * @param y defines y coordinate to test
  71080. * @returns true if the coordinates are inside the control
  71081. */
  71082. contains(x: number, y: number): boolean;
  71083. protected _getTypeName(): string;
  71084. /** Force the control to synchronize with its content */
  71085. synchronizeSizeWithContent(): void;
  71086. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71087. private _prepareWorkingCanvasForOpaqueDetection;
  71088. private _drawImage;
  71089. _draw(context: CanvasRenderingContext2D): void;
  71090. private _renderCornerPatch;
  71091. private _renderNinePatch;
  71092. dispose(): void;
  71093. /** STRETCH_NONE */
  71094. static readonly STRETCH_NONE: number;
  71095. /** STRETCH_FILL */
  71096. static readonly STRETCH_FILL: number;
  71097. /** STRETCH_UNIFORM */
  71098. static readonly STRETCH_UNIFORM: number;
  71099. /** STRETCH_EXTEND */
  71100. static readonly STRETCH_EXTEND: number;
  71101. /** NINE_PATCH */
  71102. static readonly STRETCH_NINE_PATCH: number;
  71103. }
  71104. }
  71105. declare module BABYLON.GUI {
  71106. /**
  71107. * Class used to create 2D buttons
  71108. */
  71109. export class Button extends Rectangle {
  71110. name?: string | undefined;
  71111. /**
  71112. * Function called to generate a pointer enter animation
  71113. */
  71114. pointerEnterAnimation: () => void;
  71115. /**
  71116. * Function called to generate a pointer out animation
  71117. */
  71118. pointerOutAnimation: () => void;
  71119. /**
  71120. * Function called to generate a pointer down animation
  71121. */
  71122. pointerDownAnimation: () => void;
  71123. /**
  71124. * Function called to generate a pointer up animation
  71125. */
  71126. pointerUpAnimation: () => void;
  71127. /**
  71128. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71129. */
  71130. delegatePickingToChildren: boolean;
  71131. private _image;
  71132. /**
  71133. * Returns the image part of the button (if any)
  71134. */
  71135. get image(): BABYLON.Nullable<Image>;
  71136. private _textBlock;
  71137. /**
  71138. * Returns the image part of the button (if any)
  71139. */
  71140. get textBlock(): BABYLON.Nullable<TextBlock>;
  71141. /**
  71142. * Creates a new Button
  71143. * @param name defines the name of the button
  71144. */
  71145. constructor(name?: string | undefined);
  71146. protected _getTypeName(): string;
  71147. /** @hidden */
  71148. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71149. /** @hidden */
  71150. _onPointerEnter(target: Control): boolean;
  71151. /** @hidden */
  71152. _onPointerOut(target: Control, force?: boolean): void;
  71153. /** @hidden */
  71154. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71155. /** @hidden */
  71156. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71157. /**
  71158. * Creates a new button made with an image and a text
  71159. * @param name defines the name of the button
  71160. * @param text defines the text of the button
  71161. * @param imageUrl defines the url of the image
  71162. * @returns a new Button
  71163. */
  71164. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71165. /**
  71166. * Creates a new button made with an image
  71167. * @param name defines the name of the button
  71168. * @param imageUrl defines the url of the image
  71169. * @returns a new Button
  71170. */
  71171. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71172. /**
  71173. * Creates a new button made with a text
  71174. * @param name defines the name of the button
  71175. * @param text defines the text of the button
  71176. * @returns a new Button
  71177. */
  71178. static CreateSimpleButton(name: string, text: string): Button;
  71179. /**
  71180. * Creates a new button made with an image and a centered text
  71181. * @param name defines the name of the button
  71182. * @param text defines the text of the button
  71183. * @param imageUrl defines the url of the image
  71184. * @returns a new Button
  71185. */
  71186. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71187. }
  71188. }
  71189. declare module BABYLON.GUI {
  71190. /**
  71191. * Class used to create a 2D stack panel container
  71192. */
  71193. export class StackPanel extends Container {
  71194. name?: string | undefined;
  71195. private _isVertical;
  71196. private _manualWidth;
  71197. private _manualHeight;
  71198. private _doNotTrackManualChanges;
  71199. /**
  71200. * Gets or sets a boolean indicating that layou warnings should be ignored
  71201. */
  71202. ignoreLayoutWarnings: boolean;
  71203. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71204. get isVertical(): boolean;
  71205. set isVertical(value: boolean);
  71206. /**
  71207. * Gets or sets panel width.
  71208. * This value should not be set when in horizontal mode as it will be computed automatically
  71209. */
  71210. set width(value: string | number);
  71211. get width(): string | number;
  71212. /**
  71213. * Gets or sets panel height.
  71214. * This value should not be set when in vertical mode as it will be computed automatically
  71215. */
  71216. set height(value: string | number);
  71217. get height(): string | number;
  71218. /**
  71219. * Creates a new StackPanel
  71220. * @param name defines control name
  71221. */
  71222. constructor(name?: string | undefined);
  71223. protected _getTypeName(): string;
  71224. /** @hidden */
  71225. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71226. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71227. protected _postMeasure(): void;
  71228. }
  71229. }
  71230. declare module BABYLON.GUI {
  71231. /**
  71232. * Class used to represent a 2D checkbox
  71233. */
  71234. export class Checkbox extends Control {
  71235. name?: string | undefined;
  71236. private _isChecked;
  71237. private _background;
  71238. private _checkSizeRatio;
  71239. private _thickness;
  71240. /** Gets or sets border thickness */
  71241. get thickness(): number;
  71242. set thickness(value: number);
  71243. /**
  71244. * BABYLON.Observable raised when isChecked property changes
  71245. */
  71246. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71247. /** Gets or sets a value indicating the ratio between overall size and check size */
  71248. get checkSizeRatio(): number;
  71249. set checkSizeRatio(value: number);
  71250. /** Gets or sets background color */
  71251. get background(): string;
  71252. set background(value: string);
  71253. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71254. get isChecked(): boolean;
  71255. set isChecked(value: boolean);
  71256. /**
  71257. * Creates a new CheckBox
  71258. * @param name defines the control name
  71259. */
  71260. constructor(name?: string | undefined);
  71261. protected _getTypeName(): string;
  71262. /** @hidden */
  71263. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71264. /** @hidden */
  71265. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71266. /**
  71267. * Utility function to easily create a checkbox with a header
  71268. * @param title defines the label to use for the header
  71269. * @param onValueChanged defines the callback to call when value changes
  71270. * @returns a StackPanel containing the checkbox and a textBlock
  71271. */
  71272. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71273. }
  71274. }
  71275. declare module BABYLON.GUI {
  71276. /**
  71277. * Class used to store key control properties
  71278. */
  71279. export class KeyPropertySet {
  71280. /** Width */
  71281. width?: string;
  71282. /** Height */
  71283. height?: string;
  71284. /** Left padding */
  71285. paddingLeft?: string;
  71286. /** Right padding */
  71287. paddingRight?: string;
  71288. /** Top padding */
  71289. paddingTop?: string;
  71290. /** Bottom padding */
  71291. paddingBottom?: string;
  71292. /** Foreground color */
  71293. color?: string;
  71294. /** Background color */
  71295. background?: string;
  71296. }
  71297. /**
  71298. * Class used to create virtual keyboard
  71299. */
  71300. export class VirtualKeyboard extends StackPanel {
  71301. /** BABYLON.Observable raised when a key is pressed */
  71302. onKeyPressObservable: BABYLON.Observable<string>;
  71303. /** Gets or sets default key button width */
  71304. defaultButtonWidth: string;
  71305. /** Gets or sets default key button height */
  71306. defaultButtonHeight: string;
  71307. /** Gets or sets default key button left padding */
  71308. defaultButtonPaddingLeft: string;
  71309. /** Gets or sets default key button right padding */
  71310. defaultButtonPaddingRight: string;
  71311. /** Gets or sets default key button top padding */
  71312. defaultButtonPaddingTop: string;
  71313. /** Gets or sets default key button bottom padding */
  71314. defaultButtonPaddingBottom: string;
  71315. /** Gets or sets default key button foreground color */
  71316. defaultButtonColor: string;
  71317. /** Gets or sets default key button background color */
  71318. defaultButtonBackground: string;
  71319. /** Gets or sets shift button foreground color */
  71320. shiftButtonColor: string;
  71321. /** Gets or sets shift button thickness*/
  71322. selectedShiftThickness: number;
  71323. /** Gets shift key state */
  71324. shiftState: number;
  71325. protected _getTypeName(): string;
  71326. private _createKey;
  71327. /**
  71328. * Adds a new row of keys
  71329. * @param keys defines the list of keys to add
  71330. * @param propertySets defines the associated property sets
  71331. */
  71332. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71333. /**
  71334. * Set the shift key to a specific state
  71335. * @param shiftState defines the new shift state
  71336. */
  71337. applyShiftState(shiftState: number): void;
  71338. private _currentlyConnectedInputText;
  71339. private _connectedInputTexts;
  71340. private _onKeyPressObserver;
  71341. /** Gets the input text control currently attached to the keyboard */
  71342. get connectedInputText(): BABYLON.Nullable<InputText>;
  71343. /**
  71344. * Connects the keyboard with an input text control
  71345. *
  71346. * @param input defines the target control
  71347. */
  71348. connect(input: InputText): void;
  71349. /**
  71350. * Disconnects the keyboard from connected InputText controls
  71351. *
  71352. * @param input optionally defines a target control, otherwise all are disconnected
  71353. */
  71354. disconnect(input?: InputText): void;
  71355. private _removeConnectedInputObservables;
  71356. /**
  71357. * Release all resources
  71358. */
  71359. dispose(): void;
  71360. /**
  71361. * Creates a new keyboard using a default layout
  71362. *
  71363. * @param name defines control name
  71364. * @returns a new VirtualKeyboard
  71365. */
  71366. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71367. }
  71368. }
  71369. declare module BABYLON.GUI {
  71370. /**
  71371. * Class used to create input text control
  71372. */
  71373. export class InputText extends Control implements IFocusableControl {
  71374. name?: string | undefined;
  71375. private _text;
  71376. private _placeholderText;
  71377. private _background;
  71378. private _focusedBackground;
  71379. private _focusedColor;
  71380. private _placeholderColor;
  71381. private _thickness;
  71382. private _margin;
  71383. private _autoStretchWidth;
  71384. private _maxWidth;
  71385. private _isFocused;
  71386. private _blinkTimeout;
  71387. private _blinkIsEven;
  71388. private _cursorOffset;
  71389. private _scrollLeft;
  71390. private _textWidth;
  71391. private _clickedCoordinate;
  71392. private _deadKey;
  71393. private _addKey;
  71394. private _currentKey;
  71395. private _isTextHighlightOn;
  71396. private _textHighlightColor;
  71397. private _highligherOpacity;
  71398. private _highlightedText;
  71399. private _startHighlightIndex;
  71400. private _endHighlightIndex;
  71401. private _cursorIndex;
  71402. private _onFocusSelectAll;
  71403. private _isPointerDown;
  71404. private _onClipboardObserver;
  71405. private _onPointerDblTapObserver;
  71406. /** @hidden */
  71407. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71408. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71409. promptMessage: string;
  71410. /** Force disable prompt on mobile device */
  71411. disableMobilePrompt: boolean;
  71412. /** BABYLON.Observable raised when the text changes */
  71413. onTextChangedObservable: BABYLON.Observable<InputText>;
  71414. /** BABYLON.Observable raised just before an entered character is to be added */
  71415. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71416. /** BABYLON.Observable raised when the control gets the focus */
  71417. onFocusObservable: BABYLON.Observable<InputText>;
  71418. /** BABYLON.Observable raised when the control loses the focus */
  71419. onBlurObservable: BABYLON.Observable<InputText>;
  71420. /**Observable raised when the text is highlighted */
  71421. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71422. /**Observable raised when copy event is triggered */
  71423. onTextCopyObservable: BABYLON.Observable<InputText>;
  71424. /** BABYLON.Observable raised when cut event is triggered */
  71425. onTextCutObservable: BABYLON.Observable<InputText>;
  71426. /** BABYLON.Observable raised when paste event is triggered */
  71427. onTextPasteObservable: BABYLON.Observable<InputText>;
  71428. /** BABYLON.Observable raised when a key event was processed */
  71429. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71430. /** Gets or sets the maximum width allowed by the control */
  71431. get maxWidth(): string | number;
  71432. /** Gets the maximum width allowed by the control in pixels */
  71433. get maxWidthInPixels(): number;
  71434. set maxWidth(value: string | number);
  71435. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71436. get highligherOpacity(): number;
  71437. set highligherOpacity(value: number);
  71438. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71439. get onFocusSelectAll(): boolean;
  71440. set onFocusSelectAll(value: boolean);
  71441. /** Gets or sets the text hightlight color */
  71442. get textHighlightColor(): string;
  71443. set textHighlightColor(value: string);
  71444. /** Gets or sets control margin */
  71445. get margin(): string;
  71446. /** Gets control margin in pixels */
  71447. get marginInPixels(): number;
  71448. set margin(value: string);
  71449. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71450. get autoStretchWidth(): boolean;
  71451. set autoStretchWidth(value: boolean);
  71452. /** Gets or sets border thickness */
  71453. get thickness(): number;
  71454. set thickness(value: number);
  71455. /** Gets or sets the background color when focused */
  71456. get focusedBackground(): string;
  71457. set focusedBackground(value: string);
  71458. /** Gets or sets the background color when focused */
  71459. get focusedColor(): string;
  71460. set focusedColor(value: string);
  71461. /** Gets or sets the background color */
  71462. get background(): string;
  71463. set background(value: string);
  71464. /** Gets or sets the placeholder color */
  71465. get placeholderColor(): string;
  71466. set placeholderColor(value: string);
  71467. /** Gets or sets the text displayed when the control is empty */
  71468. get placeholderText(): string;
  71469. set placeholderText(value: string);
  71470. /** Gets or sets the dead key flag */
  71471. get deadKey(): boolean;
  71472. set deadKey(flag: boolean);
  71473. /** Gets or sets the highlight text */
  71474. get highlightedText(): string;
  71475. set highlightedText(text: string);
  71476. /** Gets or sets if the current key should be added */
  71477. get addKey(): boolean;
  71478. set addKey(flag: boolean);
  71479. /** Gets or sets the value of the current key being entered */
  71480. get currentKey(): string;
  71481. set currentKey(key: string);
  71482. /** Gets or sets the text displayed in the control */
  71483. get text(): string;
  71484. set text(value: string);
  71485. /** Gets or sets control width */
  71486. get width(): string | number;
  71487. set width(value: string | number);
  71488. /**
  71489. * Creates a new InputText
  71490. * @param name defines the control name
  71491. * @param text defines the text of the control
  71492. */
  71493. constructor(name?: string | undefined, text?: string);
  71494. /** @hidden */
  71495. onBlur(): void;
  71496. /** @hidden */
  71497. onFocus(): void;
  71498. protected _getTypeName(): string;
  71499. /**
  71500. * Function called to get the list of controls that should not steal the focus from this control
  71501. * @returns an array of controls
  71502. */
  71503. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71504. /** @hidden */
  71505. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  71506. /** @hidden */
  71507. private _updateValueFromCursorIndex;
  71508. /** @hidden */
  71509. private _processDblClick;
  71510. /** @hidden */
  71511. private _selectAllText;
  71512. /**
  71513. * Handles the keyboard event
  71514. * @param evt Defines the KeyboardEvent
  71515. */
  71516. processKeyboard(evt: KeyboardEvent): void;
  71517. /** @hidden */
  71518. private _onCopyText;
  71519. /** @hidden */
  71520. private _onCutText;
  71521. /** @hidden */
  71522. private _onPasteText;
  71523. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71524. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71525. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71526. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71527. protected _beforeRenderText(text: string): string;
  71528. dispose(): void;
  71529. }
  71530. }
  71531. declare module BABYLON.GUI {
  71532. /**
  71533. * Class used to create a 2D grid container
  71534. */
  71535. export class Grid extends Container {
  71536. name?: string | undefined;
  71537. private _rowDefinitions;
  71538. private _columnDefinitions;
  71539. private _cells;
  71540. private _childControls;
  71541. /**
  71542. * Gets the number of columns
  71543. */
  71544. get columnCount(): number;
  71545. /**
  71546. * Gets the number of rows
  71547. */
  71548. get rowCount(): number;
  71549. /** Gets the list of children */
  71550. get children(): Control[];
  71551. /** Gets the list of cells (e.g. the containers) */
  71552. get cells(): {
  71553. [key: string]: Container;
  71554. };
  71555. /**
  71556. * Gets the definition of a specific row
  71557. * @param index defines the index of the row
  71558. * @returns the row definition
  71559. */
  71560. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71561. /**
  71562. * Gets the definition of a specific column
  71563. * @param index defines the index of the column
  71564. * @returns the column definition
  71565. */
  71566. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71567. /**
  71568. * Adds a new row to the grid
  71569. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71570. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  71571. * @returns the current grid
  71572. */
  71573. addRowDefinition(height: number, isPixel?: boolean): Grid;
  71574. /**
  71575. * Adds a new column to the grid
  71576. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71577. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71578. * @returns the current grid
  71579. */
  71580. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  71581. /**
  71582. * Update a row definition
  71583. * @param index defines the index of the row to update
  71584. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71585. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  71586. * @returns the current grid
  71587. */
  71588. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  71589. /**
  71590. * Update a column definition
  71591. * @param index defines the index of the column to update
  71592. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71593. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71594. * @returns the current grid
  71595. */
  71596. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  71597. /**
  71598. * Gets the list of children stored in a specific cell
  71599. * @param row defines the row to check
  71600. * @param column defines the column to check
  71601. * @returns the list of controls
  71602. */
  71603. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  71604. /**
  71605. * Gets a string representing the child cell info (row x column)
  71606. * @param child defines the control to get info from
  71607. * @returns a string containing the child cell info (row x column)
  71608. */
  71609. getChildCellInfo(child: Control): string;
  71610. private _removeCell;
  71611. private _offsetCell;
  71612. /**
  71613. * Remove a column definition at specified index
  71614. * @param index defines the index of the column to remove
  71615. * @returns the current grid
  71616. */
  71617. removeColumnDefinition(index: number): Grid;
  71618. /**
  71619. * Remove a row definition at specified index
  71620. * @param index defines the index of the row to remove
  71621. * @returns the current grid
  71622. */
  71623. removeRowDefinition(index: number): Grid;
  71624. /**
  71625. * Adds a new control to the current grid
  71626. * @param control defines the control to add
  71627. * @param row defines the row where to add the control (0 by default)
  71628. * @param column defines the column where to add the control (0 by default)
  71629. * @returns the current grid
  71630. */
  71631. addControl(control: Control, row?: number, column?: number): Grid;
  71632. /**
  71633. * Removes a control from the current container
  71634. * @param control defines the control to remove
  71635. * @returns the current container
  71636. */
  71637. removeControl(control: Control): Container;
  71638. /**
  71639. * Creates a new Grid
  71640. * @param name defines control name
  71641. */
  71642. constructor(name?: string | undefined);
  71643. protected _getTypeName(): string;
  71644. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  71645. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71646. _flagDescendantsAsMatrixDirty(): void;
  71647. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71648. /** Releases associated resources */
  71649. dispose(): void;
  71650. }
  71651. }
  71652. declare module BABYLON.GUI {
  71653. /** Class used to create color pickers */
  71654. export class ColorPicker extends Control {
  71655. name?: string | undefined;
  71656. private static _Epsilon;
  71657. private _colorWheelCanvas;
  71658. private _value;
  71659. private _tmpColor;
  71660. private _pointerStartedOnSquare;
  71661. private _pointerStartedOnWheel;
  71662. private _squareLeft;
  71663. private _squareTop;
  71664. private _squareSize;
  71665. private _h;
  71666. private _s;
  71667. private _v;
  71668. private _lastPointerDownID;
  71669. /**
  71670. * BABYLON.Observable raised when the value changes
  71671. */
  71672. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  71673. /** Gets or sets the color of the color picker */
  71674. get value(): BABYLON.Color3;
  71675. set value(value: BABYLON.Color3);
  71676. /**
  71677. * Gets or sets control width
  71678. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71679. */
  71680. get width(): string | number;
  71681. set width(value: string | number);
  71682. /**
  71683. * Gets or sets control height
  71684. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71685. */
  71686. get height(): string | number;
  71687. /** Gets or sets control height */
  71688. set height(value: string | number);
  71689. /** Gets or sets control size */
  71690. get size(): string | number;
  71691. set size(value: string | number);
  71692. /**
  71693. * Creates a new ColorPicker
  71694. * @param name defines the control name
  71695. */
  71696. constructor(name?: string | undefined);
  71697. protected _getTypeName(): string;
  71698. /** @hidden */
  71699. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71700. private _updateSquareProps;
  71701. private _drawGradientSquare;
  71702. private _drawCircle;
  71703. private _createColorWheelCanvas;
  71704. /** @hidden */
  71705. _draw(context: CanvasRenderingContext2D): void;
  71706. private _pointerIsDown;
  71707. private _updateValueFromPointer;
  71708. private _isPointOnSquare;
  71709. private _isPointOnWheel;
  71710. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71711. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71712. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71713. /**
  71714. * This function expands the color picker by creating a color picker dialog with manual
  71715. * color value input and the ability to save colors into an array to be used later in
  71716. * subsequent launches of the dialogue.
  71717. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  71718. * @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.
  71719. * @returns picked color as a hex string and the saved colors array as hex strings.
  71720. */
  71721. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  71722. pickerWidth?: string;
  71723. pickerHeight?: string;
  71724. headerHeight?: string;
  71725. lastColor?: string;
  71726. swatchLimit?: number;
  71727. numSwatchesPerLine?: number;
  71728. savedColors?: Array<string>;
  71729. }): Promise<{
  71730. savedColors?: string[];
  71731. pickedColor: string;
  71732. }>;
  71733. }
  71734. }
  71735. declare module BABYLON.GUI {
  71736. /** Class used to create 2D ellipse containers */
  71737. export class Ellipse extends Container {
  71738. name?: string | undefined;
  71739. private _thickness;
  71740. /** Gets or sets border thickness */
  71741. get thickness(): number;
  71742. set thickness(value: number);
  71743. /**
  71744. * Creates a new Ellipse
  71745. * @param name defines the control name
  71746. */
  71747. constructor(name?: string | undefined);
  71748. protected _getTypeName(): string;
  71749. protected _localDraw(context: CanvasRenderingContext2D): void;
  71750. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71751. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71752. }
  71753. }
  71754. declare module BABYLON.GUI {
  71755. /**
  71756. * Class used to create a password control
  71757. */
  71758. export class InputPassword extends InputText {
  71759. protected _beforeRenderText(text: string): string;
  71760. }
  71761. }
  71762. declare module BABYLON.GUI {
  71763. /** Class used to render 2D lines */
  71764. export class Line extends Control {
  71765. name?: string | undefined;
  71766. private _lineWidth;
  71767. private _x1;
  71768. private _y1;
  71769. private _x2;
  71770. private _y2;
  71771. private _dash;
  71772. private _connectedControl;
  71773. private _connectedControlDirtyObserver;
  71774. /** Gets or sets the dash pattern */
  71775. get dash(): Array<number>;
  71776. set dash(value: Array<number>);
  71777. /** Gets or sets the control connected with the line end */
  71778. get connectedControl(): Control;
  71779. set connectedControl(value: Control);
  71780. /** Gets or sets start coordinates on X axis */
  71781. get x1(): string | number;
  71782. set x1(value: string | number);
  71783. /** Gets or sets start coordinates on Y axis */
  71784. get y1(): string | number;
  71785. set y1(value: string | number);
  71786. /** Gets or sets end coordinates on X axis */
  71787. get x2(): string | number;
  71788. set x2(value: string | number);
  71789. /** Gets or sets end coordinates on Y axis */
  71790. get y2(): string | number;
  71791. set y2(value: string | number);
  71792. /** Gets or sets line width */
  71793. get lineWidth(): number;
  71794. set lineWidth(value: number);
  71795. /** Gets or sets horizontal alignment */
  71796. set horizontalAlignment(value: number);
  71797. /** Gets or sets vertical alignment */
  71798. set verticalAlignment(value: number);
  71799. private get _effectiveX2();
  71800. private get _effectiveY2();
  71801. /**
  71802. * Creates a new Line
  71803. * @param name defines the control name
  71804. */
  71805. constructor(name?: string | undefined);
  71806. protected _getTypeName(): string;
  71807. _draw(context: CanvasRenderingContext2D): void;
  71808. _measure(): void;
  71809. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71810. /**
  71811. * Move one end of the line given 3D cartesian coordinates.
  71812. * @param position Targeted world position
  71813. * @param scene BABYLON.Scene
  71814. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71815. */
  71816. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  71817. /**
  71818. * Move one end of the line to a position in screen absolute space.
  71819. * @param projectedPosition Position in screen absolute space (X, Y)
  71820. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71821. */
  71822. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  71823. }
  71824. }
  71825. declare module BABYLON.GUI {
  71826. /**
  71827. * Class used to store a point for a MultiLine object.
  71828. * The point can be pure 2D coordinates, a mesh or a control
  71829. */
  71830. export class MultiLinePoint {
  71831. private _multiLine;
  71832. private _x;
  71833. private _y;
  71834. private _control;
  71835. private _mesh;
  71836. private _controlObserver;
  71837. private _meshObserver;
  71838. /** @hidden */
  71839. _point: BABYLON.Vector2;
  71840. /**
  71841. * Creates a new MultiLinePoint
  71842. * @param multiLine defines the source MultiLine object
  71843. */
  71844. constructor(multiLine: MultiLine);
  71845. /** Gets or sets x coordinate */
  71846. get x(): string | number;
  71847. set x(value: string | number);
  71848. /** Gets or sets y coordinate */
  71849. get y(): string | number;
  71850. set y(value: string | number);
  71851. /** Gets or sets the control associated with this point */
  71852. get control(): BABYLON.Nullable<Control>;
  71853. set control(value: BABYLON.Nullable<Control>);
  71854. /** Gets or sets the mesh associated with this point */
  71855. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71856. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  71857. /** Resets links */
  71858. resetLinks(): void;
  71859. /**
  71860. * Gets a translation vector
  71861. * @returns the translation vector
  71862. */
  71863. translate(): BABYLON.Vector2;
  71864. private _translatePoint;
  71865. /** Release associated resources */
  71866. dispose(): void;
  71867. }
  71868. }
  71869. declare module BABYLON.GUI {
  71870. /**
  71871. * Class used to create multi line control
  71872. */
  71873. export class MultiLine extends Control {
  71874. name?: string | undefined;
  71875. private _lineWidth;
  71876. private _dash;
  71877. private _points;
  71878. private _minX;
  71879. private _minY;
  71880. private _maxX;
  71881. private _maxY;
  71882. /**
  71883. * Creates a new MultiLine
  71884. * @param name defines the control name
  71885. */
  71886. constructor(name?: string | undefined);
  71887. /** Gets or sets dash pattern */
  71888. get dash(): Array<number>;
  71889. set dash(value: Array<number>);
  71890. /**
  71891. * Gets point stored at specified index
  71892. * @param index defines the index to look for
  71893. * @returns the requested point if found
  71894. */
  71895. getAt(index: number): MultiLinePoint;
  71896. /** Function called when a point is updated */
  71897. onPointUpdate: () => void;
  71898. /**
  71899. * Adds new points to the point collection
  71900. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  71901. * @returns the list of created MultiLinePoint
  71902. */
  71903. add(...items: (AbstractMesh | Control | {
  71904. x: string | number;
  71905. y: string | number;
  71906. })[]): MultiLinePoint[];
  71907. /**
  71908. * Adds a new point to the point collection
  71909. * @param item defines the item (mesh, control or 2d coordiantes) to add
  71910. * @returns the created MultiLinePoint
  71911. */
  71912. push(item?: (AbstractMesh | Control | {
  71913. x: string | number;
  71914. y: string | number;
  71915. })): MultiLinePoint;
  71916. /**
  71917. * Remove a specific value or point from the active point collection
  71918. * @param value defines the value or point to remove
  71919. */
  71920. remove(value: number | MultiLinePoint): void;
  71921. /**
  71922. * Resets this object to initial state (no point)
  71923. */
  71924. reset(): void;
  71925. /**
  71926. * Resets all links
  71927. */
  71928. resetLinks(): void;
  71929. /** Gets or sets line width */
  71930. get lineWidth(): number;
  71931. set lineWidth(value: number);
  71932. set horizontalAlignment(value: number);
  71933. set verticalAlignment(value: number);
  71934. protected _getTypeName(): string;
  71935. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71936. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71937. _measure(): void;
  71938. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71939. dispose(): void;
  71940. }
  71941. }
  71942. declare module BABYLON.GUI {
  71943. /**
  71944. * Class used to create radio button controls
  71945. */
  71946. export class RadioButton extends Control {
  71947. name?: string | undefined;
  71948. private _isChecked;
  71949. private _background;
  71950. private _checkSizeRatio;
  71951. private _thickness;
  71952. /** Gets or sets border thickness */
  71953. get thickness(): number;
  71954. set thickness(value: number);
  71955. /** Gets or sets group name */
  71956. group: string;
  71957. /** BABYLON.Observable raised when isChecked is changed */
  71958. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71959. /** Gets or sets a value indicating the ratio between overall size and check size */
  71960. get checkSizeRatio(): number;
  71961. set checkSizeRatio(value: number);
  71962. /** Gets or sets background color */
  71963. get background(): string;
  71964. set background(value: string);
  71965. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71966. get isChecked(): boolean;
  71967. set isChecked(value: boolean);
  71968. /**
  71969. * Creates a new RadioButton
  71970. * @param name defines the control name
  71971. */
  71972. constructor(name?: string | undefined);
  71973. protected _getTypeName(): string;
  71974. _draw(context: CanvasRenderingContext2D): void;
  71975. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71976. /**
  71977. * Utility function to easily create a radio button with a header
  71978. * @param title defines the label to use for the header
  71979. * @param group defines the group to use for the radio button
  71980. * @param isChecked defines the initial state of the radio button
  71981. * @param onValueChanged defines the callback to call when value changes
  71982. * @returns a StackPanel containing the radio button and a textBlock
  71983. */
  71984. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  71985. }
  71986. }
  71987. declare module BABYLON.GUI {
  71988. /**
  71989. * Class used to create slider controls
  71990. */
  71991. export class BaseSlider extends Control {
  71992. name?: string | undefined;
  71993. protected _thumbWidth: ValueAndUnit;
  71994. private _minimum;
  71995. private _maximum;
  71996. private _value;
  71997. private _isVertical;
  71998. protected _barOffset: ValueAndUnit;
  71999. private _isThumbClamped;
  72000. protected _displayThumb: boolean;
  72001. private _step;
  72002. private _lastPointerDownID;
  72003. protected _effectiveBarOffset: number;
  72004. protected _renderLeft: number;
  72005. protected _renderTop: number;
  72006. protected _renderWidth: number;
  72007. protected _renderHeight: number;
  72008. protected _backgroundBoxLength: number;
  72009. protected _backgroundBoxThickness: number;
  72010. protected _effectiveThumbThickness: number;
  72011. /** BABYLON.Observable raised when the sldier value changes */
  72012. onValueChangedObservable: BABYLON.Observable<number>;
  72013. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72014. get displayThumb(): boolean;
  72015. set displayThumb(value: boolean);
  72016. /** Gets or sets a step to apply to values (0 by default) */
  72017. get step(): number;
  72018. set step(value: number);
  72019. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72020. get barOffset(): string | number;
  72021. /** Gets main bar offset in pixels*/
  72022. get barOffsetInPixels(): number;
  72023. set barOffset(value: string | number);
  72024. /** Gets or sets thumb width */
  72025. get thumbWidth(): string | number;
  72026. /** Gets thumb width in pixels */
  72027. get thumbWidthInPixels(): number;
  72028. set thumbWidth(value: string | number);
  72029. /** Gets or sets minimum value */
  72030. get minimum(): number;
  72031. set minimum(value: number);
  72032. /** Gets or sets maximum value */
  72033. get maximum(): number;
  72034. set maximum(value: number);
  72035. /** Gets or sets current value */
  72036. get value(): number;
  72037. set value(value: number);
  72038. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72039. get isVertical(): boolean;
  72040. set isVertical(value: boolean);
  72041. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72042. get isThumbClamped(): boolean;
  72043. set isThumbClamped(value: boolean);
  72044. /**
  72045. * Creates a new BaseSlider
  72046. * @param name defines the control name
  72047. */
  72048. constructor(name?: string | undefined);
  72049. protected _getTypeName(): string;
  72050. protected _getThumbPosition(): number;
  72051. protected _getThumbThickness(type: string): number;
  72052. protected _prepareRenderingData(type: string): void;
  72053. private _pointerIsDown;
  72054. /** @hidden */
  72055. protected _updateValueFromPointer(x: number, y: number): void;
  72056. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72057. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72058. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72059. }
  72060. }
  72061. declare module BABYLON.GUI {
  72062. /**
  72063. * Class used to create slider controls
  72064. */
  72065. export class Slider extends BaseSlider {
  72066. name?: string | undefined;
  72067. private _background;
  72068. private _borderColor;
  72069. private _isThumbCircle;
  72070. protected _displayValueBar: boolean;
  72071. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72072. get displayValueBar(): boolean;
  72073. set displayValueBar(value: boolean);
  72074. /** Gets or sets border color */
  72075. get borderColor(): string;
  72076. set borderColor(value: string);
  72077. /** Gets or sets background color */
  72078. get background(): string;
  72079. set background(value: string);
  72080. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72081. get isThumbCircle(): boolean;
  72082. set isThumbCircle(value: boolean);
  72083. /**
  72084. * Creates a new Slider
  72085. * @param name defines the control name
  72086. */
  72087. constructor(name?: string | undefined);
  72088. protected _getTypeName(): string;
  72089. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72090. }
  72091. }
  72092. declare module BABYLON.GUI {
  72093. /** Class used to create a RadioGroup
  72094. * which contains groups of radio buttons
  72095. */
  72096. export class SelectorGroup {
  72097. /** name of SelectorGroup */
  72098. name: string;
  72099. private _groupPanel;
  72100. private _selectors;
  72101. private _groupHeader;
  72102. /**
  72103. * Creates a new SelectorGroup
  72104. * @param name of group, used as a group heading
  72105. */
  72106. constructor(
  72107. /** name of SelectorGroup */
  72108. name: string);
  72109. /** Gets the groupPanel of the SelectorGroup */
  72110. get groupPanel(): StackPanel;
  72111. /** Gets the selectors array */
  72112. get selectors(): StackPanel[];
  72113. /** Gets and sets the group header */
  72114. get header(): string;
  72115. set header(label: string);
  72116. /** @hidden */
  72117. private _addGroupHeader;
  72118. /** @hidden*/
  72119. _getSelector(selectorNb: number): StackPanel | undefined;
  72120. /** Removes the selector at the given position
  72121. * @param selectorNb the position of the selector within the group
  72122. */
  72123. removeSelector(selectorNb: number): void;
  72124. }
  72125. /** Class used to create a CheckboxGroup
  72126. * which contains groups of checkbox buttons
  72127. */
  72128. export class CheckboxGroup extends SelectorGroup {
  72129. /** Adds a checkbox as a control
  72130. * @param text is the label for the selector
  72131. * @param func is the function called when the Selector is checked
  72132. * @param checked is true when Selector is checked
  72133. */
  72134. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72135. /** @hidden */
  72136. _setSelectorLabel(selectorNb: number, label: string): void;
  72137. /** @hidden */
  72138. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72139. /** @hidden */
  72140. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72141. /** @hidden */
  72142. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72143. }
  72144. /** Class used to create a RadioGroup
  72145. * which contains groups of radio buttons
  72146. */
  72147. export class RadioGroup extends SelectorGroup {
  72148. private _selectNb;
  72149. /** Adds a radio button as a control
  72150. * @param label is the label for the selector
  72151. * @param func is the function called when the Selector is checked
  72152. * @param checked is true when Selector is checked
  72153. */
  72154. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72155. /** @hidden */
  72156. _setSelectorLabel(selectorNb: number, label: string): void;
  72157. /** @hidden */
  72158. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72159. /** @hidden */
  72160. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72161. /** @hidden */
  72162. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72163. }
  72164. /** Class used to create a SliderGroup
  72165. * which contains groups of slider buttons
  72166. */
  72167. export class SliderGroup extends SelectorGroup {
  72168. /**
  72169. * Adds a slider to the SelectorGroup
  72170. * @param label is the label for the SliderBar
  72171. * @param func is the function called when the Slider moves
  72172. * @param unit is a string describing the units used, eg degrees or metres
  72173. * @param min is the minimum value for the Slider
  72174. * @param max is the maximum value for the Slider
  72175. * @param value is the start value for the Slider between min and max
  72176. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72177. */
  72178. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72179. /** @hidden */
  72180. _setSelectorLabel(selectorNb: number, label: string): void;
  72181. /** @hidden */
  72182. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72183. /** @hidden */
  72184. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72185. /** @hidden */
  72186. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72187. }
  72188. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72189. * @see http://doc.babylonjs.com/how_to/selector
  72190. */
  72191. export class SelectionPanel extends Rectangle {
  72192. /** name of SelectionPanel */
  72193. name: string;
  72194. /** an array of SelectionGroups */
  72195. groups: SelectorGroup[];
  72196. private _panel;
  72197. private _buttonColor;
  72198. private _buttonBackground;
  72199. private _headerColor;
  72200. private _barColor;
  72201. private _barHeight;
  72202. private _spacerHeight;
  72203. private _labelColor;
  72204. private _groups;
  72205. private _bars;
  72206. /**
  72207. * Creates a new SelectionPanel
  72208. * @param name of SelectionPanel
  72209. * @param groups is an array of SelectionGroups
  72210. */
  72211. constructor(
  72212. /** name of SelectionPanel */
  72213. name: string,
  72214. /** an array of SelectionGroups */
  72215. groups?: SelectorGroup[]);
  72216. protected _getTypeName(): string;
  72217. /** Gets or sets the headerColor */
  72218. get headerColor(): string;
  72219. set headerColor(color: string);
  72220. private _setHeaderColor;
  72221. /** Gets or sets the button color */
  72222. get buttonColor(): string;
  72223. set buttonColor(color: string);
  72224. private _setbuttonColor;
  72225. /** Gets or sets the label color */
  72226. get labelColor(): string;
  72227. set labelColor(color: string);
  72228. private _setLabelColor;
  72229. /** Gets or sets the button background */
  72230. get buttonBackground(): string;
  72231. set buttonBackground(color: string);
  72232. private _setButtonBackground;
  72233. /** Gets or sets the color of separator bar */
  72234. get barColor(): string;
  72235. set barColor(color: string);
  72236. private _setBarColor;
  72237. /** Gets or sets the height of separator bar */
  72238. get barHeight(): string;
  72239. set barHeight(value: string);
  72240. private _setBarHeight;
  72241. /** Gets or sets the height of spacers*/
  72242. get spacerHeight(): string;
  72243. set spacerHeight(value: string);
  72244. private _setSpacerHeight;
  72245. /** Adds a bar between groups */
  72246. private _addSpacer;
  72247. /** Add a group to the selection panel
  72248. * @param group is the selector group to add
  72249. */
  72250. addGroup(group: SelectorGroup): void;
  72251. /** Remove the group from the given position
  72252. * @param groupNb is the position of the group in the list
  72253. */
  72254. removeGroup(groupNb: number): void;
  72255. /** Change a group header label
  72256. * @param label is the new group header label
  72257. * @param groupNb is the number of the group to relabel
  72258. * */
  72259. setHeaderName(label: string, groupNb: number): void;
  72260. /** Change selector label to the one given
  72261. * @param label is the new selector label
  72262. * @param groupNb is the number of the groupcontaining the selector
  72263. * @param selectorNb is the number of the selector within a group to relabel
  72264. * */
  72265. relabel(label: string, groupNb: number, selectorNb: number): void;
  72266. /** For a given group position remove the selector at the given position
  72267. * @param groupNb is the number of the group to remove the selector from
  72268. * @param selectorNb is the number of the selector within the group
  72269. */
  72270. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72271. /** For a given group position of correct type add a checkbox button
  72272. * @param groupNb is the number of the group to remove the selector from
  72273. * @param label is the label for the selector
  72274. * @param func is the function called when the Selector is checked
  72275. * @param checked is true when Selector is checked
  72276. */
  72277. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72278. /** For a given group position of correct type add a radio button
  72279. * @param groupNb is the number of the group to remove the selector from
  72280. * @param label is the label for the selector
  72281. * @param func is the function called when the Selector is checked
  72282. * @param checked is true when Selector is checked
  72283. */
  72284. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72285. /**
  72286. * For a given slider group add a slider
  72287. * @param groupNb is the number of the group to add the slider to
  72288. * @param label is the label for the Slider
  72289. * @param func is the function called when the Slider moves
  72290. * @param unit is a string describing the units used, eg degrees or metres
  72291. * @param min is the minimum value for the Slider
  72292. * @param max is the maximum value for the Slider
  72293. * @param value is the start value for the Slider between min and max
  72294. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72295. */
  72296. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72297. }
  72298. }
  72299. declare module BABYLON.GUI {
  72300. /**
  72301. * Class used to hold a the container for ScrollViewer
  72302. * @hidden
  72303. */
  72304. export class _ScrollViewerWindow extends Container {
  72305. parentClientWidth: number;
  72306. parentClientHeight: number;
  72307. /**
  72308. * Creates a new ScrollViewerWindow
  72309. * @param name of ScrollViewerWindow
  72310. */
  72311. constructor(name?: string);
  72312. protected _getTypeName(): string;
  72313. /** @hidden */
  72314. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72315. protected _postMeasure(): void;
  72316. }
  72317. }
  72318. declare module BABYLON.GUI {
  72319. /**
  72320. * Class used to create slider controls
  72321. */
  72322. export class ScrollBar extends BaseSlider {
  72323. name?: string | undefined;
  72324. private _background;
  72325. private _borderColor;
  72326. private _tempMeasure;
  72327. /** Gets or sets border color */
  72328. get borderColor(): string;
  72329. set borderColor(value: string);
  72330. /** Gets or sets background color */
  72331. get background(): string;
  72332. set background(value: string);
  72333. /**
  72334. * Creates a new Slider
  72335. * @param name defines the control name
  72336. */
  72337. constructor(name?: string | undefined);
  72338. protected _getTypeName(): string;
  72339. protected _getThumbThickness(): number;
  72340. _draw(context: CanvasRenderingContext2D): void;
  72341. private _first;
  72342. private _originX;
  72343. private _originY;
  72344. /** @hidden */
  72345. protected _updateValueFromPointer(x: number, y: number): void;
  72346. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72347. }
  72348. }
  72349. declare module BABYLON.GUI {
  72350. /**
  72351. * Class used to create slider controls
  72352. */
  72353. export class ImageScrollBar extends BaseSlider {
  72354. name?: string | undefined;
  72355. private _backgroundBaseImage;
  72356. private _backgroundImage;
  72357. private _thumbImage;
  72358. private _thumbBaseImage;
  72359. private _thumbLength;
  72360. private _thumbHeight;
  72361. private _barImageHeight;
  72362. private _tempMeasure;
  72363. /**
  72364. * Gets or sets the image used to render the background for horizontal bar
  72365. */
  72366. get backgroundImage(): Image;
  72367. set backgroundImage(value: Image);
  72368. /**
  72369. * Gets or sets the image used to render the thumb
  72370. */
  72371. get thumbImage(): Image;
  72372. set thumbImage(value: Image);
  72373. /**
  72374. * Gets or sets the length of the thumb
  72375. */
  72376. get thumbLength(): number;
  72377. set thumbLength(value: number);
  72378. /**
  72379. * Gets or sets the height of the thumb
  72380. */
  72381. get thumbHeight(): number;
  72382. set thumbHeight(value: number);
  72383. /**
  72384. * Gets or sets the height of the bar image
  72385. */
  72386. get barImageHeight(): number;
  72387. set barImageHeight(value: number);
  72388. /**
  72389. * Creates a new ImageScrollBar
  72390. * @param name defines the control name
  72391. */
  72392. constructor(name?: string | undefined);
  72393. protected _getTypeName(): string;
  72394. protected _getThumbThickness(): number;
  72395. _draw(context: CanvasRenderingContext2D): void;
  72396. private _first;
  72397. private _originX;
  72398. private _originY;
  72399. /** @hidden */
  72400. protected _updateValueFromPointer(x: number, y: number): void;
  72401. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72402. }
  72403. }
  72404. declare module BABYLON.GUI {
  72405. /**
  72406. * Class used to hold a viewer window and sliders in a grid
  72407. */
  72408. export class ScrollViewer extends Rectangle {
  72409. private _grid;
  72410. private _horizontalBarSpace;
  72411. private _verticalBarSpace;
  72412. private _dragSpace;
  72413. private _horizontalBar;
  72414. private _verticalBar;
  72415. private _barColor;
  72416. private _barBackground;
  72417. private _barImage;
  72418. private _barBackgroundImage;
  72419. private _barSize;
  72420. private _endLeft;
  72421. private _endTop;
  72422. private _window;
  72423. private _pointerIsOver;
  72424. private _wheelPrecision;
  72425. private _onPointerObserver;
  72426. private _clientWidth;
  72427. private _clientHeight;
  72428. private _useImageBar;
  72429. private _thumbLength;
  72430. private _thumbHeight;
  72431. private _barImageHeight;
  72432. /**
  72433. * Gets the horizontal scrollbar
  72434. */
  72435. get horizontalBar(): ScrollBar | ImageScrollBar;
  72436. /**
  72437. * Gets the vertical scrollbar
  72438. */
  72439. get verticalBar(): ScrollBar | ImageScrollBar;
  72440. /**
  72441. * Adds a new control to the current container
  72442. * @param control defines the control to add
  72443. * @returns the current container
  72444. */
  72445. addControl(control: BABYLON.Nullable<Control>): Container;
  72446. /**
  72447. * Removes a control from the current container
  72448. * @param control defines the control to remove
  72449. * @returns the current container
  72450. */
  72451. removeControl(control: Control): Container;
  72452. /** Gets the list of children */
  72453. get children(): Control[];
  72454. _flagDescendantsAsMatrixDirty(): void;
  72455. /**
  72456. * Creates a new ScrollViewer
  72457. * @param name of ScrollViewer
  72458. */
  72459. constructor(name?: string, isImageBased?: boolean);
  72460. /** Reset the scroll viewer window to initial size */
  72461. resetWindow(): void;
  72462. protected _getTypeName(): string;
  72463. private _buildClientSizes;
  72464. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72465. protected _postMeasure(): void;
  72466. /**
  72467. * Gets or sets the mouse wheel precision
  72468. * from 0 to 1 with a default value of 0.05
  72469. * */
  72470. get wheelPrecision(): number;
  72471. set wheelPrecision(value: number);
  72472. /** Gets or sets the scroll bar container background color */
  72473. get scrollBackground(): string;
  72474. set scrollBackground(color: string);
  72475. /** Gets or sets the bar color */
  72476. get barColor(): string;
  72477. set barColor(color: string);
  72478. /** Gets or sets the bar image */
  72479. get thumbImage(): Image;
  72480. set thumbImage(value: Image);
  72481. /** Gets or sets the size of the bar */
  72482. get barSize(): number;
  72483. set barSize(value: number);
  72484. /** Gets or sets the length of the thumb */
  72485. get thumbLength(): number;
  72486. set thumbLength(value: number);
  72487. /** Gets or sets the height of the thumb */
  72488. get thumbHeight(): number;
  72489. set thumbHeight(value: number);
  72490. /** Gets or sets the height of the bar image */
  72491. get barImageHeight(): number;
  72492. set barImageHeight(value: number);
  72493. /** Gets or sets the bar background */
  72494. get barBackground(): string;
  72495. set barBackground(color: string);
  72496. /** Gets or sets the bar background image */
  72497. get barImage(): Image;
  72498. set barImage(value: Image);
  72499. /** @hidden */
  72500. private _updateScroller;
  72501. _link(host: AdvancedDynamicTexture): void;
  72502. /** @hidden */
  72503. private _addBar;
  72504. /** @hidden */
  72505. private _attachWheel;
  72506. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72507. /** Releases associated resources */
  72508. dispose(): void;
  72509. }
  72510. }
  72511. declare module BABYLON.GUI {
  72512. /** Class used to render a grid */
  72513. export class DisplayGrid extends Control {
  72514. name?: string | undefined;
  72515. private _cellWidth;
  72516. private _cellHeight;
  72517. private _minorLineTickness;
  72518. private _minorLineColor;
  72519. private _majorLineTickness;
  72520. private _majorLineColor;
  72521. private _majorLineFrequency;
  72522. private _background;
  72523. private _displayMajorLines;
  72524. private _displayMinorLines;
  72525. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  72526. get displayMinorLines(): boolean;
  72527. set displayMinorLines(value: boolean);
  72528. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  72529. get displayMajorLines(): boolean;
  72530. set displayMajorLines(value: boolean);
  72531. /** Gets or sets background color (Black by default) */
  72532. get background(): string;
  72533. set background(value: string);
  72534. /** Gets or sets the width of each cell (20 by default) */
  72535. get cellWidth(): number;
  72536. set cellWidth(value: number);
  72537. /** Gets or sets the height of each cell (20 by default) */
  72538. get cellHeight(): number;
  72539. set cellHeight(value: number);
  72540. /** Gets or sets the tickness of minor lines (1 by default) */
  72541. get minorLineTickness(): number;
  72542. set minorLineTickness(value: number);
  72543. /** Gets or sets the color of minor lines (DarkGray by default) */
  72544. get minorLineColor(): string;
  72545. set minorLineColor(value: string);
  72546. /** Gets or sets the tickness of major lines (2 by default) */
  72547. get majorLineTickness(): number;
  72548. set majorLineTickness(value: number);
  72549. /** Gets or sets the color of major lines (White by default) */
  72550. get majorLineColor(): string;
  72551. set majorLineColor(value: string);
  72552. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  72553. get majorLineFrequency(): number;
  72554. set majorLineFrequency(value: number);
  72555. /**
  72556. * Creates a new GridDisplayRectangle
  72557. * @param name defines the control name
  72558. */
  72559. constructor(name?: string | undefined);
  72560. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72561. protected _getTypeName(): string;
  72562. }
  72563. }
  72564. declare module BABYLON.GUI {
  72565. /**
  72566. * Class used to create slider controls based on images
  72567. */
  72568. export class ImageBasedSlider extends BaseSlider {
  72569. name?: string | undefined;
  72570. private _backgroundImage;
  72571. private _thumbImage;
  72572. private _valueBarImage;
  72573. private _tempMeasure;
  72574. get displayThumb(): boolean;
  72575. set displayThumb(value: boolean);
  72576. /**
  72577. * Gets or sets the image used to render the background
  72578. */
  72579. get backgroundImage(): Image;
  72580. set backgroundImage(value: Image);
  72581. /**
  72582. * Gets or sets the image used to render the value bar
  72583. */
  72584. get valueBarImage(): Image;
  72585. set valueBarImage(value: Image);
  72586. /**
  72587. * Gets or sets the image used to render the thumb
  72588. */
  72589. get thumbImage(): Image;
  72590. set thumbImage(value: Image);
  72591. /**
  72592. * Creates a new ImageBasedSlider
  72593. * @param name defines the control name
  72594. */
  72595. constructor(name?: string | undefined);
  72596. protected _getTypeName(): string;
  72597. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72598. }
  72599. }
  72600. declare module BABYLON.GUI {
  72601. /**
  72602. * Forcing an export so that this code will execute
  72603. * @hidden
  72604. */
  72605. const name = "Statics";
  72606. }
  72607. declare module BABYLON.GUI {
  72608. /**
  72609. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  72610. */
  72611. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  72612. /**
  72613. * Define the instrumented AdvancedDynamicTexture.
  72614. */
  72615. texture: AdvancedDynamicTexture;
  72616. private _captureRenderTime;
  72617. private _renderTime;
  72618. private _captureLayoutTime;
  72619. private _layoutTime;
  72620. private _onBeginRenderObserver;
  72621. private _onEndRenderObserver;
  72622. private _onBeginLayoutObserver;
  72623. private _onEndLayoutObserver;
  72624. /**
  72625. * Gets the perf counter used to capture render time
  72626. */
  72627. get renderTimeCounter(): BABYLON.PerfCounter;
  72628. /**
  72629. * Gets the perf counter used to capture layout time
  72630. */
  72631. get layoutTimeCounter(): BABYLON.PerfCounter;
  72632. /**
  72633. * Enable or disable the render time capture
  72634. */
  72635. get captureRenderTime(): boolean;
  72636. set captureRenderTime(value: boolean);
  72637. /**
  72638. * Enable or disable the layout time capture
  72639. */
  72640. get captureLayoutTime(): boolean;
  72641. set captureLayoutTime(value: boolean);
  72642. /**
  72643. * Instantiates a new advanced dynamic texture instrumentation.
  72644. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  72645. * @param texture Defines the AdvancedDynamicTexture to instrument
  72646. */
  72647. constructor(
  72648. /**
  72649. * Define the instrumented AdvancedDynamicTexture.
  72650. */
  72651. texture: AdvancedDynamicTexture);
  72652. /**
  72653. * Dispose and release associated resources.
  72654. */
  72655. dispose(): void;
  72656. }
  72657. }
  72658. declare module BABYLON.GUI {
  72659. /**
  72660. * Class used to load GUI via XML.
  72661. */
  72662. export class XmlLoader {
  72663. private _nodes;
  72664. private _nodeTypes;
  72665. private _isLoaded;
  72666. private _objectAttributes;
  72667. private _parentClass;
  72668. /**
  72669. * Create a new xml loader
  72670. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  72671. */
  72672. constructor(parentClass?: null);
  72673. private _getChainElement;
  72674. private _getClassAttribute;
  72675. private _createGuiElement;
  72676. private _parseGrid;
  72677. private _parseElement;
  72678. private _prepareSourceElement;
  72679. private _parseElementsFromSource;
  72680. private _parseXml;
  72681. /**
  72682. * Gets if the loading has finished.
  72683. * @returns whether the loading has finished or not
  72684. */
  72685. isLoaded(): boolean;
  72686. /**
  72687. * Gets a loaded node / control by id.
  72688. * @param id the Controls id set in the xml
  72689. * @returns element of type Control
  72690. */
  72691. getNodeById(id: string): any;
  72692. /**
  72693. * Gets all loaded nodes / controls
  72694. * @returns Array of controls
  72695. */
  72696. getNodes(): any;
  72697. /**
  72698. * Initiates the xml layout loading
  72699. * @param xmlFile defines the xml layout to load
  72700. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  72701. * @param callback defines the callback called on layout load.
  72702. */
  72703. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  72704. }
  72705. }
  72706. declare module BABYLON.GUI {
  72707. /**
  72708. * Class used to create containers for controls
  72709. */
  72710. export class Container3D extends Control3D {
  72711. private _blockLayout;
  72712. /**
  72713. * Gets the list of child controls
  72714. */
  72715. protected _children: Control3D[];
  72716. /**
  72717. * Gets the list of child controls
  72718. */
  72719. get children(): Array<Control3D>;
  72720. /**
  72721. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  72722. * This is helpful to optimize layout operation when adding multiple children in a row
  72723. */
  72724. get blockLayout(): boolean;
  72725. set blockLayout(value: boolean);
  72726. /**
  72727. * Creates a new container
  72728. * @param name defines the container name
  72729. */
  72730. constructor(name?: string);
  72731. /**
  72732. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  72733. * @returns the current container
  72734. */
  72735. updateLayout(): Container3D;
  72736. /**
  72737. * Gets a boolean indicating if the given control is in the children of this control
  72738. * @param control defines the control to check
  72739. * @returns true if the control is in the child list
  72740. */
  72741. containsControl(control: Control3D): boolean;
  72742. /**
  72743. * Adds a control to the children of this control
  72744. * @param control defines the control to add
  72745. * @returns the current container
  72746. */
  72747. addControl(control: Control3D): Container3D;
  72748. /**
  72749. * This function will be called everytime a new control is added
  72750. */
  72751. protected _arrangeChildren(): void;
  72752. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72753. /**
  72754. * Removes a control from the children of this control
  72755. * @param control defines the control to remove
  72756. * @returns the current container
  72757. */
  72758. removeControl(control: Control3D): Container3D;
  72759. protected _getTypeName(): string;
  72760. /**
  72761. * Releases all associated resources
  72762. */
  72763. dispose(): void;
  72764. /** Control rotation will remain unchanged */
  72765. static readonly UNSET_ORIENTATION: number;
  72766. /** Control will rotate to make it look at sphere central axis */
  72767. static readonly FACEORIGIN_ORIENTATION: number;
  72768. /** Control will rotate to make it look back at sphere central axis */
  72769. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  72770. /** Control will rotate to look at z axis (0, 0, 1) */
  72771. static readonly FACEFORWARD_ORIENTATION: number;
  72772. /** Control will rotate to look at negative z axis (0, 0, -1) */
  72773. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  72774. }
  72775. }
  72776. declare module BABYLON.GUI {
  72777. /**
  72778. * Class used to manage 3D user interface
  72779. * @see http://doc.babylonjs.com/how_to/gui3d
  72780. */
  72781. export class GUI3DManager implements BABYLON.IDisposable {
  72782. private _scene;
  72783. private _sceneDisposeObserver;
  72784. private _utilityLayer;
  72785. private _rootContainer;
  72786. private _pointerObserver;
  72787. private _pointerOutObserver;
  72788. /** @hidden */
  72789. _lastPickedControl: Control3D;
  72790. /** @hidden */
  72791. _lastControlOver: {
  72792. [pointerId: number]: Control3D;
  72793. };
  72794. /** @hidden */
  72795. _lastControlDown: {
  72796. [pointerId: number]: Control3D;
  72797. };
  72798. /**
  72799. * BABYLON.Observable raised when the point picked by the pointer events changed
  72800. */
  72801. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  72802. /** @hidden */
  72803. _sharedMaterials: {
  72804. [key: string]: BABYLON.Material;
  72805. };
  72806. /** Gets the hosting scene */
  72807. get scene(): BABYLON.Scene;
  72808. /** Gets associated utility layer */
  72809. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  72810. /**
  72811. * Creates a new GUI3DManager
  72812. * @param scene
  72813. */
  72814. constructor(scene?: BABYLON.Scene);
  72815. private _handlePointerOut;
  72816. private _doPicking;
  72817. /**
  72818. * Gets the root container
  72819. */
  72820. get rootContainer(): Container3D;
  72821. /**
  72822. * Gets a boolean indicating if the given control is in the root child list
  72823. * @param control defines the control to check
  72824. * @returns true if the control is in the root child list
  72825. */
  72826. containsControl(control: Control3D): boolean;
  72827. /**
  72828. * Adds a control to the root child list
  72829. * @param control defines the control to add
  72830. * @returns the current manager
  72831. */
  72832. addControl(control: Control3D): GUI3DManager;
  72833. /**
  72834. * Removes a control from the root child list
  72835. * @param control defines the control to remove
  72836. * @returns the current container
  72837. */
  72838. removeControl(control: Control3D): GUI3DManager;
  72839. /**
  72840. * Releases all associated resources
  72841. */
  72842. dispose(): void;
  72843. }
  72844. }
  72845. declare module BABYLON.GUI {
  72846. /**
  72847. * Class used to transport BABYLON.Vector3 information for pointer events
  72848. */
  72849. export class Vector3WithInfo extends BABYLON.Vector3 {
  72850. /** defines the current mouse button index */
  72851. buttonIndex: number;
  72852. /**
  72853. * Creates a new Vector3WithInfo
  72854. * @param source defines the vector3 data to transport
  72855. * @param buttonIndex defines the current mouse button index
  72856. */
  72857. constructor(source: BABYLON.Vector3,
  72858. /** defines the current mouse button index */
  72859. buttonIndex?: number);
  72860. }
  72861. }
  72862. declare module BABYLON.GUI {
  72863. /**
  72864. * Class used as base class for controls
  72865. */
  72866. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  72867. /** Defines the control name */
  72868. name?: string | undefined;
  72869. /** @hidden */
  72870. _host: GUI3DManager;
  72871. private _node;
  72872. private _downCount;
  72873. private _enterCount;
  72874. private _downPointerIds;
  72875. private _isVisible;
  72876. /** Gets or sets the control position in world space */
  72877. get position(): BABYLON.Vector3;
  72878. set position(value: BABYLON.Vector3);
  72879. /** Gets or sets the control scaling in world space */
  72880. get scaling(): BABYLON.Vector3;
  72881. set scaling(value: BABYLON.Vector3);
  72882. /** Callback used to start pointer enter animation */
  72883. pointerEnterAnimation: () => void;
  72884. /** Callback used to start pointer out animation */
  72885. pointerOutAnimation: () => void;
  72886. /** Callback used to start pointer down animation */
  72887. pointerDownAnimation: () => void;
  72888. /** Callback used to start pointer up animation */
  72889. pointerUpAnimation: () => void;
  72890. /**
  72891. * An event triggered when the pointer move over the control
  72892. */
  72893. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  72894. /**
  72895. * An event triggered when the pointer move out of the control
  72896. */
  72897. onPointerOutObservable: BABYLON.Observable<Control3D>;
  72898. /**
  72899. * An event triggered when the pointer taps the control
  72900. */
  72901. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  72902. /**
  72903. * An event triggered when pointer is up
  72904. */
  72905. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  72906. /**
  72907. * An event triggered when a control is clicked on (with a mouse)
  72908. */
  72909. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  72910. /**
  72911. * An event triggered when pointer enters the control
  72912. */
  72913. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  72914. /**
  72915. * Gets or sets the parent container
  72916. */
  72917. parent: BABYLON.Nullable<Container3D>;
  72918. private _behaviors;
  72919. /**
  72920. * Gets the list of attached behaviors
  72921. * @see http://doc.babylonjs.com/features/behaviour
  72922. */
  72923. get behaviors(): BABYLON.Behavior<Control3D>[];
  72924. /**
  72925. * Attach a behavior to the control
  72926. * @see http://doc.babylonjs.com/features/behaviour
  72927. * @param behavior defines the behavior to attach
  72928. * @returns the current control
  72929. */
  72930. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72931. /**
  72932. * Remove an attached behavior
  72933. * @see http://doc.babylonjs.com/features/behaviour
  72934. * @param behavior defines the behavior to attach
  72935. * @returns the current control
  72936. */
  72937. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72938. /**
  72939. * Gets an attached behavior by name
  72940. * @param name defines the name of the behavior to look for
  72941. * @see http://doc.babylonjs.com/features/behaviour
  72942. * @returns null if behavior was not found else the requested behavior
  72943. */
  72944. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  72945. /** Gets or sets a boolean indicating if the control is visible */
  72946. get isVisible(): boolean;
  72947. set isVisible(value: boolean);
  72948. /**
  72949. * Creates a new control
  72950. * @param name defines the control name
  72951. */
  72952. constructor(
  72953. /** Defines the control name */
  72954. name?: string | undefined);
  72955. /**
  72956. * Gets a string representing the class name
  72957. */
  72958. get typeName(): string;
  72959. /**
  72960. * Get the current class name of the control.
  72961. * @returns current class name
  72962. */
  72963. getClassName(): string;
  72964. protected _getTypeName(): string;
  72965. /**
  72966. * Gets the transform node used by this control
  72967. */
  72968. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  72969. /**
  72970. * Gets the mesh used to render this control
  72971. */
  72972. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72973. /**
  72974. * Link the control as child of the given node
  72975. * @param node defines the node to link to. Use null to unlink the control
  72976. * @returns the current control
  72977. */
  72978. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  72979. /** @hidden **/
  72980. _prepareNode(scene: BABYLON.Scene): void;
  72981. /**
  72982. * Node creation.
  72983. * Can be overriden by children
  72984. * @param scene defines the scene where the node must be attached
  72985. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  72986. */
  72987. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72988. /**
  72989. * Affect a material to the given mesh
  72990. * @param mesh defines the mesh which will represent the control
  72991. */
  72992. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  72993. /** @hidden */
  72994. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  72995. /** @hidden */
  72996. _onPointerEnter(target: Control3D): boolean;
  72997. /** @hidden */
  72998. _onPointerOut(target: Control3D): void;
  72999. /** @hidden */
  73000. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73001. /** @hidden */
  73002. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73003. /** @hidden */
  73004. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73005. /** @hidden */
  73006. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73007. /** @hidden */
  73008. _disposeNode(): void;
  73009. /**
  73010. * Releases all associated resources
  73011. */
  73012. dispose(): void;
  73013. }
  73014. }
  73015. declare module BABYLON.GUI {
  73016. /**
  73017. * Class used as a root to all buttons
  73018. */
  73019. export class AbstractButton3D extends Control3D {
  73020. /**
  73021. * Creates a new button
  73022. * @param name defines the control name
  73023. */
  73024. constructor(name?: string);
  73025. protected _getTypeName(): string;
  73026. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73027. }
  73028. }
  73029. declare module BABYLON.GUI {
  73030. /**
  73031. * Class used to create a button in 3D
  73032. */
  73033. export class Button3D extends AbstractButton3D {
  73034. /** @hidden */
  73035. protected _currentMaterial: BABYLON.Material;
  73036. private _facadeTexture;
  73037. private _content;
  73038. private _contentResolution;
  73039. private _contentScaleRatio;
  73040. /**
  73041. * Gets or sets the texture resolution used to render content (512 by default)
  73042. */
  73043. get contentResolution(): BABYLON.int;
  73044. set contentResolution(value: BABYLON.int);
  73045. /**
  73046. * Gets or sets the texture scale ratio used to render content (2 by default)
  73047. */
  73048. get contentScaleRatio(): number;
  73049. set contentScaleRatio(value: number);
  73050. protected _disposeFacadeTexture(): void;
  73051. protected _resetContent(): void;
  73052. /**
  73053. * Creates a new button
  73054. * @param name defines the control name
  73055. */
  73056. constructor(name?: string);
  73057. /**
  73058. * Gets or sets the GUI 2D content used to display the button's facade
  73059. */
  73060. get content(): Control;
  73061. set content(value: Control);
  73062. /**
  73063. * Apply the facade texture (created from the content property).
  73064. * This function can be overloaded by child classes
  73065. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73066. */
  73067. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73068. protected _getTypeName(): string;
  73069. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73070. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73071. /**
  73072. * Releases all associated resources
  73073. */
  73074. dispose(): void;
  73075. }
  73076. }
  73077. declare module BABYLON.GUI {
  73078. /**
  73079. * Abstract class used to create a container panel deployed on the surface of a volume
  73080. */
  73081. export abstract class VolumeBasedPanel extends Container3D {
  73082. private _columns;
  73083. private _rows;
  73084. private _rowThenColum;
  73085. private _orientation;
  73086. protected _cellWidth: number;
  73087. protected _cellHeight: number;
  73088. /**
  73089. * Gets or sets the distance between elements
  73090. */
  73091. margin: number;
  73092. /**
  73093. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73094. * | Value | Type | Description |
  73095. * | ----- | ----------------------------------- | ----------- |
  73096. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73097. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73098. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73099. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73100. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73101. */
  73102. get orientation(): number;
  73103. set orientation(value: number);
  73104. /**
  73105. * Gets or sets the number of columns requested (10 by default).
  73106. * The panel will automatically compute the number of rows based on number of child controls.
  73107. */
  73108. get columns(): BABYLON.int;
  73109. set columns(value: BABYLON.int);
  73110. /**
  73111. * Gets or sets a the number of rows requested.
  73112. * The panel will automatically compute the number of columns based on number of child controls.
  73113. */
  73114. get rows(): BABYLON.int;
  73115. set rows(value: BABYLON.int);
  73116. /**
  73117. * Creates new VolumeBasedPanel
  73118. */
  73119. constructor();
  73120. protected _arrangeChildren(): void;
  73121. /** Child classes must implement this function to provide correct control positioning */
  73122. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73123. /** Child classes can implement this function to provide additional processing */
  73124. protected _finalProcessing(): void;
  73125. }
  73126. }
  73127. declare module BABYLON.GUI {
  73128. /**
  73129. * Class used to create a container panel deployed on the surface of a cylinder
  73130. */
  73131. export class CylinderPanel extends VolumeBasedPanel {
  73132. private _radius;
  73133. /**
  73134. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73135. */
  73136. get radius(): BABYLON.float;
  73137. set radius(value: BABYLON.float);
  73138. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73139. private _cylindricalMapping;
  73140. }
  73141. }
  73142. declare module BABYLON.GUI {
  73143. /** @hidden */
  73144. export var fluentVertexShader: {
  73145. name: string;
  73146. shader: string;
  73147. };
  73148. }
  73149. declare module BABYLON.GUI {
  73150. /** @hidden */
  73151. export var fluentPixelShader: {
  73152. name: string;
  73153. shader: string;
  73154. };
  73155. }
  73156. declare module BABYLON.GUI {
  73157. /** @hidden */
  73158. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73159. INNERGLOW: boolean;
  73160. BORDER: boolean;
  73161. HOVERLIGHT: boolean;
  73162. TEXTURE: boolean;
  73163. constructor();
  73164. }
  73165. /**
  73166. * Class used to render controls with fluent desgin
  73167. */
  73168. export class FluentMaterial extends BABYLON.PushMaterial {
  73169. /**
  73170. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73171. */
  73172. innerGlowColorIntensity: number;
  73173. /**
  73174. * Gets or sets the inner glow color (white by default)
  73175. */
  73176. innerGlowColor: BABYLON.Color3;
  73177. /**
  73178. * Gets or sets alpha value (default is 1.0)
  73179. */
  73180. alpha: number;
  73181. /**
  73182. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73183. */
  73184. albedoColor: BABYLON.Color3;
  73185. /**
  73186. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73187. */
  73188. renderBorders: boolean;
  73189. /**
  73190. * Gets or sets border width (default is 0.5)
  73191. */
  73192. borderWidth: number;
  73193. /**
  73194. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73195. */
  73196. edgeSmoothingValue: number;
  73197. /**
  73198. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73199. */
  73200. borderMinValue: number;
  73201. /**
  73202. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73203. */
  73204. renderHoverLight: boolean;
  73205. /**
  73206. * Gets or sets the radius used to render the hover light (default is 1.0)
  73207. */
  73208. hoverRadius: number;
  73209. /**
  73210. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73211. */
  73212. hoverColor: BABYLON.Color4;
  73213. /**
  73214. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73215. */
  73216. hoverPosition: BABYLON.Vector3;
  73217. private _albedoTexture;
  73218. /** Gets or sets the texture to use for albedo color */
  73219. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73220. /**
  73221. * Creates a new Fluent material
  73222. * @param name defines the name of the material
  73223. * @param scene defines the hosting scene
  73224. */
  73225. constructor(name: string, scene: BABYLON.Scene);
  73226. needAlphaBlending(): boolean;
  73227. needAlphaTesting(): boolean;
  73228. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73229. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73230. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73231. getActiveTextures(): BABYLON.BaseTexture[];
  73232. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73233. dispose(forceDisposeEffect?: boolean): void;
  73234. clone(name: string): FluentMaterial;
  73235. serialize(): any;
  73236. getClassName(): string;
  73237. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73238. }
  73239. }
  73240. declare module BABYLON.GUI {
  73241. /**
  73242. * Class used to create a holographic button in 3D
  73243. */
  73244. export class HolographicButton extends Button3D {
  73245. private _backPlate;
  73246. private _textPlate;
  73247. private _frontPlate;
  73248. private _text;
  73249. private _imageUrl;
  73250. private _shareMaterials;
  73251. private _frontMaterial;
  73252. private _backMaterial;
  73253. private _plateMaterial;
  73254. private _pickedPointObserver;
  73255. private _tooltipFade;
  73256. private _tooltipTextBlock;
  73257. private _tooltipTexture;
  73258. private _tooltipMesh;
  73259. private _tooltipHoverObserver;
  73260. private _tooltipOutObserver;
  73261. private _disposeTooltip;
  73262. /**
  73263. * Rendering ground id of all the mesh in the button
  73264. */
  73265. set renderingGroupId(id: number);
  73266. get renderingGroupId(): number;
  73267. /**
  73268. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73269. */
  73270. set tooltipText(text: BABYLON.Nullable<string>);
  73271. get tooltipText(): BABYLON.Nullable<string>;
  73272. /**
  73273. * Gets or sets text for the button
  73274. */
  73275. get text(): string;
  73276. set text(value: string);
  73277. /**
  73278. * Gets or sets the image url for the button
  73279. */
  73280. get imageUrl(): string;
  73281. set imageUrl(value: string);
  73282. /**
  73283. * Gets the back material used by this button
  73284. */
  73285. get backMaterial(): FluentMaterial;
  73286. /**
  73287. * Gets the front material used by this button
  73288. */
  73289. get frontMaterial(): FluentMaterial;
  73290. /**
  73291. * Gets the plate material used by this button
  73292. */
  73293. get plateMaterial(): BABYLON.StandardMaterial;
  73294. /**
  73295. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73296. */
  73297. get shareMaterials(): boolean;
  73298. /**
  73299. * Creates a new button
  73300. * @param name defines the control name
  73301. */
  73302. constructor(name?: string, shareMaterials?: boolean);
  73303. protected _getTypeName(): string;
  73304. private _rebuildContent;
  73305. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73306. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73307. private _createBackMaterial;
  73308. private _createFrontMaterial;
  73309. private _createPlateMaterial;
  73310. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73311. /**
  73312. * Releases all associated resources
  73313. */
  73314. dispose(): void;
  73315. }
  73316. }
  73317. declare module BABYLON.GUI {
  73318. /**
  73319. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73320. */
  73321. export class MeshButton3D extends Button3D {
  73322. /** @hidden */
  73323. protected _currentMesh: BABYLON.Mesh;
  73324. /**
  73325. * Creates a new 3D button based on a mesh
  73326. * @param mesh mesh to become a 3D button
  73327. * @param name defines the control name
  73328. */
  73329. constructor(mesh: BABYLON.Mesh, name?: string);
  73330. protected _getTypeName(): string;
  73331. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73332. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73333. }
  73334. }
  73335. declare module BABYLON.GUI {
  73336. /**
  73337. * Class used to create a container panel deployed on the surface of a plane
  73338. */
  73339. export class PlanePanel extends VolumeBasedPanel {
  73340. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73341. }
  73342. }
  73343. declare module BABYLON.GUI {
  73344. /**
  73345. * Class used to create a container panel where items get randomized planar mapping
  73346. */
  73347. export class ScatterPanel extends VolumeBasedPanel {
  73348. private _iteration;
  73349. /**
  73350. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73351. */
  73352. get iteration(): BABYLON.float;
  73353. set iteration(value: BABYLON.float);
  73354. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73355. private _scatterMapping;
  73356. protected _finalProcessing(): void;
  73357. }
  73358. }
  73359. declare module BABYLON.GUI {
  73360. /**
  73361. * Class used to create a container panel deployed on the surface of a sphere
  73362. */
  73363. export class SpherePanel extends VolumeBasedPanel {
  73364. private _radius;
  73365. /**
  73366. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73367. */
  73368. get radius(): BABYLON.float;
  73369. set radius(value: BABYLON.float);
  73370. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73371. private _sphericalMapping;
  73372. }
  73373. }
  73374. declare module BABYLON.GUI {
  73375. /**
  73376. * Class used to create a stack panel in 3D on XY plane
  73377. */
  73378. export class StackPanel3D extends Container3D {
  73379. private _isVertical;
  73380. /**
  73381. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  73382. */
  73383. get isVertical(): boolean;
  73384. set isVertical(value: boolean);
  73385. /**
  73386. * Gets or sets the distance between elements
  73387. */
  73388. margin: number;
  73389. /**
  73390. * Creates new StackPanel
  73391. * @param isVertical
  73392. */
  73393. constructor(isVertical?: boolean);
  73394. protected _arrangeChildren(): void;
  73395. }
  73396. }
  73397. declare module BABYLON {
  73398. /**
  73399. * Configuration for glTF validation
  73400. */
  73401. export interface IGLTFValidationConfiguration {
  73402. /**
  73403. * The url of the glTF validator.
  73404. */
  73405. url: string;
  73406. }
  73407. /**
  73408. * glTF validation
  73409. */
  73410. export class GLTFValidation {
  73411. /**
  73412. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  73413. */
  73414. static Configuration: IGLTFValidationConfiguration;
  73415. private static _LoadScriptPromise;
  73416. /**
  73417. * Validate a glTF asset using the glTF-Validator.
  73418. * @param data The JSON of a glTF or the array buffer of a binary glTF
  73419. * @param rootUrl The root url for the glTF
  73420. * @param fileName The file name for the glTF
  73421. * @param getExternalResource The callback to get external resources for the glTF validator
  73422. * @returns A promise that resolves with the glTF validation results once complete
  73423. */
  73424. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  73425. }
  73426. }
  73427. declare module BABYLON {
  73428. /**
  73429. * Mode that determines the coordinate system to use.
  73430. */
  73431. export enum GLTFLoaderCoordinateSystemMode {
  73432. /**
  73433. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  73434. */
  73435. AUTO = 0,
  73436. /**
  73437. * Sets the useRightHandedSystem flag on the scene.
  73438. */
  73439. FORCE_RIGHT_HANDED = 1
  73440. }
  73441. /**
  73442. * Mode that determines what animations will start.
  73443. */
  73444. export enum GLTFLoaderAnimationStartMode {
  73445. /**
  73446. * No animation will start.
  73447. */
  73448. NONE = 0,
  73449. /**
  73450. * The first animation will start.
  73451. */
  73452. FIRST = 1,
  73453. /**
  73454. * All animations will start.
  73455. */
  73456. ALL = 2
  73457. }
  73458. /**
  73459. * Interface that contains the data for the glTF asset.
  73460. */
  73461. export interface IGLTFLoaderData {
  73462. /**
  73463. * The object that represents the glTF JSON.
  73464. */
  73465. json: Object;
  73466. /**
  73467. * The BIN chunk of a binary glTF.
  73468. */
  73469. bin: Nullable<IDataBuffer>;
  73470. }
  73471. /**
  73472. * Interface for extending the loader.
  73473. */
  73474. export interface IGLTFLoaderExtension {
  73475. /**
  73476. * The name of this extension.
  73477. */
  73478. readonly name: string;
  73479. /**
  73480. * Defines whether this extension is enabled.
  73481. */
  73482. enabled: boolean;
  73483. /**
  73484. * Defines the order of this extension.
  73485. * The loader sorts the extensions using these values when loading.
  73486. */
  73487. order?: number;
  73488. }
  73489. /**
  73490. * Loader state.
  73491. */
  73492. export enum GLTFLoaderState {
  73493. /**
  73494. * The asset is loading.
  73495. */
  73496. LOADING = 0,
  73497. /**
  73498. * The asset is ready for rendering.
  73499. */
  73500. READY = 1,
  73501. /**
  73502. * The asset is completely loaded.
  73503. */
  73504. COMPLETE = 2
  73505. }
  73506. /** @hidden */
  73507. export interface IGLTFLoader extends IDisposable {
  73508. readonly state: Nullable<GLTFLoaderState>;
  73509. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  73510. meshes: AbstractMesh[];
  73511. particleSystems: IParticleSystem[];
  73512. skeletons: Skeleton[];
  73513. animationGroups: AnimationGroup[];
  73514. }>;
  73515. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  73516. }
  73517. /**
  73518. * File loader for loading glTF files into a scene.
  73519. */
  73520. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73521. /** @hidden */
  73522. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73523. /** @hidden */
  73524. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73525. /**
  73526. * Raised when the asset has been parsed
  73527. */
  73528. onParsedObservable: Observable<IGLTFLoaderData>;
  73529. private _onParsedObserver;
  73530. /**
  73531. * Raised when the asset has been parsed
  73532. */
  73533. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  73534. /**
  73535. * 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.
  73536. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  73537. * Defaults to true.
  73538. * @hidden
  73539. */
  73540. static IncrementalLoading: boolean;
  73541. /**
  73542. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  73543. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  73544. * @hidden
  73545. */
  73546. static HomogeneousCoordinates: boolean;
  73547. /**
  73548. * The coordinate system mode. Defaults to AUTO.
  73549. */
  73550. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  73551. /**
  73552. * The animation start mode. Defaults to FIRST.
  73553. */
  73554. animationStartMode: GLTFLoaderAnimationStartMode;
  73555. /**
  73556. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  73557. */
  73558. compileMaterials: boolean;
  73559. /**
  73560. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  73561. */
  73562. useClipPlane: boolean;
  73563. /**
  73564. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  73565. */
  73566. compileShadowGenerators: boolean;
  73567. /**
  73568. * Defines if the Alpha blended materials are only applied as coverage.
  73569. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  73570. * If true, no extra effects are applied to transparent pixels.
  73571. */
  73572. transparencyAsCoverage: boolean;
  73573. /**
  73574. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  73575. * Enabling will disable offline support and glTF validator.
  73576. * Defaults to false.
  73577. */
  73578. useRangeRequests: boolean;
  73579. /**
  73580. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  73581. */
  73582. createInstances: boolean;
  73583. /**
  73584. * Function called before loading a url referenced by the asset.
  73585. */
  73586. preprocessUrlAsync: (url: string) => Promise<string>;
  73587. /**
  73588. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73589. */
  73590. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  73591. private _onMeshLoadedObserver;
  73592. /**
  73593. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73594. */
  73595. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  73596. /**
  73597. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  73598. */
  73599. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  73600. private _onTextureLoadedObserver;
  73601. /**
  73602. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  73603. */
  73604. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  73605. /**
  73606. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  73607. */
  73608. readonly onMaterialLoadedObservable: Observable<Material>;
  73609. private _onMaterialLoadedObserver;
  73610. /**
  73611. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  73612. */
  73613. set onMaterialLoaded(callback: (material: Material) => void);
  73614. /**
  73615. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  73616. */
  73617. readonly onCameraLoadedObservable: Observable<Camera>;
  73618. private _onCameraLoadedObserver;
  73619. /**
  73620. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  73621. */
  73622. set onCameraLoaded(callback: (camera: Camera) => void);
  73623. /**
  73624. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  73625. * For assets with LODs, raised when all of the LODs are complete.
  73626. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73627. */
  73628. readonly onCompleteObservable: Observable<void>;
  73629. private _onCompleteObserver;
  73630. /**
  73631. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  73632. * For assets with LODs, raised when all of the LODs are complete.
  73633. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73634. */
  73635. set onComplete(callback: () => void);
  73636. /**
  73637. * Observable raised when an error occurs.
  73638. */
  73639. readonly onErrorObservable: Observable<any>;
  73640. private _onErrorObserver;
  73641. /**
  73642. * Callback raised when an error occurs.
  73643. */
  73644. set onError(callback: (reason: any) => void);
  73645. /**
  73646. * Observable raised after the loader is disposed.
  73647. */
  73648. readonly onDisposeObservable: Observable<void>;
  73649. private _onDisposeObserver;
  73650. /**
  73651. * Callback raised after the loader is disposed.
  73652. */
  73653. set onDispose(callback: () => void);
  73654. /**
  73655. * Observable raised after a loader extension is created.
  73656. * Set additional options for a loader extension in this event.
  73657. */
  73658. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  73659. private _onExtensionLoadedObserver;
  73660. /**
  73661. * Callback raised after a loader extension is created.
  73662. */
  73663. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  73664. /**
  73665. * Defines if the loader logging is enabled.
  73666. */
  73667. get loggingEnabled(): boolean;
  73668. set loggingEnabled(value: boolean);
  73669. /**
  73670. * Defines if the loader should capture performance counters.
  73671. */
  73672. get capturePerformanceCounters(): boolean;
  73673. set capturePerformanceCounters(value: boolean);
  73674. /**
  73675. * Defines if the loader should validate the asset.
  73676. */
  73677. validate: boolean;
  73678. /**
  73679. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  73680. */
  73681. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  73682. private _onValidatedObserver;
  73683. /**
  73684. * Callback raised after a loader extension is created.
  73685. */
  73686. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  73687. private _loader;
  73688. /**
  73689. * Name of the loader ("gltf")
  73690. */
  73691. name: string;
  73692. /** @hidden */
  73693. extensions: ISceneLoaderPluginExtensions;
  73694. /**
  73695. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  73696. */
  73697. dispose(): void;
  73698. /** @hidden */
  73699. _clear(): void;
  73700. /** @hidden */
  73701. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73702. /** @hidden */
  73703. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73704. /** @hidden */
  73705. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73706. meshes: AbstractMesh[];
  73707. particleSystems: IParticleSystem[];
  73708. skeletons: Skeleton[];
  73709. animationGroups: AnimationGroup[];
  73710. }>;
  73711. /** @hidden */
  73712. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73713. /** @hidden */
  73714. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73715. /** @hidden */
  73716. canDirectLoad(data: string): boolean;
  73717. /** @hidden */
  73718. directLoad(scene: Scene, data: string): any;
  73719. /**
  73720. * The callback that allows custom handling of the root url based on the response url.
  73721. * @param rootUrl the original root url
  73722. * @param responseURL the response url if available
  73723. * @returns the new root url
  73724. */
  73725. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  73726. /** @hidden */
  73727. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  73728. /**
  73729. * The loader state or null if the loader is not active.
  73730. */
  73731. get loaderState(): Nullable<GLTFLoaderState>;
  73732. /**
  73733. * Returns a promise that resolves when the asset is completely loaded.
  73734. * @returns a promise that resolves when the asset is completely loaded.
  73735. */
  73736. whenCompleteAsync(): Promise<void>;
  73737. private _validate;
  73738. private _getLoader;
  73739. private _parseJson;
  73740. private _unpackBinaryAsync;
  73741. private _unpackBinaryV1Async;
  73742. private _unpackBinaryV2Async;
  73743. private static _parseVersion;
  73744. private static _compareVersion;
  73745. private static readonly _logSpaces;
  73746. private _logIndentLevel;
  73747. private _loggingEnabled;
  73748. /** @hidden */
  73749. _log: (message: string) => void;
  73750. /** @hidden */
  73751. _logOpen(message: string): void;
  73752. /** @hidden */
  73753. _logClose(): void;
  73754. private _logEnabled;
  73755. private _logDisabled;
  73756. private _capturePerformanceCounters;
  73757. /** @hidden */
  73758. _startPerformanceCounter: (counterName: string) => void;
  73759. /** @hidden */
  73760. _endPerformanceCounter: (counterName: string) => void;
  73761. private _startPerformanceCounterEnabled;
  73762. private _startPerformanceCounterDisabled;
  73763. private _endPerformanceCounterEnabled;
  73764. private _endPerformanceCounterDisabled;
  73765. }
  73766. }
  73767. declare module BABYLON.GLTF1 {
  73768. /**
  73769. * Enums
  73770. * @hidden
  73771. */
  73772. export enum EComponentType {
  73773. BYTE = 5120,
  73774. UNSIGNED_BYTE = 5121,
  73775. SHORT = 5122,
  73776. UNSIGNED_SHORT = 5123,
  73777. FLOAT = 5126
  73778. }
  73779. /** @hidden */
  73780. export enum EShaderType {
  73781. FRAGMENT = 35632,
  73782. VERTEX = 35633
  73783. }
  73784. /** @hidden */
  73785. export enum EParameterType {
  73786. BYTE = 5120,
  73787. UNSIGNED_BYTE = 5121,
  73788. SHORT = 5122,
  73789. UNSIGNED_SHORT = 5123,
  73790. INT = 5124,
  73791. UNSIGNED_INT = 5125,
  73792. FLOAT = 5126,
  73793. FLOAT_VEC2 = 35664,
  73794. FLOAT_VEC3 = 35665,
  73795. FLOAT_VEC4 = 35666,
  73796. INT_VEC2 = 35667,
  73797. INT_VEC3 = 35668,
  73798. INT_VEC4 = 35669,
  73799. BOOL = 35670,
  73800. BOOL_VEC2 = 35671,
  73801. BOOL_VEC3 = 35672,
  73802. BOOL_VEC4 = 35673,
  73803. FLOAT_MAT2 = 35674,
  73804. FLOAT_MAT3 = 35675,
  73805. FLOAT_MAT4 = 35676,
  73806. SAMPLER_2D = 35678
  73807. }
  73808. /** @hidden */
  73809. export enum ETextureWrapMode {
  73810. CLAMP_TO_EDGE = 33071,
  73811. MIRRORED_REPEAT = 33648,
  73812. REPEAT = 10497
  73813. }
  73814. /** @hidden */
  73815. export enum ETextureFilterType {
  73816. NEAREST = 9728,
  73817. LINEAR = 9728,
  73818. NEAREST_MIPMAP_NEAREST = 9984,
  73819. LINEAR_MIPMAP_NEAREST = 9985,
  73820. NEAREST_MIPMAP_LINEAR = 9986,
  73821. LINEAR_MIPMAP_LINEAR = 9987
  73822. }
  73823. /** @hidden */
  73824. export enum ETextureFormat {
  73825. ALPHA = 6406,
  73826. RGB = 6407,
  73827. RGBA = 6408,
  73828. LUMINANCE = 6409,
  73829. LUMINANCE_ALPHA = 6410
  73830. }
  73831. /** @hidden */
  73832. export enum ECullingType {
  73833. FRONT = 1028,
  73834. BACK = 1029,
  73835. FRONT_AND_BACK = 1032
  73836. }
  73837. /** @hidden */
  73838. export enum EBlendingFunction {
  73839. ZERO = 0,
  73840. ONE = 1,
  73841. SRC_COLOR = 768,
  73842. ONE_MINUS_SRC_COLOR = 769,
  73843. DST_COLOR = 774,
  73844. ONE_MINUS_DST_COLOR = 775,
  73845. SRC_ALPHA = 770,
  73846. ONE_MINUS_SRC_ALPHA = 771,
  73847. DST_ALPHA = 772,
  73848. ONE_MINUS_DST_ALPHA = 773,
  73849. CONSTANT_COLOR = 32769,
  73850. ONE_MINUS_CONSTANT_COLOR = 32770,
  73851. CONSTANT_ALPHA = 32771,
  73852. ONE_MINUS_CONSTANT_ALPHA = 32772,
  73853. SRC_ALPHA_SATURATE = 776
  73854. }
  73855. /** @hidden */
  73856. export interface IGLTFProperty {
  73857. extensions?: {
  73858. [key: string]: any;
  73859. };
  73860. extras?: Object;
  73861. }
  73862. /** @hidden */
  73863. export interface IGLTFChildRootProperty extends IGLTFProperty {
  73864. name?: string;
  73865. }
  73866. /** @hidden */
  73867. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  73868. bufferView: string;
  73869. byteOffset: number;
  73870. byteStride: number;
  73871. count: number;
  73872. type: string;
  73873. componentType: EComponentType;
  73874. max?: number[];
  73875. min?: number[];
  73876. name?: string;
  73877. }
  73878. /** @hidden */
  73879. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  73880. buffer: string;
  73881. byteOffset: number;
  73882. byteLength: number;
  73883. byteStride: number;
  73884. target?: number;
  73885. }
  73886. /** @hidden */
  73887. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  73888. uri: string;
  73889. byteLength?: number;
  73890. type?: string;
  73891. }
  73892. /** @hidden */
  73893. export interface IGLTFShader extends IGLTFChildRootProperty {
  73894. uri: string;
  73895. type: EShaderType;
  73896. }
  73897. /** @hidden */
  73898. export interface IGLTFProgram extends IGLTFChildRootProperty {
  73899. attributes: string[];
  73900. fragmentShader: string;
  73901. vertexShader: string;
  73902. }
  73903. /** @hidden */
  73904. export interface IGLTFTechniqueParameter {
  73905. type: number;
  73906. count?: number;
  73907. semantic?: string;
  73908. node?: string;
  73909. value?: number | boolean | string | Array<any>;
  73910. source?: string;
  73911. babylonValue?: any;
  73912. }
  73913. /** @hidden */
  73914. export interface IGLTFTechniqueCommonProfile {
  73915. lightingModel: string;
  73916. texcoordBindings: Object;
  73917. parameters?: Array<any>;
  73918. }
  73919. /** @hidden */
  73920. export interface IGLTFTechniqueStatesFunctions {
  73921. blendColor?: number[];
  73922. blendEquationSeparate?: number[];
  73923. blendFuncSeparate?: number[];
  73924. colorMask: boolean[];
  73925. cullFace: number[];
  73926. }
  73927. /** @hidden */
  73928. export interface IGLTFTechniqueStates {
  73929. enable: number[];
  73930. functions: IGLTFTechniqueStatesFunctions;
  73931. }
  73932. /** @hidden */
  73933. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  73934. parameters: {
  73935. [key: string]: IGLTFTechniqueParameter;
  73936. };
  73937. program: string;
  73938. attributes: {
  73939. [key: string]: string;
  73940. };
  73941. uniforms: {
  73942. [key: string]: string;
  73943. };
  73944. states: IGLTFTechniqueStates;
  73945. }
  73946. /** @hidden */
  73947. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  73948. technique?: string;
  73949. values: string[];
  73950. }
  73951. /** @hidden */
  73952. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  73953. attributes: {
  73954. [key: string]: string;
  73955. };
  73956. indices: string;
  73957. material: string;
  73958. mode?: number;
  73959. }
  73960. /** @hidden */
  73961. export interface IGLTFMesh extends IGLTFChildRootProperty {
  73962. primitives: IGLTFMeshPrimitive[];
  73963. }
  73964. /** @hidden */
  73965. export interface IGLTFImage extends IGLTFChildRootProperty {
  73966. uri: string;
  73967. }
  73968. /** @hidden */
  73969. export interface IGLTFSampler extends IGLTFChildRootProperty {
  73970. magFilter?: number;
  73971. minFilter?: number;
  73972. wrapS?: number;
  73973. wrapT?: number;
  73974. }
  73975. /** @hidden */
  73976. export interface IGLTFTexture extends IGLTFChildRootProperty {
  73977. sampler: string;
  73978. source: string;
  73979. format?: ETextureFormat;
  73980. internalFormat?: ETextureFormat;
  73981. target?: number;
  73982. type?: number;
  73983. babylonTexture?: Texture;
  73984. }
  73985. /** @hidden */
  73986. export interface IGLTFAmbienLight {
  73987. color?: number[];
  73988. }
  73989. /** @hidden */
  73990. export interface IGLTFDirectionalLight {
  73991. color?: number[];
  73992. }
  73993. /** @hidden */
  73994. export interface IGLTFPointLight {
  73995. color?: number[];
  73996. constantAttenuation?: number;
  73997. linearAttenuation?: number;
  73998. quadraticAttenuation?: number;
  73999. }
  74000. /** @hidden */
  74001. export interface IGLTFSpotLight {
  74002. color?: number[];
  74003. constantAttenuation?: number;
  74004. fallOfAngle?: number;
  74005. fallOffExponent?: number;
  74006. linearAttenuation?: number;
  74007. quadraticAttenuation?: number;
  74008. }
  74009. /** @hidden */
  74010. export interface IGLTFLight extends IGLTFChildRootProperty {
  74011. type: string;
  74012. }
  74013. /** @hidden */
  74014. export interface IGLTFCameraOrthographic {
  74015. xmag: number;
  74016. ymag: number;
  74017. zfar: number;
  74018. znear: number;
  74019. }
  74020. /** @hidden */
  74021. export interface IGLTFCameraPerspective {
  74022. aspectRatio: number;
  74023. yfov: number;
  74024. zfar: number;
  74025. znear: number;
  74026. }
  74027. /** @hidden */
  74028. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74029. type: string;
  74030. }
  74031. /** @hidden */
  74032. export interface IGLTFAnimationChannelTarget {
  74033. id: string;
  74034. path: string;
  74035. }
  74036. /** @hidden */
  74037. export interface IGLTFAnimationChannel {
  74038. sampler: string;
  74039. target: IGLTFAnimationChannelTarget;
  74040. }
  74041. /** @hidden */
  74042. export interface IGLTFAnimationSampler {
  74043. input: string;
  74044. output: string;
  74045. interpolation?: string;
  74046. }
  74047. /** @hidden */
  74048. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74049. channels?: IGLTFAnimationChannel[];
  74050. parameters?: {
  74051. [key: string]: string;
  74052. };
  74053. samplers?: {
  74054. [key: string]: IGLTFAnimationSampler;
  74055. };
  74056. }
  74057. /** @hidden */
  74058. export interface IGLTFNodeInstanceSkin {
  74059. skeletons: string[];
  74060. skin: string;
  74061. meshes: string[];
  74062. }
  74063. /** @hidden */
  74064. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74065. bindShapeMatrix: number[];
  74066. inverseBindMatrices: string;
  74067. jointNames: string[];
  74068. babylonSkeleton?: Skeleton;
  74069. }
  74070. /** @hidden */
  74071. export interface IGLTFNode extends IGLTFChildRootProperty {
  74072. camera?: string;
  74073. children: string[];
  74074. skin?: string;
  74075. jointName?: string;
  74076. light?: string;
  74077. matrix: number[];
  74078. mesh?: string;
  74079. meshes?: string[];
  74080. rotation?: number[];
  74081. scale?: number[];
  74082. translation?: number[];
  74083. babylonNode?: Node;
  74084. }
  74085. /** @hidden */
  74086. export interface IGLTFScene extends IGLTFChildRootProperty {
  74087. nodes: string[];
  74088. }
  74089. /** @hidden */
  74090. export interface IGLTFRuntime {
  74091. extensions: {
  74092. [key: string]: any;
  74093. };
  74094. accessors: {
  74095. [key: string]: IGLTFAccessor;
  74096. };
  74097. buffers: {
  74098. [key: string]: IGLTFBuffer;
  74099. };
  74100. bufferViews: {
  74101. [key: string]: IGLTFBufferView;
  74102. };
  74103. meshes: {
  74104. [key: string]: IGLTFMesh;
  74105. };
  74106. lights: {
  74107. [key: string]: IGLTFLight;
  74108. };
  74109. cameras: {
  74110. [key: string]: IGLTFCamera;
  74111. };
  74112. nodes: {
  74113. [key: string]: IGLTFNode;
  74114. };
  74115. images: {
  74116. [key: string]: IGLTFImage;
  74117. };
  74118. textures: {
  74119. [key: string]: IGLTFTexture;
  74120. };
  74121. shaders: {
  74122. [key: string]: IGLTFShader;
  74123. };
  74124. programs: {
  74125. [key: string]: IGLTFProgram;
  74126. };
  74127. samplers: {
  74128. [key: string]: IGLTFSampler;
  74129. };
  74130. techniques: {
  74131. [key: string]: IGLTFTechnique;
  74132. };
  74133. materials: {
  74134. [key: string]: IGLTFMaterial;
  74135. };
  74136. animations: {
  74137. [key: string]: IGLTFAnimation;
  74138. };
  74139. skins: {
  74140. [key: string]: IGLTFSkins;
  74141. };
  74142. currentScene?: Object;
  74143. scenes: {
  74144. [key: string]: IGLTFScene;
  74145. };
  74146. extensionsUsed: string[];
  74147. extensionsRequired?: string[];
  74148. buffersCount: number;
  74149. shaderscount: number;
  74150. scene: Scene;
  74151. rootUrl: string;
  74152. loadedBufferCount: number;
  74153. loadedBufferViews: {
  74154. [name: string]: ArrayBufferView;
  74155. };
  74156. loadedShaderCount: number;
  74157. importOnlyMeshes: boolean;
  74158. importMeshesNames?: string[];
  74159. dummyNodes: Node[];
  74160. }
  74161. /** @hidden */
  74162. export interface INodeToRoot {
  74163. bone: Bone;
  74164. node: IGLTFNode;
  74165. id: string;
  74166. }
  74167. /** @hidden */
  74168. export interface IJointNode {
  74169. node: IGLTFNode;
  74170. id: string;
  74171. }
  74172. }
  74173. declare module BABYLON.GLTF1 {
  74174. /**
  74175. * Utils functions for GLTF
  74176. * @hidden
  74177. */
  74178. export class GLTFUtils {
  74179. /**
  74180. * Sets the given "parameter" matrix
  74181. * @param scene: the Scene object
  74182. * @param source: the source node where to pick the matrix
  74183. * @param parameter: the GLTF technique parameter
  74184. * @param uniformName: the name of the shader's uniform
  74185. * @param shaderMaterial: the shader material
  74186. */
  74187. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74188. /**
  74189. * Sets the given "parameter" matrix
  74190. * @param shaderMaterial: the shader material
  74191. * @param uniform: the name of the shader's uniform
  74192. * @param value: the value of the uniform
  74193. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74194. */
  74195. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74196. /**
  74197. * Returns the wrap mode of the texture
  74198. * @param mode: the mode value
  74199. */
  74200. static GetWrapMode(mode: number): number;
  74201. /**
  74202. * Returns the byte stride giving an accessor
  74203. * @param accessor: the GLTF accessor objet
  74204. */
  74205. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74206. /**
  74207. * Returns the texture filter mode giving a mode value
  74208. * @param mode: the filter mode value
  74209. */
  74210. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74211. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74212. /**
  74213. * Returns a buffer from its accessor
  74214. * @param gltfRuntime: the GLTF runtime
  74215. * @param accessor: the GLTF accessor
  74216. */
  74217. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74218. /**
  74219. * Decodes a buffer view into a string
  74220. * @param view: the buffer view
  74221. */
  74222. static DecodeBufferToText(view: ArrayBufferView): string;
  74223. /**
  74224. * Returns the default material of gltf. Related to
  74225. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74226. * @param scene: the Babylon.js scene
  74227. */
  74228. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74229. private static _DefaultMaterial;
  74230. }
  74231. }
  74232. declare module BABYLON.GLTF1 {
  74233. /**
  74234. * Implementation of the base glTF spec
  74235. * @hidden
  74236. */
  74237. export class GLTFLoaderBase {
  74238. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74239. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74240. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74241. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74242. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74243. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74244. }
  74245. /**
  74246. * glTF V1 Loader
  74247. * @hidden
  74248. */
  74249. export class GLTFLoader implements IGLTFLoader {
  74250. static Extensions: {
  74251. [name: string]: GLTFLoaderExtension;
  74252. };
  74253. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74254. state: Nullable<GLTFLoaderState>;
  74255. dispose(): void;
  74256. private _importMeshAsync;
  74257. /**
  74258. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74259. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74260. * @param scene the scene the meshes should be added to
  74261. * @param data gltf data containing information of the meshes in a loaded file
  74262. * @param rootUrl root url to load from
  74263. * @param onProgress event that fires when loading progress has occured
  74264. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74265. */
  74266. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74267. meshes: AbstractMesh[];
  74268. particleSystems: IParticleSystem[];
  74269. skeletons: Skeleton[];
  74270. animationGroups: AnimationGroup[];
  74271. }>;
  74272. private _loadAsync;
  74273. /**
  74274. * Imports all objects from a loaded gltf file and adds them to the scene
  74275. * @param scene the scene the objects should be added to
  74276. * @param data gltf data containing information of the meshes in a loaded file
  74277. * @param rootUrl root url to load from
  74278. * @param onProgress event that fires when loading progress has occured
  74279. * @returns a promise which completes when objects have been loaded to the scene
  74280. */
  74281. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74282. private _loadShadersAsync;
  74283. private _loadBuffersAsync;
  74284. private _createNodes;
  74285. }
  74286. /** @hidden */
  74287. export abstract class GLTFLoaderExtension {
  74288. private _name;
  74289. constructor(name: string);
  74290. get name(): string;
  74291. /**
  74292. * Defines an override for loading the runtime
  74293. * Return true to stop further extensions from loading the runtime
  74294. */
  74295. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74296. /**
  74297. * Defines an onverride for creating gltf runtime
  74298. * Return true to stop further extensions from creating the runtime
  74299. */
  74300. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74301. /**
  74302. * Defines an override for loading buffers
  74303. * Return true to stop further extensions from loading this buffer
  74304. */
  74305. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74306. /**
  74307. * Defines an override for loading texture buffers
  74308. * Return true to stop further extensions from loading this texture data
  74309. */
  74310. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74311. /**
  74312. * Defines an override for creating textures
  74313. * Return true to stop further extensions from loading this texture
  74314. */
  74315. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74316. /**
  74317. * Defines an override for loading shader strings
  74318. * Return true to stop further extensions from loading this shader data
  74319. */
  74320. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74321. /**
  74322. * Defines an override for loading materials
  74323. * Return true to stop further extensions from loading this material
  74324. */
  74325. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74326. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74327. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74328. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74329. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74330. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74331. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74332. private static LoadTextureBufferAsync;
  74333. private static CreateTextureAsync;
  74334. private static ApplyExtensions;
  74335. }
  74336. }
  74337. declare module BABYLON.GLTF1 {
  74338. /** @hidden */
  74339. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74340. private _bin;
  74341. constructor();
  74342. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74343. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74344. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74345. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74346. }
  74347. }
  74348. declare module BABYLON.GLTF1 {
  74349. /** @hidden */
  74350. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74351. constructor();
  74352. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74353. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74354. private _loadTexture;
  74355. }
  74356. }
  74357. declare module BABYLON.GLTF2.Loader {
  74358. /**
  74359. * Loader interface with an index field.
  74360. */
  74361. export interface IArrayItem {
  74362. /**
  74363. * The index of this item in the array.
  74364. */
  74365. index: number;
  74366. }
  74367. /**
  74368. * Loader interface with additional members.
  74369. */
  74370. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  74371. /** @hidden */
  74372. _data?: Promise<ArrayBufferView>;
  74373. /** @hidden */
  74374. _babylonVertexBuffer?: Promise<VertexBuffer>;
  74375. }
  74376. /**
  74377. * Loader interface with additional members.
  74378. */
  74379. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  74380. }
  74381. /** @hidden */
  74382. export interface _IAnimationSamplerData {
  74383. input: Float32Array;
  74384. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  74385. output: Float32Array;
  74386. }
  74387. /**
  74388. * Loader interface with additional members.
  74389. */
  74390. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  74391. /** @hidden */
  74392. _data?: Promise<_IAnimationSamplerData>;
  74393. }
  74394. /**
  74395. * Loader interface with additional members.
  74396. */
  74397. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  74398. channels: IAnimationChannel[];
  74399. samplers: IAnimationSampler[];
  74400. /** @hidden */
  74401. _babylonAnimationGroup?: AnimationGroup;
  74402. }
  74403. /**
  74404. * Loader interface with additional members.
  74405. */
  74406. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  74407. /** @hidden */
  74408. _data?: Promise<ArrayBufferView>;
  74409. }
  74410. /**
  74411. * Loader interface with additional members.
  74412. */
  74413. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  74414. /** @hidden */
  74415. _data?: Promise<ArrayBufferView>;
  74416. /** @hidden */
  74417. _babylonBuffer?: Promise<Buffer>;
  74418. }
  74419. /**
  74420. * Loader interface with additional members.
  74421. */
  74422. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  74423. }
  74424. /**
  74425. * Loader interface with additional members.
  74426. */
  74427. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  74428. /** @hidden */
  74429. _data?: Promise<ArrayBufferView>;
  74430. }
  74431. /**
  74432. * Loader interface with additional members.
  74433. */
  74434. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  74435. }
  74436. /**
  74437. * Loader interface with additional members.
  74438. */
  74439. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  74440. }
  74441. /**
  74442. * Loader interface with additional members.
  74443. */
  74444. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  74445. baseColorTexture?: ITextureInfo;
  74446. metallicRoughnessTexture?: ITextureInfo;
  74447. }
  74448. /**
  74449. * Loader interface with additional members.
  74450. */
  74451. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  74452. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74453. normalTexture?: IMaterialNormalTextureInfo;
  74454. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74455. emissiveTexture?: ITextureInfo;
  74456. /** @hidden */
  74457. _data?: {
  74458. [babylonDrawMode: number]: {
  74459. babylonMaterial: Material;
  74460. babylonMeshes: AbstractMesh[];
  74461. promise: Promise<void>;
  74462. };
  74463. };
  74464. }
  74465. /**
  74466. * Loader interface with additional members.
  74467. */
  74468. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  74469. primitives: IMeshPrimitive[];
  74470. }
  74471. /**
  74472. * Loader interface with additional members.
  74473. */
  74474. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  74475. /** @hidden */
  74476. _instanceData?: {
  74477. babylonSourceMesh: Mesh;
  74478. promise: Promise<any>;
  74479. };
  74480. }
  74481. /**
  74482. * Loader interface with additional members.
  74483. */
  74484. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  74485. /**
  74486. * The parent glTF node.
  74487. */
  74488. parent?: INode;
  74489. /** @hidden */
  74490. _babylonTransformNode?: TransformNode;
  74491. /** @hidden */
  74492. _primitiveBabylonMeshes?: AbstractMesh[];
  74493. /** @hidden */
  74494. _babylonBones?: Bone[];
  74495. /** @hidden */
  74496. _numMorphTargets?: number;
  74497. }
  74498. /** @hidden */
  74499. export interface _ISamplerData {
  74500. noMipMaps: boolean;
  74501. samplingMode: number;
  74502. wrapU: number;
  74503. wrapV: number;
  74504. }
  74505. /**
  74506. * Loader interface with additional members.
  74507. */
  74508. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  74509. /** @hidden */
  74510. _data?: _ISamplerData;
  74511. }
  74512. /**
  74513. * Loader interface with additional members.
  74514. */
  74515. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  74516. }
  74517. /**
  74518. * Loader interface with additional members.
  74519. */
  74520. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  74521. /** @hidden */
  74522. _data?: {
  74523. babylonSkeleton: Skeleton;
  74524. promise: Promise<void>;
  74525. };
  74526. }
  74527. /**
  74528. * Loader interface with additional members.
  74529. */
  74530. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  74531. }
  74532. /**
  74533. * Loader interface with additional members.
  74534. */
  74535. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  74536. }
  74537. /**
  74538. * Loader interface with additional members.
  74539. */
  74540. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  74541. accessors?: IAccessor[];
  74542. animations?: IAnimation[];
  74543. buffers?: IBuffer[];
  74544. bufferViews?: IBufferView[];
  74545. cameras?: ICamera[];
  74546. images?: IImage[];
  74547. materials?: IMaterial[];
  74548. meshes?: IMesh[];
  74549. nodes?: INode[];
  74550. samplers?: ISampler[];
  74551. scenes?: IScene[];
  74552. skins?: ISkin[];
  74553. textures?: ITexture[];
  74554. }
  74555. }
  74556. declare module BABYLON.GLTF2 {
  74557. /**
  74558. * Interface for a glTF loader extension.
  74559. */
  74560. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  74561. /**
  74562. * Called after the loader state changes to LOADING.
  74563. */
  74564. onLoading?(): void;
  74565. /**
  74566. * Called after the loader state changes to READY.
  74567. */
  74568. onReady?(): void;
  74569. /**
  74570. * Define this method to modify the default behavior when loading scenes.
  74571. * @param context The context when loading the asset
  74572. * @param scene The glTF scene property
  74573. * @returns A promise that resolves when the load is complete or null if not handled
  74574. */
  74575. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  74576. /**
  74577. * Define this method to modify the default behavior when loading nodes.
  74578. * @param context The context when loading the asset
  74579. * @param node The glTF node property
  74580. * @param assign A function called synchronously after parsing the glTF properties
  74581. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  74582. */
  74583. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74584. /**
  74585. * Define this method to modify the default behavior when loading cameras.
  74586. * @param context The context when loading the asset
  74587. * @param camera The glTF camera property
  74588. * @param assign A function called synchronously after parsing the glTF properties
  74589. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  74590. */
  74591. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74592. /**
  74593. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  74594. * @param context The context when loading the asset
  74595. * @param primitive The glTF mesh primitive property
  74596. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  74597. */
  74598. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74599. /**
  74600. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74601. * @param context The context when loading the asset
  74602. * @param name The mesh name when loading the asset
  74603. * @param node The glTF node when loading the asset
  74604. * @param mesh The glTF mesh when loading the asset
  74605. * @param primitive The glTF mesh primitive property
  74606. * @param assign A function called synchronously after parsing the glTF properties
  74607. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74608. */
  74609. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74610. /**
  74611. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  74612. * @param context The context when loading the asset
  74613. * @param material The glTF material property
  74614. * @param assign A function called synchronously after parsing the glTF properties
  74615. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  74616. */
  74617. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74618. /**
  74619. * Define this method to modify the default behavior when creating materials.
  74620. * @param context The context when loading the asset
  74621. * @param material The glTF material property
  74622. * @param babylonDrawMode The draw mode for the Babylon material
  74623. * @returns The Babylon material or null if not handled
  74624. */
  74625. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74626. /**
  74627. * Define this method to modify the default behavior when loading material properties.
  74628. * @param context The context when loading the asset
  74629. * @param material The glTF material property
  74630. * @param babylonMaterial The Babylon material
  74631. * @returns A promise that resolves when the load is complete or null if not handled
  74632. */
  74633. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74634. /**
  74635. * Define this method to modify the default behavior when loading texture infos.
  74636. * @param context The context when loading the asset
  74637. * @param textureInfo The glTF texture info property
  74638. * @param assign A function called synchronously after parsing the glTF properties
  74639. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  74640. */
  74641. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  74642. /**
  74643. * Define this method to modify the default behavior when loading animations.
  74644. * @param context The context when loading the asset
  74645. * @param animation The glTF animation property
  74646. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  74647. */
  74648. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  74649. /**
  74650. * @hidden Define this method to modify the default behavior when loading skins.
  74651. * @param context The context when loading the asset
  74652. * @param node The glTF node property
  74653. * @param skin The glTF skin property
  74654. * @returns A promise that resolves when the load is complete or null if not handled
  74655. */
  74656. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  74657. /**
  74658. * @hidden Define this method to modify the default behavior when loading uris.
  74659. * @param context The context when loading the asset
  74660. * @param property The glTF property associated with the uri
  74661. * @param uri The uri to load
  74662. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74663. */
  74664. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  74665. /**
  74666. * Define this method to modify the default behavior when loading buffer views.
  74667. * @param context The context when loading the asset
  74668. * @param bufferView The glTF buffer view property
  74669. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74670. */
  74671. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  74672. /**
  74673. * Define this method to modify the default behavior when loading buffers.
  74674. * @param context The context when loading the asset
  74675. * @param buffer The glTF buffer property
  74676. * @param byteOffset The byte offset to load
  74677. * @param byteLength The byte length to load
  74678. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74679. */
  74680. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  74681. }
  74682. }
  74683. declare module BABYLON.GLTF2 {
  74684. /**
  74685. * Helper class for working with arrays when loading the glTF asset
  74686. */
  74687. export class ArrayItem {
  74688. /**
  74689. * Gets an item from the given array.
  74690. * @param context The context when loading the asset
  74691. * @param array The array to get the item from
  74692. * @param index The index to the array
  74693. * @returns The array item
  74694. */
  74695. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  74696. /**
  74697. * Assign an `index` field to each item of the given array.
  74698. * @param array The array of items
  74699. */
  74700. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  74701. }
  74702. /**
  74703. * The glTF 2.0 loader
  74704. */
  74705. export class GLTFLoader implements IGLTFLoader {
  74706. /** @hidden */
  74707. _completePromises: Promise<any>[];
  74708. private _disposed;
  74709. private _parent;
  74710. private _state;
  74711. private _extensions;
  74712. private _rootUrl;
  74713. private _fileName;
  74714. private _uniqueRootUrl;
  74715. private _gltf;
  74716. private _bin;
  74717. private _babylonScene;
  74718. private _rootBabylonMesh;
  74719. private _defaultBabylonMaterialData;
  74720. private _progressCallback?;
  74721. private _requests;
  74722. private static readonly _DefaultSampler;
  74723. private static _RegisteredExtensions;
  74724. /**
  74725. * Registers a loader extension.
  74726. * @param name The name of the loader extension.
  74727. * @param factory The factory function that creates the loader extension.
  74728. */
  74729. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  74730. /**
  74731. * Unregisters a loader extension.
  74732. * @param name The name of the loader extension.
  74733. * @returns A boolean indicating whether the extension has been unregistered
  74734. */
  74735. static UnregisterExtension(name: string): boolean;
  74736. /**
  74737. * Gets the loader state.
  74738. */
  74739. get state(): Nullable<GLTFLoaderState>;
  74740. /**
  74741. * The object that represents the glTF JSON.
  74742. */
  74743. get gltf(): IGLTF;
  74744. /**
  74745. * The BIN chunk of a binary glTF.
  74746. */
  74747. get bin(): Nullable<IDataBuffer>;
  74748. /**
  74749. * The parent file loader.
  74750. */
  74751. get parent(): GLTFFileLoader;
  74752. /**
  74753. * The Babylon scene when loading the asset.
  74754. */
  74755. get babylonScene(): Scene;
  74756. /**
  74757. * The root Babylon mesh when loading the asset.
  74758. */
  74759. get rootBabylonMesh(): Mesh;
  74760. /** @hidden */
  74761. constructor(parent: GLTFFileLoader);
  74762. /** @hidden */
  74763. dispose(): void;
  74764. /** @hidden */
  74765. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74766. meshes: AbstractMesh[];
  74767. particleSystems: IParticleSystem[];
  74768. skeletons: Skeleton[];
  74769. animationGroups: AnimationGroup[];
  74770. }>;
  74771. /** @hidden */
  74772. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74773. private _loadAsync;
  74774. private _loadData;
  74775. private _setupData;
  74776. private _loadExtensions;
  74777. private _checkExtensions;
  74778. private _setState;
  74779. private _createRootNode;
  74780. /**
  74781. * Loads a glTF scene.
  74782. * @param context The context when loading the asset
  74783. * @param scene The glTF scene property
  74784. * @returns A promise that resolves when the load is complete
  74785. */
  74786. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  74787. private _forEachPrimitive;
  74788. private _getMeshes;
  74789. private _getSkeletons;
  74790. private _getAnimationGroups;
  74791. private _startAnimations;
  74792. /**
  74793. * Loads a glTF node.
  74794. * @param context The context when loading the asset
  74795. * @param node The glTF node property
  74796. * @param assign A function called synchronously after parsing the glTF properties
  74797. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  74798. */
  74799. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  74800. private _loadMeshAsync;
  74801. /**
  74802. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74803. * @param context The context when loading the asset
  74804. * @param name The mesh name when loading the asset
  74805. * @param node The glTF node when loading the asset
  74806. * @param mesh The glTF mesh when loading the asset
  74807. * @param primitive The glTF mesh primitive property
  74808. * @param assign A function called synchronously after parsing the glTF properties
  74809. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74810. */
  74811. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74812. private _loadVertexDataAsync;
  74813. private _createMorphTargets;
  74814. private _loadMorphTargetsAsync;
  74815. private _loadMorphTargetVertexDataAsync;
  74816. private static _LoadTransform;
  74817. private _loadSkinAsync;
  74818. private _loadBones;
  74819. private _loadBone;
  74820. private _loadSkinInverseBindMatricesDataAsync;
  74821. private _updateBoneMatrices;
  74822. private _getNodeMatrix;
  74823. /**
  74824. * Loads a glTF camera.
  74825. * @param context The context when loading the asset
  74826. * @param camera The glTF camera property
  74827. * @param assign A function called synchronously after parsing the glTF properties
  74828. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  74829. */
  74830. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  74831. private _loadAnimationsAsync;
  74832. /**
  74833. * Loads a glTF animation.
  74834. * @param context The context when loading the asset
  74835. * @param animation The glTF animation property
  74836. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  74837. */
  74838. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  74839. /**
  74840. * @hidden Loads a glTF animation channel.
  74841. * @param context The context when loading the asset
  74842. * @param animationContext The context of the animation when loading the asset
  74843. * @param animation The glTF animation property
  74844. * @param channel The glTF animation channel property
  74845. * @param babylonAnimationGroup The babylon animation group property
  74846. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  74847. * @returns A void promise when the channel load is complete
  74848. */
  74849. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  74850. private _loadAnimationSamplerAsync;
  74851. private _loadBufferAsync;
  74852. /**
  74853. * Loads a glTF buffer view.
  74854. * @param context The context when loading the asset
  74855. * @param bufferView The glTF buffer view property
  74856. * @returns A promise that resolves with the loaded data when the load is complete
  74857. */
  74858. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  74859. private _loadAccessorAsync;
  74860. private _loadFloatAccessorAsync;
  74861. private _loadIndicesAccessorAsync;
  74862. private _loadVertexBufferViewAsync;
  74863. private _loadVertexAccessorAsync;
  74864. private _loadMaterialMetallicRoughnessPropertiesAsync;
  74865. /** @hidden */
  74866. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  74867. private _createDefaultMaterial;
  74868. /**
  74869. * Creates a Babylon material from a glTF material.
  74870. * @param context The context when loading the asset
  74871. * @param material The glTF material property
  74872. * @param babylonDrawMode The draw mode for the Babylon material
  74873. * @returns The Babylon material
  74874. */
  74875. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  74876. /**
  74877. * Loads properties from a glTF material into a Babylon material.
  74878. * @param context The context when loading the asset
  74879. * @param material The glTF material property
  74880. * @param babylonMaterial The Babylon material
  74881. * @returns A promise that resolves when the load is complete
  74882. */
  74883. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74884. /**
  74885. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  74886. * @param context The context when loading the asset
  74887. * @param material The glTF material property
  74888. * @param babylonMaterial The Babylon material
  74889. * @returns A promise that resolves when the load is complete
  74890. */
  74891. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74892. /**
  74893. * Loads the alpha properties from a glTF material into a Babylon material.
  74894. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  74895. * @param context The context when loading the asset
  74896. * @param material The glTF material property
  74897. * @param babylonMaterial The Babylon material
  74898. */
  74899. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  74900. /**
  74901. * Loads a glTF texture info.
  74902. * @param context The context when loading the asset
  74903. * @param textureInfo The glTF texture info property
  74904. * @param assign A function called synchronously after parsing the glTF properties
  74905. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  74906. */
  74907. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  74908. private _loadTextureAsync;
  74909. private _loadSampler;
  74910. /**
  74911. * Loads a glTF image.
  74912. * @param context The context when loading the asset
  74913. * @param image The glTF image property
  74914. * @returns A promise that resolves with the loaded data when the load is complete
  74915. */
  74916. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  74917. /**
  74918. * Loads a glTF uri.
  74919. * @param context The context when loading the asset
  74920. * @param property The glTF property associated with the uri
  74921. * @param uri The base64 or relative uri
  74922. * @returns A promise that resolves with the loaded data when the load is complete
  74923. */
  74924. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  74925. private _onProgress;
  74926. /**
  74927. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  74928. * @param babylonObject the Babylon object with metadata
  74929. * @param pointer the JSON pointer
  74930. */
  74931. static AddPointerMetadata(babylonObject: {
  74932. metadata: any;
  74933. }, pointer: string): void;
  74934. private static _GetTextureWrapMode;
  74935. private static _GetTextureSamplingMode;
  74936. private static _GetTypedArrayConstructor;
  74937. private static _GetTypedArray;
  74938. private static _GetNumComponents;
  74939. private static _ValidateUri;
  74940. private static _GetDrawMode;
  74941. private _compileMaterialsAsync;
  74942. private _compileShadowGeneratorsAsync;
  74943. private _forEachExtensions;
  74944. private _applyExtensions;
  74945. private _extensionsOnLoading;
  74946. private _extensionsOnReady;
  74947. private _extensionsLoadSceneAsync;
  74948. private _extensionsLoadNodeAsync;
  74949. private _extensionsLoadCameraAsync;
  74950. private _extensionsLoadVertexDataAsync;
  74951. private _extensionsLoadMeshPrimitiveAsync;
  74952. private _extensionsLoadMaterialAsync;
  74953. private _extensionsCreateMaterial;
  74954. private _extensionsLoadMaterialPropertiesAsync;
  74955. private _extensionsLoadTextureInfoAsync;
  74956. private _extensionsLoadAnimationAsync;
  74957. private _extensionsLoadSkinAsync;
  74958. private _extensionsLoadUriAsync;
  74959. private _extensionsLoadBufferViewAsync;
  74960. private _extensionsLoadBufferAsync;
  74961. /**
  74962. * Helper method called by a loader extension to load an glTF extension.
  74963. * @param context The context when loading the asset
  74964. * @param property The glTF property to load the extension from
  74965. * @param extensionName The name of the extension to load
  74966. * @param actionAsync The action to run
  74967. * @returns The promise returned by actionAsync or null if the extension does not exist
  74968. */
  74969. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74970. /**
  74971. * Helper method called by a loader extension to load a glTF extra.
  74972. * @param context The context when loading the asset
  74973. * @param property The glTF property to load the extra from
  74974. * @param extensionName The name of the extension to load
  74975. * @param actionAsync The action to run
  74976. * @returns The promise returned by actionAsync or null if the extra does not exist
  74977. */
  74978. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74979. /**
  74980. * Checks for presence of an extension.
  74981. * @param name The name of the extension to check
  74982. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  74983. */
  74984. isExtensionUsed(name: string): boolean;
  74985. /**
  74986. * Increments the indentation level and logs a message.
  74987. * @param message The message to log
  74988. */
  74989. logOpen(message: string): void;
  74990. /**
  74991. * Decrements the indentation level.
  74992. */
  74993. logClose(): void;
  74994. /**
  74995. * Logs a message
  74996. * @param message The message to log
  74997. */
  74998. log(message: string): void;
  74999. /**
  75000. * Starts a performance counter.
  75001. * @param counterName The name of the performance counter
  75002. */
  75003. startPerformanceCounter(counterName: string): void;
  75004. /**
  75005. * Ends a performance counter.
  75006. * @param counterName The name of the performance counter
  75007. */
  75008. endPerformanceCounter(counterName: string): void;
  75009. }
  75010. }
  75011. declare module BABYLON.GLTF2.Loader.Extensions {
  75012. /**
  75013. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75014. */
  75015. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75016. /**
  75017. * The name of this extension.
  75018. */
  75019. readonly name: string;
  75020. /**
  75021. * Defines whether this extension is enabled.
  75022. */
  75023. enabled: boolean;
  75024. private _loader;
  75025. private _lights?;
  75026. /** @hidden */
  75027. constructor(loader: GLTFLoader);
  75028. /** @hidden */
  75029. dispose(): void;
  75030. /** @hidden */
  75031. onLoading(): void;
  75032. /** @hidden */
  75033. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75034. private _loadLightAsync;
  75035. }
  75036. }
  75037. declare module BABYLON.GLTF2.Loader.Extensions {
  75038. /**
  75039. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75040. */
  75041. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75042. /**
  75043. * The name of this extension.
  75044. */
  75045. readonly name: string;
  75046. /**
  75047. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75048. */
  75049. dracoCompression?: DracoCompression;
  75050. /**
  75051. * Defines whether this extension is enabled.
  75052. */
  75053. enabled: boolean;
  75054. private _loader;
  75055. /** @hidden */
  75056. constructor(loader: GLTFLoader);
  75057. /** @hidden */
  75058. dispose(): void;
  75059. /** @hidden */
  75060. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75061. }
  75062. }
  75063. declare module BABYLON.GLTF2.Loader.Extensions {
  75064. /**
  75065. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75066. */
  75067. export class KHR_lights implements IGLTFLoaderExtension {
  75068. /**
  75069. * The name of this extension.
  75070. */
  75071. readonly name: string;
  75072. /**
  75073. * Defines whether this extension is enabled.
  75074. */
  75075. enabled: boolean;
  75076. private _loader;
  75077. private _lights?;
  75078. /** @hidden */
  75079. constructor(loader: GLTFLoader);
  75080. /** @hidden */
  75081. dispose(): void;
  75082. /** @hidden */
  75083. onLoading(): void;
  75084. /** @hidden */
  75085. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75086. }
  75087. }
  75088. declare module BABYLON.GLTF2.Loader.Extensions {
  75089. /**
  75090. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75091. */
  75092. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75093. /**
  75094. * The name of this extension.
  75095. */
  75096. readonly name: string;
  75097. /**
  75098. * Defines whether this extension is enabled.
  75099. */
  75100. enabled: boolean;
  75101. /**
  75102. * Defines a number that determines the order the extensions are applied.
  75103. */
  75104. order: number;
  75105. private _loader;
  75106. /** @hidden */
  75107. constructor(loader: GLTFLoader);
  75108. /** @hidden */
  75109. dispose(): void;
  75110. /** @hidden */
  75111. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75112. private _loadSpecularGlossinessPropertiesAsync;
  75113. }
  75114. }
  75115. declare module BABYLON.GLTF2.Loader.Extensions {
  75116. /**
  75117. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75118. */
  75119. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75120. /**
  75121. * The name of this extension.
  75122. */
  75123. readonly name: string;
  75124. /**
  75125. * Defines whether this extension is enabled.
  75126. */
  75127. enabled: boolean;
  75128. /**
  75129. * Defines a number that determines the order the extensions are applied.
  75130. */
  75131. order: number;
  75132. private _loader;
  75133. /** @hidden */
  75134. constructor(loader: GLTFLoader);
  75135. /** @hidden */
  75136. dispose(): void;
  75137. /** @hidden */
  75138. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75139. private _loadUnlitPropertiesAsync;
  75140. }
  75141. }
  75142. declare module BABYLON.GLTF2.Loader.Extensions {
  75143. /**
  75144. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75145. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75146. * !!! Experimental Extension Subject to Changes !!!
  75147. */
  75148. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75149. /**
  75150. * The name of this extension.
  75151. */
  75152. readonly name: string;
  75153. /**
  75154. * Defines whether this extension is enabled.
  75155. */
  75156. enabled: boolean;
  75157. /**
  75158. * Defines a number that determines the order the extensions are applied.
  75159. */
  75160. order: number;
  75161. private _loader;
  75162. /** @hidden */
  75163. constructor(loader: GLTFLoader);
  75164. /** @hidden */
  75165. dispose(): void;
  75166. /** @hidden */
  75167. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75168. private _loadClearCoatPropertiesAsync;
  75169. }
  75170. }
  75171. declare module BABYLON.GLTF2.Loader.Extensions {
  75172. /**
  75173. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75174. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75175. * !!! Experimental Extension Subject to Changes !!!
  75176. */
  75177. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75178. /**
  75179. * The name of this extension.
  75180. */
  75181. readonly name: string;
  75182. /**
  75183. * Defines whether this extension is enabled.
  75184. */
  75185. enabled: boolean;
  75186. /**
  75187. * Defines a number that determines the order the extensions are applied.
  75188. */
  75189. order: number;
  75190. private _loader;
  75191. /** @hidden */
  75192. constructor(loader: GLTFLoader);
  75193. /** @hidden */
  75194. dispose(): void;
  75195. /** @hidden */
  75196. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75197. private _loadSheenPropertiesAsync;
  75198. }
  75199. }
  75200. declare module BABYLON.GLTF2.Loader.Extensions {
  75201. /**
  75202. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75203. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75204. * !!! Experimental Extension Subject to Changes !!!
  75205. */
  75206. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75207. /**
  75208. * The name of this extension.
  75209. */
  75210. readonly name: string;
  75211. /**
  75212. * Defines whether this extension is enabled.
  75213. */
  75214. enabled: boolean;
  75215. /**
  75216. * Defines a number that determines the order the extensions are applied.
  75217. */
  75218. order: number;
  75219. private _loader;
  75220. /** @hidden */
  75221. constructor(loader: GLTFLoader);
  75222. /** @hidden */
  75223. dispose(): void;
  75224. /** @hidden */
  75225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75226. private _loadSpecularPropertiesAsync;
  75227. }
  75228. }
  75229. declare module BABYLON.GLTF2.Loader.Extensions {
  75230. /**
  75231. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75232. */
  75233. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75234. /**
  75235. * The name of this extension.
  75236. */
  75237. readonly name: string;
  75238. /**
  75239. * Defines whether this extension is enabled.
  75240. */
  75241. enabled: boolean;
  75242. /** @hidden */
  75243. constructor(loader: GLTFLoader);
  75244. /** @hidden */
  75245. dispose(): void;
  75246. }
  75247. }
  75248. declare module BABYLON.GLTF2.Loader.Extensions {
  75249. /**
  75250. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75251. */
  75252. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75253. /**
  75254. * The name of this extension.
  75255. */
  75256. readonly name: string;
  75257. /**
  75258. * Defines whether this extension is enabled.
  75259. */
  75260. enabled: boolean;
  75261. private _loader;
  75262. /** @hidden */
  75263. constructor(loader: GLTFLoader);
  75264. /** @hidden */
  75265. dispose(): void;
  75266. /** @hidden */
  75267. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75268. }
  75269. }
  75270. declare module BABYLON.GLTF2.Loader.Extensions {
  75271. /**
  75272. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75273. */
  75274. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75275. /**
  75276. * The name of this extension.
  75277. */
  75278. readonly name: string;
  75279. /**
  75280. * Defines whether this extension is enabled.
  75281. */
  75282. enabled: boolean;
  75283. private _loader;
  75284. private _clips;
  75285. private _emitters;
  75286. /** @hidden */
  75287. constructor(loader: GLTFLoader);
  75288. /** @hidden */
  75289. dispose(): void;
  75290. /** @hidden */
  75291. onLoading(): void;
  75292. /** @hidden */
  75293. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75294. /** @hidden */
  75295. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75296. /** @hidden */
  75297. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75298. private _loadClipAsync;
  75299. private _loadEmitterAsync;
  75300. private _getEventAction;
  75301. private _loadAnimationEventAsync;
  75302. }
  75303. }
  75304. declare module BABYLON.GLTF2.Loader.Extensions {
  75305. /**
  75306. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75307. */
  75308. export class MSFT_lod implements IGLTFLoaderExtension {
  75309. /**
  75310. * The name of this extension.
  75311. */
  75312. readonly name: string;
  75313. /**
  75314. * Defines whether this extension is enabled.
  75315. */
  75316. enabled: boolean;
  75317. /**
  75318. * Defines a number that determines the order the extensions are applied.
  75319. */
  75320. order: number;
  75321. /**
  75322. * Maximum number of LODs to load, starting from the lowest LOD.
  75323. */
  75324. maxLODsToLoad: number;
  75325. /**
  75326. * Observable raised when all node LODs of one level are loaded.
  75327. * The event data is the index of the loaded LOD starting from zero.
  75328. * Dispose the loader to cancel the loading of the next level of LODs.
  75329. */
  75330. onNodeLODsLoadedObservable: Observable<number>;
  75331. /**
  75332. * Observable raised when all material LODs of one level are loaded.
  75333. * The event data is the index of the loaded LOD starting from zero.
  75334. * Dispose the loader to cancel the loading of the next level of LODs.
  75335. */
  75336. onMaterialLODsLoadedObservable: Observable<number>;
  75337. private _loader;
  75338. private _nodeIndexLOD;
  75339. private _nodeSignalLODs;
  75340. private _nodePromiseLODs;
  75341. private _materialIndexLOD;
  75342. private _materialSignalLODs;
  75343. private _materialPromiseLODs;
  75344. private _indexLOD;
  75345. private _bufferLODs;
  75346. /** @hidden */
  75347. constructor(loader: GLTFLoader);
  75348. /** @hidden */
  75349. dispose(): void;
  75350. /** @hidden */
  75351. onReady(): void;
  75352. /** @hidden */
  75353. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75354. /** @hidden */
  75355. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75356. /** @hidden */
  75357. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75358. /** @hidden */
  75359. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75360. private _loadBufferLOD;
  75361. /**
  75362. * Gets an array of LOD properties from lowest to highest.
  75363. */
  75364. private _getLODs;
  75365. private _disposeUnusedMaterials;
  75366. }
  75367. }
  75368. declare module BABYLON.GLTF2.Loader.Extensions {
  75369. /** @hidden */
  75370. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  75371. readonly name: string;
  75372. enabled: boolean;
  75373. private _loader;
  75374. constructor(loader: GLTFLoader);
  75375. dispose(): void;
  75376. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75377. }
  75378. }
  75379. declare module BABYLON.GLTF2.Loader.Extensions {
  75380. /** @hidden */
  75381. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  75382. readonly name: string;
  75383. enabled: boolean;
  75384. private _loader;
  75385. constructor(loader: GLTFLoader);
  75386. dispose(): void;
  75387. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75388. }
  75389. }
  75390. declare module BABYLON.GLTF2.Loader.Extensions {
  75391. /**
  75392. * Store glTF extras (if present) in BJS objects' metadata
  75393. */
  75394. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  75395. /**
  75396. * The name of this extension.
  75397. */
  75398. readonly name: string;
  75399. /**
  75400. * Defines whether this extension is enabled.
  75401. */
  75402. enabled: boolean;
  75403. private _loader;
  75404. private _assignExtras;
  75405. /** @hidden */
  75406. constructor(loader: GLTFLoader);
  75407. /** @hidden */
  75408. dispose(): void;
  75409. /** @hidden */
  75410. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75411. /** @hidden */
  75412. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75413. /** @hidden */
  75414. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75415. }
  75416. }
  75417. declare module BABYLON {
  75418. /**
  75419. * Class reading and parsing the MTL file bundled with the obj file.
  75420. */
  75421. export class MTLFileLoader {
  75422. /**
  75423. * Invert Y-Axis of referenced textures on load
  75424. */
  75425. static INVERT_TEXTURE_Y: boolean;
  75426. /**
  75427. * All material loaded from the mtl will be set here
  75428. */
  75429. materials: StandardMaterial[];
  75430. /**
  75431. * This function will read the mtl file and create each material described inside
  75432. * This function could be improve by adding :
  75433. * -some component missing (Ni, Tf...)
  75434. * -including the specific options available
  75435. *
  75436. * @param scene defines the scene the material will be created in
  75437. * @param data defines the mtl data to parse
  75438. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  75439. */
  75440. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  75441. /**
  75442. * Gets the texture for the material.
  75443. *
  75444. * If the material is imported from input file,
  75445. * We sanitize the url to ensure it takes the textre from aside the material.
  75446. *
  75447. * @param rootUrl The root url to load from
  75448. * @param value The value stored in the mtl
  75449. * @return The Texture
  75450. */
  75451. private static _getTexture;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /**
  75456. * Options for loading OBJ/MTL files
  75457. */
  75458. type MeshLoadOptions = {
  75459. /**
  75460. * Defines if UVs are optimized by default during load.
  75461. */
  75462. OptimizeWithUV: boolean;
  75463. /**
  75464. * Defines custom scaling of UV coordinates of loaded meshes.
  75465. */
  75466. UVScaling: Vector2;
  75467. /**
  75468. * Invert model on y-axis (does a model scaling inversion)
  75469. */
  75470. InvertY: boolean;
  75471. /**
  75472. * Invert Y-Axis of referenced textures on load
  75473. */
  75474. InvertTextureY: boolean;
  75475. /**
  75476. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75477. */
  75478. ImportVertexColors: boolean;
  75479. /**
  75480. * Compute the normals for the model, even if normals are present in the file.
  75481. */
  75482. ComputeNormals: boolean;
  75483. /**
  75484. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75485. */
  75486. SkipMaterials: boolean;
  75487. /**
  75488. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75489. */
  75490. MaterialLoadingFailsSilently: boolean;
  75491. };
  75492. /**
  75493. * OBJ file type loader.
  75494. * This is a babylon scene loader plugin.
  75495. */
  75496. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75497. /**
  75498. * Defines if UVs are optimized by default during load.
  75499. */
  75500. static OPTIMIZE_WITH_UV: boolean;
  75501. /**
  75502. * Invert model on y-axis (does a model scaling inversion)
  75503. */
  75504. static INVERT_Y: boolean;
  75505. /**
  75506. * Invert Y-Axis of referenced textures on load
  75507. */
  75508. static get INVERT_TEXTURE_Y(): boolean;
  75509. static set INVERT_TEXTURE_Y(value: boolean);
  75510. /**
  75511. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75512. */
  75513. static IMPORT_VERTEX_COLORS: boolean;
  75514. /**
  75515. * Compute the normals for the model, even if normals are present in the file.
  75516. */
  75517. static COMPUTE_NORMALS: boolean;
  75518. /**
  75519. * Defines custom scaling of UV coordinates of loaded meshes.
  75520. */
  75521. static UV_SCALING: Vector2;
  75522. /**
  75523. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75524. */
  75525. static SKIP_MATERIALS: boolean;
  75526. /**
  75527. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75528. *
  75529. * Defaults to true for backwards compatibility.
  75530. */
  75531. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  75532. /**
  75533. * Defines the name of the plugin.
  75534. */
  75535. name: string;
  75536. /**
  75537. * Defines the extension the plugin is able to load.
  75538. */
  75539. extensions: string;
  75540. /** @hidden */
  75541. obj: RegExp;
  75542. /** @hidden */
  75543. group: RegExp;
  75544. /** @hidden */
  75545. mtllib: RegExp;
  75546. /** @hidden */
  75547. usemtl: RegExp;
  75548. /** @hidden */
  75549. smooth: RegExp;
  75550. /** @hidden */
  75551. vertexPattern: RegExp;
  75552. /** @hidden */
  75553. normalPattern: RegExp;
  75554. /** @hidden */
  75555. uvPattern: RegExp;
  75556. /** @hidden */
  75557. facePattern1: RegExp;
  75558. /** @hidden */
  75559. facePattern2: RegExp;
  75560. /** @hidden */
  75561. facePattern3: RegExp;
  75562. /** @hidden */
  75563. facePattern4: RegExp;
  75564. /** @hidden */
  75565. facePattern5: RegExp;
  75566. private _meshLoadOptions;
  75567. /**
  75568. * Creates loader for .OBJ files
  75569. *
  75570. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  75571. */
  75572. constructor(meshLoadOptions?: MeshLoadOptions);
  75573. private static get currentMeshLoadOptions();
  75574. /**
  75575. * Calls synchronously the MTL file attached to this obj.
  75576. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  75577. * Without this function materials are not displayed in the first frame (but displayed after).
  75578. * In consequence it is impossible to get material information in your HTML file
  75579. *
  75580. * @param url The URL of the MTL file
  75581. * @param rootUrl
  75582. * @param onSuccess Callback function to be called when the MTL file is loaded
  75583. * @private
  75584. */
  75585. private _loadMTL;
  75586. /**
  75587. * Instantiates a OBJ file loader plugin.
  75588. * @returns the created plugin
  75589. */
  75590. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  75591. /**
  75592. * If the data string can be loaded directly.
  75593. *
  75594. * @param data string containing the file data
  75595. * @returns if the data can be loaded directly
  75596. */
  75597. canDirectLoad(data: string): boolean;
  75598. /**
  75599. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  75600. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75601. * @param scene the scene the meshes should be added to
  75602. * @param data the OBJ data to load
  75603. * @param rootUrl root url to load from
  75604. * @param onProgress event that fires when loading progress has occured
  75605. * @param fileName Defines the name of the file to load
  75606. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75607. */
  75608. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75609. meshes: AbstractMesh[];
  75610. particleSystems: IParticleSystem[];
  75611. skeletons: Skeleton[];
  75612. animationGroups: AnimationGroup[];
  75613. }>;
  75614. /**
  75615. * Imports all objects from the loaded OBJ data and adds them to the scene
  75616. * @param scene the scene the objects should be added to
  75617. * @param data the OBJ data to load
  75618. * @param rootUrl root url to load from
  75619. * @param onProgress event that fires when loading progress has occured
  75620. * @param fileName Defines the name of the file to load
  75621. * @returns a promise which completes when objects have been loaded to the scene
  75622. */
  75623. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75624. /**
  75625. * Load into an asset container.
  75626. * @param scene The scene to load into
  75627. * @param data The data to import
  75628. * @param rootUrl The root url for scene and resources
  75629. * @param onProgress The callback when the load progresses
  75630. * @param fileName Defines the name of the file to load
  75631. * @returns The loaded asset container
  75632. */
  75633. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75634. /**
  75635. * Read the OBJ file and create an Array of meshes.
  75636. * Each mesh contains all information given by the OBJ and the MTL file.
  75637. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  75638. *
  75639. * @param meshesNames
  75640. * @param scene Scene The scene where are displayed the data
  75641. * @param data String The content of the obj file
  75642. * @param rootUrl String The path to the folder
  75643. * @returns Array<AbstractMesh>
  75644. * @private
  75645. */
  75646. private _parseSolid;
  75647. }
  75648. }
  75649. declare module BABYLON {
  75650. /**
  75651. * STL file type loader.
  75652. * This is a babylon scene loader plugin.
  75653. */
  75654. export class STLFileLoader implements ISceneLoaderPlugin {
  75655. /** @hidden */
  75656. solidPattern: RegExp;
  75657. /** @hidden */
  75658. facetsPattern: RegExp;
  75659. /** @hidden */
  75660. normalPattern: RegExp;
  75661. /** @hidden */
  75662. vertexPattern: RegExp;
  75663. /**
  75664. * Defines the name of the plugin.
  75665. */
  75666. name: string;
  75667. /**
  75668. * Defines the extensions the stl loader is able to load.
  75669. * force data to come in as an ArrayBuffer
  75670. * we'll convert to string if it looks like it's an ASCII .stl
  75671. */
  75672. extensions: ISceneLoaderPluginExtensions;
  75673. /**
  75674. * Import meshes into a scene.
  75675. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  75676. * @param scene The scene to import into
  75677. * @param data The data to import
  75678. * @param rootUrl The root url for scene and resources
  75679. * @param meshes The meshes array to import into
  75680. * @param particleSystems The particle systems array to import into
  75681. * @param skeletons The skeletons array to import into
  75682. * @param onError The callback when import fails
  75683. * @returns True if successful or false otherwise
  75684. */
  75685. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  75686. /**
  75687. * Load into a scene.
  75688. * @param scene The scene to load into
  75689. * @param data The data to import
  75690. * @param rootUrl The root url for scene and resources
  75691. * @param onError The callback when import fails
  75692. * @returns true if successful or false otherwise
  75693. */
  75694. load(scene: Scene, data: any, rootUrl: string): boolean;
  75695. /**
  75696. * Load into an asset container.
  75697. * @param scene The scene to load into
  75698. * @param data The data to import
  75699. * @param rootUrl The root url for scene and resources
  75700. * @param onError The callback when import fails
  75701. * @returns The loaded asset container
  75702. */
  75703. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  75704. private _isBinary;
  75705. private _parseBinary;
  75706. private _parseASCII;
  75707. }
  75708. }
  75709. declare module BABYLON {
  75710. /**
  75711. * Class for generating OBJ data from a Babylon scene.
  75712. */
  75713. export class OBJExport {
  75714. /**
  75715. * Exports the geometry of a Mesh array in .OBJ file format (text)
  75716. * @param mesh defines the list of meshes to serialize
  75717. * @param materials defines if materials should be exported
  75718. * @param matlibname defines the name of the associated mtl file
  75719. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  75720. * @returns the OBJ content
  75721. */
  75722. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  75723. /**
  75724. * Exports the material(s) of a mesh in .MTL file format (text)
  75725. * @param mesh defines the mesh to extract the material from
  75726. * @returns the mtl content
  75727. */
  75728. static MTL(mesh: Mesh): string;
  75729. }
  75730. }
  75731. declare module BABYLON {
  75732. /** @hidden */
  75733. export var __IGLTFExporterExtension: number;
  75734. /**
  75735. * Interface for extending the exporter
  75736. * @hidden
  75737. */
  75738. export interface IGLTFExporterExtension {
  75739. /**
  75740. * The name of this extension
  75741. */
  75742. readonly name: string;
  75743. /**
  75744. * Defines whether this extension is enabled
  75745. */
  75746. enabled: boolean;
  75747. /**
  75748. * Defines whether this extension is required
  75749. */
  75750. required: boolean;
  75751. }
  75752. }
  75753. declare module BABYLON.GLTF2.Exporter {
  75754. /** @hidden */
  75755. export var __IGLTFExporterExtensionV2: number;
  75756. /**
  75757. * Interface for a glTF exporter extension
  75758. * @hidden
  75759. */
  75760. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  75761. /**
  75762. * Define this method to modify the default behavior before exporting a texture
  75763. * @param context The context when loading the asset
  75764. * @param babylonTexture The Babylon.js texture
  75765. * @param mimeType The mime-type of the generated image
  75766. * @returns A promise that resolves with the exported texture
  75767. */
  75768. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  75769. /**
  75770. * Define this method to get notified when a texture info is created
  75771. * @param context The context when loading the asset
  75772. * @param textureInfo The glTF texture info
  75773. * @param babylonTexture The Babylon.js texture
  75774. */
  75775. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  75776. /**
  75777. * Define this method to modify the default behavior when exporting texture info
  75778. * @param context The context when loading the asset
  75779. * @param meshPrimitive glTF mesh primitive
  75780. * @param babylonSubMesh Babylon submesh
  75781. * @param binaryWriter glTF serializer binary writer instance
  75782. * @returns nullable IMeshPrimitive promise
  75783. */
  75784. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  75785. /**
  75786. * Define this method to modify the default behavior when exporting a node
  75787. * @param context The context when exporting the node
  75788. * @param node glTF node
  75789. * @param babylonNode BabylonJS node
  75790. * @returns nullable INode promise
  75791. */
  75792. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  75793. /**
  75794. * Define this method to modify the default behavior when exporting a material
  75795. * @param material glTF material
  75796. * @param babylonMaterial BabylonJS material
  75797. * @returns nullable IMaterial promise
  75798. */
  75799. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  75800. /**
  75801. * Define this method to return additional textures to export from a material
  75802. * @param material glTF material
  75803. * @param babylonMaterial BabylonJS material
  75804. * @returns List of textures
  75805. */
  75806. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  75807. /** Gets a boolean indicating that this extension was used */
  75808. wasUsed: boolean;
  75809. /** Gets a boolean indicating that this extension is required for the file to work */
  75810. required: boolean;
  75811. /**
  75812. * Called after the exporter state changes to EXPORTING
  75813. */
  75814. onExporting?(): void;
  75815. }
  75816. }
  75817. declare module BABYLON.GLTF2.Exporter {
  75818. /**
  75819. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  75820. * @hidden
  75821. */
  75822. export class _GLTFMaterialExporter {
  75823. /**
  75824. * Represents the dielectric specular values for R, G and B
  75825. */
  75826. private static readonly _DielectricSpecular;
  75827. /**
  75828. * Allows the maximum specular power to be defined for material calculations
  75829. */
  75830. private static readonly _MaxSpecularPower;
  75831. /**
  75832. * Mapping to store textures
  75833. */
  75834. private _textureMap;
  75835. /**
  75836. * Numeric tolerance value
  75837. */
  75838. private static readonly _Epsilon;
  75839. /**
  75840. * Reference to the glTF Exporter
  75841. */
  75842. private _exporter;
  75843. constructor(exporter: _Exporter);
  75844. /**
  75845. * Specifies if two colors are approximately equal in value
  75846. * @param color1 first color to compare to
  75847. * @param color2 second color to compare to
  75848. * @param epsilon threshold value
  75849. */
  75850. private static FuzzyEquals;
  75851. /**
  75852. * Gets the materials from a Babylon scene and converts them to glTF materials
  75853. * @param scene babylonjs scene
  75854. * @param mimeType texture mime type
  75855. * @param images array of images
  75856. * @param textures array of textures
  75857. * @param materials array of materials
  75858. * @param imageData mapping of texture names to base64 textures
  75859. * @param hasTextureCoords specifies if texture coordinates are present on the material
  75860. */
  75861. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  75862. /**
  75863. * Makes a copy of the glTF material without the texture parameters
  75864. * @param originalMaterial original glTF material
  75865. * @returns glTF material without texture parameters
  75866. */
  75867. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  75868. /**
  75869. * Specifies if the material has any texture parameters present
  75870. * @param material glTF Material
  75871. * @returns boolean specifying if texture parameters are present
  75872. */
  75873. _hasTexturesPresent(material: IMaterial): boolean;
  75874. /**
  75875. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  75876. * @param babylonStandardMaterial
  75877. * @returns glTF Metallic Roughness Material representation
  75878. */
  75879. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  75880. /**
  75881. * Computes the metallic factor
  75882. * @param diffuse diffused value
  75883. * @param specular specular value
  75884. * @param oneMinusSpecularStrength one minus the specular strength
  75885. * @returns metallic value
  75886. */
  75887. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  75888. /**
  75889. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  75890. * @param glTFMaterial glTF material
  75891. * @param babylonMaterial Babylon material
  75892. */
  75893. private static _SetAlphaMode;
  75894. /**
  75895. * Converts a Babylon Standard Material to a glTF Material
  75896. * @param babylonStandardMaterial BJS Standard Material
  75897. * @param mimeType mime type to use for the textures
  75898. * @param images array of glTF image interfaces
  75899. * @param textures array of glTF texture interfaces
  75900. * @param materials array of glTF material interfaces
  75901. * @param imageData map of image file name to data
  75902. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75903. */
  75904. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75905. private _finishMaterial;
  75906. /**
  75907. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75908. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  75909. * @param mimeType mime type to use for the textures
  75910. * @param images array of glTF image interfaces
  75911. * @param textures array of glTF texture interfaces
  75912. * @param materials array of glTF material interfaces
  75913. * @param imageData map of image file name to data
  75914. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75915. */
  75916. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75917. /**
  75918. * Converts an image typed array buffer to a base64 image
  75919. * @param buffer typed array buffer
  75920. * @param width width of the image
  75921. * @param height height of the image
  75922. * @param mimeType mimetype of the image
  75923. * @returns base64 image string
  75924. */
  75925. private _createBase64FromCanvasAsync;
  75926. /**
  75927. * Generates a white texture based on the specified width and height
  75928. * @param width width of the texture in pixels
  75929. * @param height height of the texture in pixels
  75930. * @param scene babylonjs scene
  75931. * @returns white texture
  75932. */
  75933. private _createWhiteTexture;
  75934. /**
  75935. * 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
  75936. * @param texture1 first texture to resize
  75937. * @param texture2 second texture to resize
  75938. * @param scene babylonjs scene
  75939. * @returns resized textures or null
  75940. */
  75941. private _resizeTexturesToSameDimensions;
  75942. /**
  75943. * Converts an array of pixels to a Float32Array
  75944. * Throws an error if the pixel format is not supported
  75945. * @param pixels - array buffer containing pixel values
  75946. * @returns Float32 of pixels
  75947. */
  75948. private _convertPixelArrayToFloat32;
  75949. /**
  75950. * Convert Specular Glossiness Textures to Metallic Roughness
  75951. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  75952. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  75953. * @param diffuseTexture texture used to store diffuse information
  75954. * @param specularGlossinessTexture texture used to store specular and glossiness information
  75955. * @param factors specular glossiness material factors
  75956. * @param mimeType the mime type to use for the texture
  75957. * @returns pbr metallic roughness interface or null
  75958. */
  75959. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  75960. /**
  75961. * Converts specular glossiness material properties to metallic roughness
  75962. * @param specularGlossiness interface with specular glossiness material properties
  75963. * @returns interface with metallic roughness material properties
  75964. */
  75965. private _convertSpecularGlossinessToMetallicRoughness;
  75966. /**
  75967. * Calculates the surface reflectance, independent of lighting conditions
  75968. * @param color Color source to calculate brightness from
  75969. * @returns number representing the perceived brightness, or zero if color is undefined
  75970. */
  75971. private _getPerceivedBrightness;
  75972. /**
  75973. * Returns the maximum color component value
  75974. * @param color
  75975. * @returns maximum color component value, or zero if color is null or undefined
  75976. */
  75977. private _getMaxComponent;
  75978. /**
  75979. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  75980. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75981. * @param mimeType mime type to use for the textures
  75982. * @param images array of glTF image interfaces
  75983. * @param textures array of glTF texture interfaces
  75984. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  75985. * @param imageData map of image file name to data
  75986. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75987. * @returns glTF PBR Metallic Roughness factors
  75988. */
  75989. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  75990. private _getGLTFTextureSampler;
  75991. private _getGLTFTextureWrapMode;
  75992. private _getGLTFTextureWrapModesSampler;
  75993. /**
  75994. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  75995. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75996. * @param mimeType mime type to use for the textures
  75997. * @param images array of glTF image interfaces
  75998. * @param textures array of glTF texture interfaces
  75999. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76000. * @param imageData map of image file name to data
  76001. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76002. * @returns glTF PBR Metallic Roughness factors
  76003. */
  76004. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76005. /**
  76006. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76007. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76008. * @param mimeType mime type to use for the textures
  76009. * @param images array of glTF image interfaces
  76010. * @param textures array of glTF texture interfaces
  76011. * @param materials array of glTF material interfaces
  76012. * @param imageData map of image file name to data
  76013. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76014. */
  76015. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76016. private setMetallicRoughnessPbrMaterial;
  76017. private getPixelsFromTexture;
  76018. /**
  76019. * Extracts a texture from a Babylon texture into file data and glTF data
  76020. * @param babylonTexture Babylon texture to extract
  76021. * @param mimeType Mime Type of the babylonTexture
  76022. * @return glTF texture info, or null if the texture format is not supported
  76023. */
  76024. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76025. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76026. /**
  76027. * Builds a texture from base64 string
  76028. * @param base64Texture base64 texture string
  76029. * @param baseTextureName Name to use for the texture
  76030. * @param mimeType image mime type for the texture
  76031. * @param images array of images
  76032. * @param textures array of textures
  76033. * @param imageData map of image data
  76034. * @returns glTF texture info, or null if the texture format is not supported
  76035. */
  76036. private _getTextureInfoFromBase64;
  76037. }
  76038. }
  76039. declare module BABYLON {
  76040. /**
  76041. * Class for holding and downloading glTF file data
  76042. */
  76043. export class GLTFData {
  76044. /**
  76045. * Object which contains the file name as the key and its data as the value
  76046. */
  76047. glTFFiles: {
  76048. [fileName: string]: string | Blob;
  76049. };
  76050. /**
  76051. * Initializes the glTF file object
  76052. */
  76053. constructor();
  76054. /**
  76055. * Downloads the glTF data as files based on their names and data
  76056. */
  76057. downloadFiles(): void;
  76058. }
  76059. }
  76060. declare module BABYLON {
  76061. /**
  76062. * Holds a collection of exporter options and parameters
  76063. */
  76064. export interface IExportOptions {
  76065. /**
  76066. * Function which indicates whether a babylon node should be exported or not
  76067. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76068. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76069. */
  76070. shouldExportNode?(node: Node): boolean;
  76071. /**
  76072. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76073. * @param metadata source metadata to read from
  76074. * @returns the data to store to glTF node extras
  76075. */
  76076. metadataSelector?(metadata: any): any;
  76077. /**
  76078. * The sample rate to bake animation curves
  76079. */
  76080. animationSampleRate?: number;
  76081. /**
  76082. * Begin serialization without waiting for the scene to be ready
  76083. */
  76084. exportWithoutWaitingForScene?: boolean;
  76085. }
  76086. /**
  76087. * Class for generating glTF data from a Babylon scene.
  76088. */
  76089. export class GLTF2Export {
  76090. /**
  76091. * Exports the geometry of the scene to .gltf file format asynchronously
  76092. * @param scene Babylon scene with scene hierarchy information
  76093. * @param filePrefix File prefix to use when generating the glTF file
  76094. * @param options Exporter options
  76095. * @returns Returns an object with a .gltf file and associates texture names
  76096. * as keys and their data and paths as values
  76097. */
  76098. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76099. private static _PreExportAsync;
  76100. private static _PostExportAsync;
  76101. /**
  76102. * Exports the geometry of the scene to .glb file format asychronously
  76103. * @param scene Babylon scene with scene hierarchy information
  76104. * @param filePrefix File prefix to use when generating glb file
  76105. * @param options Exporter options
  76106. * @returns Returns an object with a .glb filename as key and data as value
  76107. */
  76108. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76109. }
  76110. }
  76111. declare module BABYLON.GLTF2.Exporter {
  76112. /**
  76113. * @hidden
  76114. */
  76115. export class _GLTFUtilities {
  76116. /**
  76117. * Creates a buffer view based on the supplied arguments
  76118. * @param bufferIndex index value of the specified buffer
  76119. * @param byteOffset byte offset value
  76120. * @param byteLength byte length of the bufferView
  76121. * @param byteStride byte distance between conequential elements
  76122. * @param name name of the buffer view
  76123. * @returns bufferView for glTF
  76124. */
  76125. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76126. /**
  76127. * Creates an accessor based on the supplied arguments
  76128. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76129. * @param name The name of the accessor
  76130. * @param type The type of the accessor
  76131. * @param componentType The datatype of components in the attribute
  76132. * @param count The number of attributes referenced by this accessor
  76133. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76134. * @param min Minimum value of each component in this attribute
  76135. * @param max Maximum value of each component in this attribute
  76136. * @returns accessor for glTF
  76137. */
  76138. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76139. /**
  76140. * Calculates the minimum and maximum values of an array of position floats
  76141. * @param positions Positions array of a mesh
  76142. * @param vertexStart Starting vertex offset to calculate min and max values
  76143. * @param vertexCount Number of vertices to check for min and max values
  76144. * @returns min number array and max number array
  76145. */
  76146. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76147. min: number[];
  76148. max: number[];
  76149. };
  76150. /**
  76151. * Converts a new right-handed Vector3
  76152. * @param vector vector3 array
  76153. * @returns right-handed Vector3
  76154. */
  76155. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76156. /**
  76157. * Converts a Vector3 to right-handed
  76158. * @param vector Vector3 to convert to right-handed
  76159. */
  76160. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76161. /**
  76162. * Converts a three element number array to right-handed
  76163. * @param vector number array to convert to right-handed
  76164. */
  76165. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76166. /**
  76167. * Converts a new right-handed Vector3
  76168. * @param vector vector3 array
  76169. * @returns right-handed Vector3
  76170. */
  76171. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76172. /**
  76173. * Converts a Vector3 to right-handed
  76174. * @param vector Vector3 to convert to right-handed
  76175. */
  76176. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76177. /**
  76178. * Converts a three element number array to right-handed
  76179. * @param vector number array to convert to right-handed
  76180. */
  76181. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76182. /**
  76183. * Converts a Vector4 to right-handed
  76184. * @param vector Vector4 to convert to right-handed
  76185. */
  76186. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76187. /**
  76188. * Converts a Vector4 to right-handed
  76189. * @param vector Vector4 to convert to right-handed
  76190. */
  76191. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76192. /**
  76193. * Converts a Quaternion to right-handed
  76194. * @param quaternion Source quaternion to convert to right-handed
  76195. */
  76196. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76197. /**
  76198. * Converts a Quaternion to right-handed
  76199. * @param quaternion Source quaternion to convert to right-handed
  76200. */
  76201. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76202. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76203. }
  76204. }
  76205. declare module BABYLON.GLTF2.Exporter {
  76206. /**
  76207. * Converts Babylon Scene into glTF 2.0.
  76208. * @hidden
  76209. */
  76210. export class _Exporter {
  76211. /**
  76212. * Stores the glTF to export
  76213. */
  76214. _glTF: IGLTF;
  76215. /**
  76216. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76217. */
  76218. _bufferViews: IBufferView[];
  76219. /**
  76220. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76221. */
  76222. _accessors: IAccessor[];
  76223. /**
  76224. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76225. */
  76226. private _nodes;
  76227. /**
  76228. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76229. */
  76230. private _scenes;
  76231. /**
  76232. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76233. */
  76234. private _meshes;
  76235. /**
  76236. * Stores all the generated material information, which represents the appearance of each primitive
  76237. */
  76238. _materials: IMaterial[];
  76239. _materialMap: {
  76240. [materialID: number]: number;
  76241. };
  76242. /**
  76243. * Stores all the generated texture information, which is referenced by glTF materials
  76244. */
  76245. _textures: ITexture[];
  76246. /**
  76247. * Stores all the generated image information, which is referenced by glTF textures
  76248. */
  76249. _images: IImage[];
  76250. /**
  76251. * Stores all the texture samplers
  76252. */
  76253. _samplers: ISampler[];
  76254. /**
  76255. * Stores all the generated animation samplers, which is referenced by glTF animations
  76256. */
  76257. /**
  76258. * Stores the animations for glTF models
  76259. */
  76260. private _animations;
  76261. /**
  76262. * Stores the total amount of bytes stored in the glTF buffer
  76263. */
  76264. private _totalByteLength;
  76265. /**
  76266. * Stores a reference to the Babylon scene containing the source geometry and material information
  76267. */
  76268. _babylonScene: Scene;
  76269. /**
  76270. * Stores a map of the image data, where the key is the file name and the value
  76271. * is the image data
  76272. */
  76273. _imageData: {
  76274. [fileName: string]: {
  76275. data: Uint8Array;
  76276. mimeType: ImageMimeType;
  76277. };
  76278. };
  76279. /**
  76280. * Stores a map of the unique id of a node to its index in the node array
  76281. */
  76282. private _nodeMap;
  76283. /**
  76284. * Specifies if the Babylon scene should be converted to right-handed on export
  76285. */
  76286. _convertToRightHandedSystem: boolean;
  76287. /**
  76288. * Baked animation sample rate
  76289. */
  76290. private _animationSampleRate;
  76291. private _options;
  76292. private _localEngine;
  76293. _glTFMaterialExporter: _GLTFMaterialExporter;
  76294. private _extensions;
  76295. private static _ExtensionNames;
  76296. private static _ExtensionFactories;
  76297. private _applyExtension;
  76298. private _applyExtensions;
  76299. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76300. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76301. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76302. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76303. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76304. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76305. private _forEachExtensions;
  76306. private _extensionsOnExporting;
  76307. /**
  76308. * Load glTF serializer extensions
  76309. */
  76310. private _loadExtensions;
  76311. /**
  76312. * Creates a glTF Exporter instance, which can accept optional exporter options
  76313. * @param babylonScene Babylon scene object
  76314. * @param options Options to modify the behavior of the exporter
  76315. */
  76316. constructor(babylonScene: Scene, options?: IExportOptions);
  76317. dispose(): void;
  76318. /**
  76319. * Registers a glTF exporter extension
  76320. * @param name Name of the extension to export
  76321. * @param factory The factory function that creates the exporter extension
  76322. */
  76323. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76324. /**
  76325. * Un-registers an exporter extension
  76326. * @param name The name fo the exporter extension
  76327. * @returns A boolean indicating whether the extension has been un-registered
  76328. */
  76329. static UnregisterExtension(name: string): boolean;
  76330. /**
  76331. * Lazy load a local engine
  76332. */
  76333. _getLocalEngine(): Engine;
  76334. private reorderIndicesBasedOnPrimitiveMode;
  76335. /**
  76336. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76337. * clock-wise during export to glTF
  76338. * @param submesh BabylonJS submesh
  76339. * @param primitiveMode Primitive mode of the mesh
  76340. * @param sideOrientation the winding order of the submesh
  76341. * @param vertexBufferKind The type of vertex attribute
  76342. * @param meshAttributeArray The vertex attribute data
  76343. * @param byteOffset The offset to the binary data
  76344. * @param binaryWriter The binary data for the glTF file
  76345. */
  76346. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76347. /**
  76348. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76349. * clock-wise during export to glTF
  76350. * @param submesh BabylonJS submesh
  76351. * @param primitiveMode Primitive mode of the mesh
  76352. * @param sideOrientation the winding order of the submesh
  76353. * @param vertexBufferKind The type of vertex attribute
  76354. * @param meshAttributeArray The vertex attribute data
  76355. * @param byteOffset The offset to the binary data
  76356. * @param binaryWriter The binary data for the glTF file
  76357. */
  76358. private reorderTriangleFillMode;
  76359. /**
  76360. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76361. * clock-wise during export to glTF
  76362. * @param submesh BabylonJS submesh
  76363. * @param primitiveMode Primitive mode of the mesh
  76364. * @param sideOrientation the winding order of the submesh
  76365. * @param vertexBufferKind The type of vertex attribute
  76366. * @param meshAttributeArray The vertex attribute data
  76367. * @param byteOffset The offset to the binary data
  76368. * @param binaryWriter The binary data for the glTF file
  76369. */
  76370. private reorderTriangleStripDrawMode;
  76371. /**
  76372. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  76373. * clock-wise during export to glTF
  76374. * @param submesh BabylonJS submesh
  76375. * @param primitiveMode Primitive mode of the mesh
  76376. * @param sideOrientation the winding order of the submesh
  76377. * @param vertexBufferKind The type of vertex attribute
  76378. * @param meshAttributeArray The vertex attribute data
  76379. * @param byteOffset The offset to the binary data
  76380. * @param binaryWriter The binary data for the glTF file
  76381. */
  76382. private reorderTriangleFanMode;
  76383. /**
  76384. * Writes the vertex attribute data to binary
  76385. * @param vertices The vertices to write to the binary writer
  76386. * @param byteOffset The offset into the binary writer to overwrite binary data
  76387. * @param vertexAttributeKind The vertex attribute type
  76388. * @param meshAttributeArray The vertex attribute data
  76389. * @param binaryWriter The writer containing the binary data
  76390. */
  76391. private writeVertexAttributeData;
  76392. /**
  76393. * Writes mesh attribute data to a data buffer
  76394. * Returns the bytelength of the data
  76395. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  76396. * @param meshAttributeArray Array containing the attribute data
  76397. * @param binaryWriter The buffer to write the binary data to
  76398. * @param indices Used to specify the order of the vertex data
  76399. */
  76400. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  76401. /**
  76402. * Generates glTF json data
  76403. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  76404. * @param glTFPrefix Text to use when prefixing a glTF file
  76405. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  76406. * @returns json data as string
  76407. */
  76408. private generateJSON;
  76409. /**
  76410. * Generates data for .gltf and .bin files based on the glTF prefix string
  76411. * @param glTFPrefix Text to use when prefixing a glTF file
  76412. * @param dispose Dispose the exporter
  76413. * @returns GLTFData with glTF file data
  76414. */
  76415. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76416. /**
  76417. * Creates a binary buffer for glTF
  76418. * @returns array buffer for binary data
  76419. */
  76420. private _generateBinaryAsync;
  76421. /**
  76422. * Pads the number to a multiple of 4
  76423. * @param num number to pad
  76424. * @returns padded number
  76425. */
  76426. private _getPadding;
  76427. /**
  76428. * @hidden
  76429. */
  76430. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76431. /**
  76432. * Sets the TRS for each node
  76433. * @param node glTF Node for storing the transformation data
  76434. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  76435. */
  76436. private setNodeTransformation;
  76437. private getVertexBufferFromMesh;
  76438. /**
  76439. * Creates a bufferview based on the vertices type for the Babylon mesh
  76440. * @param kind Indicates the type of vertices data
  76441. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  76442. * @param binaryWriter The buffer to write the bufferview data to
  76443. */
  76444. private createBufferViewKind;
  76445. /**
  76446. * The primitive mode of the Babylon mesh
  76447. * @param babylonMesh The BabylonJS mesh
  76448. */
  76449. private getMeshPrimitiveMode;
  76450. /**
  76451. * Sets the primitive mode of the glTF mesh primitive
  76452. * @param meshPrimitive glTF mesh primitive
  76453. * @param primitiveMode The primitive mode
  76454. */
  76455. private setPrimitiveMode;
  76456. /**
  76457. * Sets the vertex attribute accessor based of the glTF mesh primitive
  76458. * @param meshPrimitive glTF mesh primitive
  76459. * @param attributeKind vertex attribute
  76460. * @returns boolean specifying if uv coordinates are present
  76461. */
  76462. private setAttributeKind;
  76463. /**
  76464. * Sets data for the primitive attributes of each submesh
  76465. * @param mesh glTF Mesh object to store the primitive attribute information
  76466. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  76467. * @param binaryWriter Buffer to write the attribute data to
  76468. */
  76469. private setPrimitiveAttributesAsync;
  76470. /**
  76471. * Creates a glTF scene based on the array of meshes
  76472. * Returns the the total byte offset
  76473. * @param babylonScene Babylon scene to get the mesh data from
  76474. * @param binaryWriter Buffer to write binary data to
  76475. */
  76476. private createSceneAsync;
  76477. /**
  76478. * Creates a mapping of Node unique id to node index and handles animations
  76479. * @param babylonScene Babylon Scene
  76480. * @param nodes Babylon transform nodes
  76481. * @param binaryWriter Buffer to write binary data to
  76482. * @returns Node mapping of unique id to index
  76483. */
  76484. private createNodeMapAndAnimationsAsync;
  76485. /**
  76486. * Creates a glTF node from a Babylon mesh
  76487. * @param babylonMesh Source Babylon mesh
  76488. * @param binaryWriter Buffer for storing geometry data
  76489. * @returns glTF node
  76490. */
  76491. private createNodeAsync;
  76492. }
  76493. /**
  76494. * @hidden
  76495. *
  76496. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  76497. */
  76498. export class _BinaryWriter {
  76499. /**
  76500. * Array buffer which stores all binary data
  76501. */
  76502. private _arrayBuffer;
  76503. /**
  76504. * View of the array buffer
  76505. */
  76506. private _dataView;
  76507. /**
  76508. * byte offset of data in array buffer
  76509. */
  76510. private _byteOffset;
  76511. /**
  76512. * Initialize binary writer with an initial byte length
  76513. * @param byteLength Initial byte length of the array buffer
  76514. */
  76515. constructor(byteLength: number);
  76516. /**
  76517. * Resize the array buffer to the specified byte length
  76518. * @param byteLength
  76519. */
  76520. private resizeBuffer;
  76521. /**
  76522. * Get an array buffer with the length of the byte offset
  76523. * @returns ArrayBuffer resized to the byte offset
  76524. */
  76525. getArrayBuffer(): ArrayBuffer;
  76526. /**
  76527. * Get the byte offset of the array buffer
  76528. * @returns byte offset
  76529. */
  76530. getByteOffset(): number;
  76531. /**
  76532. * Stores an UInt8 in the array buffer
  76533. * @param entry
  76534. * @param byteOffset If defined, specifies where to set the value as an offset.
  76535. */
  76536. setUInt8(entry: number, byteOffset?: number): void;
  76537. /**
  76538. * Gets an UInt32 in the array buffer
  76539. * @param entry
  76540. * @param byteOffset If defined, specifies where to set the value as an offset.
  76541. */
  76542. getUInt32(byteOffset: number): number;
  76543. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76544. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76545. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76546. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76547. /**
  76548. * Stores a Float32 in the array buffer
  76549. * @param entry
  76550. */
  76551. setFloat32(entry: number, byteOffset?: number): void;
  76552. /**
  76553. * Stores an UInt32 in the array buffer
  76554. * @param entry
  76555. * @param byteOffset If defined, specifies where to set the value as an offset.
  76556. */
  76557. setUInt32(entry: number, byteOffset?: number): void;
  76558. }
  76559. }
  76560. declare module BABYLON.GLTF2.Exporter {
  76561. /**
  76562. * @hidden
  76563. * Interface to store animation data.
  76564. */
  76565. export interface _IAnimationData {
  76566. /**
  76567. * Keyframe data.
  76568. */
  76569. inputs: number[];
  76570. /**
  76571. * Value data.
  76572. */
  76573. outputs: number[][];
  76574. /**
  76575. * Animation interpolation data.
  76576. */
  76577. samplerInterpolation: AnimationSamplerInterpolation;
  76578. /**
  76579. * Minimum keyframe value.
  76580. */
  76581. inputsMin: number;
  76582. /**
  76583. * Maximum keyframe value.
  76584. */
  76585. inputsMax: number;
  76586. }
  76587. /**
  76588. * @hidden
  76589. */
  76590. export interface _IAnimationInfo {
  76591. /**
  76592. * The target channel for the animation
  76593. */
  76594. animationChannelTargetPath: AnimationChannelTargetPath;
  76595. /**
  76596. * The glTF accessor type for the data.
  76597. */
  76598. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  76599. /**
  76600. * Specifies if quaternions should be used.
  76601. */
  76602. useQuaternion: boolean;
  76603. }
  76604. /**
  76605. * @hidden
  76606. * Utility class for generating glTF animation data from BabylonJS.
  76607. */
  76608. export class _GLTFAnimation {
  76609. /**
  76610. * @ignore
  76611. *
  76612. * Creates glTF channel animation from BabylonJS animation.
  76613. * @param babylonTransformNode - BabylonJS mesh.
  76614. * @param animation - animation.
  76615. * @param animationChannelTargetPath - The target animation channel.
  76616. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  76617. * @param useQuaternion - Specifies if quaternions are used.
  76618. * @returns nullable IAnimationData
  76619. */
  76620. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  76621. private static _DeduceAnimationInfo;
  76622. /**
  76623. * @ignore
  76624. * Create node animations from the transform node animations
  76625. * @param babylonNode
  76626. * @param runtimeGLTFAnimation
  76627. * @param idleGLTFAnimations
  76628. * @param nodeMap
  76629. * @param nodes
  76630. * @param binaryWriter
  76631. * @param bufferViews
  76632. * @param accessors
  76633. * @param convertToRightHandedSystem
  76634. */
  76635. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  76636. [key: number]: number;
  76637. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76638. /**
  76639. * @ignore
  76640. * Create node animations from the animation groups
  76641. * @param babylonScene
  76642. * @param glTFAnimations
  76643. * @param nodeMap
  76644. * @param nodes
  76645. * @param binaryWriter
  76646. * @param bufferViews
  76647. * @param accessors
  76648. * @param convertToRightHandedSystem
  76649. */
  76650. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  76651. [key: number]: number;
  76652. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76653. private static AddAnimation;
  76654. /**
  76655. * Create a baked animation
  76656. * @param babylonTransformNode BabylonJS mesh
  76657. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  76658. * @param animationChannelTargetPath animation target channel
  76659. * @param minFrame minimum animation frame
  76660. * @param maxFrame maximum animation frame
  76661. * @param fps frames per second of the animation
  76662. * @param inputs input key frames of the animation
  76663. * @param outputs output key frame data of the animation
  76664. * @param convertToRightHandedSystem converts the values to right-handed
  76665. * @param useQuaternion specifies if quaternions should be used
  76666. */
  76667. private static _CreateBakedAnimation;
  76668. private static _ConvertFactorToVector3OrQuaternion;
  76669. private static _SetInterpolatedValue;
  76670. /**
  76671. * Creates linear animation from the animation key frames
  76672. * @param babylonTransformNode BabylonJS mesh
  76673. * @param animation BabylonJS animation
  76674. * @param animationChannelTargetPath The target animation channel
  76675. * @param frameDelta The difference between the last and first frame of the animation
  76676. * @param inputs Array to store the key frame times
  76677. * @param outputs Array to store the key frame data
  76678. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76679. * @param useQuaternion Specifies if quaternions are used in the animation
  76680. */
  76681. private static _CreateLinearOrStepAnimation;
  76682. /**
  76683. * Creates cubic spline animation from the animation key frames
  76684. * @param babylonTransformNode BabylonJS mesh
  76685. * @param animation BabylonJS animation
  76686. * @param animationChannelTargetPath The target animation channel
  76687. * @param frameDelta The difference between the last and first frame of the animation
  76688. * @param inputs Array to store the key frame times
  76689. * @param outputs Array to store the key frame data
  76690. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76691. * @param useQuaternion Specifies if quaternions are used in the animation
  76692. */
  76693. private static _CreateCubicSplineAnimation;
  76694. private static _GetBasePositionRotationOrScale;
  76695. /**
  76696. * Adds a key frame value
  76697. * @param keyFrame
  76698. * @param animation
  76699. * @param outputs
  76700. * @param animationChannelTargetPath
  76701. * @param basePositionRotationOrScale
  76702. * @param convertToRightHandedSystem
  76703. * @param useQuaternion
  76704. */
  76705. private static _AddKeyframeValue;
  76706. /**
  76707. * Determine the interpolation based on the key frames
  76708. * @param keyFrames
  76709. * @param animationChannelTargetPath
  76710. * @param useQuaternion
  76711. */
  76712. private static _DeduceInterpolation;
  76713. /**
  76714. * Adds an input tangent or output tangent to the output data
  76715. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  76716. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  76717. * @param outputs The animation data by keyframe
  76718. * @param animationChannelTargetPath The target animation channel
  76719. * @param interpolation The interpolation type
  76720. * @param keyFrame The key frame with the animation data
  76721. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  76722. * @param useQuaternion Specifies if quaternions are used
  76723. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  76724. */
  76725. private static AddSplineTangent;
  76726. /**
  76727. * Get the minimum and maximum key frames' frame values
  76728. * @param keyFrames animation key frames
  76729. * @returns the minimum and maximum key frame value
  76730. */
  76731. private static calculateMinMaxKeyFrames;
  76732. }
  76733. }
  76734. declare module BABYLON.GLTF2.Exporter {
  76735. /** @hidden */
  76736. export var textureTransformPixelShader: {
  76737. name: string;
  76738. shader: string;
  76739. };
  76740. }
  76741. declare module BABYLON.GLTF2.Exporter.Extensions {
  76742. /**
  76743. * @hidden
  76744. */
  76745. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  76746. private _recordedTextures;
  76747. /** Name of this extension */
  76748. readonly name: string;
  76749. /** Defines whether this extension is enabled */
  76750. enabled: boolean;
  76751. /** Defines whether this extension is required */
  76752. required: boolean;
  76753. /** Reference to the glTF exporter */
  76754. private _wasUsed;
  76755. constructor(exporter: _Exporter);
  76756. dispose(): void;
  76757. /** @hidden */
  76758. get wasUsed(): boolean;
  76759. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76760. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76761. /**
  76762. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  76763. * @param babylonTexture
  76764. * @param offset
  76765. * @param rotation
  76766. * @param scale
  76767. * @param scene
  76768. */
  76769. private _textureTransformTextureAsync;
  76770. }
  76771. }
  76772. declare module BABYLON.GLTF2.Exporter.Extensions {
  76773. /**
  76774. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  76775. */
  76776. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  76777. /** The name of this extension. */
  76778. readonly name: string;
  76779. /** Defines whether this extension is enabled. */
  76780. enabled: boolean;
  76781. /** Defines whether this extension is required */
  76782. required: boolean;
  76783. /** Reference to the glTF exporter */
  76784. private _exporter;
  76785. private _lights;
  76786. /** @hidden */
  76787. constructor(exporter: _Exporter);
  76788. /** @hidden */
  76789. dispose(): void;
  76790. /** @hidden */
  76791. get wasUsed(): boolean;
  76792. /** @hidden */
  76793. onExporting(): void;
  76794. /**
  76795. * Define this method to modify the default behavior when exporting a node
  76796. * @param context The context when exporting the node
  76797. * @param node glTF node
  76798. * @param babylonNode BabylonJS node
  76799. * @returns nullable INode promise
  76800. */
  76801. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76802. }
  76803. }
  76804. declare module BABYLON.GLTF2.Exporter.Extensions {
  76805. /**
  76806. * @hidden
  76807. */
  76808. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  76809. /** Name of this extension */
  76810. readonly name: string;
  76811. /** Defines whether this extension is enabled */
  76812. enabled: boolean;
  76813. /** Defines whether this extension is required */
  76814. required: boolean;
  76815. /** Reference to the glTF exporter */
  76816. private _textureInfos;
  76817. private _exportedTextures;
  76818. private _wasUsed;
  76819. constructor(exporter: _Exporter);
  76820. dispose(): void;
  76821. /** @hidden */
  76822. get wasUsed(): boolean;
  76823. private _getTextureIndex;
  76824. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76825. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76826. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76827. }
  76828. }
  76829. declare module BABYLON {
  76830. /**
  76831. * Class for generating STL data from a Babylon scene.
  76832. */
  76833. export class STLExport {
  76834. /**
  76835. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  76836. * @param meshes list defines the mesh to serialize
  76837. * @param download triggers the automatic download of the file.
  76838. * @param fileName changes the downloads fileName.
  76839. * @param binary changes the STL to a binary type.
  76840. * @param isLittleEndian toggle for binary type exporter.
  76841. * @returns the STL as UTF8 string
  76842. */
  76843. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  76844. }
  76845. }
  76846. declare module "babylonjs-gltf2interface" {
  76847. export = BABYLON.GLTF2;
  76848. }
  76849. /**
  76850. * Module for glTF 2.0 Interface
  76851. */
  76852. declare module BABYLON.GLTF2 {
  76853. /**
  76854. * The datatype of the components in the attribute
  76855. */
  76856. const enum AccessorComponentType {
  76857. /**
  76858. * Byte
  76859. */
  76860. BYTE = 5120,
  76861. /**
  76862. * Unsigned Byte
  76863. */
  76864. UNSIGNED_BYTE = 5121,
  76865. /**
  76866. * Short
  76867. */
  76868. SHORT = 5122,
  76869. /**
  76870. * Unsigned Short
  76871. */
  76872. UNSIGNED_SHORT = 5123,
  76873. /**
  76874. * Unsigned Int
  76875. */
  76876. UNSIGNED_INT = 5125,
  76877. /**
  76878. * Float
  76879. */
  76880. FLOAT = 5126,
  76881. }
  76882. /**
  76883. * Specifies if the attirbute is a scalar, vector, or matrix
  76884. */
  76885. const enum AccessorType {
  76886. /**
  76887. * Scalar
  76888. */
  76889. SCALAR = "SCALAR",
  76890. /**
  76891. * Vector2
  76892. */
  76893. VEC2 = "VEC2",
  76894. /**
  76895. * Vector3
  76896. */
  76897. VEC3 = "VEC3",
  76898. /**
  76899. * Vector4
  76900. */
  76901. VEC4 = "VEC4",
  76902. /**
  76903. * Matrix2x2
  76904. */
  76905. MAT2 = "MAT2",
  76906. /**
  76907. * Matrix3x3
  76908. */
  76909. MAT3 = "MAT3",
  76910. /**
  76911. * Matrix4x4
  76912. */
  76913. MAT4 = "MAT4",
  76914. }
  76915. /**
  76916. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  76917. */
  76918. const enum AnimationChannelTargetPath {
  76919. /**
  76920. * Translation
  76921. */
  76922. TRANSLATION = "translation",
  76923. /**
  76924. * Rotation
  76925. */
  76926. ROTATION = "rotation",
  76927. /**
  76928. * Scale
  76929. */
  76930. SCALE = "scale",
  76931. /**
  76932. * Weights
  76933. */
  76934. WEIGHTS = "weights",
  76935. }
  76936. /**
  76937. * Interpolation algorithm
  76938. */
  76939. const enum AnimationSamplerInterpolation {
  76940. /**
  76941. * The animated values are linearly interpolated between keyframes
  76942. */
  76943. LINEAR = "LINEAR",
  76944. /**
  76945. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  76946. */
  76947. STEP = "STEP",
  76948. /**
  76949. * The animation's interpolation is computed using a cubic spline with specified tangents
  76950. */
  76951. CUBICSPLINE = "CUBICSPLINE",
  76952. }
  76953. /**
  76954. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  76955. */
  76956. const enum CameraType {
  76957. /**
  76958. * A perspective camera containing properties to create a perspective projection matrix
  76959. */
  76960. PERSPECTIVE = "perspective",
  76961. /**
  76962. * An orthographic camera containing properties to create an orthographic projection matrix
  76963. */
  76964. ORTHOGRAPHIC = "orthographic",
  76965. }
  76966. /**
  76967. * The mime-type of the image
  76968. */
  76969. const enum ImageMimeType {
  76970. /**
  76971. * JPEG Mime-type
  76972. */
  76973. JPEG = "image/jpeg",
  76974. /**
  76975. * PNG Mime-type
  76976. */
  76977. PNG = "image/png",
  76978. }
  76979. /**
  76980. * The alpha rendering mode of the material
  76981. */
  76982. const enum MaterialAlphaMode {
  76983. /**
  76984. * The alpha value is ignored and the rendered output is fully opaque
  76985. */
  76986. OPAQUE = "OPAQUE",
  76987. /**
  76988. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  76989. */
  76990. MASK = "MASK",
  76991. /**
  76992. * 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)
  76993. */
  76994. BLEND = "BLEND",
  76995. }
  76996. /**
  76997. * The type of the primitives to render
  76998. */
  76999. const enum MeshPrimitiveMode {
  77000. /**
  77001. * Points
  77002. */
  77003. POINTS = 0,
  77004. /**
  77005. * Lines
  77006. */
  77007. LINES = 1,
  77008. /**
  77009. * Line Loop
  77010. */
  77011. LINE_LOOP = 2,
  77012. /**
  77013. * Line Strip
  77014. */
  77015. LINE_STRIP = 3,
  77016. /**
  77017. * Triangles
  77018. */
  77019. TRIANGLES = 4,
  77020. /**
  77021. * Triangle Strip
  77022. */
  77023. TRIANGLE_STRIP = 5,
  77024. /**
  77025. * Triangle Fan
  77026. */
  77027. TRIANGLE_FAN = 6,
  77028. }
  77029. /**
  77030. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77031. */
  77032. const enum TextureMagFilter {
  77033. /**
  77034. * Nearest
  77035. */
  77036. NEAREST = 9728,
  77037. /**
  77038. * Linear
  77039. */
  77040. LINEAR = 9729,
  77041. }
  77042. /**
  77043. * Minification filter. All valid values correspond to WebGL enums
  77044. */
  77045. const enum TextureMinFilter {
  77046. /**
  77047. * Nearest
  77048. */
  77049. NEAREST = 9728,
  77050. /**
  77051. * Linear
  77052. */
  77053. LINEAR = 9729,
  77054. /**
  77055. * Nearest Mip-Map Nearest
  77056. */
  77057. NEAREST_MIPMAP_NEAREST = 9984,
  77058. /**
  77059. * Linear Mipmap Nearest
  77060. */
  77061. LINEAR_MIPMAP_NEAREST = 9985,
  77062. /**
  77063. * Nearest Mipmap Linear
  77064. */
  77065. NEAREST_MIPMAP_LINEAR = 9986,
  77066. /**
  77067. * Linear Mipmap Linear
  77068. */
  77069. LINEAR_MIPMAP_LINEAR = 9987,
  77070. }
  77071. /**
  77072. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77073. */
  77074. const enum TextureWrapMode {
  77075. /**
  77076. * Clamp to Edge
  77077. */
  77078. CLAMP_TO_EDGE = 33071,
  77079. /**
  77080. * Mirrored Repeat
  77081. */
  77082. MIRRORED_REPEAT = 33648,
  77083. /**
  77084. * Repeat
  77085. */
  77086. REPEAT = 10497,
  77087. }
  77088. /**
  77089. * glTF Property
  77090. */
  77091. interface IProperty {
  77092. /**
  77093. * Dictionary object with extension-specific objects
  77094. */
  77095. extensions?: {
  77096. [key: string]: any;
  77097. };
  77098. /**
  77099. * Application-Specific data
  77100. */
  77101. extras?: any;
  77102. }
  77103. /**
  77104. * glTF Child of Root Property
  77105. */
  77106. interface IChildRootProperty extends IProperty {
  77107. /**
  77108. * The user-defined name of this object
  77109. */
  77110. name?: string;
  77111. }
  77112. /**
  77113. * Indices of those attributes that deviate from their initialization value
  77114. */
  77115. interface IAccessorSparseIndices extends IProperty {
  77116. /**
  77117. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77118. */
  77119. bufferView: number;
  77120. /**
  77121. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77122. */
  77123. byteOffset?: number;
  77124. /**
  77125. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77126. */
  77127. componentType: AccessorComponentType;
  77128. }
  77129. /**
  77130. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77131. */
  77132. interface IAccessorSparseValues extends IProperty {
  77133. /**
  77134. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77135. */
  77136. bufferView: number;
  77137. /**
  77138. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77139. */
  77140. byteOffset?: number;
  77141. }
  77142. /**
  77143. * Sparse storage of attributes that deviate from their initialization value
  77144. */
  77145. interface IAccessorSparse extends IProperty {
  77146. /**
  77147. * The number of attributes encoded in this sparse accessor
  77148. */
  77149. count: number;
  77150. /**
  77151. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77152. */
  77153. indices: IAccessorSparseIndices;
  77154. /**
  77155. * 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
  77156. */
  77157. values: IAccessorSparseValues;
  77158. }
  77159. /**
  77160. * 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
  77161. */
  77162. interface IAccessor extends IChildRootProperty {
  77163. /**
  77164. * The index of the bufferview
  77165. */
  77166. bufferView?: number;
  77167. /**
  77168. * The offset relative to the start of the bufferView in bytes
  77169. */
  77170. byteOffset?: number;
  77171. /**
  77172. * The datatype of components in the attribute
  77173. */
  77174. componentType: AccessorComponentType;
  77175. /**
  77176. * Specifies whether integer data values should be normalized
  77177. */
  77178. normalized?: boolean;
  77179. /**
  77180. * The number of attributes referenced by this accessor
  77181. */
  77182. count: number;
  77183. /**
  77184. * Specifies if the attribute is a scalar, vector, or matrix
  77185. */
  77186. type: AccessorType;
  77187. /**
  77188. * Maximum value of each component in this attribute
  77189. */
  77190. max?: number[];
  77191. /**
  77192. * Minimum value of each component in this attribute
  77193. */
  77194. min?: number[];
  77195. /**
  77196. * Sparse storage of attributes that deviate from their initialization value
  77197. */
  77198. sparse?: IAccessorSparse;
  77199. }
  77200. /**
  77201. * Targets an animation's sampler at a node's property
  77202. */
  77203. interface IAnimationChannel extends IProperty {
  77204. /**
  77205. * The index of a sampler in this animation used to compute the value for the target
  77206. */
  77207. sampler: number;
  77208. /**
  77209. * The index of the node and TRS property to target
  77210. */
  77211. target: IAnimationChannelTarget;
  77212. }
  77213. /**
  77214. * The index of the node and TRS property that an animation channel targets
  77215. */
  77216. interface IAnimationChannelTarget extends IProperty {
  77217. /**
  77218. * The index of the node to target
  77219. */
  77220. node: number;
  77221. /**
  77222. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77223. */
  77224. path: AnimationChannelTargetPath;
  77225. }
  77226. /**
  77227. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77228. */
  77229. interface IAnimationSampler extends IProperty {
  77230. /**
  77231. * The index of an accessor containing keyframe input values, e.g., time
  77232. */
  77233. input: number;
  77234. /**
  77235. * Interpolation algorithm
  77236. */
  77237. interpolation?: AnimationSamplerInterpolation;
  77238. /**
  77239. * The index of an accessor, containing keyframe output values
  77240. */
  77241. output: number;
  77242. }
  77243. /**
  77244. * A keyframe animation
  77245. */
  77246. interface IAnimation extends IChildRootProperty {
  77247. /**
  77248. * An array of channels, each of which targets an animation's sampler at a node's property
  77249. */
  77250. channels: IAnimationChannel[];
  77251. /**
  77252. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77253. */
  77254. samplers: IAnimationSampler[];
  77255. }
  77256. /**
  77257. * Metadata about the glTF asset
  77258. */
  77259. interface IAsset extends IChildRootProperty {
  77260. /**
  77261. * A copyright message suitable for display to credit the content creator
  77262. */
  77263. copyright?: string;
  77264. /**
  77265. * Tool that generated this glTF model. Useful for debugging
  77266. */
  77267. generator?: string;
  77268. /**
  77269. * The glTF version that this asset targets
  77270. */
  77271. version: string;
  77272. /**
  77273. * The minimum glTF version that this asset targets
  77274. */
  77275. minVersion?: string;
  77276. }
  77277. /**
  77278. * A buffer points to binary geometry, animation, or skins
  77279. */
  77280. interface IBuffer extends IChildRootProperty {
  77281. /**
  77282. * 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
  77283. */
  77284. uri?: string;
  77285. /**
  77286. * The length of the buffer in bytes
  77287. */
  77288. byteLength: number;
  77289. }
  77290. /**
  77291. * A view into a buffer generally representing a subset of the buffer
  77292. */
  77293. interface IBufferView extends IChildRootProperty {
  77294. /**
  77295. * The index of the buffer
  77296. */
  77297. buffer: number;
  77298. /**
  77299. * The offset into the buffer in bytes
  77300. */
  77301. byteOffset?: number;
  77302. /**
  77303. * The lenth of the bufferView in bytes
  77304. */
  77305. byteLength: number;
  77306. /**
  77307. * The stride, in bytes
  77308. */
  77309. byteStride?: number;
  77310. }
  77311. /**
  77312. * An orthographic camera containing properties to create an orthographic projection matrix
  77313. */
  77314. interface ICameraOrthographic extends IProperty {
  77315. /**
  77316. * The floating-point horizontal magnification of the view. Must not be zero
  77317. */
  77318. xmag: number;
  77319. /**
  77320. * The floating-point vertical magnification of the view. Must not be zero
  77321. */
  77322. ymag: number;
  77323. /**
  77324. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77325. */
  77326. zfar: number;
  77327. /**
  77328. * The floating-point distance to the near clipping plane
  77329. */
  77330. znear: number;
  77331. }
  77332. /**
  77333. * A perspective camera containing properties to create a perspective projection matrix
  77334. */
  77335. interface ICameraPerspective extends IProperty {
  77336. /**
  77337. * The floating-point aspect ratio of the field of view
  77338. */
  77339. aspectRatio?: number;
  77340. /**
  77341. * The floating-point vertical field of view in radians
  77342. */
  77343. yfov: number;
  77344. /**
  77345. * The floating-point distance to the far clipping plane
  77346. */
  77347. zfar?: number;
  77348. /**
  77349. * The floating-point distance to the near clipping plane
  77350. */
  77351. znear: number;
  77352. }
  77353. /**
  77354. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77355. */
  77356. interface ICamera extends IChildRootProperty {
  77357. /**
  77358. * An orthographic camera containing properties to create an orthographic projection matrix
  77359. */
  77360. orthographic?: ICameraOrthographic;
  77361. /**
  77362. * A perspective camera containing properties to create a perspective projection matrix
  77363. */
  77364. perspective?: ICameraPerspective;
  77365. /**
  77366. * Specifies if the camera uses a perspective or orthographic projection
  77367. */
  77368. type: CameraType;
  77369. }
  77370. /**
  77371. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  77372. */
  77373. interface IImage extends IChildRootProperty {
  77374. /**
  77375. * 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
  77376. */
  77377. uri?: string;
  77378. /**
  77379. * The image's MIME type
  77380. */
  77381. mimeType?: ImageMimeType;
  77382. /**
  77383. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  77384. */
  77385. bufferView?: number;
  77386. }
  77387. /**
  77388. * Material Normal Texture Info
  77389. */
  77390. interface IMaterialNormalTextureInfo extends ITextureInfo {
  77391. /**
  77392. * The scalar multiplier applied to each normal vector of the normal texture
  77393. */
  77394. scale?: number;
  77395. }
  77396. /**
  77397. * Material Occlusion Texture Info
  77398. */
  77399. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  77400. /**
  77401. * A scalar multiplier controlling the amount of occlusion applied
  77402. */
  77403. strength?: number;
  77404. }
  77405. /**
  77406. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  77407. */
  77408. interface IMaterialPbrMetallicRoughness {
  77409. /**
  77410. * The material's base color factor
  77411. */
  77412. baseColorFactor?: number[];
  77413. /**
  77414. * The base color texture
  77415. */
  77416. baseColorTexture?: ITextureInfo;
  77417. /**
  77418. * The metalness of the material
  77419. */
  77420. metallicFactor?: number;
  77421. /**
  77422. * The roughness of the material
  77423. */
  77424. roughnessFactor?: number;
  77425. /**
  77426. * The metallic-roughness texture
  77427. */
  77428. metallicRoughnessTexture?: ITextureInfo;
  77429. }
  77430. /**
  77431. * The material appearance of a primitive
  77432. */
  77433. interface IMaterial extends IChildRootProperty {
  77434. /**
  77435. * 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
  77436. */
  77437. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77438. /**
  77439. * The normal map texture
  77440. */
  77441. normalTexture?: IMaterialNormalTextureInfo;
  77442. /**
  77443. * The occlusion map texture
  77444. */
  77445. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77446. /**
  77447. * The emissive map texture
  77448. */
  77449. emissiveTexture?: ITextureInfo;
  77450. /**
  77451. * 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
  77452. */
  77453. emissiveFactor?: number[];
  77454. /**
  77455. * The alpha rendering mode of the material
  77456. */
  77457. alphaMode?: MaterialAlphaMode;
  77458. /**
  77459. * The alpha cutoff value of the material
  77460. */
  77461. alphaCutoff?: number;
  77462. /**
  77463. * Specifies whether the material is double sided
  77464. */
  77465. doubleSided?: boolean;
  77466. }
  77467. /**
  77468. * Geometry to be rendered with the given material
  77469. */
  77470. interface IMeshPrimitive extends IProperty {
  77471. /**
  77472. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  77473. */
  77474. attributes: {
  77475. [name: string]: number;
  77476. };
  77477. /**
  77478. * The index of the accessor that contains the indices
  77479. */
  77480. indices?: number;
  77481. /**
  77482. * The index of the material to apply to this primitive when rendering
  77483. */
  77484. material?: number;
  77485. /**
  77486. * The type of primitives to render. All valid values correspond to WebGL enums
  77487. */
  77488. mode?: MeshPrimitiveMode;
  77489. /**
  77490. * 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
  77491. */
  77492. targets?: {
  77493. [name: string]: number;
  77494. }[];
  77495. }
  77496. /**
  77497. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  77498. */
  77499. interface IMesh extends IChildRootProperty {
  77500. /**
  77501. * An array of primitives, each defining geometry to be rendered with a material
  77502. */
  77503. primitives: IMeshPrimitive[];
  77504. /**
  77505. * Array of weights to be applied to the Morph Targets
  77506. */
  77507. weights?: number[];
  77508. }
  77509. /**
  77510. * A node in the node hierarchy
  77511. */
  77512. interface INode extends IChildRootProperty {
  77513. /**
  77514. * The index of the camera referenced by this node
  77515. */
  77516. camera?: number;
  77517. /**
  77518. * The indices of this node's children
  77519. */
  77520. children?: number[];
  77521. /**
  77522. * The index of the skin referenced by this node
  77523. */
  77524. skin?: number;
  77525. /**
  77526. * A floating-point 4x4 transformation matrix stored in column-major order
  77527. */
  77528. matrix?: number[];
  77529. /**
  77530. * The index of the mesh in this node
  77531. */
  77532. mesh?: number;
  77533. /**
  77534. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  77535. */
  77536. rotation?: number[];
  77537. /**
  77538. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  77539. */
  77540. scale?: number[];
  77541. /**
  77542. * The node's translation along the x, y, and z axes
  77543. */
  77544. translation?: number[];
  77545. /**
  77546. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  77547. */
  77548. weights?: number[];
  77549. }
  77550. /**
  77551. * Texture sampler properties for filtering and wrapping modes
  77552. */
  77553. interface ISampler extends IChildRootProperty {
  77554. /**
  77555. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77556. */
  77557. magFilter?: TextureMagFilter;
  77558. /**
  77559. * Minification filter. All valid values correspond to WebGL enums
  77560. */
  77561. minFilter?: TextureMinFilter;
  77562. /**
  77563. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77564. */
  77565. wrapS?: TextureWrapMode;
  77566. /**
  77567. * T (V) wrapping mode. All valid values correspond to WebGL enums
  77568. */
  77569. wrapT?: TextureWrapMode;
  77570. }
  77571. /**
  77572. * The root nodes of a scene
  77573. */
  77574. interface IScene extends IChildRootProperty {
  77575. /**
  77576. * The indices of each root node
  77577. */
  77578. nodes: number[];
  77579. }
  77580. /**
  77581. * Joints and matrices defining a skin
  77582. */
  77583. interface ISkin extends IChildRootProperty {
  77584. /**
  77585. * 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
  77586. */
  77587. inverseBindMatrices?: number;
  77588. /**
  77589. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  77590. */
  77591. skeleton?: number;
  77592. /**
  77593. * 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)
  77594. */
  77595. joints: number[];
  77596. }
  77597. /**
  77598. * A texture and its sampler
  77599. */
  77600. interface ITexture extends IChildRootProperty {
  77601. /**
  77602. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  77603. */
  77604. sampler?: number;
  77605. /**
  77606. * The index of the image used by this texture
  77607. */
  77608. source: number;
  77609. }
  77610. /**
  77611. * Reference to a texture
  77612. */
  77613. interface ITextureInfo extends IProperty {
  77614. /**
  77615. * The index of the texture
  77616. */
  77617. index: number;
  77618. /**
  77619. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  77620. */
  77621. texCoord?: number;
  77622. }
  77623. /**
  77624. * The root object for a glTF asset
  77625. */
  77626. interface IGLTF extends IProperty {
  77627. /**
  77628. * An array of accessors. An accessor is a typed view into a bufferView
  77629. */
  77630. accessors?: IAccessor[];
  77631. /**
  77632. * An array of keyframe animations
  77633. */
  77634. animations?: IAnimation[];
  77635. /**
  77636. * Metadata about the glTF asset
  77637. */
  77638. asset: IAsset;
  77639. /**
  77640. * An array of buffers. A buffer points to binary geometry, animation, or skins
  77641. */
  77642. buffers?: IBuffer[];
  77643. /**
  77644. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  77645. */
  77646. bufferViews?: IBufferView[];
  77647. /**
  77648. * An array of cameras
  77649. */
  77650. cameras?: ICamera[];
  77651. /**
  77652. * Names of glTF extensions used somewhere in this asset
  77653. */
  77654. extensionsUsed?: string[];
  77655. /**
  77656. * Names of glTF extensions required to properly load this asset
  77657. */
  77658. extensionsRequired?: string[];
  77659. /**
  77660. * An array of images. An image defines data used to create a texture
  77661. */
  77662. images?: IImage[];
  77663. /**
  77664. * An array of materials. A material defines the appearance of a primitive
  77665. */
  77666. materials?: IMaterial[];
  77667. /**
  77668. * An array of meshes. A mesh is a set of primitives to be rendered
  77669. */
  77670. meshes?: IMesh[];
  77671. /**
  77672. * An array of nodes
  77673. */
  77674. nodes?: INode[];
  77675. /**
  77676. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  77677. */
  77678. samplers?: ISampler[];
  77679. /**
  77680. * The index of the default scene
  77681. */
  77682. scene?: number;
  77683. /**
  77684. * An array of scenes
  77685. */
  77686. scenes?: IScene[];
  77687. /**
  77688. * An array of skins. A skin is defined by joints and matrices
  77689. */
  77690. skins?: ISkin[];
  77691. /**
  77692. * An array of textures
  77693. */
  77694. textures?: ITexture[];
  77695. }
  77696. /**
  77697. * The glTF validation results
  77698. * @ignore
  77699. */
  77700. interface IGLTFValidationResults {
  77701. info: {
  77702. generator: string;
  77703. hasAnimations: boolean;
  77704. hasDefaultScene: boolean;
  77705. hasMaterials: boolean;
  77706. hasMorphTargets: boolean;
  77707. hasSkins: boolean;
  77708. hasTextures: boolean;
  77709. maxAttributesUsed: number;
  77710. primitivesCount: number
  77711. };
  77712. issues: {
  77713. messages: Array<string>;
  77714. numErrors: number;
  77715. numHints: number;
  77716. numInfos: number;
  77717. numWarnings: number;
  77718. truncated: boolean
  77719. };
  77720. mimeType: string;
  77721. uri: string;
  77722. validatedAt: string;
  77723. validatorVersion: string;
  77724. }
  77725. /**
  77726. * The glTF validation options
  77727. */
  77728. interface IGLTFValidationOptions {
  77729. /** Uri to use */
  77730. uri?: string;
  77731. /** Function used to load external resources */
  77732. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  77733. /** Boolean indicating that we need to validate accessor data */
  77734. validateAccessorData?: boolean;
  77735. /** max number of issues allowed */
  77736. maxIssues?: number;
  77737. /** Ignored issues */
  77738. ignoredIssues?: Array<string>;
  77739. /** Value to override severy settings */
  77740. severityOverrides?: Object;
  77741. }
  77742. /**
  77743. * The glTF validator object
  77744. * @ignore
  77745. */
  77746. interface IGLTFValidator {
  77747. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77748. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77749. }
  77750. }
  77751. declare module BABYLON {
  77752. /** @hidden */
  77753. export var cellPixelShader: {
  77754. name: string;
  77755. shader: string;
  77756. };
  77757. }
  77758. declare module BABYLON {
  77759. /** @hidden */
  77760. export var cellVertexShader: {
  77761. name: string;
  77762. shader: string;
  77763. };
  77764. }
  77765. declare module BABYLON {
  77766. export class CellMaterial extends BABYLON.PushMaterial {
  77767. private _diffuseTexture;
  77768. diffuseTexture: BABYLON.BaseTexture;
  77769. diffuseColor: BABYLON.Color3;
  77770. _computeHighLevel: boolean;
  77771. computeHighLevel: boolean;
  77772. private _disableLighting;
  77773. disableLighting: boolean;
  77774. private _maxSimultaneousLights;
  77775. maxSimultaneousLights: number;
  77776. private _renderId;
  77777. constructor(name: string, scene: BABYLON.Scene);
  77778. needAlphaBlending(): boolean;
  77779. needAlphaTesting(): boolean;
  77780. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77781. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77782. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77783. getAnimatables(): BABYLON.IAnimatable[];
  77784. getActiveTextures(): BABYLON.BaseTexture[];
  77785. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77786. dispose(forceDisposeEffect?: boolean): void;
  77787. getClassName(): string;
  77788. clone(name: string): CellMaterial;
  77789. serialize(): any;
  77790. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  77791. }
  77792. }
  77793. declare module BABYLON {
  77794. export class CustomShaderStructure {
  77795. FragmentStore: string;
  77796. VertexStore: string;
  77797. constructor();
  77798. }
  77799. export class ShaderSpecialParts {
  77800. constructor();
  77801. Fragment_Begin: string;
  77802. Fragment_Definitions: string;
  77803. Fragment_MainBegin: string;
  77804. Fragment_Custom_Diffuse: string;
  77805. Fragment_Before_Lights: string;
  77806. Fragment_Before_Fog: string;
  77807. Fragment_Custom_Alpha: string;
  77808. Fragment_Before_FragColor: string;
  77809. Vertex_Begin: string;
  77810. Vertex_Definitions: string;
  77811. Vertex_MainBegin: string;
  77812. Vertex_Before_PositionUpdated: string;
  77813. Vertex_Before_NormalUpdated: string;
  77814. Vertex_MainEnd: string;
  77815. }
  77816. export class CustomMaterial extends BABYLON.StandardMaterial {
  77817. static ShaderIndexer: number;
  77818. CustomParts: ShaderSpecialParts;
  77819. _isCreatedShader: boolean;
  77820. _createdShaderName: string;
  77821. _customUniform: string[];
  77822. _newUniforms: string[];
  77823. _newUniformInstances: any[];
  77824. _newSamplerInstances: BABYLON.Texture[];
  77825. FragmentShader: string;
  77826. VertexShader: string;
  77827. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77828. ReviewUniform(name: string, arr: string[]): string[];
  77829. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  77830. constructor(name: string, scene: BABYLON.Scene);
  77831. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  77832. Fragment_Begin(shaderPart: string): CustomMaterial;
  77833. Fragment_Definitions(shaderPart: string): CustomMaterial;
  77834. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  77835. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  77836. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  77837. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  77838. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  77839. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  77840. Vertex_Begin(shaderPart: string): CustomMaterial;
  77841. Vertex_Definitions(shaderPart: string): CustomMaterial;
  77842. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  77843. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  77844. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  77845. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  77846. }
  77847. }
  77848. declare module BABYLON {
  77849. export class ShaderAlebdoParts {
  77850. constructor();
  77851. Fragment_Begin: string;
  77852. Fragment_Definitions: string;
  77853. Fragment_MainBegin: string;
  77854. Fragment_Custom_Albedo: string;
  77855. Fragment_Before_Lights: string;
  77856. Fragment_Custom_MetallicRoughness: string;
  77857. Fragment_Custom_MicroSurface: string;
  77858. Fragment_Before_Fog: string;
  77859. Fragment_Custom_Alpha: string;
  77860. Fragment_Before_FragColor: string;
  77861. Vertex_Begin: string;
  77862. Vertex_Definitions: string;
  77863. Vertex_MainBegin: string;
  77864. Vertex_Before_PositionUpdated: string;
  77865. Vertex_Before_NormalUpdated: string;
  77866. Vertex_MainEnd: string;
  77867. }
  77868. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  77869. static ShaderIndexer: number;
  77870. CustomParts: ShaderAlebdoParts;
  77871. _isCreatedShader: boolean;
  77872. _createdShaderName: string;
  77873. _customUniform: string[];
  77874. _newUniforms: string[];
  77875. _newUniformInstances: any[];
  77876. _newSamplerInstances: BABYLON.Texture[];
  77877. FragmentShader: string;
  77878. VertexShader: string;
  77879. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77880. ReviewUniform(name: string, arr: string[]): string[];
  77881. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  77882. constructor(name: string, scene: BABYLON.Scene);
  77883. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  77884. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  77885. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  77886. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  77887. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  77888. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  77889. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  77890. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  77891. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  77892. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  77893. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  77894. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  77895. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  77896. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  77897. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  77898. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  77899. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  77900. }
  77901. }
  77902. declare module BABYLON {
  77903. /** @hidden */
  77904. export var firePixelShader: {
  77905. name: string;
  77906. shader: string;
  77907. };
  77908. }
  77909. declare module BABYLON {
  77910. /** @hidden */
  77911. export var fireVertexShader: {
  77912. name: string;
  77913. shader: string;
  77914. };
  77915. }
  77916. declare module BABYLON {
  77917. export class FireMaterial extends BABYLON.PushMaterial {
  77918. private _diffuseTexture;
  77919. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77920. private _distortionTexture;
  77921. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77922. private _opacityTexture;
  77923. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77924. diffuseColor: BABYLON.Color3;
  77925. speed: number;
  77926. private _scaledDiffuse;
  77927. private _renderId;
  77928. private _lastTime;
  77929. constructor(name: string, scene: BABYLON.Scene);
  77930. needAlphaBlending(): boolean;
  77931. needAlphaTesting(): boolean;
  77932. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77933. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77934. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77935. getAnimatables(): BABYLON.IAnimatable[];
  77936. getActiveTextures(): BABYLON.BaseTexture[];
  77937. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77938. getClassName(): string;
  77939. dispose(forceDisposeEffect?: boolean): void;
  77940. clone(name: string): FireMaterial;
  77941. serialize(): any;
  77942. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  77943. }
  77944. }
  77945. declare module BABYLON {
  77946. /** @hidden */
  77947. export var furPixelShader: {
  77948. name: string;
  77949. shader: string;
  77950. };
  77951. }
  77952. declare module BABYLON {
  77953. /** @hidden */
  77954. export var furVertexShader: {
  77955. name: string;
  77956. shader: string;
  77957. };
  77958. }
  77959. declare module BABYLON {
  77960. export class FurMaterial extends BABYLON.PushMaterial {
  77961. private _diffuseTexture;
  77962. diffuseTexture: BABYLON.BaseTexture;
  77963. private _heightTexture;
  77964. heightTexture: BABYLON.BaseTexture;
  77965. diffuseColor: BABYLON.Color3;
  77966. furLength: number;
  77967. furAngle: number;
  77968. furColor: BABYLON.Color3;
  77969. furOffset: number;
  77970. furSpacing: number;
  77971. furGravity: BABYLON.Vector3;
  77972. furSpeed: number;
  77973. furDensity: number;
  77974. furOcclusion: number;
  77975. furTexture: BABYLON.DynamicTexture;
  77976. private _disableLighting;
  77977. disableLighting: boolean;
  77978. private _maxSimultaneousLights;
  77979. maxSimultaneousLights: number;
  77980. highLevelFur: boolean;
  77981. _meshes: BABYLON.AbstractMesh[];
  77982. private _renderId;
  77983. private _furTime;
  77984. constructor(name: string, scene: BABYLON.Scene);
  77985. get furTime(): number;
  77986. set furTime(furTime: number);
  77987. needAlphaBlending(): boolean;
  77988. needAlphaTesting(): boolean;
  77989. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77990. updateFur(): void;
  77991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77993. getAnimatables(): BABYLON.IAnimatable[];
  77994. getActiveTextures(): BABYLON.BaseTexture[];
  77995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77996. dispose(forceDisposeEffect?: boolean): void;
  77997. clone(name: string): FurMaterial;
  77998. serialize(): any;
  77999. getClassName(): string;
  78000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78001. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78002. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78003. }
  78004. }
  78005. declare module BABYLON {
  78006. /** @hidden */
  78007. export var gradientPixelShader: {
  78008. name: string;
  78009. shader: string;
  78010. };
  78011. }
  78012. declare module BABYLON {
  78013. /** @hidden */
  78014. export var gradientVertexShader: {
  78015. name: string;
  78016. shader: string;
  78017. };
  78018. }
  78019. declare module BABYLON {
  78020. export class GradientMaterial extends BABYLON.PushMaterial {
  78021. private _maxSimultaneousLights;
  78022. maxSimultaneousLights: number;
  78023. topColor: BABYLON.Color3;
  78024. topColorAlpha: number;
  78025. bottomColor: BABYLON.Color3;
  78026. bottomColorAlpha: number;
  78027. offset: number;
  78028. scale: number;
  78029. smoothness: number;
  78030. private _disableLighting;
  78031. disableLighting: boolean;
  78032. private _renderId;
  78033. constructor(name: string, scene: BABYLON.Scene);
  78034. needAlphaBlending(): boolean;
  78035. needAlphaTesting(): boolean;
  78036. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78037. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78038. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78039. getAnimatables(): BABYLON.IAnimatable[];
  78040. dispose(forceDisposeEffect?: boolean): void;
  78041. clone(name: string): GradientMaterial;
  78042. serialize(): any;
  78043. getClassName(): string;
  78044. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78045. }
  78046. }
  78047. declare module BABYLON {
  78048. /** @hidden */
  78049. export var gridPixelShader: {
  78050. name: string;
  78051. shader: string;
  78052. };
  78053. }
  78054. declare module BABYLON {
  78055. /** @hidden */
  78056. export var gridVertexShader: {
  78057. name: string;
  78058. shader: string;
  78059. };
  78060. }
  78061. declare module BABYLON {
  78062. /**
  78063. * The grid materials allows you to wrap any shape with a grid.
  78064. * Colors are customizable.
  78065. */
  78066. export class GridMaterial extends BABYLON.PushMaterial {
  78067. /**
  78068. * Main color of the grid (e.g. between lines)
  78069. */
  78070. mainColor: BABYLON.Color3;
  78071. /**
  78072. * Color of the grid lines.
  78073. */
  78074. lineColor: BABYLON.Color3;
  78075. /**
  78076. * The scale of the grid compared to unit.
  78077. */
  78078. gridRatio: number;
  78079. /**
  78080. * Allows setting an offset for the grid lines.
  78081. */
  78082. gridOffset: BABYLON.Vector3;
  78083. /**
  78084. * The frequency of thicker lines.
  78085. */
  78086. majorUnitFrequency: number;
  78087. /**
  78088. * The visibility of minor units in the grid.
  78089. */
  78090. minorUnitVisibility: number;
  78091. /**
  78092. * The grid opacity outside of the lines.
  78093. */
  78094. opacity: number;
  78095. /**
  78096. * Determine RBG output is premultiplied by alpha value.
  78097. */
  78098. preMultiplyAlpha: boolean;
  78099. private _opacityTexture;
  78100. opacityTexture: BABYLON.BaseTexture;
  78101. private _gridControl;
  78102. private _renderId;
  78103. /**
  78104. * constructor
  78105. * @param name The name given to the material in order to identify it afterwards.
  78106. * @param scene The scene the material is used in.
  78107. */
  78108. constructor(name: string, scene: BABYLON.Scene);
  78109. /**
  78110. * Returns wehter or not the grid requires alpha blending.
  78111. */
  78112. needAlphaBlending(): boolean;
  78113. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78114. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78115. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78116. /**
  78117. * Dispose the material and its associated resources.
  78118. * @param forceDisposeEffect will also dispose the used effect when true
  78119. */
  78120. dispose(forceDisposeEffect?: boolean): void;
  78121. clone(name: string): GridMaterial;
  78122. serialize(): any;
  78123. getClassName(): string;
  78124. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78125. }
  78126. }
  78127. declare module BABYLON {
  78128. /** @hidden */
  78129. export var lavaPixelShader: {
  78130. name: string;
  78131. shader: string;
  78132. };
  78133. }
  78134. declare module BABYLON {
  78135. /** @hidden */
  78136. export var lavaVertexShader: {
  78137. name: string;
  78138. shader: string;
  78139. };
  78140. }
  78141. declare module BABYLON {
  78142. export class LavaMaterial extends BABYLON.PushMaterial {
  78143. private _diffuseTexture;
  78144. diffuseTexture: BABYLON.BaseTexture;
  78145. noiseTexture: BABYLON.BaseTexture;
  78146. fogColor: BABYLON.Color3;
  78147. speed: number;
  78148. movingSpeed: number;
  78149. lowFrequencySpeed: number;
  78150. fogDensity: number;
  78151. private _lastTime;
  78152. diffuseColor: BABYLON.Color3;
  78153. private _disableLighting;
  78154. disableLighting: boolean;
  78155. private _unlit;
  78156. unlit: boolean;
  78157. private _maxSimultaneousLights;
  78158. maxSimultaneousLights: number;
  78159. private _scaledDiffuse;
  78160. private _renderId;
  78161. constructor(name: string, scene: BABYLON.Scene);
  78162. needAlphaBlending(): boolean;
  78163. needAlphaTesting(): boolean;
  78164. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78165. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78166. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78167. getAnimatables(): BABYLON.IAnimatable[];
  78168. getActiveTextures(): BABYLON.BaseTexture[];
  78169. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78170. dispose(forceDisposeEffect?: boolean): void;
  78171. clone(name: string): LavaMaterial;
  78172. serialize(): any;
  78173. getClassName(): string;
  78174. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78175. }
  78176. }
  78177. declare module BABYLON {
  78178. /** @hidden */
  78179. export var mixPixelShader: {
  78180. name: string;
  78181. shader: string;
  78182. };
  78183. }
  78184. declare module BABYLON {
  78185. /** @hidden */
  78186. export var mixVertexShader: {
  78187. name: string;
  78188. shader: string;
  78189. };
  78190. }
  78191. declare module BABYLON {
  78192. export class MixMaterial extends BABYLON.PushMaterial {
  78193. /**
  78194. * Mix textures
  78195. */
  78196. private _mixTexture1;
  78197. mixTexture1: BABYLON.BaseTexture;
  78198. private _mixTexture2;
  78199. mixTexture2: BABYLON.BaseTexture;
  78200. /**
  78201. * Diffuse textures
  78202. */
  78203. private _diffuseTexture1;
  78204. diffuseTexture1: BABYLON.Texture;
  78205. private _diffuseTexture2;
  78206. diffuseTexture2: BABYLON.Texture;
  78207. private _diffuseTexture3;
  78208. diffuseTexture3: BABYLON.Texture;
  78209. private _diffuseTexture4;
  78210. diffuseTexture4: BABYLON.Texture;
  78211. private _diffuseTexture5;
  78212. diffuseTexture5: BABYLON.Texture;
  78213. private _diffuseTexture6;
  78214. diffuseTexture6: BABYLON.Texture;
  78215. private _diffuseTexture7;
  78216. diffuseTexture7: BABYLON.Texture;
  78217. private _diffuseTexture8;
  78218. diffuseTexture8: BABYLON.Texture;
  78219. /**
  78220. * Uniforms
  78221. */
  78222. diffuseColor: BABYLON.Color3;
  78223. specularColor: BABYLON.Color3;
  78224. specularPower: number;
  78225. private _disableLighting;
  78226. disableLighting: boolean;
  78227. private _maxSimultaneousLights;
  78228. maxSimultaneousLights: number;
  78229. private _renderId;
  78230. constructor(name: string, scene: BABYLON.Scene);
  78231. needAlphaBlending(): boolean;
  78232. needAlphaTesting(): boolean;
  78233. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78234. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78235. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78236. getAnimatables(): BABYLON.IAnimatable[];
  78237. getActiveTextures(): BABYLON.BaseTexture[];
  78238. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78239. dispose(forceDisposeEffect?: boolean): void;
  78240. clone(name: string): MixMaterial;
  78241. serialize(): any;
  78242. getClassName(): string;
  78243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78244. }
  78245. }
  78246. declare module BABYLON {
  78247. /** @hidden */
  78248. export var normalPixelShader: {
  78249. name: string;
  78250. shader: string;
  78251. };
  78252. }
  78253. declare module BABYLON {
  78254. /** @hidden */
  78255. export var normalVertexShader: {
  78256. name: string;
  78257. shader: string;
  78258. };
  78259. }
  78260. declare module BABYLON {
  78261. export class NormalMaterial extends BABYLON.PushMaterial {
  78262. private _diffuseTexture;
  78263. diffuseTexture: BABYLON.BaseTexture;
  78264. diffuseColor: BABYLON.Color3;
  78265. private _disableLighting;
  78266. disableLighting: boolean;
  78267. private _maxSimultaneousLights;
  78268. maxSimultaneousLights: number;
  78269. private _renderId;
  78270. constructor(name: string, scene: BABYLON.Scene);
  78271. needAlphaBlending(): boolean;
  78272. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78273. needAlphaTesting(): boolean;
  78274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78275. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78277. getAnimatables(): BABYLON.IAnimatable[];
  78278. getActiveTextures(): BABYLON.BaseTexture[];
  78279. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78280. dispose(forceDisposeEffect?: boolean): void;
  78281. clone(name: string): NormalMaterial;
  78282. serialize(): any;
  78283. getClassName(): string;
  78284. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78285. }
  78286. }
  78287. declare module BABYLON {
  78288. /** @hidden */
  78289. export var shadowOnlyPixelShader: {
  78290. name: string;
  78291. shader: string;
  78292. };
  78293. }
  78294. declare module BABYLON {
  78295. /** @hidden */
  78296. export var shadowOnlyVertexShader: {
  78297. name: string;
  78298. shader: string;
  78299. };
  78300. }
  78301. declare module BABYLON {
  78302. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78303. private _renderId;
  78304. private _activeLight;
  78305. constructor(name: string, scene: BABYLON.Scene);
  78306. shadowColor: BABYLON.Color3;
  78307. needAlphaBlending(): boolean;
  78308. needAlphaTesting(): boolean;
  78309. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78310. get activeLight(): BABYLON.IShadowLight;
  78311. set activeLight(light: BABYLON.IShadowLight);
  78312. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78313. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78314. clone(name: string): ShadowOnlyMaterial;
  78315. serialize(): any;
  78316. getClassName(): string;
  78317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78318. }
  78319. }
  78320. declare module BABYLON {
  78321. /** @hidden */
  78322. export var simplePixelShader: {
  78323. name: string;
  78324. shader: string;
  78325. };
  78326. }
  78327. declare module BABYLON {
  78328. /** @hidden */
  78329. export var simpleVertexShader: {
  78330. name: string;
  78331. shader: string;
  78332. };
  78333. }
  78334. declare module BABYLON {
  78335. export class SimpleMaterial extends BABYLON.PushMaterial {
  78336. private _diffuseTexture;
  78337. diffuseTexture: BABYLON.BaseTexture;
  78338. diffuseColor: BABYLON.Color3;
  78339. private _disableLighting;
  78340. disableLighting: boolean;
  78341. private _maxSimultaneousLights;
  78342. maxSimultaneousLights: number;
  78343. private _renderId;
  78344. constructor(name: string, scene: BABYLON.Scene);
  78345. needAlphaBlending(): boolean;
  78346. needAlphaTesting(): boolean;
  78347. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78348. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78349. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78350. getAnimatables(): BABYLON.IAnimatable[];
  78351. getActiveTextures(): BABYLON.BaseTexture[];
  78352. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78353. dispose(forceDisposeEffect?: boolean): void;
  78354. clone(name: string): SimpleMaterial;
  78355. serialize(): any;
  78356. getClassName(): string;
  78357. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78358. }
  78359. }
  78360. declare module BABYLON {
  78361. /** @hidden */
  78362. export var skyPixelShader: {
  78363. name: string;
  78364. shader: string;
  78365. };
  78366. }
  78367. declare module BABYLON {
  78368. /** @hidden */
  78369. export var skyVertexShader: {
  78370. name: string;
  78371. shader: string;
  78372. };
  78373. }
  78374. declare module BABYLON {
  78375. /**
  78376. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  78377. * @see https://doc.babylonjs.com/extensions/sky
  78378. */
  78379. export class SkyMaterial extends BABYLON.PushMaterial {
  78380. /**
  78381. * Defines the overall luminance of sky in interval ]0, 1[.
  78382. */
  78383. luminance: number;
  78384. /**
  78385. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  78386. */
  78387. turbidity: number;
  78388. /**
  78389. * Defines the sky appearance (light intensity).
  78390. */
  78391. rayleigh: number;
  78392. /**
  78393. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  78394. */
  78395. mieCoefficient: number;
  78396. /**
  78397. * Defines the amount of haze particles following the Mie scattering theory.
  78398. */
  78399. mieDirectionalG: number;
  78400. /**
  78401. * Defines the distance of the sun according to the active scene camera.
  78402. */
  78403. distance: number;
  78404. /**
  78405. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  78406. * "inclined".
  78407. */
  78408. inclination: number;
  78409. /**
  78410. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  78411. * an object direction and a reference direction.
  78412. */
  78413. azimuth: number;
  78414. /**
  78415. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  78416. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  78417. */
  78418. sunPosition: BABYLON.Vector3;
  78419. /**
  78420. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  78421. * .sunPosition property.
  78422. */
  78423. useSunPosition: boolean;
  78424. /**
  78425. * Defines an offset vector used to get a horizon offset.
  78426. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  78427. */
  78428. cameraOffset: BABYLON.Vector3;
  78429. private _cameraPosition;
  78430. private _renderId;
  78431. /**
  78432. * Instantiates a new sky material.
  78433. * This material allows to create dynamic and texture free
  78434. * effects for skyboxes by taking care of the atmosphere state.
  78435. * @see https://doc.babylonjs.com/extensions/sky
  78436. * @param name Define the name of the material in the scene
  78437. * @param scene Define the scene the material belong to
  78438. */
  78439. constructor(name: string, scene: BABYLON.Scene);
  78440. /**
  78441. * Specifies if the material will require alpha blending
  78442. * @returns a boolean specifying if alpha blending is needed
  78443. */
  78444. needAlphaBlending(): boolean;
  78445. /**
  78446. * Specifies if this material should be rendered in alpha test mode
  78447. * @returns false as the sky material doesn't need alpha testing.
  78448. */
  78449. needAlphaTesting(): boolean;
  78450. /**
  78451. * Get the texture used for alpha test purpose.
  78452. * @returns null as the sky material has no texture.
  78453. */
  78454. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78455. /**
  78456. * Get if the submesh is ready to be used and all its information available.
  78457. * Child classes can use it to update shaders
  78458. * @param mesh defines the mesh to check
  78459. * @param subMesh defines which submesh to check
  78460. * @param useInstances specifies that instances should be used
  78461. * @returns a boolean indicating that the submesh is ready or not
  78462. */
  78463. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78464. /**
  78465. * Binds the submesh to this material by preparing the effect and shader to draw
  78466. * @param world defines the world transformation matrix
  78467. * @param mesh defines the mesh containing the submesh
  78468. * @param subMesh defines the submesh to bind the material to
  78469. */
  78470. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78471. /**
  78472. * Get the list of animatables in the material.
  78473. * @returns the list of animatables object used in the material
  78474. */
  78475. getAnimatables(): BABYLON.IAnimatable[];
  78476. /**
  78477. * Disposes the material
  78478. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78479. */
  78480. dispose(forceDisposeEffect?: boolean): void;
  78481. /**
  78482. * Makes a duplicate of the material, and gives it a new name
  78483. * @param name defines the new name for the duplicated material
  78484. * @returns the cloned material
  78485. */
  78486. clone(name: string): SkyMaterial;
  78487. /**
  78488. * Serializes this material in a JSON representation
  78489. * @returns the serialized material object
  78490. */
  78491. serialize(): any;
  78492. /**
  78493. * Gets the current class name of the material e.g. "SkyMaterial"
  78494. * Mainly use in serialization.
  78495. * @returns the class name
  78496. */
  78497. getClassName(): string;
  78498. /**
  78499. * Creates a sky material from parsed material data
  78500. * @param source defines the JSON representation of the material
  78501. * @param scene defines the hosting scene
  78502. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  78503. * @returns a new sky material
  78504. */
  78505. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  78506. }
  78507. }
  78508. declare module BABYLON {
  78509. /** @hidden */
  78510. export var terrainPixelShader: {
  78511. name: string;
  78512. shader: string;
  78513. };
  78514. }
  78515. declare module BABYLON {
  78516. /** @hidden */
  78517. export var terrainVertexShader: {
  78518. name: string;
  78519. shader: string;
  78520. };
  78521. }
  78522. declare module BABYLON {
  78523. export class TerrainMaterial extends BABYLON.PushMaterial {
  78524. private _mixTexture;
  78525. mixTexture: BABYLON.BaseTexture;
  78526. private _diffuseTexture1;
  78527. diffuseTexture1: BABYLON.Texture;
  78528. private _diffuseTexture2;
  78529. diffuseTexture2: BABYLON.Texture;
  78530. private _diffuseTexture3;
  78531. diffuseTexture3: BABYLON.Texture;
  78532. private _bumpTexture1;
  78533. bumpTexture1: BABYLON.Texture;
  78534. private _bumpTexture2;
  78535. bumpTexture2: BABYLON.Texture;
  78536. private _bumpTexture3;
  78537. bumpTexture3: BABYLON.Texture;
  78538. diffuseColor: BABYLON.Color3;
  78539. specularColor: BABYLON.Color3;
  78540. specularPower: number;
  78541. private _disableLighting;
  78542. disableLighting: boolean;
  78543. private _maxSimultaneousLights;
  78544. maxSimultaneousLights: number;
  78545. private _renderId;
  78546. constructor(name: string, scene: BABYLON.Scene);
  78547. needAlphaBlending(): boolean;
  78548. needAlphaTesting(): boolean;
  78549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78552. getAnimatables(): BABYLON.IAnimatable[];
  78553. getActiveTextures(): BABYLON.BaseTexture[];
  78554. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78555. dispose(forceDisposeEffect?: boolean): void;
  78556. clone(name: string): TerrainMaterial;
  78557. serialize(): any;
  78558. getClassName(): string;
  78559. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  78560. }
  78561. }
  78562. declare module BABYLON {
  78563. /** @hidden */
  78564. export var triplanarPixelShader: {
  78565. name: string;
  78566. shader: string;
  78567. };
  78568. }
  78569. declare module BABYLON {
  78570. /** @hidden */
  78571. export var triplanarVertexShader: {
  78572. name: string;
  78573. shader: string;
  78574. };
  78575. }
  78576. declare module BABYLON {
  78577. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  78578. mixTexture: BABYLON.BaseTexture;
  78579. private _diffuseTextureX;
  78580. diffuseTextureX: BABYLON.BaseTexture;
  78581. private _diffuseTextureY;
  78582. diffuseTextureY: BABYLON.BaseTexture;
  78583. private _diffuseTextureZ;
  78584. diffuseTextureZ: BABYLON.BaseTexture;
  78585. private _normalTextureX;
  78586. normalTextureX: BABYLON.BaseTexture;
  78587. private _normalTextureY;
  78588. normalTextureY: BABYLON.BaseTexture;
  78589. private _normalTextureZ;
  78590. normalTextureZ: BABYLON.BaseTexture;
  78591. tileSize: number;
  78592. diffuseColor: BABYLON.Color3;
  78593. specularColor: BABYLON.Color3;
  78594. specularPower: number;
  78595. private _disableLighting;
  78596. disableLighting: boolean;
  78597. private _maxSimultaneousLights;
  78598. maxSimultaneousLights: number;
  78599. private _renderId;
  78600. constructor(name: string, scene: BABYLON.Scene);
  78601. needAlphaBlending(): boolean;
  78602. needAlphaTesting(): boolean;
  78603. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78604. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78605. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78606. getAnimatables(): BABYLON.IAnimatable[];
  78607. getActiveTextures(): BABYLON.BaseTexture[];
  78608. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78609. dispose(forceDisposeEffect?: boolean): void;
  78610. clone(name: string): TriPlanarMaterial;
  78611. serialize(): any;
  78612. getClassName(): string;
  78613. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  78614. }
  78615. }
  78616. declare module BABYLON {
  78617. /** @hidden */
  78618. export var waterPixelShader: {
  78619. name: string;
  78620. shader: string;
  78621. };
  78622. }
  78623. declare module BABYLON {
  78624. /** @hidden */
  78625. export var waterVertexShader: {
  78626. name: string;
  78627. shader: string;
  78628. };
  78629. }
  78630. declare module BABYLON {
  78631. export class WaterMaterial extends BABYLON.PushMaterial {
  78632. renderTargetSize: BABYLON.Vector2;
  78633. private _bumpTexture;
  78634. bumpTexture: BABYLON.BaseTexture;
  78635. diffuseColor: BABYLON.Color3;
  78636. specularColor: BABYLON.Color3;
  78637. specularPower: number;
  78638. private _disableLighting;
  78639. disableLighting: boolean;
  78640. private _maxSimultaneousLights;
  78641. maxSimultaneousLights: number;
  78642. /**
  78643. * @param {number}: Represents the wind force
  78644. */
  78645. windForce: number;
  78646. /**
  78647. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  78648. */
  78649. windDirection: BABYLON.Vector2;
  78650. /**
  78651. * @param {number}: Wave height, represents the height of the waves
  78652. */
  78653. waveHeight: number;
  78654. /**
  78655. * @param {number}: Bump height, represents the bump height related to the bump map
  78656. */
  78657. bumpHeight: number;
  78658. /**
  78659. * @param {boolean}: Add a smaller moving bump to less steady waves.
  78660. */
  78661. private _bumpSuperimpose;
  78662. bumpSuperimpose: boolean;
  78663. /**
  78664. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  78665. */
  78666. private _fresnelSeparate;
  78667. fresnelSeparate: boolean;
  78668. /**
  78669. * @param {boolean}: bump Waves modify the reflection.
  78670. */
  78671. private _bumpAffectsReflection;
  78672. bumpAffectsReflection: boolean;
  78673. /**
  78674. * @param {number}: The water color blended with the refraction (near)
  78675. */
  78676. waterColor: BABYLON.Color3;
  78677. /**
  78678. * @param {number}: The blend factor related to the water color
  78679. */
  78680. colorBlendFactor: number;
  78681. /**
  78682. * @param {number}: The water color blended with the reflection (far)
  78683. */
  78684. waterColor2: BABYLON.Color3;
  78685. /**
  78686. * @param {number}: The blend factor related to the water color (reflection, far)
  78687. */
  78688. colorBlendFactor2: number;
  78689. /**
  78690. * @param {number}: Represents the maximum length of a wave
  78691. */
  78692. waveLength: number;
  78693. /**
  78694. * @param {number}: Defines the waves speed
  78695. */
  78696. waveSpeed: number;
  78697. /**
  78698. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  78699. * will avoid calculating useless pixels in the pixel shader of the water material.
  78700. */
  78701. disableClipPlane: boolean;
  78702. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  78703. private _mesh;
  78704. private _refractionRTT;
  78705. private _reflectionRTT;
  78706. private _reflectionTransform;
  78707. private _lastTime;
  78708. private _lastDeltaTime;
  78709. private _renderId;
  78710. private _useLogarithmicDepth;
  78711. private _waitingRenderList;
  78712. private _imageProcessingConfiguration;
  78713. private _imageProcessingObserver;
  78714. /**
  78715. * Gets a boolean indicating that current material needs to register RTT
  78716. */
  78717. get hasRenderTargetTextures(): boolean;
  78718. /**
  78719. * Constructor
  78720. */
  78721. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  78722. get useLogarithmicDepth(): boolean;
  78723. set useLogarithmicDepth(value: boolean);
  78724. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78725. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78726. addToRenderList(node: any): void;
  78727. enableRenderTargets(enable: boolean): void;
  78728. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  78729. get renderTargetsEnabled(): boolean;
  78730. needAlphaBlending(): boolean;
  78731. needAlphaTesting(): boolean;
  78732. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78733. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78734. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78735. private _createRenderTargets;
  78736. getAnimatables(): BABYLON.IAnimatable[];
  78737. getActiveTextures(): BABYLON.BaseTexture[];
  78738. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78739. dispose(forceDisposeEffect?: boolean): void;
  78740. clone(name: string): WaterMaterial;
  78741. serialize(): any;
  78742. getClassName(): string;
  78743. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  78744. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  78745. }
  78746. }
  78747. declare module BABYLON {
  78748. /** @hidden */
  78749. export var asciiartPixelShader: {
  78750. name: string;
  78751. shader: string;
  78752. };
  78753. }
  78754. declare module BABYLON {
  78755. /**
  78756. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  78757. *
  78758. * It basically takes care rendering the font front the given font size to a texture.
  78759. * This is used later on in the postprocess.
  78760. */
  78761. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  78762. private _font;
  78763. private _text;
  78764. private _charSize;
  78765. /**
  78766. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78767. */
  78768. get charSize(): number;
  78769. /**
  78770. * Create a new instance of the Ascii Art FontTexture class
  78771. * @param name the name of the texture
  78772. * @param font the font to use, use the W3C CSS notation
  78773. * @param text the caracter set to use in the rendering.
  78774. * @param scene the scene that owns the texture
  78775. */
  78776. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78777. /**
  78778. * Gets the max char width of a font.
  78779. * @param font the font to use, use the W3C CSS notation
  78780. * @return the max char width
  78781. */
  78782. private getFontWidth;
  78783. /**
  78784. * Gets the max char height of a font.
  78785. * @param font the font to use, use the W3C CSS notation
  78786. * @return the max char height
  78787. */
  78788. private getFontHeight;
  78789. /**
  78790. * Clones the current AsciiArtTexture.
  78791. * @return the clone of the texture.
  78792. */
  78793. clone(): AsciiArtFontTexture;
  78794. /**
  78795. * Parses a json object representing the texture and returns an instance of it.
  78796. * @param source the source JSON representation
  78797. * @param scene the scene to create the texture for
  78798. * @return the parsed texture
  78799. */
  78800. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  78801. }
  78802. /**
  78803. * Option available in the Ascii Art Post Process.
  78804. */
  78805. export interface IAsciiArtPostProcessOptions {
  78806. /**
  78807. * The font to use following the w3c font definition.
  78808. */
  78809. font?: string;
  78810. /**
  78811. * The character set to use in the postprocess.
  78812. */
  78813. characterSet?: string;
  78814. /**
  78815. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78816. * This number is defined between 0 and 1;
  78817. */
  78818. mixToTile?: number;
  78819. /**
  78820. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78821. * This number is defined between 0 and 1;
  78822. */
  78823. mixToNormal?: number;
  78824. }
  78825. /**
  78826. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  78827. *
  78828. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78829. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  78830. */
  78831. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  78832. /**
  78833. * The font texture used to render the char in the post process.
  78834. */
  78835. private _asciiArtFontTexture;
  78836. /**
  78837. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78838. * This number is defined between 0 and 1;
  78839. */
  78840. mixToTile: number;
  78841. /**
  78842. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78843. * This number is defined between 0 and 1;
  78844. */
  78845. mixToNormal: number;
  78846. /**
  78847. * Instantiates a new Ascii Art Post Process.
  78848. * @param name the name to give to the postprocess
  78849. * @camera the camera to apply the post process to.
  78850. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  78851. */
  78852. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  78853. }
  78854. }
  78855. declare module BABYLON {
  78856. /** @hidden */
  78857. export var digitalrainPixelShader: {
  78858. name: string;
  78859. shader: string;
  78860. };
  78861. }
  78862. declare module BABYLON {
  78863. /**
  78864. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  78865. *
  78866. * It basically takes care rendering the font front the given font size to a texture.
  78867. * This is used later on in the postprocess.
  78868. */
  78869. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  78870. private _font;
  78871. private _text;
  78872. private _charSize;
  78873. /**
  78874. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78875. */
  78876. get charSize(): number;
  78877. /**
  78878. * Create a new instance of the Digital Rain FontTexture class
  78879. * @param name the name of the texture
  78880. * @param font the font to use, use the W3C CSS notation
  78881. * @param text the caracter set to use in the rendering.
  78882. * @param scene the scene that owns the texture
  78883. */
  78884. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78885. /**
  78886. * Gets the max char width of a font.
  78887. * @param font the font to use, use the W3C CSS notation
  78888. * @return the max char width
  78889. */
  78890. private getFontWidth;
  78891. /**
  78892. * Gets the max char height of a font.
  78893. * @param font the font to use, use the W3C CSS notation
  78894. * @return the max char height
  78895. */
  78896. private getFontHeight;
  78897. /**
  78898. * Clones the current DigitalRainFontTexture.
  78899. * @return the clone of the texture.
  78900. */
  78901. clone(): DigitalRainFontTexture;
  78902. /**
  78903. * Parses a json object representing the texture and returns an instance of it.
  78904. * @param source the source JSON representation
  78905. * @param scene the scene to create the texture for
  78906. * @return the parsed texture
  78907. */
  78908. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  78909. }
  78910. /**
  78911. * Option available in the Digital Rain Post Process.
  78912. */
  78913. export interface IDigitalRainPostProcessOptions {
  78914. /**
  78915. * The font to use following the w3c font definition.
  78916. */
  78917. font?: string;
  78918. /**
  78919. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78920. * This number is defined between 0 and 1;
  78921. */
  78922. mixToTile?: number;
  78923. /**
  78924. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78925. * This number is defined between 0 and 1;
  78926. */
  78927. mixToNormal?: number;
  78928. }
  78929. /**
  78930. * DigitalRainPostProcess helps rendering everithing in digital rain.
  78931. *
  78932. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78933. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  78934. */
  78935. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  78936. /**
  78937. * The font texture used to render the char in the post process.
  78938. */
  78939. private _digitalRainFontTexture;
  78940. /**
  78941. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78942. * This number is defined between 0 and 1;
  78943. */
  78944. mixToTile: number;
  78945. /**
  78946. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78947. * This number is defined between 0 and 1;
  78948. */
  78949. mixToNormal: number;
  78950. /**
  78951. * Instantiates a new Digital Rain Post Process.
  78952. * @param name the name to give to the postprocess
  78953. * @camera the camera to apply the post process to.
  78954. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  78955. */
  78956. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  78957. }
  78958. }
  78959. declare module BABYLON {
  78960. /** @hidden */
  78961. export var brickProceduralTexturePixelShader: {
  78962. name: string;
  78963. shader: string;
  78964. };
  78965. }
  78966. declare module BABYLON {
  78967. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  78968. private _numberOfBricksHeight;
  78969. private _numberOfBricksWidth;
  78970. private _jointColor;
  78971. private _brickColor;
  78972. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78973. updateShaderUniforms(): void;
  78974. get numberOfBricksHeight(): number;
  78975. set numberOfBricksHeight(value: number);
  78976. get numberOfBricksWidth(): number;
  78977. set numberOfBricksWidth(value: number);
  78978. get jointColor(): BABYLON.Color3;
  78979. set jointColor(value: BABYLON.Color3);
  78980. get brickColor(): BABYLON.Color3;
  78981. set brickColor(value: BABYLON.Color3);
  78982. /**
  78983. * Serializes this brick procedural texture
  78984. * @returns a serialized brick procedural texture object
  78985. */
  78986. serialize(): any;
  78987. /**
  78988. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  78989. * @param parsedTexture defines parsed texture data
  78990. * @param scene defines the current scene
  78991. * @param rootUrl defines the root URL containing brick procedural texture information
  78992. * @returns a parsed Brick Procedural BABYLON.Texture
  78993. */
  78994. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  78995. }
  78996. }
  78997. declare module BABYLON {
  78998. /** @hidden */
  78999. export var cloudProceduralTexturePixelShader: {
  79000. name: string;
  79001. shader: string;
  79002. };
  79003. }
  79004. declare module BABYLON {
  79005. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79006. private _skyColor;
  79007. private _cloudColor;
  79008. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79009. updateShaderUniforms(): void;
  79010. get skyColor(): BABYLON.Color4;
  79011. set skyColor(value: BABYLON.Color4);
  79012. get cloudColor(): BABYLON.Color4;
  79013. set cloudColor(value: BABYLON.Color4);
  79014. /**
  79015. * Serializes this cloud procedural texture
  79016. * @returns a serialized cloud procedural texture object
  79017. */
  79018. serialize(): any;
  79019. /**
  79020. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79021. * @param parsedTexture defines parsed texture data
  79022. * @param scene defines the current scene
  79023. * @param rootUrl defines the root URL containing cloud procedural texture information
  79024. * @returns a parsed Cloud Procedural BABYLON.Texture
  79025. */
  79026. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79027. }
  79028. }
  79029. declare module BABYLON {
  79030. /** @hidden */
  79031. export var fireProceduralTexturePixelShader: {
  79032. name: string;
  79033. shader: string;
  79034. };
  79035. }
  79036. declare module BABYLON {
  79037. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79038. private _time;
  79039. private _speed;
  79040. private _autoGenerateTime;
  79041. private _fireColors;
  79042. private _alphaThreshold;
  79043. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79044. updateShaderUniforms(): void;
  79045. render(useCameraPostProcess?: boolean): void;
  79046. static get PurpleFireColors(): BABYLON.Color3[];
  79047. static get GreenFireColors(): BABYLON.Color3[];
  79048. static get RedFireColors(): BABYLON.Color3[];
  79049. static get BlueFireColors(): BABYLON.Color3[];
  79050. get autoGenerateTime(): boolean;
  79051. set autoGenerateTime(value: boolean);
  79052. get fireColors(): BABYLON.Color3[];
  79053. set fireColors(value: BABYLON.Color3[]);
  79054. get time(): number;
  79055. set time(value: number);
  79056. get speed(): BABYLON.Vector2;
  79057. set speed(value: BABYLON.Vector2);
  79058. get alphaThreshold(): number;
  79059. set alphaThreshold(value: number);
  79060. /**
  79061. * Serializes this fire procedural texture
  79062. * @returns a serialized fire procedural texture object
  79063. */
  79064. serialize(): any;
  79065. /**
  79066. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79067. * @param parsedTexture defines parsed texture data
  79068. * @param scene defines the current scene
  79069. * @param rootUrl defines the root URL containing fire procedural texture information
  79070. * @returns a parsed Fire Procedural BABYLON.Texture
  79071. */
  79072. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79073. }
  79074. }
  79075. declare module BABYLON {
  79076. /** @hidden */
  79077. export var grassProceduralTexturePixelShader: {
  79078. name: string;
  79079. shader: string;
  79080. };
  79081. }
  79082. declare module BABYLON {
  79083. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79084. private _grassColors;
  79085. private _groundColor;
  79086. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79087. updateShaderUniforms(): void;
  79088. get grassColors(): BABYLON.Color3[];
  79089. set grassColors(value: BABYLON.Color3[]);
  79090. get groundColor(): BABYLON.Color3;
  79091. set groundColor(value: BABYLON.Color3);
  79092. /**
  79093. * Serializes this grass procedural texture
  79094. * @returns a serialized grass procedural texture object
  79095. */
  79096. serialize(): any;
  79097. /**
  79098. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79099. * @param parsedTexture defines parsed texture data
  79100. * @param scene defines the current scene
  79101. * @param rootUrl defines the root URL containing grass procedural texture information
  79102. * @returns a parsed Grass Procedural BABYLON.Texture
  79103. */
  79104. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79105. }
  79106. }
  79107. declare module BABYLON {
  79108. /** @hidden */
  79109. export var marbleProceduralTexturePixelShader: {
  79110. name: string;
  79111. shader: string;
  79112. };
  79113. }
  79114. declare module BABYLON {
  79115. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79116. private _numberOfTilesHeight;
  79117. private _numberOfTilesWidth;
  79118. private _amplitude;
  79119. private _jointColor;
  79120. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79121. updateShaderUniforms(): void;
  79122. get numberOfTilesHeight(): number;
  79123. set numberOfTilesHeight(value: number);
  79124. get amplitude(): number;
  79125. set amplitude(value: number);
  79126. get numberOfTilesWidth(): number;
  79127. set numberOfTilesWidth(value: number);
  79128. get jointColor(): BABYLON.Color3;
  79129. set jointColor(value: BABYLON.Color3);
  79130. /**
  79131. * Serializes this marble procedural texture
  79132. * @returns a serialized marble procedural texture object
  79133. */
  79134. serialize(): any;
  79135. /**
  79136. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79137. * @param parsedTexture defines parsed texture data
  79138. * @param scene defines the current scene
  79139. * @param rootUrl defines the root URL containing marble procedural texture information
  79140. * @returns a parsed Marble Procedural BABYLON.Texture
  79141. */
  79142. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79143. }
  79144. }
  79145. declare module BABYLON {
  79146. /** @hidden */
  79147. export var normalMapProceduralTexturePixelShader: {
  79148. name: string;
  79149. shader: string;
  79150. };
  79151. }
  79152. declare module BABYLON {
  79153. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79154. private _baseTexture;
  79155. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79156. updateShaderUniforms(): void;
  79157. render(useCameraPostProcess?: boolean): void;
  79158. resize(size: any, generateMipMaps: any): void;
  79159. get baseTexture(): BABYLON.Texture;
  79160. set baseTexture(texture: BABYLON.Texture);
  79161. /**
  79162. * Serializes this normal map procedural texture
  79163. * @returns a serialized normal map procedural texture object
  79164. */
  79165. serialize(): any;
  79166. /**
  79167. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79168. * @param parsedTexture defines parsed texture data
  79169. * @param scene defines the current scene
  79170. * @param rootUrl defines the root URL containing normal map procedural texture information
  79171. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79172. */
  79173. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79174. }
  79175. }
  79176. declare module BABYLON {
  79177. /** @hidden */
  79178. export var perlinNoiseProceduralTexturePixelShader: {
  79179. name: string;
  79180. shader: string;
  79181. };
  79182. }
  79183. declare module BABYLON {
  79184. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79185. time: number;
  79186. timeScale: number;
  79187. translationSpeed: number;
  79188. private _currentTranslation;
  79189. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79190. updateShaderUniforms(): void;
  79191. render(useCameraPostProcess?: boolean): void;
  79192. resize(size: any, generateMipMaps: any): void;
  79193. /**
  79194. * Serializes this perlin noise procedural texture
  79195. * @returns a serialized perlin noise procedural texture object
  79196. */
  79197. serialize(): any;
  79198. /**
  79199. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79200. * @param parsedTexture defines parsed texture data
  79201. * @param scene defines the current scene
  79202. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79203. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79204. */
  79205. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79206. }
  79207. }
  79208. declare module BABYLON {
  79209. /** @hidden */
  79210. export var roadProceduralTexturePixelShader: {
  79211. name: string;
  79212. shader: string;
  79213. };
  79214. }
  79215. declare module BABYLON {
  79216. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79217. private _roadColor;
  79218. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79219. updateShaderUniforms(): void;
  79220. get roadColor(): BABYLON.Color3;
  79221. set roadColor(value: BABYLON.Color3);
  79222. /**
  79223. * Serializes this road procedural texture
  79224. * @returns a serialized road procedural texture object
  79225. */
  79226. serialize(): any;
  79227. /**
  79228. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79229. * @param parsedTexture defines parsed texture data
  79230. * @param scene defines the current scene
  79231. * @param rootUrl defines the root URL containing road procedural texture information
  79232. * @returns a parsed Road Procedural BABYLON.Texture
  79233. */
  79234. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79235. }
  79236. }
  79237. declare module BABYLON {
  79238. /** @hidden */
  79239. export var starfieldProceduralTexturePixelShader: {
  79240. name: string;
  79241. shader: string;
  79242. };
  79243. }
  79244. declare module BABYLON {
  79245. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79246. private _time;
  79247. private _alpha;
  79248. private _beta;
  79249. private _zoom;
  79250. private _formuparam;
  79251. private _stepsize;
  79252. private _tile;
  79253. private _brightness;
  79254. private _darkmatter;
  79255. private _distfading;
  79256. private _saturation;
  79257. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79258. updateShaderUniforms(): void;
  79259. get time(): number;
  79260. set time(value: number);
  79261. get alpha(): number;
  79262. set alpha(value: number);
  79263. get beta(): number;
  79264. set beta(value: number);
  79265. get formuparam(): number;
  79266. set formuparam(value: number);
  79267. get stepsize(): number;
  79268. set stepsize(value: number);
  79269. get zoom(): number;
  79270. set zoom(value: number);
  79271. get tile(): number;
  79272. set tile(value: number);
  79273. get brightness(): number;
  79274. set brightness(value: number);
  79275. get darkmatter(): number;
  79276. set darkmatter(value: number);
  79277. get distfading(): number;
  79278. set distfading(value: number);
  79279. get saturation(): number;
  79280. set saturation(value: number);
  79281. /**
  79282. * Serializes this starfield procedural texture
  79283. * @returns a serialized starfield procedural texture object
  79284. */
  79285. serialize(): any;
  79286. /**
  79287. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79288. * @param parsedTexture defines parsed texture data
  79289. * @param scene defines the current scene
  79290. * @param rootUrl defines the root URL containing startfield procedural texture information
  79291. * @returns a parsed Starfield Procedural BABYLON.Texture
  79292. */
  79293. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79294. }
  79295. }
  79296. declare module BABYLON {
  79297. /** @hidden */
  79298. export var woodProceduralTexturePixelShader: {
  79299. name: string;
  79300. shader: string;
  79301. };
  79302. }
  79303. declare module BABYLON {
  79304. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79305. private _ampScale;
  79306. private _woodColor;
  79307. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79308. updateShaderUniforms(): void;
  79309. get ampScale(): number;
  79310. set ampScale(value: number);
  79311. get woodColor(): BABYLON.Color3;
  79312. set woodColor(value: BABYLON.Color3);
  79313. /**
  79314. * Serializes this wood procedural texture
  79315. * @returns a serialized wood procedural texture object
  79316. */
  79317. serialize(): any;
  79318. /**
  79319. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79320. * @param parsedTexture defines parsed texture data
  79321. * @param scene defines the current scene
  79322. * @param rootUrl defines the root URL containing wood procedural texture information
  79323. * @returns a parsed Wood Procedural BABYLON.Texture
  79324. */
  79325. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79326. }
  79327. }