documentation.d.ts 3.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279
  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: string | ArrayBuffer | (string | ArrayBuffer)[], 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: ArrayBuffer, 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: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7639. /** @hidden */
  7640. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | 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 shadowMapPixelShader: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var bonesDeclaration: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var morphTargetsVertexGlobalDeclaration: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var morphTargetsVertexDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var instancesDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var helperFunctions: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var morphTargetsVertex: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var instancesVertex: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var bonesVertex: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapVertexShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var depthBoxBlurPixelShader: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /**
  9375. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9376. */
  9377. export interface ICustomShaderOptions {
  9378. /**
  9379. * Gets or sets the custom shader name to use
  9380. */
  9381. shaderName: string;
  9382. /**
  9383. * The list of attribute names used in the shader
  9384. */
  9385. attributes?: string[];
  9386. /**
  9387. * The list of unifrom names used in the shader
  9388. */
  9389. uniforms?: string[];
  9390. /**
  9391. * The list of sampler names used in the shader
  9392. */
  9393. samplers?: string[];
  9394. /**
  9395. * The list of defines used in the shader
  9396. */
  9397. defines?: string[];
  9398. }
  9399. /**
  9400. * Interface to implement to create a shadow generator compatible with BJS.
  9401. */
  9402. export interface IShadowGenerator {
  9403. /**
  9404. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9405. * @returns The render target texture if present otherwise, null
  9406. */
  9407. getShadowMap(): Nullable<RenderTargetTexture>;
  9408. /**
  9409. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9410. * @param subMesh The submesh we want to render in the shadow map
  9411. * @param useInstances Defines wether will draw in the map using instances
  9412. * @returns true if ready otherwise, false
  9413. */
  9414. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9415. /**
  9416. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9417. * @param defines Defines of the material we want to update
  9418. * @param lightIndex Index of the light in the enabled light list of the material
  9419. */
  9420. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9421. /**
  9422. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9423. * defined in the generator but impacting the effect).
  9424. * It implies the unifroms available on the materials are the standard BJS ones.
  9425. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9426. * @param effect The effect we are binfing the information for
  9427. */
  9428. bindShadowLight(lightIndex: string, effect: Effect): void;
  9429. /**
  9430. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9431. * (eq to shadow prjection matrix * light transform matrix)
  9432. * @returns The transform matrix used to create the shadow map
  9433. */
  9434. getTransformMatrix(): Matrix;
  9435. /**
  9436. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9437. * Cube and 2D textures for instance.
  9438. */
  9439. recreateShadowMap(): void;
  9440. /**
  9441. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9442. * @param onCompiled Callback triggered at the and of the effects compilation
  9443. * @param options Sets of optional options forcing the compilation with different modes
  9444. */
  9445. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9446. useInstances: boolean;
  9447. }>): void;
  9448. /**
  9449. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9450. * @param options Sets of optional options forcing the compilation with different modes
  9451. * @returns A promise that resolves when the compilation completes
  9452. */
  9453. forceCompilationAsync(options?: Partial<{
  9454. useInstances: boolean;
  9455. }>): Promise<void>;
  9456. /**
  9457. * Serializes the shadow generator setup to a json object.
  9458. * @returns The serialized JSON object
  9459. */
  9460. serialize(): any;
  9461. /**
  9462. * Disposes the Shadow map and related Textures and effects.
  9463. */
  9464. dispose(): void;
  9465. }
  9466. /**
  9467. * Default implementation IShadowGenerator.
  9468. * This is the main object responsible of generating shadows in the framework.
  9469. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9470. */
  9471. export class ShadowGenerator implements IShadowGenerator {
  9472. /**
  9473. * Name of the shadow generator class
  9474. */
  9475. static CLASSNAME: string;
  9476. /**
  9477. * Shadow generator mode None: no filtering applied.
  9478. */
  9479. static readonly FILTER_NONE: number;
  9480. /**
  9481. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9482. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9483. */
  9484. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9485. /**
  9486. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9487. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9488. */
  9489. static readonly FILTER_POISSONSAMPLING: number;
  9490. /**
  9491. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9492. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9493. */
  9494. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9495. /**
  9496. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9497. * edge artifacts on steep falloff.
  9498. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9499. */
  9500. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9501. /**
  9502. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9503. * edge artifacts on steep falloff.
  9504. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9505. */
  9506. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9507. /**
  9508. * Shadow generator mode PCF: Percentage Closer Filtering
  9509. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9510. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9511. */
  9512. static readonly FILTER_PCF: number;
  9513. /**
  9514. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9515. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9516. * Contact Hardening
  9517. */
  9518. static readonly FILTER_PCSS: number;
  9519. /**
  9520. * Reserved for PCF and PCSS
  9521. * Highest Quality.
  9522. *
  9523. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9524. *
  9525. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9526. */
  9527. static readonly QUALITY_HIGH: number;
  9528. /**
  9529. * Reserved for PCF and PCSS
  9530. * Good tradeoff for quality/perf cross devices
  9531. *
  9532. * Execute PCF on a 3*3 kernel.
  9533. *
  9534. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9535. */
  9536. static readonly QUALITY_MEDIUM: number;
  9537. /**
  9538. * Reserved for PCF and PCSS
  9539. * The lowest quality but the fastest.
  9540. *
  9541. * Execute PCF on a 1*1 kernel.
  9542. *
  9543. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9544. */
  9545. static readonly QUALITY_LOW: number;
  9546. /** Gets or sets the custom shader name to use */
  9547. customShaderOptions: ICustomShaderOptions;
  9548. /**
  9549. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9550. */
  9551. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9552. /**
  9553. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9554. */
  9555. onAfterShadowMapRenderObservable: Observable<Effect>;
  9556. /**
  9557. * Observable triggered before a mesh is rendered in the shadow map.
  9558. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9559. */
  9560. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9561. /**
  9562. * Observable triggered after a mesh is rendered in the shadow map.
  9563. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9564. */
  9565. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9566. protected _bias: number;
  9567. /**
  9568. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9569. */
  9570. get bias(): number;
  9571. /**
  9572. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9573. */
  9574. set bias(bias: number);
  9575. protected _normalBias: number;
  9576. /**
  9577. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9578. */
  9579. get normalBias(): number;
  9580. /**
  9581. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9582. */
  9583. set normalBias(normalBias: number);
  9584. protected _blurBoxOffset: number;
  9585. /**
  9586. * Gets the blur box offset: offset applied during the blur pass.
  9587. * Only useful if useKernelBlur = false
  9588. */
  9589. get blurBoxOffset(): number;
  9590. /**
  9591. * Sets the blur box offset: offset applied during the blur pass.
  9592. * Only useful if useKernelBlur = false
  9593. */
  9594. set blurBoxOffset(value: number);
  9595. protected _blurScale: number;
  9596. /**
  9597. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9598. * 2 means half of the size.
  9599. */
  9600. get blurScale(): number;
  9601. /**
  9602. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9603. * 2 means half of the size.
  9604. */
  9605. set blurScale(value: number);
  9606. protected _blurKernel: number;
  9607. /**
  9608. * Gets the blur kernel: kernel size of the blur pass.
  9609. * Only useful if useKernelBlur = true
  9610. */
  9611. get blurKernel(): number;
  9612. /**
  9613. * Sets the blur kernel: kernel size of the blur pass.
  9614. * Only useful if useKernelBlur = true
  9615. */
  9616. set blurKernel(value: number);
  9617. protected _useKernelBlur: boolean;
  9618. /**
  9619. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9620. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9621. */
  9622. get useKernelBlur(): boolean;
  9623. /**
  9624. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9625. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9626. */
  9627. set useKernelBlur(value: boolean);
  9628. protected _depthScale: number;
  9629. /**
  9630. * Gets the depth scale used in ESM mode.
  9631. */
  9632. get depthScale(): number;
  9633. /**
  9634. * Sets the depth scale used in ESM mode.
  9635. * This can override the scale stored on the light.
  9636. */
  9637. set depthScale(value: number);
  9638. protected _validateFilter(filter: number): number;
  9639. protected _filter: number;
  9640. /**
  9641. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9642. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9643. */
  9644. get filter(): number;
  9645. /**
  9646. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9647. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9648. */
  9649. set filter(value: number);
  9650. /**
  9651. * Gets if the current filter is set to Poisson Sampling.
  9652. */
  9653. get usePoissonSampling(): boolean;
  9654. /**
  9655. * Sets the current filter to Poisson Sampling.
  9656. */
  9657. set usePoissonSampling(value: boolean);
  9658. /**
  9659. * Gets if the current filter is set to ESM.
  9660. */
  9661. get useExponentialShadowMap(): boolean;
  9662. /**
  9663. * Sets the current filter is to ESM.
  9664. */
  9665. set useExponentialShadowMap(value: boolean);
  9666. /**
  9667. * Gets if the current filter is set to filtered ESM.
  9668. */
  9669. get useBlurExponentialShadowMap(): boolean;
  9670. /**
  9671. * Gets if the current filter is set to filtered ESM.
  9672. */
  9673. set useBlurExponentialShadowMap(value: boolean);
  9674. /**
  9675. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9676. * exponential to prevent steep falloff artifacts).
  9677. */
  9678. get useCloseExponentialShadowMap(): boolean;
  9679. /**
  9680. * Sets the current filter to "close ESM" (using the inverse of the
  9681. * exponential to prevent steep falloff artifacts).
  9682. */
  9683. set useCloseExponentialShadowMap(value: boolean);
  9684. /**
  9685. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9686. * exponential to prevent steep falloff artifacts).
  9687. */
  9688. get useBlurCloseExponentialShadowMap(): boolean;
  9689. /**
  9690. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9691. * exponential to prevent steep falloff artifacts).
  9692. */
  9693. set useBlurCloseExponentialShadowMap(value: boolean);
  9694. /**
  9695. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9696. */
  9697. get usePercentageCloserFiltering(): boolean;
  9698. /**
  9699. * Sets the current filter to "PCF" (percentage closer filtering).
  9700. */
  9701. set usePercentageCloserFiltering(value: boolean);
  9702. protected _filteringQuality: number;
  9703. /**
  9704. * Gets the PCF or PCSS Quality.
  9705. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9706. */
  9707. get filteringQuality(): number;
  9708. /**
  9709. * Sets the PCF or PCSS Quality.
  9710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9711. */
  9712. set filteringQuality(filteringQuality: number);
  9713. /**
  9714. * Gets if the current filter is set to "PCSS" (contact hardening).
  9715. */
  9716. get useContactHardeningShadow(): boolean;
  9717. /**
  9718. * Sets the current filter to "PCSS" (contact hardening).
  9719. */
  9720. set useContactHardeningShadow(value: boolean);
  9721. protected _contactHardeningLightSizeUVRatio: number;
  9722. /**
  9723. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9724. * Using a ratio helps keeping shape stability independently of the map size.
  9725. *
  9726. * It does not account for the light projection as it was having too much
  9727. * instability during the light setup or during light position changes.
  9728. *
  9729. * Only valid if useContactHardeningShadow is true.
  9730. */
  9731. get contactHardeningLightSizeUVRatio(): number;
  9732. /**
  9733. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9734. * Using a ratio helps keeping shape stability independently of the map size.
  9735. *
  9736. * It does not account for the light projection as it was having too much
  9737. * instability during the light setup or during light position changes.
  9738. *
  9739. * Only valid if useContactHardeningShadow is true.
  9740. */
  9741. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9742. protected _darkness: number;
  9743. /** Gets or sets the actual darkness of a shadow */
  9744. get darkness(): number;
  9745. set darkness(value: number);
  9746. /**
  9747. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9748. * 0 means strongest and 1 would means no shadow.
  9749. * @returns the darkness.
  9750. */
  9751. getDarkness(): number;
  9752. /**
  9753. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9754. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9755. * @returns the shadow generator allowing fluent coding.
  9756. */
  9757. setDarkness(darkness: number): ShadowGenerator;
  9758. protected _transparencyShadow: boolean;
  9759. /** Gets or sets the ability to have transparent shadow */
  9760. get transparencyShadow(): boolean;
  9761. set transparencyShadow(value: boolean);
  9762. /**
  9763. * Sets the ability to have transparent shadow (boolean).
  9764. * @param transparent True if transparent else False
  9765. * @returns the shadow generator allowing fluent coding
  9766. */
  9767. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9768. protected _shadowMap: Nullable<RenderTargetTexture>;
  9769. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9770. /**
  9771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9772. * @returns The render target texture if present otherwise, null
  9773. */
  9774. getShadowMap(): Nullable<RenderTargetTexture>;
  9775. /**
  9776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9777. * @returns The render target texture if the shadow map is present otherwise, null
  9778. */
  9779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9780. /**
  9781. * Gets the class name of that object
  9782. * @returns "ShadowGenerator"
  9783. */
  9784. getClassName(): string;
  9785. /**
  9786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9787. * @param mesh Mesh to add
  9788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9789. * @returns the Shadow Generator itself
  9790. */
  9791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9792. /**
  9793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9794. * @param mesh Mesh to remove
  9795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9796. * @returns the Shadow Generator itself
  9797. */
  9798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9799. /**
  9800. * Controls the extent to which the shadows fade out at the edge of the frustum
  9801. */
  9802. frustumEdgeFalloff: number;
  9803. protected _light: IShadowLight;
  9804. /**
  9805. * Returns the associated light object.
  9806. * @returns the light generating the shadow
  9807. */
  9808. getLight(): IShadowLight;
  9809. /**
  9810. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9811. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9812. * It might on the other hand introduce peter panning.
  9813. */
  9814. forceBackFacesOnly: boolean;
  9815. protected _scene: Scene;
  9816. protected _lightDirection: Vector3;
  9817. protected _effect: Effect;
  9818. protected _viewMatrix: Matrix;
  9819. protected _projectionMatrix: Matrix;
  9820. protected _transformMatrix: Matrix;
  9821. protected _cachedPosition: Vector3;
  9822. protected _cachedDirection: Vector3;
  9823. protected _cachedDefines: string;
  9824. protected _currentRenderID: number;
  9825. protected _boxBlurPostprocess: Nullable<PostProcess>;
  9826. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  9827. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  9828. protected _blurPostProcesses: PostProcess[];
  9829. protected _mapSize: number;
  9830. protected _currentFaceIndex: number;
  9831. protected _currentFaceIndexCache: number;
  9832. protected _textureType: number;
  9833. protected _defaultTextureMatrix: Matrix;
  9834. protected _storedUniqueId: Nullable<number>;
  9835. /** @hidden */
  9836. static _SceneComponentInitialization: (scene: Scene) => void;
  9837. /**
  9838. * Creates a ShadowGenerator object.
  9839. * A ShadowGenerator is the required tool to use the shadows.
  9840. * Each light casting shadows needs to use its own ShadowGenerator.
  9841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9843. * @param light The light object generating the shadows.
  9844. * @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.
  9845. */
  9846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9847. protected _initializeGenerator(): void;
  9848. protected _createTargetRenderTexture(): void;
  9849. protected _initializeShadowMap(): void;
  9850. protected _initializeBlurRTTAndPostProcesses(): void;
  9851. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  9852. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  9853. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  9854. protected _applyFilterValues(): void;
  9855. /**
  9856. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9857. * @param onCompiled Callback triggered at the and of the effects compilation
  9858. * @param options Sets of optional options forcing the compilation with different modes
  9859. */
  9860. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9861. useInstances: boolean;
  9862. }>): void;
  9863. /**
  9864. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9865. * @param options Sets of optional options forcing the compilation with different modes
  9866. * @returns A promise that resolves when the compilation completes
  9867. */
  9868. forceCompilationAsync(options?: Partial<{
  9869. useInstances: boolean;
  9870. }>): Promise<void>;
  9871. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  9872. /**
  9873. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9874. * @param subMesh The submesh we want to render in the shadow map
  9875. * @param useInstances Defines wether will draw in the map using instances
  9876. * @returns true if ready otherwise, false
  9877. */
  9878. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9879. /**
  9880. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9881. * @param defines Defines of the material we want to update
  9882. * @param lightIndex Index of the light in the enabled light list of the material
  9883. */
  9884. prepareDefines(defines: any, lightIndex: number): void;
  9885. /**
  9886. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9887. * defined in the generator but impacting the effect).
  9888. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9889. * @param effect The effect we are binfing the information for
  9890. */
  9891. bindShadowLight(lightIndex: string, effect: Effect): void;
  9892. /**
  9893. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9894. * (eq to shadow prjection matrix * light transform matrix)
  9895. * @returns The transform matrix used to create the shadow map
  9896. */
  9897. getTransformMatrix(): Matrix;
  9898. /**
  9899. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9900. * Cube and 2D textures for instance.
  9901. */
  9902. recreateShadowMap(): void;
  9903. protected _disposeBlurPostProcesses(): void;
  9904. protected _disposeRTTandPostProcesses(): void;
  9905. /**
  9906. * Disposes the ShadowGenerator.
  9907. * Returns nothing.
  9908. */
  9909. dispose(): void;
  9910. /**
  9911. * Serializes the shadow generator setup to a json object.
  9912. * @returns The serialized JSON object
  9913. */
  9914. serialize(): any;
  9915. /**
  9916. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9917. * @param parsedShadowGenerator The JSON object to parse
  9918. * @param scene The scene to create the shadow map for
  9919. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  9920. * @returns The parsed shadow generator
  9921. */
  9922. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  9923. }
  9924. }
  9925. declare module BABYLON {
  9926. /**
  9927. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9928. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9929. * 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.
  9930. */
  9931. export abstract class Light extends Node {
  9932. /**
  9933. * Falloff Default: light is falling off following the material specification:
  9934. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9935. */
  9936. static readonly FALLOFF_DEFAULT: number;
  9937. /**
  9938. * Falloff Physical: light is falling off following the inverse squared distance law.
  9939. */
  9940. static readonly FALLOFF_PHYSICAL: number;
  9941. /**
  9942. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9943. * to enhance interoperability with other engines.
  9944. */
  9945. static readonly FALLOFF_GLTF: number;
  9946. /**
  9947. * Falloff Standard: light is falling off like in the standard material
  9948. * to enhance interoperability with other materials.
  9949. */
  9950. static readonly FALLOFF_STANDARD: number;
  9951. /**
  9952. * If every light affecting the material is in this lightmapMode,
  9953. * material.lightmapTexture adds or multiplies
  9954. * (depends on material.useLightmapAsShadowmap)
  9955. * after every other light calculations.
  9956. */
  9957. static readonly LIGHTMAP_DEFAULT: number;
  9958. /**
  9959. * material.lightmapTexture as only diffuse lighting from this light
  9960. * adds only specular lighting from this light
  9961. * adds dynamic shadows
  9962. */
  9963. static readonly LIGHTMAP_SPECULAR: number;
  9964. /**
  9965. * material.lightmapTexture as only lighting
  9966. * no light calculation from this light
  9967. * only adds dynamic shadows from this light
  9968. */
  9969. static readonly LIGHTMAP_SHADOWSONLY: number;
  9970. /**
  9971. * Each light type uses the default quantity according to its type:
  9972. * point/spot lights use luminous intensity
  9973. * directional lights use illuminance
  9974. */
  9975. static readonly INTENSITYMODE_AUTOMATIC: number;
  9976. /**
  9977. * lumen (lm)
  9978. */
  9979. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9980. /**
  9981. * candela (lm/sr)
  9982. */
  9983. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9984. /**
  9985. * lux (lm/m^2)
  9986. */
  9987. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9988. /**
  9989. * nit (cd/m^2)
  9990. */
  9991. static readonly INTENSITYMODE_LUMINANCE: number;
  9992. /**
  9993. * Light type const id of the point light.
  9994. */
  9995. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9996. /**
  9997. * Light type const id of the directional light.
  9998. */
  9999. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10000. /**
  10001. * Light type const id of the spot light.
  10002. */
  10003. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10004. /**
  10005. * Light type const id of the hemispheric light.
  10006. */
  10007. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10008. /**
  10009. * Diffuse gives the basic color to an object.
  10010. */
  10011. diffuse: Color3;
  10012. /**
  10013. * Specular produces a highlight color on an object.
  10014. * Note: This is note affecting PBR materials.
  10015. */
  10016. specular: Color3;
  10017. /**
  10018. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10019. * falling off base on range or angle.
  10020. * This can be set to any values in Light.FALLOFF_x.
  10021. *
  10022. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10023. * other types of materials.
  10024. */
  10025. falloffType: number;
  10026. /**
  10027. * Strength of the light.
  10028. * Note: By default it is define in the framework own unit.
  10029. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10030. */
  10031. intensity: number;
  10032. private _range;
  10033. protected _inverseSquaredRange: number;
  10034. /**
  10035. * Defines how far from the source the light is impacting in scene units.
  10036. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10037. */
  10038. get range(): number;
  10039. /**
  10040. * Defines how far from the source the light is impacting in scene units.
  10041. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10042. */
  10043. set range(value: number);
  10044. /**
  10045. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10046. * of light.
  10047. */
  10048. private _photometricScale;
  10049. private _intensityMode;
  10050. /**
  10051. * Gets the photometric scale used to interpret the intensity.
  10052. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10053. */
  10054. get intensityMode(): number;
  10055. /**
  10056. * Sets the photometric scale used to interpret the intensity.
  10057. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10058. */
  10059. set intensityMode(value: number);
  10060. private _radius;
  10061. /**
  10062. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10063. */
  10064. get radius(): number;
  10065. /**
  10066. * sets the light radius used by PBR Materials to simulate soft area lights.
  10067. */
  10068. set radius(value: number);
  10069. private _renderPriority;
  10070. /**
  10071. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10072. * exceeding the number allowed of the materials.
  10073. */
  10074. renderPriority: number;
  10075. private _shadowEnabled;
  10076. /**
  10077. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10078. * the current shadow generator.
  10079. */
  10080. get shadowEnabled(): boolean;
  10081. /**
  10082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10083. * the current shadow generator.
  10084. */
  10085. set shadowEnabled(value: boolean);
  10086. private _includedOnlyMeshes;
  10087. /**
  10088. * Gets the only meshes impacted by this light.
  10089. */
  10090. get includedOnlyMeshes(): AbstractMesh[];
  10091. /**
  10092. * Sets the only meshes impacted by this light.
  10093. */
  10094. set includedOnlyMeshes(value: AbstractMesh[]);
  10095. private _excludedMeshes;
  10096. /**
  10097. * Gets the meshes not impacted by this light.
  10098. */
  10099. get excludedMeshes(): AbstractMesh[];
  10100. /**
  10101. * Sets the meshes not impacted by this light.
  10102. */
  10103. set excludedMeshes(value: AbstractMesh[]);
  10104. private _excludeWithLayerMask;
  10105. /**
  10106. * Gets the layer id use to find what meshes are not impacted by the light.
  10107. * Inactive if 0
  10108. */
  10109. get excludeWithLayerMask(): number;
  10110. /**
  10111. * Sets the layer id use to find what meshes are not impacted by the light.
  10112. * Inactive if 0
  10113. */
  10114. set excludeWithLayerMask(value: number);
  10115. private _includeOnlyWithLayerMask;
  10116. /**
  10117. * Gets the layer id use to find what meshes are impacted by the light.
  10118. * Inactive if 0
  10119. */
  10120. get includeOnlyWithLayerMask(): number;
  10121. /**
  10122. * Sets the layer id use to find what meshes are impacted by the light.
  10123. * Inactive if 0
  10124. */
  10125. set includeOnlyWithLayerMask(value: number);
  10126. private _lightmapMode;
  10127. /**
  10128. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10129. */
  10130. get lightmapMode(): number;
  10131. /**
  10132. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10133. */
  10134. set lightmapMode(value: number);
  10135. /**
  10136. * Shadow generator associted to the light.
  10137. * @hidden Internal use only.
  10138. */
  10139. _shadowGenerator: Nullable<IShadowGenerator>;
  10140. /**
  10141. * @hidden Internal use only.
  10142. */
  10143. _excludedMeshesIds: string[];
  10144. /**
  10145. * @hidden Internal use only.
  10146. */
  10147. _includedOnlyMeshesIds: string[];
  10148. /**
  10149. * The current light unifom buffer.
  10150. * @hidden Internal use only.
  10151. */
  10152. _uniformBuffer: UniformBuffer;
  10153. /** @hidden */
  10154. _renderId: number;
  10155. /**
  10156. * Creates a Light object in the scene.
  10157. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10158. * @param name The firendly name of the light
  10159. * @param scene The scene the light belongs too
  10160. */
  10161. constructor(name: string, scene: Scene);
  10162. protected abstract _buildUniformLayout(): void;
  10163. /**
  10164. * Sets the passed Effect "effect" with the Light information.
  10165. * @param effect The effect to update
  10166. * @param lightIndex The index of the light in the effect to update
  10167. * @returns The light
  10168. */
  10169. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10170. /**
  10171. * Sets the passed Effect "effect" with the Light textures.
  10172. * @param effect The effect to update
  10173. * @param lightIndex The index of the light in the effect to update
  10174. * @returns The light
  10175. */
  10176. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10177. /**
  10178. * Binds the lights information from the scene to the effect for the given mesh.
  10179. * @param lightIndex Light index
  10180. * @param scene The scene where the light belongs to
  10181. * @param effect The effect we are binding the data to
  10182. * @param useSpecular Defines if specular is supported
  10183. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10184. */
  10185. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10186. /**
  10187. * Sets the passed Effect "effect" with the Light information.
  10188. * @param effect The effect to update
  10189. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10190. * @returns The light
  10191. */
  10192. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10193. /**
  10194. * Returns the string "Light".
  10195. * @returns the class name
  10196. */
  10197. getClassName(): string;
  10198. /** @hidden */
  10199. readonly _isLight: boolean;
  10200. /**
  10201. * Converts the light information to a readable string for debug purpose.
  10202. * @param fullDetails Supports for multiple levels of logging within scene loading
  10203. * @returns the human readable light info
  10204. */
  10205. toString(fullDetails?: boolean): string;
  10206. /** @hidden */
  10207. protected _syncParentEnabledState(): void;
  10208. /**
  10209. * Set the enabled state of this node.
  10210. * @param value - the new enabled state
  10211. */
  10212. setEnabled(value: boolean): void;
  10213. /**
  10214. * Returns the Light associated shadow generator if any.
  10215. * @return the associated shadow generator.
  10216. */
  10217. getShadowGenerator(): Nullable<IShadowGenerator>;
  10218. /**
  10219. * Returns a Vector3, the absolute light position in the World.
  10220. * @returns the world space position of the light
  10221. */
  10222. getAbsolutePosition(): Vector3;
  10223. /**
  10224. * Specifies if the light will affect the passed mesh.
  10225. * @param mesh The mesh to test against the light
  10226. * @return true the mesh is affected otherwise, false.
  10227. */
  10228. canAffectMesh(mesh: AbstractMesh): boolean;
  10229. /**
  10230. * Sort function to order lights for rendering.
  10231. * @param a First Light object to compare to second.
  10232. * @param b Second Light object to compare first.
  10233. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10234. */
  10235. static CompareLightsPriority(a: Light, b: Light): number;
  10236. /**
  10237. * Releases resources associated with this node.
  10238. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10239. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10240. */
  10241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10242. /**
  10243. * Returns the light type ID (integer).
  10244. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10245. */
  10246. getTypeID(): number;
  10247. /**
  10248. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10249. * @returns the scaled intensity in intensity mode unit
  10250. */
  10251. getScaledIntensity(): number;
  10252. /**
  10253. * Returns a new Light object, named "name", from the current one.
  10254. * @param name The name of the cloned light
  10255. * @returns the new created light
  10256. */
  10257. clone(name: string): Nullable<Light>;
  10258. /**
  10259. * Serializes the current light into a Serialization object.
  10260. * @returns the serialized object.
  10261. */
  10262. serialize(): any;
  10263. /**
  10264. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10265. * This new light is named "name" and added to the passed scene.
  10266. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10267. * @param name The friendly name of the light
  10268. * @param scene The scene the new light will belong to
  10269. * @returns the constructor function
  10270. */
  10271. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10272. /**
  10273. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10274. * @param parsedLight The JSON representation of the light
  10275. * @param scene The scene to create the parsed light in
  10276. * @returns the created light after parsing
  10277. */
  10278. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10279. private _hookArrayForExcluded;
  10280. private _hookArrayForIncludedOnly;
  10281. private _resyncMeshes;
  10282. /**
  10283. * Forces the meshes to update their light related information in their rendering used effects
  10284. * @hidden Internal Use Only
  10285. */
  10286. _markMeshesAsLightDirty(): void;
  10287. /**
  10288. * Recomputes the cached photometric scale if needed.
  10289. */
  10290. private _computePhotometricScale;
  10291. /**
  10292. * Returns the Photometric Scale according to the light type and intensity mode.
  10293. */
  10294. private _getPhotometricScale;
  10295. /**
  10296. * Reorder the light in the scene according to their defined priority.
  10297. * @hidden Internal Use Only
  10298. */
  10299. _reorderLightsInScene(): void;
  10300. /**
  10301. * Prepares the list of defines specific to the light type.
  10302. * @param defines the list of defines
  10303. * @param lightIndex defines the index of the light for the effect
  10304. */
  10305. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10306. }
  10307. }
  10308. declare module BABYLON {
  10309. /**
  10310. * Interface used to define Action
  10311. */
  10312. export interface IAction {
  10313. /**
  10314. * Trigger for the action
  10315. */
  10316. trigger: number;
  10317. /** Options of the trigger */
  10318. triggerOptions: any;
  10319. /**
  10320. * Gets the trigger parameters
  10321. * @returns the trigger parameters
  10322. */
  10323. getTriggerParameter(): any;
  10324. /**
  10325. * Internal only - executes current action event
  10326. * @hidden
  10327. */
  10328. _executeCurrent(evt?: ActionEvent): void;
  10329. /**
  10330. * Serialize placeholder for child classes
  10331. * @param parent of child
  10332. * @returns the serialized object
  10333. */
  10334. serialize(parent: any): any;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. _prepare(): void;
  10340. /**
  10341. * Internal only - manager for action
  10342. * @hidden
  10343. */
  10344. _actionManager: AbstractActionManager;
  10345. /**
  10346. * Adds action to chain of actions, may be a DoNothingAction
  10347. * @param action defines the next action to execute
  10348. * @returns The action passed in
  10349. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10350. */
  10351. then(action: IAction): IAction;
  10352. }
  10353. /**
  10354. * The action to be carried out following a trigger
  10355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10356. */
  10357. export class Action implements IAction {
  10358. /** the trigger, with or without parameters, for the action */
  10359. triggerOptions: any;
  10360. /**
  10361. * Trigger for the action
  10362. */
  10363. trigger: number;
  10364. /**
  10365. * Internal only - manager for action
  10366. * @hidden
  10367. */
  10368. _actionManager: ActionManager;
  10369. private _nextActiveAction;
  10370. private _child;
  10371. private _condition?;
  10372. private _triggerParameter;
  10373. /**
  10374. * An event triggered prior to action being executed.
  10375. */
  10376. onBeforeExecuteObservable: Observable<Action>;
  10377. /**
  10378. * Creates a new Action
  10379. * @param triggerOptions the trigger, with or without parameters, for the action
  10380. * @param condition an optional determinant of action
  10381. */
  10382. constructor(
  10383. /** the trigger, with or without parameters, for the action */
  10384. triggerOptions: any, condition?: Condition);
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. _prepare(): void;
  10390. /**
  10391. * Gets the trigger parameters
  10392. * @returns the trigger parameters
  10393. */
  10394. getTriggerParameter(): any;
  10395. /**
  10396. * Internal only - executes current action event
  10397. * @hidden
  10398. */
  10399. _executeCurrent(evt?: ActionEvent): void;
  10400. /**
  10401. * Execute placeholder for child classes
  10402. * @param evt optional action event
  10403. */
  10404. execute(evt?: ActionEvent): void;
  10405. /**
  10406. * Skips to next active action
  10407. */
  10408. skipToNextActiveAction(): void;
  10409. /**
  10410. * Adds action to chain of actions, may be a DoNothingAction
  10411. * @param action defines the next action to execute
  10412. * @returns The action passed in
  10413. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10414. */
  10415. then(action: Action): Action;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. _getProperty(propertyPath: string): string;
  10421. /**
  10422. * Internal only
  10423. * @hidden
  10424. */
  10425. _getEffectiveTarget(target: any, propertyPath: string): any;
  10426. /**
  10427. * Serialize placeholder for child classes
  10428. * @param parent of child
  10429. * @returns the serialized object
  10430. */
  10431. serialize(parent: any): any;
  10432. /**
  10433. * Internal only called by serialize
  10434. * @hidden
  10435. */
  10436. protected _serialize(serializedAction: any, parent?: any): any;
  10437. /**
  10438. * Internal only
  10439. * @hidden
  10440. */
  10441. static _SerializeValueAsString: (value: any) => string;
  10442. /**
  10443. * Internal only
  10444. * @hidden
  10445. */
  10446. static _GetTargetProperty: (target: Node | Scene) => {
  10447. name: string;
  10448. targetType: string;
  10449. value: string;
  10450. };
  10451. }
  10452. }
  10453. declare module BABYLON {
  10454. /**
  10455. * A Condition applied to an Action
  10456. */
  10457. export class Condition {
  10458. /**
  10459. * Internal only - manager for action
  10460. * @hidden
  10461. */
  10462. _actionManager: ActionManager;
  10463. /**
  10464. * Internal only
  10465. * @hidden
  10466. */
  10467. _evaluationId: number;
  10468. /**
  10469. * Internal only
  10470. * @hidden
  10471. */
  10472. _currentResult: boolean;
  10473. /**
  10474. * Creates a new Condition
  10475. * @param actionManager the manager of the action the condition is applied to
  10476. */
  10477. constructor(actionManager: ActionManager);
  10478. /**
  10479. * Check if the current condition is valid
  10480. * @returns a boolean
  10481. */
  10482. isValid(): boolean;
  10483. /**
  10484. * Internal only
  10485. * @hidden
  10486. */
  10487. _getProperty(propertyPath: string): string;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. _getEffectiveTarget(target: any, propertyPath: string): any;
  10493. /**
  10494. * Serialize placeholder for child classes
  10495. * @returns the serialized object
  10496. */
  10497. serialize(): any;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. protected _serialize(serializedCondition: any): any;
  10503. }
  10504. /**
  10505. * Defines specific conditional operators as extensions of Condition
  10506. */
  10507. export class ValueCondition extends Condition {
  10508. /** path to specify the property of the target the conditional operator uses */
  10509. propertyPath: string;
  10510. /** the value compared by the conditional operator against the current value of the property */
  10511. value: any;
  10512. /** the conditional operator, default ValueCondition.IsEqual */
  10513. operator: number;
  10514. /**
  10515. * Internal only
  10516. * @hidden
  10517. */
  10518. private static _IsEqual;
  10519. /**
  10520. * Internal only
  10521. * @hidden
  10522. */
  10523. private static _IsDifferent;
  10524. /**
  10525. * Internal only
  10526. * @hidden
  10527. */
  10528. private static _IsGreater;
  10529. /**
  10530. * Internal only
  10531. * @hidden
  10532. */
  10533. private static _IsLesser;
  10534. /**
  10535. * returns the number for IsEqual
  10536. */
  10537. static get IsEqual(): number;
  10538. /**
  10539. * Returns the number for IsDifferent
  10540. */
  10541. static get IsDifferent(): number;
  10542. /**
  10543. * Returns the number for IsGreater
  10544. */
  10545. static get IsGreater(): number;
  10546. /**
  10547. * Returns the number for IsLesser
  10548. */
  10549. static get IsLesser(): number;
  10550. /**
  10551. * Internal only The action manager for the condition
  10552. * @hidden
  10553. */
  10554. _actionManager: ActionManager;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. private _target;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. private _effectiveTarget;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. private _property;
  10570. /**
  10571. * Creates a new ValueCondition
  10572. * @param actionManager manager for the action the condition applies to
  10573. * @param target for the action
  10574. * @param propertyPath path to specify the property of the target the conditional operator uses
  10575. * @param value the value compared by the conditional operator against the current value of the property
  10576. * @param operator the conditional operator, default ValueCondition.IsEqual
  10577. */
  10578. constructor(actionManager: ActionManager, target: any,
  10579. /** path to specify the property of the target the conditional operator uses */
  10580. propertyPath: string,
  10581. /** the value compared by the conditional operator against the current value of the property */
  10582. value: any,
  10583. /** the conditional operator, default ValueCondition.IsEqual */
  10584. operator?: number);
  10585. /**
  10586. * Compares the given value with the property value for the specified conditional operator
  10587. * @returns the result of the comparison
  10588. */
  10589. isValid(): boolean;
  10590. /**
  10591. * Serialize the ValueCondition into a JSON compatible object
  10592. * @returns serialization object
  10593. */
  10594. serialize(): any;
  10595. /**
  10596. * Gets the name of the conditional operator for the ValueCondition
  10597. * @param operator the conditional operator
  10598. * @returns the name
  10599. */
  10600. static GetOperatorName(operator: number): string;
  10601. }
  10602. /**
  10603. * Defines a predicate condition as an extension of Condition
  10604. */
  10605. export class PredicateCondition extends Condition {
  10606. /** defines the predicate function used to validate the condition */
  10607. predicate: () => boolean;
  10608. /**
  10609. * Internal only - manager for action
  10610. * @hidden
  10611. */
  10612. _actionManager: ActionManager;
  10613. /**
  10614. * Creates a new PredicateCondition
  10615. * @param actionManager manager for the action the condition applies to
  10616. * @param predicate defines the predicate function used to validate the condition
  10617. */
  10618. constructor(actionManager: ActionManager,
  10619. /** defines the predicate function used to validate the condition */
  10620. predicate: () => boolean);
  10621. /**
  10622. * @returns the validity of the predicate condition
  10623. */
  10624. isValid(): boolean;
  10625. }
  10626. /**
  10627. * Defines a state condition as an extension of Condition
  10628. */
  10629. export class StateCondition extends Condition {
  10630. /** Value to compare with target state */
  10631. value: string;
  10632. /**
  10633. * Internal only - manager for action
  10634. * @hidden
  10635. */
  10636. _actionManager: ActionManager;
  10637. /**
  10638. * Internal only
  10639. * @hidden
  10640. */
  10641. private _target;
  10642. /**
  10643. * Creates a new StateCondition
  10644. * @param actionManager manager for the action the condition applies to
  10645. * @param target of the condition
  10646. * @param value to compare with target state
  10647. */
  10648. constructor(actionManager: ActionManager, target: any,
  10649. /** Value to compare with target state */
  10650. value: string);
  10651. /**
  10652. * Gets a boolean indicating if the current condition is met
  10653. * @returns the validity of the state
  10654. */
  10655. isValid(): boolean;
  10656. /**
  10657. * Serialize the StateCondition into a JSON compatible object
  10658. * @returns serialization object
  10659. */
  10660. serialize(): any;
  10661. }
  10662. }
  10663. declare module BABYLON {
  10664. /**
  10665. * This defines an action responsible to toggle a boolean once triggered.
  10666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10667. */
  10668. export class SwitchBooleanAction extends Action {
  10669. /**
  10670. * The path to the boolean property in the target object
  10671. */
  10672. propertyPath: string;
  10673. private _target;
  10674. private _effectiveTarget;
  10675. private _property;
  10676. /**
  10677. * Instantiate the action
  10678. * @param triggerOptions defines the trigger options
  10679. * @param target defines the object containing the boolean
  10680. * @param propertyPath defines the path to the boolean property in the target object
  10681. * @param condition defines the trigger related conditions
  10682. */
  10683. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10684. /** @hidden */
  10685. _prepare(): void;
  10686. /**
  10687. * Execute the action toggle the boolean value.
  10688. */
  10689. execute(): void;
  10690. /**
  10691. * Serializes the actions and its related information.
  10692. * @param parent defines the object to serialize in
  10693. * @returns the serialized object
  10694. */
  10695. serialize(parent: any): any;
  10696. }
  10697. /**
  10698. * This defines an action responsible to set a the state field of the target
  10699. * to a desired value once triggered.
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10701. */
  10702. export class SetStateAction extends Action {
  10703. /**
  10704. * The value to store in the state field.
  10705. */
  10706. value: string;
  10707. private _target;
  10708. /**
  10709. * Instantiate the action
  10710. * @param triggerOptions defines the trigger options
  10711. * @param target defines the object containing the state property
  10712. * @param value defines the value to store in the state field
  10713. * @param condition defines the trigger related conditions
  10714. */
  10715. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10716. /**
  10717. * Execute the action and store the value on the target state property.
  10718. */
  10719. execute(): void;
  10720. /**
  10721. * Serializes the actions and its related information.
  10722. * @param parent defines the object to serialize in
  10723. * @returns the serialized object
  10724. */
  10725. serialize(parent: any): any;
  10726. }
  10727. /**
  10728. * This defines an action responsible to set a property of the target
  10729. * to a desired value once triggered.
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10731. */
  10732. export class SetValueAction extends Action {
  10733. /**
  10734. * The path of the property to set in the target.
  10735. */
  10736. propertyPath: string;
  10737. /**
  10738. * The value to set in the property
  10739. */
  10740. value: any;
  10741. private _target;
  10742. private _effectiveTarget;
  10743. private _property;
  10744. /**
  10745. * Instantiate the action
  10746. * @param triggerOptions defines the trigger options
  10747. * @param target defines the object containing the property
  10748. * @param propertyPath defines the path of the property to set in the target
  10749. * @param value defines the value to set in the property
  10750. * @param condition defines the trigger related conditions
  10751. */
  10752. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10753. /** @hidden */
  10754. _prepare(): void;
  10755. /**
  10756. * Execute the action and set the targetted property to the desired value.
  10757. */
  10758. execute(): void;
  10759. /**
  10760. * Serializes the actions and its related information.
  10761. * @param parent defines the object to serialize in
  10762. * @returns the serialized object
  10763. */
  10764. serialize(parent: any): any;
  10765. }
  10766. /**
  10767. * This defines an action responsible to increment the target value
  10768. * to a desired value once triggered.
  10769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10770. */
  10771. export class IncrementValueAction extends Action {
  10772. /**
  10773. * The path of the property to increment in the target.
  10774. */
  10775. propertyPath: string;
  10776. /**
  10777. * The value we should increment the property by.
  10778. */
  10779. value: any;
  10780. private _target;
  10781. private _effectiveTarget;
  10782. private _property;
  10783. /**
  10784. * Instantiate the action
  10785. * @param triggerOptions defines the trigger options
  10786. * @param target defines the object containing the property
  10787. * @param propertyPath defines the path of the property to increment in the target
  10788. * @param value defines the value value we should increment the property by
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10792. /** @hidden */
  10793. _prepare(): void;
  10794. /**
  10795. * Execute the action and increment the target of the value amount.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. /**
  10806. * This defines an action responsible to start an animation once triggered.
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10808. */
  10809. export class PlayAnimationAction extends Action {
  10810. /**
  10811. * Where the animation should start (animation frame)
  10812. */
  10813. from: number;
  10814. /**
  10815. * Where the animation should stop (animation frame)
  10816. */
  10817. to: number;
  10818. /**
  10819. * Define if the animation should loop or stop after the first play.
  10820. */
  10821. loop?: boolean;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the target animation or animation name
  10827. * @param from defines from where the animation should start (animation frame)
  10828. * @param end defines where the animation should stop (animation frame)
  10829. * @param loop defines if the animation should loop or stop after the first play
  10830. * @param condition defines the trigger related conditions
  10831. */
  10832. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10833. /** @hidden */
  10834. _prepare(): void;
  10835. /**
  10836. * Execute the action and play the animation.
  10837. */
  10838. execute(): void;
  10839. /**
  10840. * Serializes the actions and its related information.
  10841. * @param parent defines the object to serialize in
  10842. * @returns the serialized object
  10843. */
  10844. serialize(parent: any): any;
  10845. }
  10846. /**
  10847. * This defines an action responsible to stop an animation once triggered.
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10849. */
  10850. export class StopAnimationAction extends Action {
  10851. private _target;
  10852. /**
  10853. * Instantiate the action
  10854. * @param triggerOptions defines the trigger options
  10855. * @param target defines the target animation or animation name
  10856. * @param condition defines the trigger related conditions
  10857. */
  10858. constructor(triggerOptions: any, target: any, condition?: Condition);
  10859. /** @hidden */
  10860. _prepare(): void;
  10861. /**
  10862. * Execute the action and stop the animation.
  10863. */
  10864. execute(): void;
  10865. /**
  10866. * Serializes the actions and its related information.
  10867. * @param parent defines the object to serialize in
  10868. * @returns the serialized object
  10869. */
  10870. serialize(parent: any): any;
  10871. }
  10872. /**
  10873. * This defines an action responsible that does nothing once triggered.
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10875. */
  10876. export class DoNothingAction extends Action {
  10877. /**
  10878. * Instantiate the action
  10879. * @param triggerOptions defines the trigger options
  10880. * @param condition defines the trigger related conditions
  10881. */
  10882. constructor(triggerOptions?: any, condition?: Condition);
  10883. /**
  10884. * Execute the action and do nothing.
  10885. */
  10886. execute(): void;
  10887. /**
  10888. * Serializes the actions and its related information.
  10889. * @param parent defines the object to serialize in
  10890. * @returns the serialized object
  10891. */
  10892. serialize(parent: any): any;
  10893. }
  10894. /**
  10895. * This defines an action responsible to trigger several actions once triggered.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class CombineAction extends Action {
  10899. /**
  10900. * The list of aggregated animations to run.
  10901. */
  10902. children: Action[];
  10903. /**
  10904. * Instantiate the action
  10905. * @param triggerOptions defines the trigger options
  10906. * @param children defines the list of aggregated animations to run
  10907. * @param condition defines the trigger related conditions
  10908. */
  10909. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10910. /** @hidden */
  10911. _prepare(): void;
  10912. /**
  10913. * Execute the action and executes all the aggregated actions.
  10914. */
  10915. execute(evt: ActionEvent): void;
  10916. /**
  10917. * Serializes the actions and its related information.
  10918. * @param parent defines the object to serialize in
  10919. * @returns the serialized object
  10920. */
  10921. serialize(parent: any): any;
  10922. }
  10923. /**
  10924. * This defines an action responsible to run code (external event) once triggered.
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10926. */
  10927. export class ExecuteCodeAction extends Action {
  10928. /**
  10929. * The callback function to run.
  10930. */
  10931. func: (evt: ActionEvent) => void;
  10932. /**
  10933. * Instantiate the action
  10934. * @param triggerOptions defines the trigger options
  10935. * @param func defines the callback function to run
  10936. * @param condition defines the trigger related conditions
  10937. */
  10938. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10939. /**
  10940. * Execute the action and run the attached code.
  10941. */
  10942. execute(evt: ActionEvent): void;
  10943. }
  10944. /**
  10945. * This defines an action responsible to set the parent property of the target once triggered.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class SetParentAction extends Action {
  10949. private _parent;
  10950. private _target;
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param target defines the target containing the parent property
  10955. * @param parent defines from where the animation should start (animation frame)
  10956. * @param condition defines the trigger related conditions
  10957. */
  10958. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10959. /** @hidden */
  10960. _prepare(): void;
  10961. /**
  10962. * Execute the action and set the parent property.
  10963. */
  10964. execute(): void;
  10965. /**
  10966. * Serializes the actions and its related information.
  10967. * @param parent defines the object to serialize in
  10968. * @returns the serialized object
  10969. */
  10970. serialize(parent: any): any;
  10971. }
  10972. }
  10973. declare module BABYLON {
  10974. /**
  10975. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10976. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10978. */
  10979. export class ActionManager extends AbstractActionManager {
  10980. /**
  10981. * Nothing
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10983. */
  10984. static readonly NothingTrigger: number;
  10985. /**
  10986. * On pick
  10987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10988. */
  10989. static readonly OnPickTrigger: number;
  10990. /**
  10991. * On left pick
  10992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10993. */
  10994. static readonly OnLeftPickTrigger: number;
  10995. /**
  10996. * On right pick
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10998. */
  10999. static readonly OnRightPickTrigger: number;
  11000. /**
  11001. * On center pick
  11002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11003. */
  11004. static readonly OnCenterPickTrigger: number;
  11005. /**
  11006. * On pick down
  11007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11008. */
  11009. static readonly OnPickDownTrigger: number;
  11010. /**
  11011. * On double pick
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11013. */
  11014. static readonly OnDoublePickTrigger: number;
  11015. /**
  11016. * On pick up
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11018. */
  11019. static readonly OnPickUpTrigger: number;
  11020. /**
  11021. * On pick out.
  11022. * This trigger will only be raised if you also declared a OnPickDown
  11023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11024. */
  11025. static readonly OnPickOutTrigger: number;
  11026. /**
  11027. * On long press
  11028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11029. */
  11030. static readonly OnLongPressTrigger: number;
  11031. /**
  11032. * On pointer over
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11034. */
  11035. static readonly OnPointerOverTrigger: number;
  11036. /**
  11037. * On pointer out
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly OnPointerOutTrigger: number;
  11041. /**
  11042. * On every frame
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnEveryFrameTrigger: number;
  11046. /**
  11047. * On intersection enter
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnIntersectionEnterTrigger: number;
  11051. /**
  11052. * On intersection exit
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnIntersectionExitTrigger: number;
  11056. /**
  11057. * On key down
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnKeyDownTrigger: number;
  11061. /**
  11062. * On key up
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnKeyUpTrigger: number;
  11066. private _scene;
  11067. /**
  11068. * Creates a new action manager
  11069. * @param scene defines the hosting scene
  11070. */
  11071. constructor(scene: Scene);
  11072. /**
  11073. * Releases all associated resources
  11074. */
  11075. dispose(): void;
  11076. /**
  11077. * Gets hosting scene
  11078. * @returns the hosting scene
  11079. */
  11080. getScene(): Scene;
  11081. /**
  11082. * Does this action manager handles actions of any of the given triggers
  11083. * @param triggers defines the triggers to be tested
  11084. * @return a boolean indicating whether one (or more) of the triggers is handled
  11085. */
  11086. hasSpecificTriggers(triggers: number[]): boolean;
  11087. /**
  11088. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11089. * speed.
  11090. * @param triggerA defines the trigger to be tested
  11091. * @param triggerB defines the trigger to be tested
  11092. * @return a boolean indicating whether one (or more) of the triggers is handled
  11093. */
  11094. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11095. /**
  11096. * Does this action manager handles actions of a given trigger
  11097. * @param trigger defines the trigger to be tested
  11098. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11099. * @return whether the trigger is handled
  11100. */
  11101. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11102. /**
  11103. * Does this action manager has pointer triggers
  11104. */
  11105. get hasPointerTriggers(): boolean;
  11106. /**
  11107. * Does this action manager has pick triggers
  11108. */
  11109. get hasPickTriggers(): boolean;
  11110. /**
  11111. * Registers an action to this action manager
  11112. * @param action defines the action to be registered
  11113. * @return the action amended (prepared) after registration
  11114. */
  11115. registerAction(action: IAction): Nullable<IAction>;
  11116. /**
  11117. * Unregisters an action to this action manager
  11118. * @param action defines the action to be unregistered
  11119. * @return a boolean indicating whether the action has been unregistered
  11120. */
  11121. unregisterAction(action: IAction): Boolean;
  11122. /**
  11123. * Process a specific trigger
  11124. * @param trigger defines the trigger to process
  11125. * @param evt defines the event details to be processed
  11126. */
  11127. processTrigger(trigger: number, evt?: IActionEvent): void;
  11128. /** @hidden */
  11129. _getEffectiveTarget(target: any, propertyPath: string): any;
  11130. /** @hidden */
  11131. _getProperty(propertyPath: string): string;
  11132. /**
  11133. * Serialize this manager to a JSON object
  11134. * @param name defines the property name to store this manager
  11135. * @returns a JSON representation of this manager
  11136. */
  11137. serialize(name: string): any;
  11138. /**
  11139. * Creates a new ActionManager from a JSON data
  11140. * @param parsedActions defines the JSON data to read from
  11141. * @param object defines the hosting mesh
  11142. * @param scene defines the hosting scene
  11143. */
  11144. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11145. /**
  11146. * Get a trigger name by index
  11147. * @param trigger defines the trigger index
  11148. * @returns a trigger name
  11149. */
  11150. static GetTriggerName(trigger: number): string;
  11151. }
  11152. }
  11153. declare module BABYLON {
  11154. /**
  11155. * Class representing a ray with position and direction
  11156. */
  11157. export class Ray {
  11158. /** origin point */
  11159. origin: Vector3;
  11160. /** direction */
  11161. direction: Vector3;
  11162. /** length of the ray */
  11163. length: number;
  11164. private static readonly TmpVector3;
  11165. private _tmpRay;
  11166. /**
  11167. * Creates a new ray
  11168. * @param origin origin point
  11169. * @param direction direction
  11170. * @param length length of the ray
  11171. */
  11172. constructor(
  11173. /** origin point */
  11174. origin: Vector3,
  11175. /** direction */
  11176. direction: Vector3,
  11177. /** length of the ray */
  11178. length?: number);
  11179. /**
  11180. * Checks if the ray intersects a box
  11181. * @param minimum bound of the box
  11182. * @param maximum bound of the box
  11183. * @param intersectionTreshold extra extend to be added to the box in all direction
  11184. * @returns if the box was hit
  11185. */
  11186. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11187. /**
  11188. * Checks if the ray intersects a box
  11189. * @param box the bounding box to check
  11190. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11191. * @returns if the box was hit
  11192. */
  11193. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11194. /**
  11195. * If the ray hits a sphere
  11196. * @param sphere the bounding sphere to check
  11197. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11198. * @returns true if it hits the sphere
  11199. */
  11200. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11201. /**
  11202. * If the ray hits a triange
  11203. * @param vertex0 triangle vertex
  11204. * @param vertex1 triangle vertex
  11205. * @param vertex2 triangle vertex
  11206. * @returns intersection information if hit
  11207. */
  11208. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11209. /**
  11210. * Checks if ray intersects a plane
  11211. * @param plane the plane to check
  11212. * @returns the distance away it was hit
  11213. */
  11214. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11215. /**
  11216. * Calculate the intercept of a ray on a given axis
  11217. * @param axis to check 'x' | 'y' | 'z'
  11218. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11219. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11220. */
  11221. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11222. /**
  11223. * Checks if ray intersects a mesh
  11224. * @param mesh the mesh to check
  11225. * @param fastCheck if only the bounding box should checked
  11226. * @returns picking info of the intersecton
  11227. */
  11228. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11229. /**
  11230. * Checks if ray intersects a mesh
  11231. * @param meshes the meshes to check
  11232. * @param fastCheck if only the bounding box should checked
  11233. * @param results array to store result in
  11234. * @returns Array of picking infos
  11235. */
  11236. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11237. private _comparePickingInfo;
  11238. private static smallnum;
  11239. private static rayl;
  11240. /**
  11241. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11242. * @param sega the first point of the segment to test the intersection against
  11243. * @param segb the second point of the segment to test the intersection against
  11244. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11245. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11246. */
  11247. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11248. /**
  11249. * Update the ray from viewport position
  11250. * @param x position
  11251. * @param y y position
  11252. * @param viewportWidth viewport width
  11253. * @param viewportHeight viewport height
  11254. * @param world world matrix
  11255. * @param view view matrix
  11256. * @param projection projection matrix
  11257. * @returns this ray updated
  11258. */
  11259. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11260. /**
  11261. * Creates a ray with origin and direction of 0,0,0
  11262. * @returns the new ray
  11263. */
  11264. static Zero(): Ray;
  11265. /**
  11266. * Creates a new ray from screen space and viewport
  11267. * @param x position
  11268. * @param y y position
  11269. * @param viewportWidth viewport width
  11270. * @param viewportHeight viewport height
  11271. * @param world world matrix
  11272. * @param view view matrix
  11273. * @param projection projection matrix
  11274. * @returns new ray
  11275. */
  11276. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11277. /**
  11278. * 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
  11279. * transformed to the given world matrix.
  11280. * @param origin The origin point
  11281. * @param end The end point
  11282. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11283. * @returns the new ray
  11284. */
  11285. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11286. /**
  11287. * Transforms a ray by a matrix
  11288. * @param ray ray to transform
  11289. * @param matrix matrix to apply
  11290. * @returns the resulting new ray
  11291. */
  11292. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11293. /**
  11294. * Transforms a ray by a matrix
  11295. * @param ray ray to transform
  11296. * @param matrix matrix to apply
  11297. * @param result ray to store result in
  11298. */
  11299. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11300. /**
  11301. * Unproject a ray from screen space to object space
  11302. * @param sourceX defines the screen space x coordinate to use
  11303. * @param sourceY defines the screen space y coordinate to use
  11304. * @param viewportWidth defines the current width of the viewport
  11305. * @param viewportHeight defines the current height of the viewport
  11306. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11307. * @param view defines the view matrix to use
  11308. * @param projection defines the projection matrix to use
  11309. */
  11310. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11311. }
  11312. /**
  11313. * Type used to define predicate used to select faces when a mesh intersection is detected
  11314. */
  11315. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11316. interface Scene {
  11317. /** @hidden */
  11318. _tempPickingRay: Nullable<Ray>;
  11319. /** @hidden */
  11320. _cachedRayForTransform: Ray;
  11321. /** @hidden */
  11322. _pickWithRayInverseMatrix: Matrix;
  11323. /** @hidden */
  11324. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11325. /** @hidden */
  11326. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11327. }
  11328. }
  11329. declare module BABYLON {
  11330. /**
  11331. * Groups all the scene component constants in one place to ease maintenance.
  11332. * @hidden
  11333. */
  11334. export class SceneComponentConstants {
  11335. static readonly NAME_EFFECTLAYER: string;
  11336. static readonly NAME_LAYER: string;
  11337. static readonly NAME_LENSFLARESYSTEM: string;
  11338. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11339. static readonly NAME_PARTICLESYSTEM: string;
  11340. static readonly NAME_GAMEPAD: string;
  11341. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11342. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11343. static readonly NAME_DEPTHRENDERER: string;
  11344. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11345. static readonly NAME_SPRITE: string;
  11346. static readonly NAME_OUTLINERENDERER: string;
  11347. static readonly NAME_PROCEDURALTEXTURE: string;
  11348. static readonly NAME_SHADOWGENERATOR: string;
  11349. static readonly NAME_OCTREE: string;
  11350. static readonly NAME_PHYSICSENGINE: string;
  11351. static readonly NAME_AUDIO: string;
  11352. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11353. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11354. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11355. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11356. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11357. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11358. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11359. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11360. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11361. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11362. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11363. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11364. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11365. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11366. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11367. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11368. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11369. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11370. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11371. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11372. static readonly STEP_AFTERRENDER_AUDIO: number;
  11373. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11374. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11375. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11376. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11377. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11378. static readonly STEP_POINTERMOVE_SPRITE: number;
  11379. static readonly STEP_POINTERDOWN_SPRITE: number;
  11380. static readonly STEP_POINTERUP_SPRITE: number;
  11381. }
  11382. /**
  11383. * This represents a scene component.
  11384. *
  11385. * This is used to decouple the dependency the scene is having on the different workloads like
  11386. * layers, post processes...
  11387. */
  11388. export interface ISceneComponent {
  11389. /**
  11390. * The name of the component. Each component must have a unique name.
  11391. */
  11392. name: string;
  11393. /**
  11394. * The scene the component belongs to.
  11395. */
  11396. scene: Scene;
  11397. /**
  11398. * Register the component to one instance of a scene.
  11399. */
  11400. register(): void;
  11401. /**
  11402. * Rebuilds the elements related to this component in case of
  11403. * context lost for instance.
  11404. */
  11405. rebuild(): void;
  11406. /**
  11407. * Disposes the component and the associated ressources.
  11408. */
  11409. dispose(): void;
  11410. }
  11411. /**
  11412. * This represents a SERIALIZABLE scene component.
  11413. *
  11414. * This extends Scene Component to add Serialization methods on top.
  11415. */
  11416. export interface ISceneSerializableComponent extends ISceneComponent {
  11417. /**
  11418. * Adds all the elements from the container to the scene
  11419. * @param container the container holding the elements
  11420. */
  11421. addFromContainer(container: AbstractScene): void;
  11422. /**
  11423. * Removes all the elements in the container from the scene
  11424. * @param container contains the elements to remove
  11425. * @param dispose if the removed element should be disposed (default: false)
  11426. */
  11427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11428. /**
  11429. * Serializes the component data to the specified json object
  11430. * @param serializationObject The object to serialize to
  11431. */
  11432. serialize(serializationObject: any): void;
  11433. }
  11434. /**
  11435. * Strong typing of a Mesh related stage step action
  11436. */
  11437. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11438. /**
  11439. * Strong typing of a Evaluate Sub Mesh related stage step action
  11440. */
  11441. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11442. /**
  11443. * Strong typing of a Active Mesh related stage step action
  11444. */
  11445. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11446. /**
  11447. * Strong typing of a Camera related stage step action
  11448. */
  11449. export type CameraStageAction = (camera: Camera) => void;
  11450. /**
  11451. * Strong typing of a Camera Frame buffer related stage step action
  11452. */
  11453. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11454. /**
  11455. * Strong typing of a Render Target related stage step action
  11456. */
  11457. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11458. /**
  11459. * Strong typing of a RenderingGroup related stage step action
  11460. */
  11461. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11462. /**
  11463. * Strong typing of a Mesh Render related stage step action
  11464. */
  11465. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11466. /**
  11467. * Strong typing of a simple stage step action
  11468. */
  11469. export type SimpleStageAction = () => void;
  11470. /**
  11471. * Strong typing of a render target action.
  11472. */
  11473. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11474. /**
  11475. * Strong typing of a pointer move action.
  11476. */
  11477. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11478. /**
  11479. * Strong typing of a pointer up/down action.
  11480. */
  11481. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11482. /**
  11483. * Representation of a stage in the scene (Basically a list of ordered steps)
  11484. * @hidden
  11485. */
  11486. export class Stage<T extends Function> extends Array<{
  11487. index: number;
  11488. component: ISceneComponent;
  11489. action: T;
  11490. }> {
  11491. /**
  11492. * Hide ctor from the rest of the world.
  11493. * @param items The items to add.
  11494. */
  11495. private constructor();
  11496. /**
  11497. * Creates a new Stage.
  11498. * @returns A new instance of a Stage
  11499. */
  11500. static Create<T extends Function>(): Stage<T>;
  11501. /**
  11502. * Registers a step in an ordered way in the targeted stage.
  11503. * @param index Defines the position to register the step in
  11504. * @param component Defines the component attached to the step
  11505. * @param action Defines the action to launch during the step
  11506. */
  11507. registerStep(index: number, component: ISceneComponent, action: T): void;
  11508. /**
  11509. * Clears all the steps from the stage.
  11510. */
  11511. clear(): void;
  11512. }
  11513. }
  11514. declare module BABYLON {
  11515. interface Scene {
  11516. /** @hidden */
  11517. _pointerOverSprite: Nullable<Sprite>;
  11518. /** @hidden */
  11519. _pickedDownSprite: Nullable<Sprite>;
  11520. /** @hidden */
  11521. _tempSpritePickingRay: Nullable<Ray>;
  11522. /**
  11523. * All of the sprite managers added to this scene
  11524. * @see http://doc.babylonjs.com/babylon101/sprites
  11525. */
  11526. spriteManagers: Array<ISpriteManager>;
  11527. /**
  11528. * An event triggered when sprites rendering is about to start
  11529. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11530. */
  11531. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11532. /**
  11533. * An event triggered when sprites rendering is done
  11534. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11535. */
  11536. onAfterSpritesRenderingObservable: Observable<Scene>;
  11537. /** @hidden */
  11538. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11539. /** Launch a ray to try to pick a sprite in the scene
  11540. * @param x position on screen
  11541. * @param y position on screen
  11542. * @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
  11543. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11544. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11545. * @returns a PickingInfo
  11546. */
  11547. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11548. /** Use the given ray to pick a sprite in the scene
  11549. * @param ray The ray (in world space) to use to pick meshes
  11550. * @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
  11551. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11552. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11553. * @returns a PickingInfo
  11554. */
  11555. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11556. /** @hidden */
  11557. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11558. /** Launch a ray to try to pick sprites in the scene
  11559. * @param x position on screen
  11560. * @param y position on screen
  11561. * @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
  11562. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11563. * @returns a PickingInfo array
  11564. */
  11565. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11566. /** Use the given ray to pick sprites in the scene
  11567. * @param ray The ray (in world space) to use to pick meshes
  11568. * @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
  11569. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11570. * @returns a PickingInfo array
  11571. */
  11572. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11573. /**
  11574. * Force the sprite under the pointer
  11575. * @param sprite defines the sprite to use
  11576. */
  11577. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11578. /**
  11579. * Gets the sprite under the pointer
  11580. * @returns a Sprite or null if no sprite is under the pointer
  11581. */
  11582. getPointerOverSprite(): Nullable<Sprite>;
  11583. }
  11584. /**
  11585. * Defines the sprite scene component responsible to manage sprites
  11586. * in a given scene.
  11587. */
  11588. export class SpriteSceneComponent implements ISceneComponent {
  11589. /**
  11590. * The component name helpfull to identify the component in the list of scene components.
  11591. */
  11592. readonly name: string;
  11593. /**
  11594. * The scene the component belongs to.
  11595. */
  11596. scene: Scene;
  11597. /** @hidden */
  11598. private _spritePredicate;
  11599. /**
  11600. * Creates a new instance of the component for the given scene
  11601. * @param scene Defines the scene to register the component in
  11602. */
  11603. constructor(scene: Scene);
  11604. /**
  11605. * Registers the component in a given scene
  11606. */
  11607. register(): void;
  11608. /**
  11609. * Rebuilds the elements related to this component in case of
  11610. * context lost for instance.
  11611. */
  11612. rebuild(): void;
  11613. /**
  11614. * Disposes the component and the associated ressources.
  11615. */
  11616. dispose(): void;
  11617. private _pickSpriteButKeepRay;
  11618. private _pointerMove;
  11619. private _pointerDown;
  11620. private _pointerUp;
  11621. }
  11622. }
  11623. declare module BABYLON {
  11624. /** @hidden */
  11625. export var fogFragmentDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module BABYLON {
  11631. /** @hidden */
  11632. export var fogFragment: {
  11633. name: string;
  11634. shader: string;
  11635. };
  11636. }
  11637. declare module BABYLON {
  11638. /** @hidden */
  11639. export var spritesPixelShader: {
  11640. name: string;
  11641. shader: string;
  11642. };
  11643. }
  11644. declare module BABYLON {
  11645. /** @hidden */
  11646. export var fogVertexDeclaration: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module BABYLON {
  11652. /** @hidden */
  11653. export var spritesVertexShader: {
  11654. name: string;
  11655. shader: string;
  11656. };
  11657. }
  11658. declare module BABYLON {
  11659. /**
  11660. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11661. */
  11662. export interface ISpriteManager extends IDisposable {
  11663. /**
  11664. * Restricts the camera to viewing objects with the same layerMask.
  11665. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11666. */
  11667. layerMask: number;
  11668. /**
  11669. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11670. */
  11671. isPickable: boolean;
  11672. /**
  11673. * Specifies the rendering group id for this mesh (0 by default)
  11674. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11675. */
  11676. renderingGroupId: number;
  11677. /**
  11678. * Defines the list of sprites managed by the manager.
  11679. */
  11680. sprites: Array<Sprite>;
  11681. /**
  11682. * Tests the intersection of a sprite with a specific ray.
  11683. * @param ray The ray we are sending to test the collision
  11684. * @param camera The camera space we are sending rays in
  11685. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11686. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11687. * @returns picking info or null.
  11688. */
  11689. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11690. /**
  11691. * Intersects the sprites with a ray
  11692. * @param ray defines the ray to intersect with
  11693. * @param camera defines the current active camera
  11694. * @param predicate defines a predicate used to select candidate sprites
  11695. * @returns null if no hit or a PickingInfo array
  11696. */
  11697. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11698. /**
  11699. * Renders the list of sprites on screen.
  11700. */
  11701. render(): void;
  11702. }
  11703. /**
  11704. * Class used to manage multiple sprites on the same spritesheet
  11705. * @see http://doc.babylonjs.com/babylon101/sprites
  11706. */
  11707. export class SpriteManager implements ISpriteManager {
  11708. /** defines the manager's name */
  11709. name: string;
  11710. /** Gets the list of sprites */
  11711. sprites: Sprite[];
  11712. /** Gets or sets the rendering group id (0 by default) */
  11713. renderingGroupId: number;
  11714. /** Gets or sets camera layer mask */
  11715. layerMask: number;
  11716. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11717. fogEnabled: boolean;
  11718. /** Gets or sets a boolean indicating if the sprites are pickable */
  11719. isPickable: boolean;
  11720. /** Defines the default width of a cell in the spritesheet */
  11721. cellWidth: number;
  11722. /** Defines the default height of a cell in the spritesheet */
  11723. cellHeight: number;
  11724. /** Associative array from JSON sprite data file */
  11725. private _cellData;
  11726. /** Array of sprite names from JSON sprite data file */
  11727. private _spriteMap;
  11728. /** True when packed cell data from JSON file is ready*/
  11729. private _packedAndReady;
  11730. /**
  11731. * An event triggered when the manager is disposed.
  11732. */
  11733. onDisposeObservable: Observable<SpriteManager>;
  11734. private _onDisposeObserver;
  11735. /**
  11736. * Callback called when the manager is disposed
  11737. */
  11738. set onDispose(callback: () => void);
  11739. private _capacity;
  11740. private _fromPacked;
  11741. private _spriteTexture;
  11742. private _epsilon;
  11743. private _scene;
  11744. private _vertexData;
  11745. private _buffer;
  11746. private _vertexBuffers;
  11747. private _indexBuffer;
  11748. private _effectBase;
  11749. private _effectFog;
  11750. /**
  11751. * Gets or sets the spritesheet texture
  11752. */
  11753. get texture(): Texture;
  11754. set texture(value: Texture);
  11755. /**
  11756. * Creates a new sprite manager
  11757. * @param name defines the manager's name
  11758. * @param imgUrl defines the sprite sheet url
  11759. * @param capacity defines the maximum allowed number of sprites
  11760. * @param cellSize defines the size of a sprite cell
  11761. * @param scene defines the hosting scene
  11762. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11763. * @param samplingMode defines the smapling mode to use with spritesheet
  11764. * @param fromPacked set to false; do not alter
  11765. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11766. */
  11767. constructor(
  11768. /** defines the manager's name */
  11769. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11770. private _makePacked;
  11771. private _appendSpriteVertex;
  11772. /**
  11773. * Intersects the sprites with a ray
  11774. * @param ray defines the ray to intersect with
  11775. * @param camera defines the current active camera
  11776. * @param predicate defines a predicate used to select candidate sprites
  11777. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11778. * @returns null if no hit or a PickingInfo
  11779. */
  11780. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11781. /**
  11782. * Intersects the sprites with a ray
  11783. * @param ray defines the ray to intersect with
  11784. * @param camera defines the current active camera
  11785. * @param predicate defines a predicate used to select candidate sprites
  11786. * @returns null if no hit or a PickingInfo array
  11787. */
  11788. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11789. /**
  11790. * Render all child sprites
  11791. */
  11792. render(): void;
  11793. /**
  11794. * Release associated resources
  11795. */
  11796. dispose(): void;
  11797. }
  11798. }
  11799. declare module BABYLON {
  11800. /**
  11801. * Class used to represent a sprite
  11802. * @see http://doc.babylonjs.com/babylon101/sprites
  11803. */
  11804. export class Sprite {
  11805. /** defines the name */
  11806. name: string;
  11807. /** Gets or sets the current world position */
  11808. position: Vector3;
  11809. /** Gets or sets the main color */
  11810. color: Color4;
  11811. /** Gets or sets the width */
  11812. width: number;
  11813. /** Gets or sets the height */
  11814. height: number;
  11815. /** Gets or sets rotation angle */
  11816. angle: number;
  11817. /** Gets or sets the cell index in the sprite sheet */
  11818. cellIndex: number;
  11819. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11820. cellRef: string;
  11821. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11822. invertU: number;
  11823. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11824. invertV: number;
  11825. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11826. disposeWhenFinishedAnimating: boolean;
  11827. /** Gets the list of attached animations */
  11828. animations: Animation[];
  11829. /** Gets or sets a boolean indicating if the sprite can be picked */
  11830. isPickable: boolean;
  11831. /**
  11832. * Gets or sets the associated action manager
  11833. */
  11834. actionManager: Nullable<ActionManager>;
  11835. private _animationStarted;
  11836. private _loopAnimation;
  11837. private _fromIndex;
  11838. private _toIndex;
  11839. private _delay;
  11840. private _direction;
  11841. private _manager;
  11842. private _time;
  11843. private _onAnimationEnd;
  11844. /**
  11845. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11846. */
  11847. isVisible: boolean;
  11848. /**
  11849. * Gets or sets the sprite size
  11850. */
  11851. get size(): number;
  11852. set size(value: number);
  11853. /**
  11854. * Creates a new Sprite
  11855. * @param name defines the name
  11856. * @param manager defines the manager
  11857. */
  11858. constructor(
  11859. /** defines the name */
  11860. name: string, manager: ISpriteManager);
  11861. /**
  11862. * Starts an animation
  11863. * @param from defines the initial key
  11864. * @param to defines the end key
  11865. * @param loop defines if the animation must loop
  11866. * @param delay defines the start delay (in ms)
  11867. * @param onAnimationEnd defines a callback to call when animation ends
  11868. */
  11869. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11870. /** Stops current animation (if any) */
  11871. stopAnimation(): void;
  11872. /** @hidden */
  11873. _animate(deltaTime: number): void;
  11874. /** Release associated resources */
  11875. dispose(): void;
  11876. }
  11877. }
  11878. declare module BABYLON {
  11879. /**
  11880. * Information about the result of picking within a scene
  11881. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11882. */
  11883. export class PickingInfo {
  11884. /** @hidden */
  11885. _pickingUnavailable: boolean;
  11886. /**
  11887. * If the pick collided with an object
  11888. */
  11889. hit: boolean;
  11890. /**
  11891. * Distance away where the pick collided
  11892. */
  11893. distance: number;
  11894. /**
  11895. * The location of pick collision
  11896. */
  11897. pickedPoint: Nullable<Vector3>;
  11898. /**
  11899. * The mesh corresponding the the pick collision
  11900. */
  11901. pickedMesh: Nullable<AbstractMesh>;
  11902. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bu: number;
  11904. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11905. bv: number;
  11906. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11907. faceId: number;
  11908. /** Id of the the submesh that was picked */
  11909. subMeshId: number;
  11910. /** If a sprite was picked, this will be the sprite the pick collided with */
  11911. pickedSprite: Nullable<Sprite>;
  11912. /**
  11913. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11914. */
  11915. originMesh: Nullable<AbstractMesh>;
  11916. /**
  11917. * The ray that was used to perform the picking.
  11918. */
  11919. ray: Nullable<Ray>;
  11920. /**
  11921. * Gets the normal correspodning to the face the pick collided with
  11922. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11923. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11924. * @returns The normal correspodning to the face the pick collided with
  11925. */
  11926. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11927. /**
  11928. * Gets the texture coordinates of where the pick occured
  11929. * @returns the vector containing the coordnates of the texture
  11930. */
  11931. getTextureCoordinates(): Nullable<Vector2>;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * Gather the list of pointer event types as constants.
  11937. */
  11938. export class PointerEventTypes {
  11939. /**
  11940. * 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.
  11941. */
  11942. static readonly POINTERDOWN: number;
  11943. /**
  11944. * The pointerup event is fired when a pointer is no longer active.
  11945. */
  11946. static readonly POINTERUP: number;
  11947. /**
  11948. * The pointermove event is fired when a pointer changes coordinates.
  11949. */
  11950. static readonly POINTERMOVE: number;
  11951. /**
  11952. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11953. */
  11954. static readonly POINTERWHEEL: number;
  11955. /**
  11956. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11957. */
  11958. static readonly POINTERPICK: number;
  11959. /**
  11960. * The pointertap event is fired when a the object has been touched and released without drag.
  11961. */
  11962. static readonly POINTERTAP: number;
  11963. /**
  11964. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11965. */
  11966. static readonly POINTERDOUBLETAP: number;
  11967. }
  11968. /**
  11969. * Base class of pointer info types.
  11970. */
  11971. export class PointerInfoBase {
  11972. /**
  11973. * Defines the type of event (PointerEventTypes)
  11974. */
  11975. type: number;
  11976. /**
  11977. * Defines the related dom event
  11978. */
  11979. event: PointerEvent | MouseWheelEvent;
  11980. /**
  11981. * Instantiates the base class of pointers info.
  11982. * @param type Defines the type of event (PointerEventTypes)
  11983. * @param event Defines the related dom event
  11984. */
  11985. constructor(
  11986. /**
  11987. * Defines the type of event (PointerEventTypes)
  11988. */
  11989. type: number,
  11990. /**
  11991. * Defines the related dom event
  11992. */
  11993. event: PointerEvent | MouseWheelEvent);
  11994. }
  11995. /**
  11996. * This class is used to store pointer related info for the onPrePointerObservable event.
  11997. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11998. */
  11999. export class PointerInfoPre extends PointerInfoBase {
  12000. /**
  12001. * Ray from a pointer if availible (eg. 6dof controller)
  12002. */
  12003. ray: Nullable<Ray>;
  12004. /**
  12005. * Defines the local position of the pointer on the canvas.
  12006. */
  12007. localPosition: Vector2;
  12008. /**
  12009. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12010. */
  12011. skipOnPointerObservable: boolean;
  12012. /**
  12013. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12014. * @param type Defines the type of event (PointerEventTypes)
  12015. * @param event Defines the related dom event
  12016. * @param localX Defines the local x coordinates of the pointer when the event occured
  12017. * @param localY Defines the local y coordinates of the pointer when the event occured
  12018. */
  12019. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12020. }
  12021. /**
  12022. * This type contains all the data related to a pointer event in Babylon.js.
  12023. * 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.
  12024. */
  12025. export class PointerInfo extends PointerInfoBase {
  12026. /**
  12027. * Defines the picking info associated to the info (if any)\
  12028. */
  12029. pickInfo: Nullable<PickingInfo>;
  12030. /**
  12031. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12032. * @param type Defines the type of event (PointerEventTypes)
  12033. * @param event Defines the related dom event
  12034. * @param pickInfo Defines the picking info associated to the info (if any)\
  12035. */
  12036. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12037. /**
  12038. * Defines the picking info associated to the info (if any)\
  12039. */
  12040. pickInfo: Nullable<PickingInfo>);
  12041. }
  12042. /**
  12043. * Data relating to a touch event on the screen.
  12044. */
  12045. export interface PointerTouch {
  12046. /**
  12047. * X coordinate of touch.
  12048. */
  12049. x: number;
  12050. /**
  12051. * Y coordinate of touch.
  12052. */
  12053. y: number;
  12054. /**
  12055. * Id of touch. Unique for each finger.
  12056. */
  12057. pointerId: number;
  12058. /**
  12059. * Event type passed from DOM.
  12060. */
  12061. type: any;
  12062. }
  12063. }
  12064. declare module BABYLON {
  12065. /**
  12066. * Manage the mouse inputs to control the movement of a free camera.
  12067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12068. */
  12069. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12070. /**
  12071. * Define if touch is enabled in the mouse input
  12072. */
  12073. touchEnabled: boolean;
  12074. /**
  12075. * Defines the camera the input is attached to.
  12076. */
  12077. camera: FreeCamera;
  12078. /**
  12079. * Defines the buttons associated with the input to handle camera move.
  12080. */
  12081. buttons: number[];
  12082. /**
  12083. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12084. */
  12085. angularSensibility: number;
  12086. private _pointerInput;
  12087. private _onMouseMove;
  12088. private _observer;
  12089. private previousPosition;
  12090. /**
  12091. * Observable for when a pointer move event occurs containing the move offset
  12092. */
  12093. onPointerMovedObservable: Observable<{
  12094. offsetX: number;
  12095. offsetY: number;
  12096. }>;
  12097. /**
  12098. * @hidden
  12099. * If the camera should be rotated automatically based on pointer movement
  12100. */
  12101. _allowCameraRotation: boolean;
  12102. /**
  12103. * Manage the mouse inputs to control the movement of a free camera.
  12104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12105. * @param touchEnabled Defines if touch is enabled or not
  12106. */
  12107. constructor(
  12108. /**
  12109. * Define if touch is enabled in the mouse input
  12110. */
  12111. touchEnabled?: boolean);
  12112. /**
  12113. * Attach the input controls to a specific dom element to get the input from.
  12114. * @param element Defines the element the controls should be listened from
  12115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12116. */
  12117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12118. /**
  12119. * Called on JS contextmenu event.
  12120. * Override this method to provide functionality.
  12121. */
  12122. protected onContextMenu(evt: PointerEvent): void;
  12123. /**
  12124. * Detach the current controls from the specified dom element.
  12125. * @param element Defines the element to stop listening the inputs from
  12126. */
  12127. detachControl(element: Nullable<HTMLElement>): void;
  12128. /**
  12129. * Gets the class name of the current intput.
  12130. * @returns the class name
  12131. */
  12132. getClassName(): string;
  12133. /**
  12134. * Get the friendly name associated with the input class.
  12135. * @returns the input friendly name
  12136. */
  12137. getSimpleName(): string;
  12138. }
  12139. }
  12140. declare module BABYLON {
  12141. /**
  12142. * Manage the touch inputs to control the movement of a free camera.
  12143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12144. */
  12145. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12146. /**
  12147. * Defines the camera the input is attached to.
  12148. */
  12149. camera: FreeCamera;
  12150. /**
  12151. * Defines the touch sensibility for rotation.
  12152. * The higher the faster.
  12153. */
  12154. touchAngularSensibility: number;
  12155. /**
  12156. * Defines the touch sensibility for move.
  12157. * The higher the faster.
  12158. */
  12159. touchMoveSensibility: number;
  12160. private _offsetX;
  12161. private _offsetY;
  12162. private _pointerPressed;
  12163. private _pointerInput;
  12164. private _observer;
  12165. private _onLostFocus;
  12166. /**
  12167. * Attach the input controls to a specific dom element to get the input from.
  12168. * @param element Defines the element the controls should be listened from
  12169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12170. */
  12171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12172. /**
  12173. * Detach the current controls from the specified dom element.
  12174. * @param element Defines the element to stop listening the inputs from
  12175. */
  12176. detachControl(element: Nullable<HTMLElement>): void;
  12177. /**
  12178. * Update the current camera state depending on the inputs that have been used this frame.
  12179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12180. */
  12181. checkInputs(): void;
  12182. /**
  12183. * Gets the class name of the current intput.
  12184. * @returns the class name
  12185. */
  12186. getClassName(): string;
  12187. /**
  12188. * Get the friendly name associated with the input class.
  12189. * @returns the input friendly name
  12190. */
  12191. getSimpleName(): string;
  12192. }
  12193. }
  12194. declare module BABYLON {
  12195. /**
  12196. * Default Inputs manager for the FreeCamera.
  12197. * It groups all the default supported inputs for ease of use.
  12198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12199. */
  12200. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12201. /**
  12202. * @hidden
  12203. */
  12204. _mouseInput: Nullable<FreeCameraMouseInput>;
  12205. /**
  12206. * Instantiates a new FreeCameraInputsManager.
  12207. * @param camera Defines the camera the inputs belong to
  12208. */
  12209. constructor(camera: FreeCamera);
  12210. /**
  12211. * Add keyboard input support to the input manager.
  12212. * @returns the current input manager
  12213. */
  12214. addKeyboard(): FreeCameraInputsManager;
  12215. /**
  12216. * Add mouse input support to the input manager.
  12217. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12218. * @returns the current input manager
  12219. */
  12220. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12221. /**
  12222. * Removes the mouse input support from the manager
  12223. * @returns the current input manager
  12224. */
  12225. removeMouse(): FreeCameraInputsManager;
  12226. /**
  12227. * Add touch input support to the input manager.
  12228. * @returns the current input manager
  12229. */
  12230. addTouch(): FreeCameraInputsManager;
  12231. /**
  12232. * Remove all attached input methods from a camera
  12233. */
  12234. clear(): void;
  12235. }
  12236. }
  12237. declare module BABYLON {
  12238. /**
  12239. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12240. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12241. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12242. */
  12243. export class FreeCamera extends TargetCamera {
  12244. /**
  12245. * Define the collision ellipsoid of the camera.
  12246. * This is helpful to simulate a camera body like the player body around the camera
  12247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12248. */
  12249. ellipsoid: Vector3;
  12250. /**
  12251. * Define an offset for the position of the ellipsoid around the camera.
  12252. * This can be helpful to determine the center of the body near the gravity center of the body
  12253. * instead of its head.
  12254. */
  12255. ellipsoidOffset: Vector3;
  12256. /**
  12257. * Enable or disable collisions of the camera with the rest of the scene objects.
  12258. */
  12259. checkCollisions: boolean;
  12260. /**
  12261. * Enable or disable gravity on the camera.
  12262. */
  12263. applyGravity: boolean;
  12264. /**
  12265. * Define the input manager associated to the camera.
  12266. */
  12267. inputs: FreeCameraInputsManager;
  12268. /**
  12269. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12270. * Higher values reduce sensitivity.
  12271. */
  12272. get angularSensibility(): number;
  12273. /**
  12274. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12275. * Higher values reduce sensitivity.
  12276. */
  12277. set angularSensibility(value: number);
  12278. /**
  12279. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12280. */
  12281. get keysUp(): number[];
  12282. set keysUp(value: number[]);
  12283. /**
  12284. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12285. */
  12286. get keysDown(): number[];
  12287. set keysDown(value: number[]);
  12288. /**
  12289. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12290. */
  12291. get keysLeft(): number[];
  12292. set keysLeft(value: number[]);
  12293. /**
  12294. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12295. */
  12296. get keysRight(): number[];
  12297. set keysRight(value: number[]);
  12298. /**
  12299. * Event raised when the camera collide with a mesh in the scene.
  12300. */
  12301. onCollide: (collidedMesh: AbstractMesh) => void;
  12302. private _collider;
  12303. private _needMoveForGravity;
  12304. private _oldPosition;
  12305. private _diffPosition;
  12306. private _newPosition;
  12307. /** @hidden */
  12308. _localDirection: Vector3;
  12309. /** @hidden */
  12310. _transformedDirection: Vector3;
  12311. /**
  12312. * Instantiates a Free Camera.
  12313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12314. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12316. * @param name Define the name of the camera in the scene
  12317. * @param position Define the start position of the camera in the scene
  12318. * @param scene Define the scene the camera belongs to
  12319. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12320. */
  12321. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12322. /**
  12323. * Attached controls to the current camera.
  12324. * @param element Defines the element the controls should be listened from
  12325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12326. */
  12327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12328. /**
  12329. * Detach the current controls from the camera.
  12330. * The camera will stop reacting to inputs.
  12331. * @param element Defines the element to stop listening the inputs from
  12332. */
  12333. detachControl(element: HTMLElement): void;
  12334. private _collisionMask;
  12335. /**
  12336. * Define a collision mask to limit the list of object the camera can collide with
  12337. */
  12338. get collisionMask(): number;
  12339. set collisionMask(mask: number);
  12340. /** @hidden */
  12341. _collideWithWorld(displacement: Vector3): void;
  12342. private _onCollisionPositionChange;
  12343. /** @hidden */
  12344. _checkInputs(): void;
  12345. /** @hidden */
  12346. _decideIfNeedsToMove(): boolean;
  12347. /** @hidden */
  12348. _updatePosition(): void;
  12349. /**
  12350. * Destroy the camera and release the current resources hold by it.
  12351. */
  12352. dispose(): void;
  12353. /**
  12354. * Gets the current object class name.
  12355. * @return the class name
  12356. */
  12357. getClassName(): string;
  12358. }
  12359. }
  12360. declare module BABYLON {
  12361. /**
  12362. * Represents a gamepad control stick position
  12363. */
  12364. export class StickValues {
  12365. /**
  12366. * The x component of the control stick
  12367. */
  12368. x: number;
  12369. /**
  12370. * The y component of the control stick
  12371. */
  12372. y: number;
  12373. /**
  12374. * Initializes the gamepad x and y control stick values
  12375. * @param x The x component of the gamepad control stick value
  12376. * @param y The y component of the gamepad control stick value
  12377. */
  12378. constructor(
  12379. /**
  12380. * The x component of the control stick
  12381. */
  12382. x: number,
  12383. /**
  12384. * The y component of the control stick
  12385. */
  12386. y: number);
  12387. }
  12388. /**
  12389. * An interface which manages callbacks for gamepad button changes
  12390. */
  12391. export interface GamepadButtonChanges {
  12392. /**
  12393. * Called when a gamepad has been changed
  12394. */
  12395. changed: boolean;
  12396. /**
  12397. * Called when a gamepad press event has been triggered
  12398. */
  12399. pressChanged: boolean;
  12400. /**
  12401. * Called when a touch event has been triggered
  12402. */
  12403. touchChanged: boolean;
  12404. /**
  12405. * Called when a value has changed
  12406. */
  12407. valueChanged: boolean;
  12408. }
  12409. /**
  12410. * Represents a gamepad
  12411. */
  12412. export class Gamepad {
  12413. /**
  12414. * The id of the gamepad
  12415. */
  12416. id: string;
  12417. /**
  12418. * The index of the gamepad
  12419. */
  12420. index: number;
  12421. /**
  12422. * The browser gamepad
  12423. */
  12424. browserGamepad: any;
  12425. /**
  12426. * Specifies what type of gamepad this represents
  12427. */
  12428. type: number;
  12429. private _leftStick;
  12430. private _rightStick;
  12431. /** @hidden */
  12432. _isConnected: boolean;
  12433. private _leftStickAxisX;
  12434. private _leftStickAxisY;
  12435. private _rightStickAxisX;
  12436. private _rightStickAxisY;
  12437. /**
  12438. * Triggered when the left control stick has been changed
  12439. */
  12440. private _onleftstickchanged;
  12441. /**
  12442. * Triggered when the right control stick has been changed
  12443. */
  12444. private _onrightstickchanged;
  12445. /**
  12446. * Represents a gamepad controller
  12447. */
  12448. static GAMEPAD: number;
  12449. /**
  12450. * Represents a generic controller
  12451. */
  12452. static GENERIC: number;
  12453. /**
  12454. * Represents an XBox controller
  12455. */
  12456. static XBOX: number;
  12457. /**
  12458. * Represents a pose-enabled controller
  12459. */
  12460. static POSE_ENABLED: number;
  12461. /**
  12462. * Represents an Dual Shock controller
  12463. */
  12464. static DUALSHOCK: number;
  12465. /**
  12466. * Specifies whether the left control stick should be Y-inverted
  12467. */
  12468. protected _invertLeftStickY: boolean;
  12469. /**
  12470. * Specifies if the gamepad has been connected
  12471. */
  12472. get isConnected(): boolean;
  12473. /**
  12474. * Initializes the gamepad
  12475. * @param id The id of the gamepad
  12476. * @param index The index of the gamepad
  12477. * @param browserGamepad The browser gamepad
  12478. * @param leftStickX The x component of the left joystick
  12479. * @param leftStickY The y component of the left joystick
  12480. * @param rightStickX The x component of the right joystick
  12481. * @param rightStickY The y component of the right joystick
  12482. */
  12483. constructor(
  12484. /**
  12485. * The id of the gamepad
  12486. */
  12487. id: string,
  12488. /**
  12489. * The index of the gamepad
  12490. */
  12491. index: number,
  12492. /**
  12493. * The browser gamepad
  12494. */
  12495. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12496. /**
  12497. * Callback triggered when the left joystick has changed
  12498. * @param callback
  12499. */
  12500. onleftstickchanged(callback: (values: StickValues) => void): void;
  12501. /**
  12502. * Callback triggered when the right joystick has changed
  12503. * @param callback
  12504. */
  12505. onrightstickchanged(callback: (values: StickValues) => void): void;
  12506. /**
  12507. * Gets the left joystick
  12508. */
  12509. get leftStick(): StickValues;
  12510. /**
  12511. * Sets the left joystick values
  12512. */
  12513. set leftStick(newValues: StickValues);
  12514. /**
  12515. * Gets the right joystick
  12516. */
  12517. get rightStick(): StickValues;
  12518. /**
  12519. * Sets the right joystick value
  12520. */
  12521. set rightStick(newValues: StickValues);
  12522. /**
  12523. * Updates the gamepad joystick positions
  12524. */
  12525. update(): void;
  12526. /**
  12527. * Disposes the gamepad
  12528. */
  12529. dispose(): void;
  12530. }
  12531. /**
  12532. * Represents a generic gamepad
  12533. */
  12534. export class GenericPad extends Gamepad {
  12535. private _buttons;
  12536. private _onbuttondown;
  12537. private _onbuttonup;
  12538. /**
  12539. * Observable triggered when a button has been pressed
  12540. */
  12541. onButtonDownObservable: Observable<number>;
  12542. /**
  12543. * Observable triggered when a button has been released
  12544. */
  12545. onButtonUpObservable: Observable<number>;
  12546. /**
  12547. * Callback triggered when a button has been pressed
  12548. * @param callback Called when a button has been pressed
  12549. */
  12550. onbuttondown(callback: (buttonPressed: number) => void): void;
  12551. /**
  12552. * Callback triggered when a button has been released
  12553. * @param callback Called when a button has been released
  12554. */
  12555. onbuttonup(callback: (buttonReleased: number) => void): void;
  12556. /**
  12557. * Initializes the generic gamepad
  12558. * @param id The id of the generic gamepad
  12559. * @param index The index of the generic gamepad
  12560. * @param browserGamepad The browser gamepad
  12561. */
  12562. constructor(id: string, index: number, browserGamepad: any);
  12563. private _setButtonValue;
  12564. /**
  12565. * Updates the generic gamepad
  12566. */
  12567. update(): void;
  12568. /**
  12569. * Disposes the generic gamepad
  12570. */
  12571. dispose(): void;
  12572. }
  12573. }
  12574. declare module BABYLON {
  12575. interface Engine {
  12576. /**
  12577. * Creates a raw texture
  12578. * @param data defines the data to store in the texture
  12579. * @param width defines the width of the texture
  12580. * @param height defines the height of the texture
  12581. * @param format defines the format of the data
  12582. * @param generateMipMaps defines if the engine should generate the mip levels
  12583. * @param invertY defines if data must be stored with Y axis inverted
  12584. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12585. * @param compression defines the compression used (null by default)
  12586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12587. * @returns the raw texture inside an InternalTexture
  12588. */
  12589. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12590. /**
  12591. * Update a raw texture
  12592. * @param texture defines the texture to update
  12593. * @param data defines the data to store in the texture
  12594. * @param format defines the format of the data
  12595. * @param invertY defines if data must be stored with Y axis inverted
  12596. */
  12597. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12598. /**
  12599. * Update a raw texture
  12600. * @param texture defines the texture to update
  12601. * @param data defines the data to store in the texture
  12602. * @param format defines the format of the data
  12603. * @param invertY defines if data must be stored with Y axis inverted
  12604. * @param compression defines the compression used (null by default)
  12605. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12606. */
  12607. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12608. /**
  12609. * Creates a new raw cube texture
  12610. * @param data defines the array of data to use to create each face
  12611. * @param size defines the size of the textures
  12612. * @param format defines the format of the data
  12613. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12614. * @param generateMipMaps defines if the engine should generate the mip levels
  12615. * @param invertY defines if data must be stored with Y axis inverted
  12616. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12617. * @param compression defines the compression used (null by default)
  12618. * @returns the cube texture as an InternalTexture
  12619. */
  12620. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12621. /**
  12622. * Update a raw cube texture
  12623. * @param texture defines the texture to udpdate
  12624. * @param data defines the data to store
  12625. * @param format defines the data format
  12626. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12627. * @param invertY defines if data must be stored with Y axis inverted
  12628. */
  12629. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12630. /**
  12631. * Update a raw cube texture
  12632. * @param texture defines the texture to udpdate
  12633. * @param data defines the data to store
  12634. * @param format defines the data format
  12635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12636. * @param invertY defines if data must be stored with Y axis inverted
  12637. * @param compression defines the compression used (null by default)
  12638. */
  12639. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12640. /**
  12641. * Update a raw cube texture
  12642. * @param texture defines the texture to udpdate
  12643. * @param data defines the data to store
  12644. * @param format defines the data format
  12645. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12646. * @param invertY defines if data must be stored with Y axis inverted
  12647. * @param compression defines the compression used (null by default)
  12648. * @param level defines which level of the texture to update
  12649. */
  12650. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12651. /**
  12652. * Creates a new raw cube texture from a specified url
  12653. * @param url defines the url where the data is located
  12654. * @param scene defines the current scene
  12655. * @param size defines the size of the textures
  12656. * @param format defines the format of the data
  12657. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12658. * @param noMipmap defines if the engine should avoid generating the mip levels
  12659. * @param callback defines a callback used to extract texture data from loaded data
  12660. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12661. * @param onLoad defines a callback called when texture is loaded
  12662. * @param onError defines a callback called if there is an error
  12663. * @returns the cube texture as an InternalTexture
  12664. */
  12665. 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;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12679. * @param invertY defines if data must be stored with Y axis inverted
  12680. * @returns the cube texture as an InternalTexture
  12681. */
  12682. 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;
  12683. /**
  12684. * Creates a new raw 3D texture
  12685. * @param data defines the data used to create the texture
  12686. * @param width defines the width of the texture
  12687. * @param height defines the height of the texture
  12688. * @param depth defines the depth of the texture
  12689. * @param format defines the format of the texture
  12690. * @param generateMipMaps defines if the engine must generate mip levels
  12691. * @param invertY defines if data must be stored with Y axis inverted
  12692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12693. * @param compression defines the compressed used (can be null)
  12694. * @param textureType defines the compressed used (can be null)
  12695. * @returns a new raw 3D texture (stored in an InternalTexture)
  12696. */
  12697. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12698. /**
  12699. * Update a raw 3D texture
  12700. * @param texture defines the texture to update
  12701. * @param data defines the data to store
  12702. * @param format defines the data format
  12703. * @param invertY defines if data must be stored with Y axis inverted
  12704. */
  12705. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12706. /**
  12707. * Update a raw 3D texture
  12708. * @param texture defines the texture to update
  12709. * @param data defines the data to store
  12710. * @param format defines the data format
  12711. * @param invertY defines if data must be stored with Y axis inverted
  12712. * @param compression defines the used compression (can be null)
  12713. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12714. */
  12715. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12716. /**
  12717. * Creates a new raw 2D array texture
  12718. * @param data defines the data used to create the texture
  12719. * @param width defines the width of the texture
  12720. * @param height defines the height of the texture
  12721. * @param depth defines the number of layers of the texture
  12722. * @param format defines the format of the texture
  12723. * @param generateMipMaps defines if the engine must generate mip levels
  12724. * @param invertY defines if data must be stored with Y axis inverted
  12725. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12726. * @param compression defines the compressed used (can be null)
  12727. * @param textureType defines the compressed used (can be null)
  12728. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12729. */
  12730. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12731. /**
  12732. * Update a raw 2D array texture
  12733. * @param texture defines the texture to update
  12734. * @param data defines the data to store
  12735. * @param format defines the data format
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. */
  12738. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12739. /**
  12740. * Update a raw 2D array texture
  12741. * @param texture defines the texture to update
  12742. * @param data defines the data to store
  12743. * @param format defines the data format
  12744. * @param invertY defines if data must be stored with Y axis inverted
  12745. * @param compression defines the used compression (can be null)
  12746. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12747. */
  12748. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12749. }
  12750. }
  12751. declare module BABYLON {
  12752. /**
  12753. * Raw texture can help creating a texture directly from an array of data.
  12754. * This can be super useful if you either get the data from an uncompressed source or
  12755. * if you wish to create your texture pixel by pixel.
  12756. */
  12757. export class RawTexture extends Texture {
  12758. /**
  12759. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12760. */
  12761. format: number;
  12762. private _engine;
  12763. /**
  12764. * Instantiates a new RawTexture.
  12765. * Raw texture can help creating a texture directly from an array of data.
  12766. * This can be super useful if you either get the data from an uncompressed source or
  12767. * if you wish to create your texture pixel by pixel.
  12768. * @param data define the array of data to use to create the texture
  12769. * @param width define the width of the texture
  12770. * @param height define the height of the texture
  12771. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12772. * @param scene define the scene the texture belongs to
  12773. * @param generateMipMaps define whether mip maps should be generated or not
  12774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12776. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12777. */
  12778. constructor(data: ArrayBufferView, width: number, height: number,
  12779. /**
  12780. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12781. */
  12782. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12783. /**
  12784. * Updates the texture underlying data.
  12785. * @param data Define the new data of the texture
  12786. */
  12787. update(data: ArrayBufferView): void;
  12788. /**
  12789. * Creates a luminance texture from some data.
  12790. * @param data Define the texture data
  12791. * @param width Define the width of the texture
  12792. * @param height Define the height of the texture
  12793. * @param scene Define the scene the texture belongs to
  12794. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12797. * @returns the luminance texture
  12798. */
  12799. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12800. /**
  12801. * Creates a luminance alpha texture from some data.
  12802. * @param data Define the texture data
  12803. * @param width Define the width of the texture
  12804. * @param height Define the height of the texture
  12805. * @param scene Define the scene the texture belongs to
  12806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12809. * @returns the luminance alpha texture
  12810. */
  12811. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12812. /**
  12813. * Creates an alpha texture from some data.
  12814. * @param data Define the texture data
  12815. * @param width Define the width of the texture
  12816. * @param height Define the height of the texture
  12817. * @param scene Define the scene the texture belongs to
  12818. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12819. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12820. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12821. * @returns the alpha texture
  12822. */
  12823. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12824. /**
  12825. * Creates a RGB texture from some data.
  12826. * @param data Define the texture data
  12827. * @param width Define the width of the texture
  12828. * @param height Define the height of the texture
  12829. * @param scene Define the scene the texture belongs to
  12830. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12831. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12832. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12833. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12834. * @returns the RGB alpha texture
  12835. */
  12836. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12837. /**
  12838. * Creates a RGBA texture from some data.
  12839. * @param data Define the texture data
  12840. * @param width Define the width of the texture
  12841. * @param height Define the height of the texture
  12842. * @param scene Define the scene the texture belongs to
  12843. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12844. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12845. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12846. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12847. * @returns the RGBA texture
  12848. */
  12849. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12850. /**
  12851. * Creates a R texture from some data.
  12852. * @param data Define the texture data
  12853. * @param width Define the width of the texture
  12854. * @param height Define the height of the texture
  12855. * @param scene Define the scene the texture belongs to
  12856. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12857. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12858. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12859. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12860. * @returns the R texture
  12861. */
  12862. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12863. }
  12864. }
  12865. declare module BABYLON {
  12866. /**
  12867. * Interface for the size containing width and height
  12868. */
  12869. export interface ISize {
  12870. /**
  12871. * Width
  12872. */
  12873. width: number;
  12874. /**
  12875. * Heighht
  12876. */
  12877. height: number;
  12878. }
  12879. /**
  12880. * Size containing widht and height
  12881. */
  12882. export class Size implements ISize {
  12883. /**
  12884. * Width
  12885. */
  12886. width: number;
  12887. /**
  12888. * Height
  12889. */
  12890. height: number;
  12891. /**
  12892. * Creates a Size object from the given width and height (floats).
  12893. * @param width width of the new size
  12894. * @param height height of the new size
  12895. */
  12896. constructor(width: number, height: number);
  12897. /**
  12898. * Returns a string with the Size width and height
  12899. * @returns a string with the Size width and height
  12900. */
  12901. toString(): string;
  12902. /**
  12903. * "Size"
  12904. * @returns the string "Size"
  12905. */
  12906. getClassName(): string;
  12907. /**
  12908. * Returns the Size hash code.
  12909. * @returns a hash code for a unique width and height
  12910. */
  12911. getHashCode(): number;
  12912. /**
  12913. * Updates the current size from the given one.
  12914. * @param src the given size
  12915. */
  12916. copyFrom(src: Size): void;
  12917. /**
  12918. * Updates in place the current Size from the given floats.
  12919. * @param width width of the new size
  12920. * @param height height of the new size
  12921. * @returns the updated Size.
  12922. */
  12923. copyFromFloats(width: number, height: number): Size;
  12924. /**
  12925. * Updates in place the current Size from the given floats.
  12926. * @param width width to set
  12927. * @param height height to set
  12928. * @returns the updated Size.
  12929. */
  12930. set(width: number, height: number): Size;
  12931. /**
  12932. * Multiplies the width and height by numbers
  12933. * @param w factor to multiple the width by
  12934. * @param h factor to multiple the height by
  12935. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12936. */
  12937. multiplyByFloats(w: number, h: number): Size;
  12938. /**
  12939. * Clones the size
  12940. * @returns a new Size copied from the given one.
  12941. */
  12942. clone(): Size;
  12943. /**
  12944. * True if the current Size and the given one width and height are strictly equal.
  12945. * @param other the other size to compare against
  12946. * @returns True if the current Size and the given one width and height are strictly equal.
  12947. */
  12948. equals(other: Size): boolean;
  12949. /**
  12950. * The surface of the Size : width * height (float).
  12951. */
  12952. get surface(): number;
  12953. /**
  12954. * Create a new size of zero
  12955. * @returns a new Size set to (0.0, 0.0)
  12956. */
  12957. static Zero(): Size;
  12958. /**
  12959. * Sums the width and height of two sizes
  12960. * @param otherSize size to add to this size
  12961. * @returns a new Size set as the addition result of the current Size and the given one.
  12962. */
  12963. add(otherSize: Size): Size;
  12964. /**
  12965. * Subtracts the width and height of two
  12966. * @param otherSize size to subtract to this size
  12967. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12968. */
  12969. subtract(otherSize: Size): Size;
  12970. /**
  12971. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12972. * @param start starting size to lerp between
  12973. * @param end end size to lerp between
  12974. * @param amount amount to lerp between the start and end values
  12975. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12976. */
  12977. static Lerp(start: Size, end: Size, amount: number): Size;
  12978. }
  12979. }
  12980. declare module BABYLON {
  12981. /**
  12982. * Defines a runtime animation
  12983. */
  12984. export class RuntimeAnimation {
  12985. private _events;
  12986. /**
  12987. * The current frame of the runtime animation
  12988. */
  12989. private _currentFrame;
  12990. /**
  12991. * The animation used by the runtime animation
  12992. */
  12993. private _animation;
  12994. /**
  12995. * The target of the runtime animation
  12996. */
  12997. private _target;
  12998. /**
  12999. * The initiating animatable
  13000. */
  13001. private _host;
  13002. /**
  13003. * The original value of the runtime animation
  13004. */
  13005. private _originalValue;
  13006. /**
  13007. * The original blend value of the runtime animation
  13008. */
  13009. private _originalBlendValue;
  13010. /**
  13011. * The offsets cache of the runtime animation
  13012. */
  13013. private _offsetsCache;
  13014. /**
  13015. * The high limits cache of the runtime animation
  13016. */
  13017. private _highLimitsCache;
  13018. /**
  13019. * Specifies if the runtime animation has been stopped
  13020. */
  13021. private _stopped;
  13022. /**
  13023. * The blending factor of the runtime animation
  13024. */
  13025. private _blendingFactor;
  13026. /**
  13027. * The BabylonJS scene
  13028. */
  13029. private _scene;
  13030. /**
  13031. * The current value of the runtime animation
  13032. */
  13033. private _currentValue;
  13034. /** @hidden */
  13035. _animationState: _IAnimationState;
  13036. /**
  13037. * The active target of the runtime animation
  13038. */
  13039. private _activeTargets;
  13040. private _currentActiveTarget;
  13041. private _directTarget;
  13042. /**
  13043. * The target path of the runtime animation
  13044. */
  13045. private _targetPath;
  13046. /**
  13047. * The weight of the runtime animation
  13048. */
  13049. private _weight;
  13050. /**
  13051. * The ratio offset of the runtime animation
  13052. */
  13053. private _ratioOffset;
  13054. /**
  13055. * The previous delay of the runtime animation
  13056. */
  13057. private _previousDelay;
  13058. /**
  13059. * The previous ratio of the runtime animation
  13060. */
  13061. private _previousRatio;
  13062. private _enableBlending;
  13063. private _keys;
  13064. private _minFrame;
  13065. private _maxFrame;
  13066. private _minValue;
  13067. private _maxValue;
  13068. private _targetIsArray;
  13069. /**
  13070. * Gets the current frame of the runtime animation
  13071. */
  13072. get currentFrame(): number;
  13073. /**
  13074. * Gets the weight of the runtime animation
  13075. */
  13076. get weight(): number;
  13077. /**
  13078. * Gets the current value of the runtime animation
  13079. */
  13080. get currentValue(): any;
  13081. /**
  13082. * Gets the target path of the runtime animation
  13083. */
  13084. get targetPath(): string;
  13085. /**
  13086. * Gets the actual target of the runtime animation
  13087. */
  13088. get target(): any;
  13089. /** @hidden */
  13090. _onLoop: () => void;
  13091. /**
  13092. * Create a new RuntimeAnimation object
  13093. * @param target defines the target of the animation
  13094. * @param animation defines the source animation object
  13095. * @param scene defines the hosting scene
  13096. * @param host defines the initiating Animatable
  13097. */
  13098. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13099. private _preparePath;
  13100. /**
  13101. * Gets the animation from the runtime animation
  13102. */
  13103. get animation(): Animation;
  13104. /**
  13105. * Resets the runtime animation to the beginning
  13106. * @param restoreOriginal defines whether to restore the target property to the original value
  13107. */
  13108. reset(restoreOriginal?: boolean): void;
  13109. /**
  13110. * Specifies if the runtime animation is stopped
  13111. * @returns Boolean specifying if the runtime animation is stopped
  13112. */
  13113. isStopped(): boolean;
  13114. /**
  13115. * Disposes of the runtime animation
  13116. */
  13117. dispose(): void;
  13118. /**
  13119. * Apply the interpolated value to the target
  13120. * @param currentValue defines the value computed by the animation
  13121. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13122. */
  13123. setValue(currentValue: any, weight: number): void;
  13124. private _getOriginalValues;
  13125. private _setValue;
  13126. /**
  13127. * Gets the loop pmode of the runtime animation
  13128. * @returns Loop Mode
  13129. */
  13130. private _getCorrectLoopMode;
  13131. /**
  13132. * Move the current animation to a given frame
  13133. * @param frame defines the frame to move to
  13134. */
  13135. goToFrame(frame: number): void;
  13136. /**
  13137. * @hidden Internal use only
  13138. */
  13139. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13140. /**
  13141. * Execute the current animation
  13142. * @param delay defines the delay to add to the current frame
  13143. * @param from defines the lower bound of the animation range
  13144. * @param to defines the upper bound of the animation range
  13145. * @param loop defines if the current animation must loop
  13146. * @param speedRatio defines the current speed ratio
  13147. * @param weight defines the weight of the animation (default is -1 so no weight)
  13148. * @param onLoop optional callback called when animation loops
  13149. * @returns a boolean indicating if the animation is running
  13150. */
  13151. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13152. }
  13153. }
  13154. declare module BABYLON {
  13155. /**
  13156. * Class used to store an actual running animation
  13157. */
  13158. export class Animatable {
  13159. /** defines the target object */
  13160. target: any;
  13161. /** defines the starting frame number (default is 0) */
  13162. fromFrame: number;
  13163. /** defines the ending frame number (default is 100) */
  13164. toFrame: number;
  13165. /** defines if the animation must loop (default is false) */
  13166. loopAnimation: boolean;
  13167. /** defines a callback to call when animation ends if it is not looping */
  13168. onAnimationEnd?: (() => void) | null | undefined;
  13169. /** defines a callback to call when animation loops */
  13170. onAnimationLoop?: (() => void) | null | undefined;
  13171. private _localDelayOffset;
  13172. private _pausedDelay;
  13173. private _runtimeAnimations;
  13174. private _paused;
  13175. private _scene;
  13176. private _speedRatio;
  13177. private _weight;
  13178. private _syncRoot;
  13179. /**
  13180. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13181. * This will only apply for non looping animation (default is true)
  13182. */
  13183. disposeOnEnd: boolean;
  13184. /**
  13185. * Gets a boolean indicating if the animation has started
  13186. */
  13187. animationStarted: boolean;
  13188. /**
  13189. * Observer raised when the animation ends
  13190. */
  13191. onAnimationEndObservable: Observable<Animatable>;
  13192. /**
  13193. * Observer raised when the animation loops
  13194. */
  13195. onAnimationLoopObservable: Observable<Animatable>;
  13196. /**
  13197. * Gets the root Animatable used to synchronize and normalize animations
  13198. */
  13199. get syncRoot(): Nullable<Animatable>;
  13200. /**
  13201. * Gets the current frame of the first RuntimeAnimation
  13202. * Used to synchronize Animatables
  13203. */
  13204. get masterFrame(): number;
  13205. /**
  13206. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13207. */
  13208. get weight(): number;
  13209. set weight(value: number);
  13210. /**
  13211. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13212. */
  13213. get speedRatio(): number;
  13214. set speedRatio(value: number);
  13215. /**
  13216. * Creates a new Animatable
  13217. * @param scene defines the hosting scene
  13218. * @param target defines the target object
  13219. * @param fromFrame defines the starting frame number (default is 0)
  13220. * @param toFrame defines the ending frame number (default is 100)
  13221. * @param loopAnimation defines if the animation must loop (default is false)
  13222. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13223. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13224. * @param animations defines a group of animation to add to the new Animatable
  13225. * @param onAnimationLoop defines a callback to call when animation loops
  13226. */
  13227. constructor(scene: Scene,
  13228. /** defines the target object */
  13229. target: any,
  13230. /** defines the starting frame number (default is 0) */
  13231. fromFrame?: number,
  13232. /** defines the ending frame number (default is 100) */
  13233. toFrame?: number,
  13234. /** defines if the animation must loop (default is false) */
  13235. loopAnimation?: boolean, speedRatio?: number,
  13236. /** defines a callback to call when animation ends if it is not looping */
  13237. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13238. /** defines a callback to call when animation loops */
  13239. onAnimationLoop?: (() => void) | null | undefined);
  13240. /**
  13241. * Synchronize and normalize current Animatable with a source Animatable
  13242. * This is useful when using animation weights and when animations are not of the same length
  13243. * @param root defines the root Animatable to synchronize with
  13244. * @returns the current Animatable
  13245. */
  13246. syncWith(root: Animatable): Animatable;
  13247. /**
  13248. * Gets the list of runtime animations
  13249. * @returns an array of RuntimeAnimation
  13250. */
  13251. getAnimations(): RuntimeAnimation[];
  13252. /**
  13253. * Adds more animations to the current animatable
  13254. * @param target defines the target of the animations
  13255. * @param animations defines the new animations to add
  13256. */
  13257. appendAnimations(target: any, animations: Animation[]): void;
  13258. /**
  13259. * Gets the source animation for a specific property
  13260. * @param property defines the propertyu to look for
  13261. * @returns null or the source animation for the given property
  13262. */
  13263. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13264. /**
  13265. * Gets the runtime animation for a specific property
  13266. * @param property defines the propertyu to look for
  13267. * @returns null or the runtime animation for the given property
  13268. */
  13269. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13270. /**
  13271. * Resets the animatable to its original state
  13272. */
  13273. reset(): void;
  13274. /**
  13275. * Allows the animatable to blend with current running animations
  13276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13277. * @param blendingSpeed defines the blending speed to use
  13278. */
  13279. enableBlending(blendingSpeed: number): void;
  13280. /**
  13281. * Disable animation blending
  13282. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13283. */
  13284. disableBlending(): void;
  13285. /**
  13286. * Jump directly to a given frame
  13287. * @param frame defines the frame to jump to
  13288. */
  13289. goToFrame(frame: number): void;
  13290. /**
  13291. * Pause the animation
  13292. */
  13293. pause(): void;
  13294. /**
  13295. * Restart the animation
  13296. */
  13297. restart(): void;
  13298. private _raiseOnAnimationEnd;
  13299. /**
  13300. * Stop and delete the current animation
  13301. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13302. * @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)
  13303. */
  13304. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13305. /**
  13306. * Wait asynchronously for the animation to end
  13307. * @returns a promise which will be fullfilled when the animation ends
  13308. */
  13309. waitAsync(): Promise<Animatable>;
  13310. /** @hidden */
  13311. _animate(delay: number): boolean;
  13312. }
  13313. interface Scene {
  13314. /** @hidden */
  13315. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13316. /** @hidden */
  13317. _processLateAnimationBindingsForMatrices(holder: {
  13318. totalWeight: number;
  13319. animations: RuntimeAnimation[];
  13320. originalValue: Matrix;
  13321. }): any;
  13322. /** @hidden */
  13323. _processLateAnimationBindingsForQuaternions(holder: {
  13324. totalWeight: number;
  13325. animations: RuntimeAnimation[];
  13326. originalValue: Quaternion;
  13327. }, refQuaternion: Quaternion): Quaternion;
  13328. /** @hidden */
  13329. _processLateAnimationBindings(): void;
  13330. /**
  13331. * Will start the animation sequence of a given target
  13332. * @param target defines the target
  13333. * @param from defines from which frame should animation start
  13334. * @param to defines until which frame should animation run.
  13335. * @param weight defines the weight to apply to the animation (1.0 by default)
  13336. * @param loop defines if the animation loops
  13337. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13338. * @param onAnimationEnd defines the function to be executed when the animation ends
  13339. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13340. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13341. * @param onAnimationLoop defines the callback to call when an animation loops
  13342. * @returns the animatable object created for this animation
  13343. */
  13344. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13345. /**
  13346. * Will start the animation sequence of a given target
  13347. * @param target defines the target
  13348. * @param from defines from which frame should animation start
  13349. * @param to defines until which frame should animation run.
  13350. * @param loop defines if the animation loops
  13351. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13352. * @param onAnimationEnd defines the function to be executed when the animation ends
  13353. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13354. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13355. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13356. * @param onAnimationLoop defines the callback to call when an animation loops
  13357. * @returns the animatable object created for this animation
  13358. */
  13359. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13360. /**
  13361. * Will start the animation sequence of a given target and its hierarchy
  13362. * @param target defines the target
  13363. * @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.
  13364. * @param from defines from which frame should animation start
  13365. * @param to defines until which frame should animation run.
  13366. * @param loop defines if the animation loops
  13367. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13368. * @param onAnimationEnd defines the function to be executed when the animation ends
  13369. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13370. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13371. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13372. * @param onAnimationLoop defines the callback to call when an animation loops
  13373. * @returns the list of created animatables
  13374. */
  13375. 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[];
  13376. /**
  13377. * Begin a new animation on a given node
  13378. * @param target defines the target where the animation will take place
  13379. * @param animations defines the list of animations to start
  13380. * @param from defines the initial value
  13381. * @param to defines the final value
  13382. * @param loop defines if you want animation to loop (off by default)
  13383. * @param speedRatio defines the speed ratio to apply to all animations
  13384. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13385. * @param onAnimationLoop defines the callback to call when an animation loops
  13386. * @returns the list of created animatables
  13387. */
  13388. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13389. /**
  13390. * Begin a new animation on a given node and its hierarchy
  13391. * @param target defines the root node where the animation will take place
  13392. * @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.
  13393. * @param animations defines the list of animations to start
  13394. * @param from defines the initial value
  13395. * @param to defines the final value
  13396. * @param loop defines if you want animation to loop (off by default)
  13397. * @param speedRatio defines the speed ratio to apply to all animations
  13398. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13399. * @param onAnimationLoop defines the callback to call when an animation loops
  13400. * @returns the list of animatables created for all nodes
  13401. */
  13402. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13403. /**
  13404. * Gets the animatable associated with a specific target
  13405. * @param target defines the target of the animatable
  13406. * @returns the required animatable if found
  13407. */
  13408. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13409. /**
  13410. * Gets all animatables associated with a given target
  13411. * @param target defines the target to look animatables for
  13412. * @returns an array of Animatables
  13413. */
  13414. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13415. /**
  13416. * Stops and removes all animations that have been applied to the scene
  13417. */
  13418. stopAllAnimations(): void;
  13419. /**
  13420. * Gets the current delta time used by animation engine
  13421. */
  13422. deltaTime: number;
  13423. }
  13424. interface Bone {
  13425. /**
  13426. * Copy an animation range from another bone
  13427. * @param source defines the source bone
  13428. * @param rangeName defines the range name to copy
  13429. * @param frameOffset defines the frame offset
  13430. * @param rescaleAsRequired defines if rescaling must be applied if required
  13431. * @param skelDimensionsRatio defines the scaling ratio
  13432. * @returns true if operation was successful
  13433. */
  13434. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13435. }
  13436. }
  13437. declare module BABYLON {
  13438. /**
  13439. * Class used to override all child animations of a given target
  13440. */
  13441. export class AnimationPropertiesOverride {
  13442. /**
  13443. * Gets or sets a value indicating if animation blending must be used
  13444. */
  13445. enableBlending: boolean;
  13446. /**
  13447. * Gets or sets the blending speed to use when enableBlending is true
  13448. */
  13449. blendingSpeed: number;
  13450. /**
  13451. * Gets or sets the default loop mode to use
  13452. */
  13453. loopMode: number;
  13454. }
  13455. }
  13456. declare module BABYLON {
  13457. /**
  13458. * Class used to handle skinning animations
  13459. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13460. */
  13461. export class Skeleton implements IAnimatable {
  13462. /** defines the skeleton name */
  13463. name: string;
  13464. /** defines the skeleton Id */
  13465. id: string;
  13466. /**
  13467. * Defines the list of child bones
  13468. */
  13469. bones: Bone[];
  13470. /**
  13471. * Defines an estimate of the dimension of the skeleton at rest
  13472. */
  13473. dimensionsAtRest: Vector3;
  13474. /**
  13475. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13476. */
  13477. needInitialSkinMatrix: boolean;
  13478. /**
  13479. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13480. */
  13481. overrideMesh: Nullable<AbstractMesh>;
  13482. /**
  13483. * Gets the list of animations attached to this skeleton
  13484. */
  13485. animations: Array<Animation>;
  13486. private _scene;
  13487. private _isDirty;
  13488. private _transformMatrices;
  13489. private _transformMatrixTexture;
  13490. private _meshesWithPoseMatrix;
  13491. private _animatables;
  13492. private _identity;
  13493. private _synchronizedWithMesh;
  13494. private _ranges;
  13495. private _lastAbsoluteTransformsUpdateId;
  13496. private _canUseTextureForBones;
  13497. private _uniqueId;
  13498. /** @hidden */
  13499. _numBonesWithLinkedTransformNode: number;
  13500. /** @hidden */
  13501. _hasWaitingData: Nullable<boolean>;
  13502. /**
  13503. * Specifies if the skeleton should be serialized
  13504. */
  13505. doNotSerialize: boolean;
  13506. private _useTextureToStoreBoneMatrices;
  13507. /**
  13508. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13509. * Please note that this option is not available if the hardware does not support it
  13510. */
  13511. get useTextureToStoreBoneMatrices(): boolean;
  13512. set useTextureToStoreBoneMatrices(value: boolean);
  13513. private _animationPropertiesOverride;
  13514. /**
  13515. * Gets or sets the animation properties override
  13516. */
  13517. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13518. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13519. /**
  13520. * List of inspectable custom properties (used by the Inspector)
  13521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13522. */
  13523. inspectableCustomProperties: IInspectable[];
  13524. /**
  13525. * An observable triggered before computing the skeleton's matrices
  13526. */
  13527. onBeforeComputeObservable: Observable<Skeleton>;
  13528. /**
  13529. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13530. */
  13531. get isUsingTextureForMatrices(): boolean;
  13532. /**
  13533. * Gets the unique ID of this skeleton
  13534. */
  13535. get uniqueId(): number;
  13536. /**
  13537. * Creates a new skeleton
  13538. * @param name defines the skeleton name
  13539. * @param id defines the skeleton Id
  13540. * @param scene defines the hosting scene
  13541. */
  13542. constructor(
  13543. /** defines the skeleton name */
  13544. name: string,
  13545. /** defines the skeleton Id */
  13546. id: string, scene: Scene);
  13547. /**
  13548. * Gets the current object class name.
  13549. * @return the class name
  13550. */
  13551. getClassName(): string;
  13552. /**
  13553. * Returns an array containing the root bones
  13554. * @returns an array containing the root bones
  13555. */
  13556. getChildren(): Array<Bone>;
  13557. /**
  13558. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13559. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13560. * @returns a Float32Array containing matrices data
  13561. */
  13562. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13563. /**
  13564. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13565. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13566. * @returns a raw texture containing the data
  13567. */
  13568. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13569. /**
  13570. * Gets the current hosting scene
  13571. * @returns a scene object
  13572. */
  13573. getScene(): Scene;
  13574. /**
  13575. * Gets a string representing the current skeleton data
  13576. * @param fullDetails defines a boolean indicating if we want a verbose version
  13577. * @returns a string representing the current skeleton data
  13578. */
  13579. toString(fullDetails?: boolean): string;
  13580. /**
  13581. * Get bone's index searching by name
  13582. * @param name defines bone's name to search for
  13583. * @return the indice of the bone. Returns -1 if not found
  13584. */
  13585. getBoneIndexByName(name: string): number;
  13586. /**
  13587. * Creater a new animation range
  13588. * @param name defines the name of the range
  13589. * @param from defines the start key
  13590. * @param to defines the end key
  13591. */
  13592. createAnimationRange(name: string, from: number, to: number): void;
  13593. /**
  13594. * Delete a specific animation range
  13595. * @param name defines the name of the range
  13596. * @param deleteFrames defines if frames must be removed as well
  13597. */
  13598. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13599. /**
  13600. * Gets a specific animation range
  13601. * @param name defines the name of the range to look for
  13602. * @returns the requested animation range or null if not found
  13603. */
  13604. getAnimationRange(name: string): Nullable<AnimationRange>;
  13605. /**
  13606. * Gets the list of all animation ranges defined on this skeleton
  13607. * @returns an array
  13608. */
  13609. getAnimationRanges(): Nullable<AnimationRange>[];
  13610. /**
  13611. * Copy animation range from a source skeleton.
  13612. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13613. * @param source defines the source skeleton
  13614. * @param name defines the name of the range to copy
  13615. * @param rescaleAsRequired defines if rescaling must be applied if required
  13616. * @returns true if operation was successful
  13617. */
  13618. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13619. /**
  13620. * Forces the skeleton to go to rest pose
  13621. */
  13622. returnToRest(): void;
  13623. private _getHighestAnimationFrame;
  13624. /**
  13625. * Begin a specific animation range
  13626. * @param name defines the name of the range to start
  13627. * @param loop defines if looping must be turned on (false by default)
  13628. * @param speedRatio defines the speed ratio to apply (1 by default)
  13629. * @param onAnimationEnd defines a callback which will be called when animation will end
  13630. * @returns a new animatable
  13631. */
  13632. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13633. /** @hidden */
  13634. _markAsDirty(): void;
  13635. /** @hidden */
  13636. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13637. /** @hidden */
  13638. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13639. private _computeTransformMatrices;
  13640. /**
  13641. * Build all resources required to render a skeleton
  13642. */
  13643. prepare(): void;
  13644. /**
  13645. * Gets the list of animatables currently running for this skeleton
  13646. * @returns an array of animatables
  13647. */
  13648. getAnimatables(): IAnimatable[];
  13649. /**
  13650. * Clone the current skeleton
  13651. * @param name defines the name of the new skeleton
  13652. * @param id defines the id of the new skeleton
  13653. * @returns the new skeleton
  13654. */
  13655. clone(name: string, id?: string): Skeleton;
  13656. /**
  13657. * Enable animation blending for this skeleton
  13658. * @param blendingSpeed defines the blending speed to apply
  13659. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13660. */
  13661. enableBlending(blendingSpeed?: number): void;
  13662. /**
  13663. * Releases all resources associated with the current skeleton
  13664. */
  13665. dispose(): void;
  13666. /**
  13667. * Serialize the skeleton in a JSON object
  13668. * @returns a JSON object
  13669. */
  13670. serialize(): any;
  13671. /**
  13672. * Creates a new skeleton from serialized data
  13673. * @param parsedSkeleton defines the serialized data
  13674. * @param scene defines the hosting scene
  13675. * @returns a new skeleton
  13676. */
  13677. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13678. /**
  13679. * Compute all node absolute transforms
  13680. * @param forceUpdate defines if computation must be done even if cache is up to date
  13681. */
  13682. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13683. /**
  13684. * Gets the root pose matrix
  13685. * @returns a matrix
  13686. */
  13687. getPoseMatrix(): Nullable<Matrix>;
  13688. /**
  13689. * Sorts bones per internal index
  13690. */
  13691. sortBones(): void;
  13692. private _sortBones;
  13693. }
  13694. }
  13695. declare module BABYLON {
  13696. /**
  13697. * Class used to store bone information
  13698. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13699. */
  13700. export class Bone extends Node {
  13701. /**
  13702. * defines the bone name
  13703. */
  13704. name: string;
  13705. private static _tmpVecs;
  13706. private static _tmpQuat;
  13707. private static _tmpMats;
  13708. /**
  13709. * Gets the list of child bones
  13710. */
  13711. children: Bone[];
  13712. /** Gets the animations associated with this bone */
  13713. animations: Animation[];
  13714. /**
  13715. * Gets or sets bone length
  13716. */
  13717. length: number;
  13718. /**
  13719. * @hidden Internal only
  13720. * Set this value to map this bone to a different index in the transform matrices
  13721. * Set this value to -1 to exclude the bone from the transform matrices
  13722. */
  13723. _index: Nullable<number>;
  13724. private _skeleton;
  13725. private _localMatrix;
  13726. private _restPose;
  13727. private _baseMatrix;
  13728. private _absoluteTransform;
  13729. private _invertedAbsoluteTransform;
  13730. private _parent;
  13731. private _scalingDeterminant;
  13732. private _worldTransform;
  13733. private _localScaling;
  13734. private _localRotation;
  13735. private _localPosition;
  13736. private _needToDecompose;
  13737. private _needToCompose;
  13738. /** @hidden */
  13739. _linkedTransformNode: Nullable<TransformNode>;
  13740. /** @hidden */
  13741. _waitingTransformNodeId: Nullable<string>;
  13742. /** @hidden */
  13743. get _matrix(): Matrix;
  13744. /** @hidden */
  13745. set _matrix(value: Matrix);
  13746. /**
  13747. * Create a new bone
  13748. * @param name defines the bone name
  13749. * @param skeleton defines the parent skeleton
  13750. * @param parentBone defines the parent (can be null if the bone is the root)
  13751. * @param localMatrix defines the local matrix
  13752. * @param restPose defines the rest pose matrix
  13753. * @param baseMatrix defines the base matrix
  13754. * @param index defines index of the bone in the hiearchy
  13755. */
  13756. constructor(
  13757. /**
  13758. * defines the bone name
  13759. */
  13760. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13761. /**
  13762. * Gets the current object class name.
  13763. * @return the class name
  13764. */
  13765. getClassName(): string;
  13766. /**
  13767. * Gets the parent skeleton
  13768. * @returns a skeleton
  13769. */
  13770. getSkeleton(): Skeleton;
  13771. /**
  13772. * Gets parent bone
  13773. * @returns a bone or null if the bone is the root of the bone hierarchy
  13774. */
  13775. getParent(): Nullable<Bone>;
  13776. /**
  13777. * Returns an array containing the root bones
  13778. * @returns an array containing the root bones
  13779. */
  13780. getChildren(): Array<Bone>;
  13781. /**
  13782. * Gets the node index in matrix array generated for rendering
  13783. * @returns the node index
  13784. */
  13785. getIndex(): number;
  13786. /**
  13787. * Sets the parent bone
  13788. * @param parent defines the parent (can be null if the bone is the root)
  13789. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13790. */
  13791. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13792. /**
  13793. * Gets the local matrix
  13794. * @returns a matrix
  13795. */
  13796. getLocalMatrix(): Matrix;
  13797. /**
  13798. * Gets the base matrix (initial matrix which remains unchanged)
  13799. * @returns a matrix
  13800. */
  13801. getBaseMatrix(): Matrix;
  13802. /**
  13803. * Gets the rest pose matrix
  13804. * @returns a matrix
  13805. */
  13806. getRestPose(): Matrix;
  13807. /**
  13808. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13809. */
  13810. getWorldMatrix(): Matrix;
  13811. /**
  13812. * Sets the local matrix to rest pose matrix
  13813. */
  13814. returnToRest(): void;
  13815. /**
  13816. * Gets the inverse of the absolute transform matrix.
  13817. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13818. * @returns a matrix
  13819. */
  13820. getInvertedAbsoluteTransform(): Matrix;
  13821. /**
  13822. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13823. * @returns a matrix
  13824. */
  13825. getAbsoluteTransform(): Matrix;
  13826. /**
  13827. * Links with the given transform node.
  13828. * The local matrix of this bone is copied from the transform node every frame.
  13829. * @param transformNode defines the transform node to link to
  13830. */
  13831. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13832. /**
  13833. * Gets the node used to drive the bone's transformation
  13834. * @returns a transform node or null
  13835. */
  13836. getTransformNode(): Nullable<TransformNode>;
  13837. /** Gets or sets current position (in local space) */
  13838. get position(): Vector3;
  13839. set position(newPosition: Vector3);
  13840. /** Gets or sets current rotation (in local space) */
  13841. get rotation(): Vector3;
  13842. set rotation(newRotation: Vector3);
  13843. /** Gets or sets current rotation quaternion (in local space) */
  13844. get rotationQuaternion(): Quaternion;
  13845. set rotationQuaternion(newRotation: Quaternion);
  13846. /** Gets or sets current scaling (in local space) */
  13847. get scaling(): Vector3;
  13848. set scaling(newScaling: Vector3);
  13849. /**
  13850. * Gets the animation properties override
  13851. */
  13852. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13853. private _decompose;
  13854. private _compose;
  13855. /**
  13856. * Update the base and local matrices
  13857. * @param matrix defines the new base or local matrix
  13858. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13859. * @param updateLocalMatrix defines if the local matrix should be updated
  13860. */
  13861. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13862. /** @hidden */
  13863. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13864. /**
  13865. * Flag the bone as dirty (Forcing it to update everything)
  13866. */
  13867. markAsDirty(): void;
  13868. /** @hidden */
  13869. _markAsDirtyAndCompose(): void;
  13870. private _markAsDirtyAndDecompose;
  13871. /**
  13872. * Translate the bone in local or world space
  13873. * @param vec The amount to translate the bone
  13874. * @param space The space that the translation is in
  13875. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13876. */
  13877. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13878. /**
  13879. * Set the postion of the bone in local or world space
  13880. * @param position The position to set the bone
  13881. * @param space The space that the position is in
  13882. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13883. */
  13884. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13885. /**
  13886. * Set the absolute position of the bone (world space)
  13887. * @param position The position to set the bone
  13888. * @param mesh The mesh that this bone is attached to
  13889. */
  13890. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13891. /**
  13892. * Scale the bone on the x, y and z axes (in local space)
  13893. * @param x The amount to scale the bone on the x axis
  13894. * @param y The amount to scale the bone on the y axis
  13895. * @param z The amount to scale the bone on the z axis
  13896. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13897. */
  13898. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13899. /**
  13900. * Set the bone scaling in local space
  13901. * @param scale defines the scaling vector
  13902. */
  13903. setScale(scale: Vector3): void;
  13904. /**
  13905. * Gets the current scaling in local space
  13906. * @returns the current scaling vector
  13907. */
  13908. getScale(): Vector3;
  13909. /**
  13910. * Gets the current scaling in local space and stores it in a target vector
  13911. * @param result defines the target vector
  13912. */
  13913. getScaleToRef(result: Vector3): void;
  13914. /**
  13915. * Set the yaw, pitch, and roll of the bone in local or world space
  13916. * @param yaw The rotation of the bone on the y axis
  13917. * @param pitch The rotation of the bone on the x axis
  13918. * @param roll The rotation of the bone on the z axis
  13919. * @param space The space that the axes of rotation are in
  13920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13921. */
  13922. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13923. /**
  13924. * Add a rotation to the bone on an axis in local or world space
  13925. * @param axis The axis to rotate the bone on
  13926. * @param amount The amount to rotate the bone
  13927. * @param space The space that the axis is in
  13928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13929. */
  13930. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13931. /**
  13932. * Set the rotation of the bone to a particular axis angle in local or world space
  13933. * @param axis The axis to rotate the bone on
  13934. * @param angle The angle that the bone should be rotated to
  13935. * @param space The space that the axis is in
  13936. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13937. */
  13938. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13939. /**
  13940. * Set the euler rotation of the bone in local of world space
  13941. * @param rotation The euler rotation that the bone should be set to
  13942. * @param space The space that the rotation is in
  13943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13944. */
  13945. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13946. /**
  13947. * Set the quaternion rotation of the bone in local of world space
  13948. * @param quat The quaternion rotation that the bone should be set to
  13949. * @param space The space that the rotation is in
  13950. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13951. */
  13952. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13953. /**
  13954. * Set the rotation matrix of the bone in local of world space
  13955. * @param rotMat The rotation matrix that the bone should be set to
  13956. * @param space The space that the rotation is in
  13957. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13958. */
  13959. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13960. private _rotateWithMatrix;
  13961. private _getNegativeRotationToRef;
  13962. /**
  13963. * Get the position of the bone in local or world space
  13964. * @param space The space that the returned position is in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. * @returns The position of the bone
  13967. */
  13968. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13969. /**
  13970. * Copy the position of the bone to a vector3 in local or world space
  13971. * @param space The space that the returned position is in
  13972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13973. * @param result The vector3 to copy the position to
  13974. */
  13975. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13976. /**
  13977. * Get the absolute position of the bone (world space)
  13978. * @param mesh The mesh that this bone is attached to
  13979. * @returns The absolute position of the bone
  13980. */
  13981. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13982. /**
  13983. * Copy the absolute position of the bone (world space) to the result param
  13984. * @param mesh The mesh that this bone is attached to
  13985. * @param result The vector3 to copy the absolute position to
  13986. */
  13987. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13988. /**
  13989. * Compute the absolute transforms of this bone and its children
  13990. */
  13991. computeAbsoluteTransforms(): void;
  13992. /**
  13993. * Get the world direction from an axis that is in the local space of the bone
  13994. * @param localAxis The local direction that is used to compute the world direction
  13995. * @param mesh The mesh that this bone is attached to
  13996. * @returns The world direction
  13997. */
  13998. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13999. /**
  14000. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14001. * @param localAxis The local direction that is used to compute the world direction
  14002. * @param mesh The mesh that this bone is attached to
  14003. * @param result The vector3 that the world direction will be copied to
  14004. */
  14005. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14006. /**
  14007. * Get the euler rotation of the bone in local or world space
  14008. * @param space The space that the rotation should be in
  14009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14010. * @returns The euler rotation
  14011. */
  14012. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14013. /**
  14014. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14015. * @param space The space that the rotation should be in
  14016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14017. * @param result The vector3 that the rotation should be copied to
  14018. */
  14019. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14020. /**
  14021. * Get the quaternion rotation of the bone in either local or world space
  14022. * @param space The space that the rotation should be in
  14023. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14024. * @returns The quaternion rotation
  14025. */
  14026. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14027. /**
  14028. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14029. * @param space The space that the rotation should be in
  14030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14031. * @param result The quaternion that the rotation should be copied to
  14032. */
  14033. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14034. /**
  14035. * Get the rotation matrix 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 rotation matrix
  14039. */
  14040. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14041. /**
  14042. * Copy the rotation matrix of the bone to a matrix. 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 quaternion that the rotation should be copied to
  14046. */
  14047. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14048. /**
  14049. * Get the world position of a point that is in the local space of the bone
  14050. * @param position The local position
  14051. * @param mesh The mesh that this bone is attached to
  14052. * @returns The world position
  14053. */
  14054. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14055. /**
  14056. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14057. * @param position The local position
  14058. * @param mesh The mesh that this bone is attached to
  14059. * @param result The vector3 that the world position should be copied to
  14060. */
  14061. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14062. /**
  14063. * Get the local position of a point that is in world space
  14064. * @param position The world position
  14065. * @param mesh The mesh that this bone is attached to
  14066. * @returns The local position
  14067. */
  14068. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14069. /**
  14070. * Get the local position of a point that is in world space and copy it to the result param
  14071. * @param position The world position
  14072. * @param mesh The mesh that this bone is attached to
  14073. * @param result The vector3 that the local position should be copied to
  14074. */
  14075. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14076. }
  14077. }
  14078. declare module BABYLON {
  14079. /**
  14080. * 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.
  14081. * @see https://doc.babylonjs.com/how_to/transformnode
  14082. */
  14083. export class TransformNode extends Node {
  14084. /**
  14085. * Object will not rotate to face the camera
  14086. */
  14087. static BILLBOARDMODE_NONE: number;
  14088. /**
  14089. * Object will rotate to face the camera but only on the x axis
  14090. */
  14091. static BILLBOARDMODE_X: number;
  14092. /**
  14093. * Object will rotate to face the camera but only on the y axis
  14094. */
  14095. static BILLBOARDMODE_Y: number;
  14096. /**
  14097. * Object will rotate to face the camera but only on the z axis
  14098. */
  14099. static BILLBOARDMODE_Z: number;
  14100. /**
  14101. * Object will rotate to face the camera
  14102. */
  14103. static BILLBOARDMODE_ALL: number;
  14104. /**
  14105. * Object will rotate to face the camera's position instead of orientation
  14106. */
  14107. static BILLBOARDMODE_USE_POSITION: number;
  14108. private _forward;
  14109. private _forwardInverted;
  14110. private _up;
  14111. private _right;
  14112. private _rightInverted;
  14113. private _position;
  14114. private _rotation;
  14115. private _rotationQuaternion;
  14116. protected _scaling: Vector3;
  14117. protected _isDirty: boolean;
  14118. private _transformToBoneReferal;
  14119. private _isAbsoluteSynced;
  14120. private _billboardMode;
  14121. /**
  14122. * Gets or sets the billboard mode. Default is 0.
  14123. *
  14124. * | Value | Type | Description |
  14125. * | --- | --- | --- |
  14126. * | 0 | BILLBOARDMODE_NONE | |
  14127. * | 1 | BILLBOARDMODE_X | |
  14128. * | 2 | BILLBOARDMODE_Y | |
  14129. * | 4 | BILLBOARDMODE_Z | |
  14130. * | 7 | BILLBOARDMODE_ALL | |
  14131. *
  14132. */
  14133. get billboardMode(): number;
  14134. set billboardMode(value: number);
  14135. private _preserveParentRotationForBillboard;
  14136. /**
  14137. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14138. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14139. */
  14140. get preserveParentRotationForBillboard(): boolean;
  14141. set preserveParentRotationForBillboard(value: boolean);
  14142. /**
  14143. * 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
  14144. */
  14145. scalingDeterminant: number;
  14146. private _infiniteDistance;
  14147. /**
  14148. * Gets or sets the distance of the object to max, often used by skybox
  14149. */
  14150. get infiniteDistance(): boolean;
  14151. set infiniteDistance(value: boolean);
  14152. /**
  14153. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14154. * By default the system will update normals to compensate
  14155. */
  14156. ignoreNonUniformScaling: boolean;
  14157. /**
  14158. * 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
  14159. */
  14160. reIntegrateRotationIntoRotationQuaternion: boolean;
  14161. /** @hidden */
  14162. _poseMatrix: Nullable<Matrix>;
  14163. /** @hidden */
  14164. _localMatrix: Matrix;
  14165. private _usePivotMatrix;
  14166. private _absolutePosition;
  14167. private _absoluteScaling;
  14168. private _absoluteRotationQuaternion;
  14169. private _pivotMatrix;
  14170. private _pivotMatrixInverse;
  14171. protected _postMultiplyPivotMatrix: boolean;
  14172. protected _isWorldMatrixFrozen: boolean;
  14173. /** @hidden */
  14174. _indexInSceneTransformNodesArray: number;
  14175. /**
  14176. * An event triggered after the world matrix is updated
  14177. */
  14178. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14179. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14180. /**
  14181. * Gets a string identifying the name of the class
  14182. * @returns "TransformNode" string
  14183. */
  14184. getClassName(): string;
  14185. /**
  14186. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14187. */
  14188. get position(): Vector3;
  14189. set position(newPosition: Vector3);
  14190. /**
  14191. * 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)).
  14192. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14193. */
  14194. get rotation(): Vector3;
  14195. set rotation(newRotation: Vector3);
  14196. /**
  14197. * 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)).
  14198. */
  14199. get scaling(): Vector3;
  14200. set scaling(newScaling: Vector3);
  14201. /**
  14202. * 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).
  14203. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14204. */
  14205. get rotationQuaternion(): Nullable<Quaternion>;
  14206. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14207. /**
  14208. * The forward direction of that transform in world space.
  14209. */
  14210. get forward(): Vector3;
  14211. /**
  14212. * The up direction of that transform in world space.
  14213. */
  14214. get up(): Vector3;
  14215. /**
  14216. * The right direction of that transform in world space.
  14217. */
  14218. get right(): Vector3;
  14219. /**
  14220. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14221. * @param matrix the matrix to copy the pose from
  14222. * @returns this TransformNode.
  14223. */
  14224. updatePoseMatrix(matrix: Matrix): TransformNode;
  14225. /**
  14226. * Returns the mesh Pose matrix.
  14227. * @returns the pose matrix
  14228. */
  14229. getPoseMatrix(): Matrix;
  14230. /** @hidden */
  14231. _isSynchronized(): boolean;
  14232. /** @hidden */
  14233. _initCache(): void;
  14234. /**
  14235. * Flag the transform node as dirty (Forcing it to update everything)
  14236. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14237. * @returns this transform node
  14238. */
  14239. markAsDirty(property: string): TransformNode;
  14240. /**
  14241. * Returns the current mesh absolute position.
  14242. * Returns a Vector3.
  14243. */
  14244. get absolutePosition(): Vector3;
  14245. /**
  14246. * Returns the current mesh absolute scaling.
  14247. * Returns a Vector3.
  14248. */
  14249. get absoluteScaling(): Vector3;
  14250. /**
  14251. * Returns the current mesh absolute rotation.
  14252. * Returns a Quaternion.
  14253. */
  14254. get absoluteRotationQuaternion(): Quaternion;
  14255. /**
  14256. * Sets a new matrix to apply before all other transformation
  14257. * @param matrix defines the transform matrix
  14258. * @returns the current TransformNode
  14259. */
  14260. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14261. /**
  14262. * Sets a new pivot matrix to the current node
  14263. * @param matrix defines the new pivot matrix to use
  14264. * @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
  14265. * @returns the current TransformNode
  14266. */
  14267. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14268. /**
  14269. * Returns the mesh pivot matrix.
  14270. * Default : Identity.
  14271. * @returns the matrix
  14272. */
  14273. getPivotMatrix(): Matrix;
  14274. /**
  14275. * Instantiate (when possible) or clone that node with its hierarchy
  14276. * @param newParent defines the new parent to use for the instance (or clone)
  14277. * @param options defines options to configure how copy is done
  14278. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14279. * @returns an instance (or a clone) of the current node with its hiearchy
  14280. */
  14281. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14282. doNotInstantiate: boolean;
  14283. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14284. /**
  14285. * Prevents the World matrix to be computed any longer
  14286. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14287. * @returns the TransformNode.
  14288. */
  14289. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14290. /**
  14291. * Allows back the World matrix computation.
  14292. * @returns the TransformNode.
  14293. */
  14294. unfreezeWorldMatrix(): this;
  14295. /**
  14296. * True if the World matrix has been frozen.
  14297. */
  14298. get isWorldMatrixFrozen(): boolean;
  14299. /**
  14300. * Retuns the mesh absolute position in the World.
  14301. * @returns a Vector3.
  14302. */
  14303. getAbsolutePosition(): Vector3;
  14304. /**
  14305. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14306. * @param absolutePosition the absolute position to set
  14307. * @returns the TransformNode.
  14308. */
  14309. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14310. /**
  14311. * Sets the mesh position in its local space.
  14312. * @param vector3 the position to set in localspace
  14313. * @returns the TransformNode.
  14314. */
  14315. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14316. /**
  14317. * Returns the mesh position in the local space from the current World matrix values.
  14318. * @returns a new Vector3.
  14319. */
  14320. getPositionExpressedInLocalSpace(): Vector3;
  14321. /**
  14322. * Translates the mesh along the passed Vector3 in its local space.
  14323. * @param vector3 the distance to translate in localspace
  14324. * @returns the TransformNode.
  14325. */
  14326. locallyTranslate(vector3: Vector3): TransformNode;
  14327. private static _lookAtVectorCache;
  14328. /**
  14329. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14330. * @param targetPoint the position (must be in same space as current mesh) to look at
  14331. * @param yawCor optional yaw (y-axis) correction in radians
  14332. * @param pitchCor optional pitch (x-axis) correction in radians
  14333. * @param rollCor optional roll (z-axis) correction in radians
  14334. * @param space the choosen space of the target
  14335. * @returns the TransformNode.
  14336. */
  14337. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14338. /**
  14339. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14340. * This Vector3 is expressed in the World space.
  14341. * @param localAxis axis to rotate
  14342. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14343. */
  14344. getDirection(localAxis: Vector3): Vector3;
  14345. /**
  14346. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14347. * localAxis is expressed in the mesh local space.
  14348. * result is computed in the Wordl space from the mesh World matrix.
  14349. * @param localAxis axis to rotate
  14350. * @param result the resulting transformnode
  14351. * @returns this TransformNode.
  14352. */
  14353. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14354. /**
  14355. * Sets this transform node rotation to the given local axis.
  14356. * @param localAxis the axis in local space
  14357. * @param yawCor optional yaw (y-axis) correction in radians
  14358. * @param pitchCor optional pitch (x-axis) correction in radians
  14359. * @param rollCor optional roll (z-axis) correction in radians
  14360. * @returns this TransformNode
  14361. */
  14362. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14363. /**
  14364. * Sets a new pivot point to the current node
  14365. * @param point defines the new pivot point to use
  14366. * @param space defines if the point is in world or local space (local by default)
  14367. * @returns the current TransformNode
  14368. */
  14369. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14370. /**
  14371. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14372. * @returns the pivot point
  14373. */
  14374. getPivotPoint(): Vector3;
  14375. /**
  14376. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14377. * @param result the vector3 to store the result
  14378. * @returns this TransformNode.
  14379. */
  14380. getPivotPointToRef(result: Vector3): TransformNode;
  14381. /**
  14382. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14383. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14384. */
  14385. getAbsolutePivotPoint(): Vector3;
  14386. /**
  14387. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14388. * @param result vector3 to store the result
  14389. * @returns this TransformNode.
  14390. */
  14391. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14392. /**
  14393. * Defines the passed node as the parent of the current node.
  14394. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14395. * @see https://doc.babylonjs.com/how_to/parenting
  14396. * @param node the node ot set as the parent
  14397. * @returns this TransformNode.
  14398. */
  14399. setParent(node: Nullable<Node>): TransformNode;
  14400. private _nonUniformScaling;
  14401. /**
  14402. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14403. */
  14404. get nonUniformScaling(): boolean;
  14405. /** @hidden */
  14406. _updateNonUniformScalingState(value: boolean): boolean;
  14407. /**
  14408. * Attach the current TransformNode to another TransformNode associated with a bone
  14409. * @param bone Bone affecting the TransformNode
  14410. * @param affectedTransformNode TransformNode associated with the bone
  14411. * @returns this object
  14412. */
  14413. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14414. /**
  14415. * Detach the transform node if its associated with a bone
  14416. * @returns this object
  14417. */
  14418. detachFromBone(): TransformNode;
  14419. private static _rotationAxisCache;
  14420. /**
  14421. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14422. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14423. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14424. * The passed axis is also normalized.
  14425. * @param axis the axis to rotate around
  14426. * @param amount the amount to rotate in radians
  14427. * @param space Space to rotate in (Default: local)
  14428. * @returns the TransformNode.
  14429. */
  14430. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14431. /**
  14432. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14433. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14434. * The passed axis is also normalized. .
  14435. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14436. * @param point the point to rotate around
  14437. * @param axis the axis to rotate around
  14438. * @param amount the amount to rotate in radians
  14439. * @returns the TransformNode
  14440. */
  14441. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14442. /**
  14443. * Translates the mesh along the axis vector for the passed distance in the given space.
  14444. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14445. * @param axis the axis to translate in
  14446. * @param distance the distance to translate
  14447. * @param space Space to rotate in (Default: local)
  14448. * @returns the TransformNode.
  14449. */
  14450. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14451. /**
  14452. * Adds a rotation step to the mesh current rotation.
  14453. * x, y, z are Euler angles expressed in radians.
  14454. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14455. * This means this rotation is made in the mesh local space only.
  14456. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14457. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14458. * ```javascript
  14459. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14460. * ```
  14461. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14462. * 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.
  14463. * @param x Rotation to add
  14464. * @param y Rotation to add
  14465. * @param z Rotation to add
  14466. * @returns the TransformNode.
  14467. */
  14468. addRotation(x: number, y: number, z: number): TransformNode;
  14469. /**
  14470. * @hidden
  14471. */
  14472. protected _getEffectiveParent(): Nullable<Node>;
  14473. /**
  14474. * Computes the world matrix of the node
  14475. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14476. * @returns the world matrix
  14477. */
  14478. computeWorldMatrix(force?: boolean): Matrix;
  14479. /**
  14480. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14481. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14482. */
  14483. resetLocalMatrix(independentOfChildren?: boolean): void;
  14484. protected _afterComputeWorldMatrix(): void;
  14485. /**
  14486. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14487. * @param func callback function to add
  14488. *
  14489. * @returns the TransformNode.
  14490. */
  14491. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14492. /**
  14493. * Removes a registered callback function.
  14494. * @param func callback function to remove
  14495. * @returns the TransformNode.
  14496. */
  14497. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14498. /**
  14499. * Gets the position of the current mesh in camera space
  14500. * @param camera defines the camera to use
  14501. * @returns a position
  14502. */
  14503. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14504. /**
  14505. * Returns the distance from the mesh to the active camera
  14506. * @param camera defines the camera to use
  14507. * @returns the distance
  14508. */
  14509. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14510. /**
  14511. * Clone the current transform node
  14512. * @param name Name of the new clone
  14513. * @param newParent New parent for the clone
  14514. * @param doNotCloneChildren Do not clone children hierarchy
  14515. * @returns the new transform node
  14516. */
  14517. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14518. /**
  14519. * Serializes the objects information.
  14520. * @param currentSerializationObject defines the object to serialize in
  14521. * @returns the serialized object
  14522. */
  14523. serialize(currentSerializationObject?: any): any;
  14524. /**
  14525. * Returns a new TransformNode object parsed from the source provided.
  14526. * @param parsedTransformNode is the source.
  14527. * @param scene the scne the object belongs to
  14528. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14529. * @returns a new TransformNode object parsed from the source provided.
  14530. */
  14531. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14532. /**
  14533. * Get all child-transformNodes of this node
  14534. * @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
  14535. * @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
  14536. * @returns an array of TransformNode
  14537. */
  14538. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14539. /**
  14540. * Releases resources associated with this transform node.
  14541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14543. */
  14544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14545. /**
  14546. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14547. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14548. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14549. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14550. * @returns the current mesh
  14551. */
  14552. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14553. private _syncAbsoluteScalingAndRotation;
  14554. }
  14555. }
  14556. declare module BABYLON {
  14557. /**
  14558. * Defines the types of pose enabled controllers that are supported
  14559. */
  14560. export enum PoseEnabledControllerType {
  14561. /**
  14562. * HTC Vive
  14563. */
  14564. VIVE = 0,
  14565. /**
  14566. * Oculus Rift
  14567. */
  14568. OCULUS = 1,
  14569. /**
  14570. * Windows mixed reality
  14571. */
  14572. WINDOWS = 2,
  14573. /**
  14574. * Samsung gear VR
  14575. */
  14576. GEAR_VR = 3,
  14577. /**
  14578. * Google Daydream
  14579. */
  14580. DAYDREAM = 4,
  14581. /**
  14582. * Generic
  14583. */
  14584. GENERIC = 5
  14585. }
  14586. /**
  14587. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14588. */
  14589. export interface MutableGamepadButton {
  14590. /**
  14591. * Value of the button/trigger
  14592. */
  14593. value: number;
  14594. /**
  14595. * If the button/trigger is currently touched
  14596. */
  14597. touched: boolean;
  14598. /**
  14599. * If the button/trigger is currently pressed
  14600. */
  14601. pressed: boolean;
  14602. }
  14603. /**
  14604. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14605. * @hidden
  14606. */
  14607. export interface ExtendedGamepadButton extends GamepadButton {
  14608. /**
  14609. * If the button/trigger is currently pressed
  14610. */
  14611. readonly pressed: boolean;
  14612. /**
  14613. * If the button/trigger is currently touched
  14614. */
  14615. readonly touched: boolean;
  14616. /**
  14617. * Value of the button/trigger
  14618. */
  14619. readonly value: number;
  14620. }
  14621. /** @hidden */
  14622. export interface _GamePadFactory {
  14623. /**
  14624. * Returns wether or not the current gamepad can be created for this type of controller.
  14625. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14626. * @returns true if it can be created, otherwise false
  14627. */
  14628. canCreate(gamepadInfo: any): boolean;
  14629. /**
  14630. * Creates a new instance of the Gamepad.
  14631. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14632. * @returns the new gamepad instance
  14633. */
  14634. create(gamepadInfo: any): Gamepad;
  14635. }
  14636. /**
  14637. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14638. */
  14639. export class PoseEnabledControllerHelper {
  14640. /** @hidden */
  14641. static _ControllerFactories: _GamePadFactory[];
  14642. /** @hidden */
  14643. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14644. /**
  14645. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14646. * @param vrGamepad the gamepad to initialized
  14647. * @returns a vr controller of the type the gamepad identified as
  14648. */
  14649. static InitiateController(vrGamepad: any): Gamepad;
  14650. }
  14651. /**
  14652. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14653. */
  14654. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14655. /**
  14656. * If the controller is used in a webXR session
  14657. */
  14658. isXR: boolean;
  14659. private _deviceRoomPosition;
  14660. private _deviceRoomRotationQuaternion;
  14661. /**
  14662. * The device position in babylon space
  14663. */
  14664. devicePosition: Vector3;
  14665. /**
  14666. * The device rotation in babylon space
  14667. */
  14668. deviceRotationQuaternion: Quaternion;
  14669. /**
  14670. * The scale factor of the device in babylon space
  14671. */
  14672. deviceScaleFactor: number;
  14673. /**
  14674. * (Likely devicePosition should be used instead) The device position in its room space
  14675. */
  14676. position: Vector3;
  14677. /**
  14678. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14679. */
  14680. rotationQuaternion: Quaternion;
  14681. /**
  14682. * The type of controller (Eg. Windows mixed reality)
  14683. */
  14684. controllerType: PoseEnabledControllerType;
  14685. protected _calculatedPosition: Vector3;
  14686. private _calculatedRotation;
  14687. /**
  14688. * The raw pose from the device
  14689. */
  14690. rawPose: DevicePose;
  14691. private _trackPosition;
  14692. private _maxRotationDistFromHeadset;
  14693. private _draggedRoomRotation;
  14694. /**
  14695. * @hidden
  14696. */
  14697. _disableTrackPosition(fixedPosition: Vector3): void;
  14698. /**
  14699. * Internal, the mesh attached to the controller
  14700. * @hidden
  14701. */
  14702. _mesh: Nullable<AbstractMesh>;
  14703. private _poseControlledCamera;
  14704. private _leftHandSystemQuaternion;
  14705. /**
  14706. * Internal, matrix used to convert room space to babylon space
  14707. * @hidden
  14708. */
  14709. _deviceToWorld: Matrix;
  14710. /**
  14711. * Node to be used when casting a ray from the controller
  14712. * @hidden
  14713. */
  14714. _pointingPoseNode: Nullable<TransformNode>;
  14715. /**
  14716. * Name of the child mesh that can be used to cast a ray from the controller
  14717. */
  14718. static readonly POINTING_POSE: string;
  14719. /**
  14720. * Creates a new PoseEnabledController from a gamepad
  14721. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14722. */
  14723. constructor(browserGamepad: any);
  14724. private _workingMatrix;
  14725. /**
  14726. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14727. */
  14728. update(): void;
  14729. /**
  14730. * Updates only the pose device and mesh without doing any button event checking
  14731. */
  14732. protected _updatePoseAndMesh(): void;
  14733. /**
  14734. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14735. * @param poseData raw pose fromthe device
  14736. */
  14737. updateFromDevice(poseData: DevicePose): void;
  14738. /**
  14739. * @hidden
  14740. */
  14741. _meshAttachedObservable: Observable<AbstractMesh>;
  14742. /**
  14743. * Attaches a mesh to the controller
  14744. * @param mesh the mesh to be attached
  14745. */
  14746. attachToMesh(mesh: AbstractMesh): void;
  14747. /**
  14748. * Attaches the controllers mesh to a camera
  14749. * @param camera the camera the mesh should be attached to
  14750. */
  14751. attachToPoseControlledCamera(camera: TargetCamera): void;
  14752. /**
  14753. * Disposes of the controller
  14754. */
  14755. dispose(): void;
  14756. /**
  14757. * The mesh that is attached to the controller
  14758. */
  14759. get mesh(): Nullable<AbstractMesh>;
  14760. /**
  14761. * Gets the ray of the controller in the direction the controller is pointing
  14762. * @param length the length the resulting ray should be
  14763. * @returns a ray in the direction the controller is pointing
  14764. */
  14765. getForwardRay(length?: number): Ray;
  14766. }
  14767. }
  14768. declare module BABYLON {
  14769. /**
  14770. * Defines the WebVRController object that represents controllers tracked in 3D space
  14771. */
  14772. export abstract class WebVRController extends PoseEnabledController {
  14773. /**
  14774. * Internal, the default controller model for the controller
  14775. */
  14776. protected _defaultModel: Nullable<AbstractMesh>;
  14777. /**
  14778. * Fired when the trigger state has changed
  14779. */
  14780. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14781. /**
  14782. * Fired when the main button state has changed
  14783. */
  14784. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14785. /**
  14786. * Fired when the secondary button state has changed
  14787. */
  14788. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14789. /**
  14790. * Fired when the pad state has changed
  14791. */
  14792. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14793. /**
  14794. * Fired when controllers stick values have changed
  14795. */
  14796. onPadValuesChangedObservable: Observable<StickValues>;
  14797. /**
  14798. * Array of button availible on the controller
  14799. */
  14800. protected _buttons: Array<MutableGamepadButton>;
  14801. private _onButtonStateChange;
  14802. /**
  14803. * Fired when a controller button's state has changed
  14804. * @param callback the callback containing the button that was modified
  14805. */
  14806. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14807. /**
  14808. * X and Y axis corresponding to the controllers joystick
  14809. */
  14810. pad: StickValues;
  14811. /**
  14812. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14813. */
  14814. hand: string;
  14815. /**
  14816. * The default controller model for the controller
  14817. */
  14818. get defaultModel(): Nullable<AbstractMesh>;
  14819. /**
  14820. * Creates a new WebVRController from a gamepad
  14821. * @param vrGamepad the gamepad that the WebVRController should be created from
  14822. */
  14823. constructor(vrGamepad: any);
  14824. /**
  14825. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14826. */
  14827. update(): void;
  14828. /**
  14829. * Function to be called when a button is modified
  14830. */
  14831. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14832. /**
  14833. * Loads a mesh and attaches it to the controller
  14834. * @param scene the scene the mesh should be added to
  14835. * @param meshLoaded callback for when the mesh has been loaded
  14836. */
  14837. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14838. private _setButtonValue;
  14839. private _changes;
  14840. private _checkChanges;
  14841. /**
  14842. * Disposes of th webVRCOntroller
  14843. */
  14844. dispose(): void;
  14845. }
  14846. }
  14847. declare module BABYLON {
  14848. /**
  14849. * The HemisphericLight simulates the ambient environment light,
  14850. * so the passed direction is the light reflection direction, not the incoming direction.
  14851. */
  14852. export class HemisphericLight extends Light {
  14853. /**
  14854. * The groundColor is the light in the opposite direction to the one specified during creation.
  14855. * 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.
  14856. */
  14857. groundColor: Color3;
  14858. /**
  14859. * The light reflection direction, not the incoming direction.
  14860. */
  14861. direction: Vector3;
  14862. /**
  14863. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14864. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14865. * The HemisphericLight can't cast shadows.
  14866. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14867. * @param name The friendly name of the light
  14868. * @param direction The direction of the light reflection
  14869. * @param scene The scene the light belongs to
  14870. */
  14871. constructor(name: string, direction: Vector3, scene: Scene);
  14872. protected _buildUniformLayout(): void;
  14873. /**
  14874. * Returns the string "HemisphericLight".
  14875. * @return The class name
  14876. */
  14877. getClassName(): string;
  14878. /**
  14879. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14880. * Returns the updated direction.
  14881. * @param target The target the direction should point to
  14882. * @return The computed direction
  14883. */
  14884. setDirectionToTarget(target: Vector3): Vector3;
  14885. /**
  14886. * Returns the shadow generator associated to the light.
  14887. * @returns Always null for hemispheric lights because it does not support shadows.
  14888. */
  14889. getShadowGenerator(): Nullable<IShadowGenerator>;
  14890. /**
  14891. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14892. * @param effect The effect to update
  14893. * @param lightIndex The index of the light in the effect to update
  14894. * @returns The hemispheric light
  14895. */
  14896. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14897. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14898. /**
  14899. * Computes the world matrix of the node
  14900. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14901. * @param useWasUpdatedFlag defines a reserved property
  14902. * @returns the world matrix
  14903. */
  14904. computeWorldMatrix(): Matrix;
  14905. /**
  14906. * Returns the integer 3.
  14907. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14908. */
  14909. getTypeID(): number;
  14910. /**
  14911. * Prepares the list of defines specific to the light type.
  14912. * @param defines the list of defines
  14913. * @param lightIndex defines the index of the light for the effect
  14914. */
  14915. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14916. }
  14917. }
  14918. declare module BABYLON {
  14919. /** @hidden */
  14920. export var vrMultiviewToSingleviewPixelShader: {
  14921. name: string;
  14922. shader: string;
  14923. };
  14924. }
  14925. declare module BABYLON {
  14926. /**
  14927. * Renders to multiple views with a single draw call
  14928. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14929. */
  14930. export class MultiviewRenderTarget extends RenderTargetTexture {
  14931. /**
  14932. * Creates a multiview render target
  14933. * @param scene scene used with the render target
  14934. * @param size the size of the render target (used for each view)
  14935. */
  14936. constructor(scene: Scene, size?: number | {
  14937. width: number;
  14938. height: number;
  14939. } | {
  14940. ratio: number;
  14941. });
  14942. /**
  14943. * @hidden
  14944. * @param faceIndex the face index, if its a cube texture
  14945. */
  14946. _bindFrameBuffer(faceIndex?: number): void;
  14947. /**
  14948. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14949. * @returns the view count
  14950. */
  14951. getViewCount(): number;
  14952. }
  14953. }
  14954. declare module BABYLON {
  14955. /**
  14956. * Represents a camera frustum
  14957. */
  14958. export class Frustum {
  14959. /**
  14960. * Gets the planes representing the frustum
  14961. * @param transform matrix to be applied to the returned planes
  14962. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14963. */
  14964. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14965. /**
  14966. * Gets the near frustum plane transformed by the transform matrix
  14967. * @param transform transformation matrix to be applied to the resulting frustum plane
  14968. * @param frustumPlane the resuling frustum plane
  14969. */
  14970. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14971. /**
  14972. * Gets the far frustum plane transformed by the transform matrix
  14973. * @param transform transformation matrix to be applied to the resulting frustum plane
  14974. * @param frustumPlane the resuling frustum plane
  14975. */
  14976. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14977. /**
  14978. * Gets the left frustum plane transformed by the transform matrix
  14979. * @param transform transformation matrix to be applied to the resulting frustum plane
  14980. * @param frustumPlane the resuling frustum plane
  14981. */
  14982. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14983. /**
  14984. * Gets the right frustum plane transformed by the transform matrix
  14985. * @param transform transformation matrix to be applied to the resulting frustum plane
  14986. * @param frustumPlane the resuling frustum plane
  14987. */
  14988. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14989. /**
  14990. * Gets the top frustum plane transformed by the transform matrix
  14991. * @param transform transformation matrix to be applied to the resulting frustum plane
  14992. * @param frustumPlane the resuling frustum plane
  14993. */
  14994. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14995. /**
  14996. * Gets the bottom frustum plane transformed by the transform matrix
  14997. * @param transform transformation matrix to be applied to the resulting frustum plane
  14998. * @param frustumPlane the resuling frustum plane
  14999. */
  15000. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15001. /**
  15002. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15003. * @param transform transformation matrix to be applied to the resulting frustum planes
  15004. * @param frustumPlanes the resuling frustum planes
  15005. */
  15006. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15007. }
  15008. }
  15009. declare module BABYLON {
  15010. interface Engine {
  15011. /**
  15012. * Creates a new multiview render target
  15013. * @param width defines the width of the texture
  15014. * @param height defines the height of the texture
  15015. * @returns the created multiview texture
  15016. */
  15017. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15018. /**
  15019. * Binds a multiview framebuffer to be drawn to
  15020. * @param multiviewTexture texture to bind
  15021. */
  15022. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15023. }
  15024. interface Camera {
  15025. /**
  15026. * @hidden
  15027. * 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)
  15028. */
  15029. _useMultiviewToSingleView: boolean;
  15030. /**
  15031. * @hidden
  15032. * 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)
  15033. */
  15034. _multiviewTexture: Nullable<RenderTargetTexture>;
  15035. /**
  15036. * @hidden
  15037. * ensures the multiview texture of the camera exists and has the specified width/height
  15038. * @param width height to set on the multiview texture
  15039. * @param height width to set on the multiview texture
  15040. */
  15041. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15042. }
  15043. interface Scene {
  15044. /** @hidden */
  15045. _transformMatrixR: Matrix;
  15046. /** @hidden */
  15047. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15048. /** @hidden */
  15049. _createMultiviewUbo(): void;
  15050. /** @hidden */
  15051. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15052. /** @hidden */
  15053. _renderMultiviewToSingleView(camera: Camera): void;
  15054. }
  15055. }
  15056. declare module BABYLON {
  15057. /**
  15058. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15059. * This will not be used for webXR as it supports displaying texture arrays directly
  15060. */
  15061. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15062. /**
  15063. * Initializes a VRMultiviewToSingleview
  15064. * @param name name of the post process
  15065. * @param camera camera to be applied to
  15066. * @param scaleFactor scaling factor to the size of the output texture
  15067. */
  15068. constructor(name: string, camera: Camera, scaleFactor: number);
  15069. }
  15070. }
  15071. declare module BABYLON {
  15072. /**
  15073. * Interface used to define additional presentation attributes
  15074. */
  15075. export interface IVRPresentationAttributes {
  15076. /**
  15077. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15078. */
  15079. highRefreshRate: boolean;
  15080. /**
  15081. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15082. */
  15083. foveationLevel: number;
  15084. }
  15085. interface Engine {
  15086. /** @hidden */
  15087. _vrDisplay: any;
  15088. /** @hidden */
  15089. _vrSupported: boolean;
  15090. /** @hidden */
  15091. _oldSize: Size;
  15092. /** @hidden */
  15093. _oldHardwareScaleFactor: number;
  15094. /** @hidden */
  15095. _vrExclusivePointerMode: boolean;
  15096. /** @hidden */
  15097. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15098. /** @hidden */
  15099. _onVRDisplayPointerRestricted: () => void;
  15100. /** @hidden */
  15101. _onVRDisplayPointerUnrestricted: () => void;
  15102. /** @hidden */
  15103. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15104. /** @hidden */
  15105. _onVrDisplayDisconnect: Nullable<() => void>;
  15106. /** @hidden */
  15107. _onVrDisplayPresentChange: Nullable<() => void>;
  15108. /**
  15109. * Observable signaled when VR display mode changes
  15110. */
  15111. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15112. /**
  15113. * Observable signaled when VR request present is complete
  15114. */
  15115. onVRRequestPresentComplete: Observable<boolean>;
  15116. /**
  15117. * Observable signaled when VR request present starts
  15118. */
  15119. onVRRequestPresentStart: Observable<Engine>;
  15120. /**
  15121. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15122. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15123. */
  15124. isInVRExclusivePointerMode: boolean;
  15125. /**
  15126. * Gets a boolean indicating if a webVR device was detected
  15127. * @returns true if a webVR device was detected
  15128. */
  15129. isVRDevicePresent(): boolean;
  15130. /**
  15131. * Gets the current webVR device
  15132. * @returns the current webVR device (or null)
  15133. */
  15134. getVRDevice(): any;
  15135. /**
  15136. * Initializes a webVR display and starts listening to display change events
  15137. * The onVRDisplayChangedObservable will be notified upon these changes
  15138. * @returns A promise containing a VRDisplay and if vr is supported
  15139. */
  15140. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15141. /** @hidden */
  15142. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15143. /**
  15144. * Gets or sets the presentation attributes used to configure VR rendering
  15145. */
  15146. vrPresentationAttributes?: IVRPresentationAttributes;
  15147. /**
  15148. * Call this function to switch to webVR mode
  15149. * Will do nothing if webVR is not supported or if there is no webVR device
  15150. * @param options the webvr options provided to the camera. mainly used for multiview
  15151. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15152. */
  15153. enableVR(options: WebVROptions): void;
  15154. /** @hidden */
  15155. _onVRFullScreenTriggered(): void;
  15156. }
  15157. }
  15158. declare module BABYLON {
  15159. /**
  15160. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15161. * IMPORTANT!! The data is right-hand data.
  15162. * @export
  15163. * @interface DevicePose
  15164. */
  15165. export interface DevicePose {
  15166. /**
  15167. * The position of the device, values in array are [x,y,z].
  15168. */
  15169. readonly position: Nullable<Float32Array>;
  15170. /**
  15171. * The linearVelocity of the device, values in array are [x,y,z].
  15172. */
  15173. readonly linearVelocity: Nullable<Float32Array>;
  15174. /**
  15175. * The linearAcceleration of the device, values in array are [x,y,z].
  15176. */
  15177. readonly linearAcceleration: Nullable<Float32Array>;
  15178. /**
  15179. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15180. */
  15181. readonly orientation: Nullable<Float32Array>;
  15182. /**
  15183. * The angularVelocity of the device, values in array are [x,y,z].
  15184. */
  15185. readonly angularVelocity: Nullable<Float32Array>;
  15186. /**
  15187. * The angularAcceleration of the device, values in array are [x,y,z].
  15188. */
  15189. readonly angularAcceleration: Nullable<Float32Array>;
  15190. }
  15191. /**
  15192. * Interface representing a pose controlled object in Babylon.
  15193. * A pose controlled object has both regular pose values as well as pose values
  15194. * from an external device such as a VR head mounted display
  15195. */
  15196. export interface PoseControlled {
  15197. /**
  15198. * The position of the object in babylon space.
  15199. */
  15200. position: Vector3;
  15201. /**
  15202. * The rotation quaternion of the object in babylon space.
  15203. */
  15204. rotationQuaternion: Quaternion;
  15205. /**
  15206. * The position of the device in babylon space.
  15207. */
  15208. devicePosition?: Vector3;
  15209. /**
  15210. * The rotation quaternion of the device in babylon space.
  15211. */
  15212. deviceRotationQuaternion: Quaternion;
  15213. /**
  15214. * The raw pose coming from the device.
  15215. */
  15216. rawPose: Nullable<DevicePose>;
  15217. /**
  15218. * The scale of the device to be used when translating from device space to babylon space.
  15219. */
  15220. deviceScaleFactor: number;
  15221. /**
  15222. * Updates the poseControlled values based on the input device pose.
  15223. * @param poseData the pose data to update the object with
  15224. */
  15225. updateFromDevice(poseData: DevicePose): void;
  15226. }
  15227. /**
  15228. * Set of options to customize the webVRCamera
  15229. */
  15230. export interface WebVROptions {
  15231. /**
  15232. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15233. */
  15234. trackPosition?: boolean;
  15235. /**
  15236. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15237. */
  15238. positionScale?: number;
  15239. /**
  15240. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15241. */
  15242. displayName?: string;
  15243. /**
  15244. * Should the native controller meshes be initialized. (default: true)
  15245. */
  15246. controllerMeshes?: boolean;
  15247. /**
  15248. * Creating a default HemiLight only on controllers. (default: true)
  15249. */
  15250. defaultLightingOnControllers?: boolean;
  15251. /**
  15252. * If you don't want to use the default VR button of the helper. (default: false)
  15253. */
  15254. useCustomVRButton?: boolean;
  15255. /**
  15256. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15257. */
  15258. customVRButton?: HTMLButtonElement;
  15259. /**
  15260. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15261. */
  15262. rayLength?: number;
  15263. /**
  15264. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15265. */
  15266. defaultHeight?: number;
  15267. /**
  15268. * If multiview should be used if availible (default: false)
  15269. */
  15270. useMultiview?: boolean;
  15271. }
  15272. /**
  15273. * This represents a WebVR camera.
  15274. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15275. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15276. */
  15277. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15278. private webVROptions;
  15279. /**
  15280. * @hidden
  15281. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15282. */
  15283. _vrDevice: any;
  15284. /**
  15285. * The rawPose of the vrDevice.
  15286. */
  15287. rawPose: Nullable<DevicePose>;
  15288. private _onVREnabled;
  15289. private _specsVersion;
  15290. private _attached;
  15291. private _frameData;
  15292. protected _descendants: Array<Node>;
  15293. private _deviceRoomPosition;
  15294. /** @hidden */
  15295. _deviceRoomRotationQuaternion: Quaternion;
  15296. private _standingMatrix;
  15297. /**
  15298. * Represents device position in babylon space.
  15299. */
  15300. devicePosition: Vector3;
  15301. /**
  15302. * Represents device rotation in babylon space.
  15303. */
  15304. deviceRotationQuaternion: Quaternion;
  15305. /**
  15306. * The scale of the device to be used when translating from device space to babylon space.
  15307. */
  15308. deviceScaleFactor: number;
  15309. private _deviceToWorld;
  15310. private _worldToDevice;
  15311. /**
  15312. * References to the webVR controllers for the vrDevice.
  15313. */
  15314. controllers: Array<WebVRController>;
  15315. /**
  15316. * Emits an event when a controller is attached.
  15317. */
  15318. onControllersAttachedObservable: Observable<WebVRController[]>;
  15319. /**
  15320. * Emits an event when a controller's mesh has been loaded;
  15321. */
  15322. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15323. /**
  15324. * Emits an event when the HMD's pose has been updated.
  15325. */
  15326. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15327. private _poseSet;
  15328. /**
  15329. * If the rig cameras be used as parent instead of this camera.
  15330. */
  15331. rigParenting: boolean;
  15332. private _lightOnControllers;
  15333. private _defaultHeight?;
  15334. /**
  15335. * Instantiates a WebVRFreeCamera.
  15336. * @param name The name of the WebVRFreeCamera
  15337. * @param position The starting anchor position for the camera
  15338. * @param scene The scene the camera belongs to
  15339. * @param webVROptions a set of customizable options for the webVRCamera
  15340. */
  15341. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15342. /**
  15343. * Gets the device distance from the ground in meters.
  15344. * @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.
  15345. */
  15346. deviceDistanceToRoomGround(): number;
  15347. /**
  15348. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15349. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15350. */
  15351. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15352. /**
  15353. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15354. * @returns A promise with a boolean set to if the standing matrix is supported.
  15355. */
  15356. useStandingMatrixAsync(): Promise<boolean>;
  15357. /**
  15358. * Disposes the camera
  15359. */
  15360. dispose(): void;
  15361. /**
  15362. * Gets a vrController by name.
  15363. * @param name The name of the controller to retreive
  15364. * @returns the controller matching the name specified or null if not found
  15365. */
  15366. getControllerByName(name: string): Nullable<WebVRController>;
  15367. private _leftController;
  15368. /**
  15369. * The controller corresponding to the users left hand.
  15370. */
  15371. get leftController(): Nullable<WebVRController>;
  15372. private _rightController;
  15373. /**
  15374. * The controller corresponding to the users right hand.
  15375. */
  15376. get rightController(): Nullable<WebVRController>;
  15377. /**
  15378. * Casts a ray forward from the vrCamera's gaze.
  15379. * @param length Length of the ray (default: 100)
  15380. * @returns the ray corresponding to the gaze
  15381. */
  15382. getForwardRay(length?: number): Ray;
  15383. /**
  15384. * @hidden
  15385. * Updates the camera based on device's frame data
  15386. */
  15387. _checkInputs(): void;
  15388. /**
  15389. * Updates the poseControlled values based on the input device pose.
  15390. * @param poseData Pose coming from the device
  15391. */
  15392. updateFromDevice(poseData: DevicePose): void;
  15393. private _htmlElementAttached;
  15394. private _detachIfAttached;
  15395. /**
  15396. * WebVR's attach control will start broadcasting frames to the device.
  15397. * Note that in certain browsers (chrome for example) this function must be called
  15398. * within a user-interaction callback. Example:
  15399. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15400. *
  15401. * @param element html element to attach the vrDevice to
  15402. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15403. */
  15404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15405. /**
  15406. * Detaches the camera from the html element and disables VR
  15407. *
  15408. * @param element html element to detach from
  15409. */
  15410. detachControl(element: HTMLElement): void;
  15411. /**
  15412. * @returns the name of this class
  15413. */
  15414. getClassName(): string;
  15415. /**
  15416. * Calls resetPose on the vrDisplay
  15417. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15418. */
  15419. resetToCurrentRotation(): void;
  15420. /**
  15421. * @hidden
  15422. * Updates the rig cameras (left and right eye)
  15423. */
  15424. _updateRigCameras(): void;
  15425. private _workingVector;
  15426. private _oneVector;
  15427. private _workingMatrix;
  15428. private updateCacheCalled;
  15429. private _correctPositionIfNotTrackPosition;
  15430. /**
  15431. * @hidden
  15432. * Updates the cached values of the camera
  15433. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15434. */
  15435. _updateCache(ignoreParentClass?: boolean): void;
  15436. /**
  15437. * @hidden
  15438. * Get current device position in babylon world
  15439. */
  15440. _computeDevicePosition(): void;
  15441. /**
  15442. * Updates the current device position and rotation in the babylon world
  15443. */
  15444. update(): void;
  15445. /**
  15446. * @hidden
  15447. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15448. * @returns an identity matrix
  15449. */
  15450. _getViewMatrix(): Matrix;
  15451. private _tmpMatrix;
  15452. /**
  15453. * This function is called by the two RIG cameras.
  15454. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15455. * @hidden
  15456. */
  15457. _getWebVRViewMatrix(): Matrix;
  15458. /** @hidden */
  15459. _getWebVRProjectionMatrix(): Matrix;
  15460. private _onGamepadConnectedObserver;
  15461. private _onGamepadDisconnectedObserver;
  15462. private _updateCacheWhenTrackingDisabledObserver;
  15463. /**
  15464. * Initializes the controllers and their meshes
  15465. */
  15466. initControllers(): void;
  15467. }
  15468. }
  15469. declare module BABYLON {
  15470. /**
  15471. * Size options for a post process
  15472. */
  15473. export type PostProcessOptions = {
  15474. width: number;
  15475. height: number;
  15476. };
  15477. /**
  15478. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15479. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15480. */
  15481. export class PostProcess {
  15482. /** Name of the PostProcess. */
  15483. name: string;
  15484. /**
  15485. * Gets or sets the unique id of the post process
  15486. */
  15487. uniqueId: number;
  15488. /**
  15489. * Width of the texture to apply the post process on
  15490. */
  15491. width: number;
  15492. /**
  15493. * Height of the texture to apply the post process on
  15494. */
  15495. height: number;
  15496. /**
  15497. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15498. * @hidden
  15499. */
  15500. _outputTexture: Nullable<InternalTexture>;
  15501. /**
  15502. * Sampling mode used by the shader
  15503. * See https://doc.babylonjs.com/classes/3.1/texture
  15504. */
  15505. renderTargetSamplingMode: number;
  15506. /**
  15507. * Clear color to use when screen clearing
  15508. */
  15509. clearColor: Color4;
  15510. /**
  15511. * If the buffer needs to be cleared before applying the post process. (default: true)
  15512. * Should be set to false if shader will overwrite all previous pixels.
  15513. */
  15514. autoClear: boolean;
  15515. /**
  15516. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15517. */
  15518. alphaMode: number;
  15519. /**
  15520. * Sets the setAlphaBlendConstants of the babylon engine
  15521. */
  15522. alphaConstants: Color4;
  15523. /**
  15524. * Animations to be used for the post processing
  15525. */
  15526. animations: Animation[];
  15527. /**
  15528. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15529. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15530. */
  15531. enablePixelPerfectMode: boolean;
  15532. /**
  15533. * Force the postprocess to be applied without taking in account viewport
  15534. */
  15535. forceFullscreenViewport: boolean;
  15536. /**
  15537. * List of inspectable custom properties (used by the Inspector)
  15538. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15539. */
  15540. inspectableCustomProperties: IInspectable[];
  15541. /**
  15542. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15543. *
  15544. * | Value | Type | Description |
  15545. * | ----- | ----------------------------------- | ----------- |
  15546. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15547. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15548. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15549. *
  15550. */
  15551. scaleMode: number;
  15552. /**
  15553. * Force textures to be a power of two (default: false)
  15554. */
  15555. alwaysForcePOT: boolean;
  15556. private _samples;
  15557. /**
  15558. * Number of sample textures (default: 1)
  15559. */
  15560. get samples(): number;
  15561. set samples(n: number);
  15562. /**
  15563. * Modify the scale of the post process to be the same as the viewport (default: false)
  15564. */
  15565. adaptScaleToCurrentViewport: boolean;
  15566. private _camera;
  15567. private _scene;
  15568. private _engine;
  15569. private _options;
  15570. private _reusable;
  15571. private _textureType;
  15572. private _textureFormat;
  15573. /**
  15574. * Smart array of input and output textures for the post process.
  15575. * @hidden
  15576. */
  15577. _textures: SmartArray<InternalTexture>;
  15578. /**
  15579. * The index in _textures that corresponds to the output texture.
  15580. * @hidden
  15581. */
  15582. _currentRenderTextureInd: number;
  15583. private _effect;
  15584. private _samplers;
  15585. private _fragmentUrl;
  15586. private _vertexUrl;
  15587. private _parameters;
  15588. private _scaleRatio;
  15589. protected _indexParameters: any;
  15590. private _shareOutputWithPostProcess;
  15591. private _texelSize;
  15592. private _forcedOutputTexture;
  15593. /**
  15594. * Returns the fragment url or shader name used in the post process.
  15595. * @returns the fragment url or name in the shader store.
  15596. */
  15597. getEffectName(): string;
  15598. /**
  15599. * An event triggered when the postprocess is activated.
  15600. */
  15601. onActivateObservable: Observable<Camera>;
  15602. private _onActivateObserver;
  15603. /**
  15604. * A function that is added to the onActivateObservable
  15605. */
  15606. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15607. /**
  15608. * An event triggered when the postprocess changes its size.
  15609. */
  15610. onSizeChangedObservable: Observable<PostProcess>;
  15611. private _onSizeChangedObserver;
  15612. /**
  15613. * A function that is added to the onSizeChangedObservable
  15614. */
  15615. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15616. /**
  15617. * An event triggered when the postprocess applies its effect.
  15618. */
  15619. onApplyObservable: Observable<Effect>;
  15620. private _onApplyObserver;
  15621. /**
  15622. * A function that is added to the onApplyObservable
  15623. */
  15624. set onApply(callback: (effect: Effect) => void);
  15625. /**
  15626. * An event triggered before rendering the postprocess
  15627. */
  15628. onBeforeRenderObservable: Observable<Effect>;
  15629. private _onBeforeRenderObserver;
  15630. /**
  15631. * A function that is added to the onBeforeRenderObservable
  15632. */
  15633. set onBeforeRender(callback: (effect: Effect) => void);
  15634. /**
  15635. * An event triggered after rendering the postprocess
  15636. */
  15637. onAfterRenderObservable: Observable<Effect>;
  15638. private _onAfterRenderObserver;
  15639. /**
  15640. * A function that is added to the onAfterRenderObservable
  15641. */
  15642. set onAfterRender(callback: (efect: Effect) => void);
  15643. /**
  15644. * 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
  15645. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15646. */
  15647. get inputTexture(): InternalTexture;
  15648. set inputTexture(value: InternalTexture);
  15649. /**
  15650. * Gets the camera which post process is applied to.
  15651. * @returns The camera the post process is applied to.
  15652. */
  15653. getCamera(): Camera;
  15654. /**
  15655. * Gets the texel size of the postprocess.
  15656. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15657. */
  15658. get texelSize(): Vector2;
  15659. /**
  15660. * Creates a new instance PostProcess
  15661. * @param name The name of the PostProcess.
  15662. * @param fragmentUrl The url of the fragment shader to be used.
  15663. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15664. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15665. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15666. * @param camera The camera to apply the render pass to.
  15667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15668. * @param engine The engine which the post process will be applied. (default: current engine)
  15669. * @param reusable If the post process can be reused on the same frame. (default: false)
  15670. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15671. * @param textureType Type of textures used when performing the post process. (default: 0)
  15672. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15673. * @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
  15674. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15675. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  15676. */
  15677. constructor(
  15678. /** Name of the PostProcess. */
  15679. 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);
  15680. /**
  15681. * Gets a string idenfifying the name of the class
  15682. * @returns "PostProcess" string
  15683. */
  15684. getClassName(): string;
  15685. /**
  15686. * Gets the engine which this post process belongs to.
  15687. * @returns The engine the post process was enabled with.
  15688. */
  15689. getEngine(): Engine;
  15690. /**
  15691. * The effect that is created when initializing the post process.
  15692. * @returns The created effect corresponding the the postprocess.
  15693. */
  15694. getEffect(): Effect;
  15695. /**
  15696. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15697. * @param postProcess The post process to share the output with.
  15698. * @returns This post process.
  15699. */
  15700. shareOutputWith(postProcess: PostProcess): PostProcess;
  15701. /**
  15702. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15703. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15704. */
  15705. useOwnOutput(): void;
  15706. /**
  15707. * Updates the effect with the current post process compile time values and recompiles the shader.
  15708. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15709. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15710. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15711. * @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
  15712. * @param onCompiled Called when the shader has been compiled.
  15713. * @param onError Called if there is an error when compiling a shader.
  15714. */
  15715. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15716. /**
  15717. * The post process is reusable if it can be used multiple times within one frame.
  15718. * @returns If the post process is reusable
  15719. */
  15720. isReusable(): boolean;
  15721. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15722. markTextureDirty(): void;
  15723. /**
  15724. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15725. * 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.
  15726. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15727. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15728. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15729. * @returns The target texture that was bound to be written to.
  15730. */
  15731. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15732. /**
  15733. * If the post process is supported.
  15734. */
  15735. get isSupported(): boolean;
  15736. /**
  15737. * The aspect ratio of the output texture.
  15738. */
  15739. get aspectRatio(): number;
  15740. /**
  15741. * Get a value indicating if the post-process is ready to be used
  15742. * @returns true if the post-process is ready (shader is compiled)
  15743. */
  15744. isReady(): boolean;
  15745. /**
  15746. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15747. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15748. */
  15749. apply(): Nullable<Effect>;
  15750. private _disposeTextures;
  15751. /**
  15752. * Disposes the post process.
  15753. * @param camera The camera to dispose the post process on.
  15754. */
  15755. dispose(camera?: Camera): void;
  15756. }
  15757. }
  15758. declare module BABYLON {
  15759. /** @hidden */
  15760. export var kernelBlurVaryingDeclaration: {
  15761. name: string;
  15762. shader: string;
  15763. };
  15764. }
  15765. declare module BABYLON {
  15766. /** @hidden */
  15767. export var kernelBlurFragment: {
  15768. name: string;
  15769. shader: string;
  15770. };
  15771. }
  15772. declare module BABYLON {
  15773. /** @hidden */
  15774. export var kernelBlurFragment2: {
  15775. name: string;
  15776. shader: string;
  15777. };
  15778. }
  15779. declare module BABYLON {
  15780. /** @hidden */
  15781. export var kernelBlurPixelShader: {
  15782. name: string;
  15783. shader: string;
  15784. };
  15785. }
  15786. declare module BABYLON {
  15787. /** @hidden */
  15788. export var kernelBlurVertex: {
  15789. name: string;
  15790. shader: string;
  15791. };
  15792. }
  15793. declare module BABYLON {
  15794. /** @hidden */
  15795. export var kernelBlurVertexShader: {
  15796. name: string;
  15797. shader: string;
  15798. };
  15799. }
  15800. declare module BABYLON {
  15801. /**
  15802. * The Blur Post Process which blurs an image based on a kernel and direction.
  15803. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15804. */
  15805. export class BlurPostProcess extends PostProcess {
  15806. /** The direction in which to blur the image. */
  15807. direction: Vector2;
  15808. private blockCompilation;
  15809. protected _kernel: number;
  15810. protected _idealKernel: number;
  15811. protected _packedFloat: boolean;
  15812. private _staticDefines;
  15813. /**
  15814. * Sets the length in pixels of the blur sample region
  15815. */
  15816. set kernel(v: number);
  15817. /**
  15818. * Gets the length in pixels of the blur sample region
  15819. */
  15820. get kernel(): number;
  15821. /**
  15822. * Sets wether or not the blur needs to unpack/repack floats
  15823. */
  15824. set packedFloat(v: boolean);
  15825. /**
  15826. * Gets wether or not the blur is unpacking/repacking floats
  15827. */
  15828. get packedFloat(): boolean;
  15829. /**
  15830. * Creates a new instance BlurPostProcess
  15831. * @param name The name of the effect.
  15832. * @param direction The direction in which to blur the image.
  15833. * @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.
  15834. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15835. * @param camera The camera to apply the render pass to.
  15836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15837. * @param engine The engine which the post process will be applied. (default: current engine)
  15838. * @param reusable If the post process can be reused on the same frame. (default: false)
  15839. * @param textureType Type of textures used when performing the post process. (default: 0)
  15840. * @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)
  15841. */
  15842. constructor(name: string,
  15843. /** The direction in which to blur the image. */
  15844. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15845. /**
  15846. * Updates the effect with the current post process compile time values and recompiles the shader.
  15847. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15848. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15849. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15850. * @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
  15851. * @param onCompiled Called when the shader has been compiled.
  15852. * @param onError Called if there is an error when compiling a shader.
  15853. */
  15854. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15855. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15856. /**
  15857. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15858. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15859. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15860. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15861. * The gaps between physical kernels are compensated for in the weighting of the samples
  15862. * @param idealKernel Ideal blur kernel.
  15863. * @return Nearest best kernel.
  15864. */
  15865. protected _nearestBestKernel(idealKernel: number): number;
  15866. /**
  15867. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15868. * @param x The point on the Gaussian distribution to sample.
  15869. * @return the value of the Gaussian function at x.
  15870. */
  15871. protected _gaussianWeight(x: number): number;
  15872. /**
  15873. * Generates a string that can be used as a floating point number in GLSL.
  15874. * @param x Value to print.
  15875. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15876. * @return GLSL float string.
  15877. */
  15878. protected _glslFloat(x: number, decimalFigures?: number): string;
  15879. }
  15880. }
  15881. declare module BABYLON {
  15882. /**
  15883. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15884. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15885. * You can then easily use it as a reflectionTexture on a flat surface.
  15886. * In case the surface is not a plane, please consider relying on reflection probes.
  15887. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15888. */
  15889. export class MirrorTexture extends RenderTargetTexture {
  15890. private scene;
  15891. /**
  15892. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15893. * 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.
  15894. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15895. */
  15896. mirrorPlane: Plane;
  15897. /**
  15898. * Define the blur ratio used to blur the reflection if needed.
  15899. */
  15900. set blurRatio(value: number);
  15901. get blurRatio(): number;
  15902. /**
  15903. * Define the adaptive blur kernel used to blur the reflection if needed.
  15904. * This will autocompute the closest best match for the `blurKernel`
  15905. */
  15906. set adaptiveBlurKernel(value: number);
  15907. /**
  15908. * Define the blur kernel used to blur the reflection if needed.
  15909. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15910. */
  15911. set blurKernel(value: number);
  15912. /**
  15913. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15914. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15915. */
  15916. set blurKernelX(value: number);
  15917. get blurKernelX(): number;
  15918. /**
  15919. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15920. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15921. */
  15922. set blurKernelY(value: number);
  15923. get blurKernelY(): number;
  15924. private _autoComputeBlurKernel;
  15925. protected _onRatioRescale(): void;
  15926. private _updateGammaSpace;
  15927. private _imageProcessingConfigChangeObserver;
  15928. private _transformMatrix;
  15929. private _mirrorMatrix;
  15930. private _savedViewMatrix;
  15931. private _blurX;
  15932. private _blurY;
  15933. private _adaptiveBlurKernel;
  15934. private _blurKernelX;
  15935. private _blurKernelY;
  15936. private _blurRatio;
  15937. /**
  15938. * Instantiates a Mirror Texture.
  15939. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15940. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15941. * You can then easily use it as a reflectionTexture on a flat surface.
  15942. * In case the surface is not a plane, please consider relying on reflection probes.
  15943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15944. * @param name
  15945. * @param size
  15946. * @param scene
  15947. * @param generateMipMaps
  15948. * @param type
  15949. * @param samplingMode
  15950. * @param generateDepthBuffer
  15951. */
  15952. constructor(name: string, size: number | {
  15953. width: number;
  15954. height: number;
  15955. } | {
  15956. ratio: number;
  15957. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15958. private _preparePostProcesses;
  15959. /**
  15960. * Clone the mirror texture.
  15961. * @returns the cloned texture
  15962. */
  15963. clone(): MirrorTexture;
  15964. /**
  15965. * Serialize the texture to a JSON representation you could use in Parse later on
  15966. * @returns the serialized JSON representation
  15967. */
  15968. serialize(): any;
  15969. /**
  15970. * Dispose the texture and release its associated resources.
  15971. */
  15972. dispose(): void;
  15973. }
  15974. }
  15975. declare module BABYLON {
  15976. /**
  15977. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15978. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15979. */
  15980. export class Texture extends BaseTexture {
  15981. /**
  15982. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15983. */
  15984. static SerializeBuffers: boolean;
  15985. /** @hidden */
  15986. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15987. /** @hidden */
  15988. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15989. /** @hidden */
  15990. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15991. /** nearest is mag = nearest and min = nearest and mip = linear */
  15992. static readonly NEAREST_SAMPLINGMODE: number;
  15993. /** nearest is mag = nearest and min = nearest and mip = linear */
  15994. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15995. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15996. static readonly BILINEAR_SAMPLINGMODE: number;
  15997. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15998. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15999. /** Trilinear is mag = linear and min = linear and mip = linear */
  16000. static readonly TRILINEAR_SAMPLINGMODE: number;
  16001. /** Trilinear is mag = linear and min = linear and mip = linear */
  16002. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16003. /** mag = nearest and min = nearest and mip = nearest */
  16004. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16005. /** mag = nearest and min = linear and mip = nearest */
  16006. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16007. /** mag = nearest and min = linear and mip = linear */
  16008. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16009. /** mag = nearest and min = linear and mip = none */
  16010. static readonly NEAREST_LINEAR: number;
  16011. /** mag = nearest and min = nearest and mip = none */
  16012. static readonly NEAREST_NEAREST: number;
  16013. /** mag = linear and min = nearest and mip = nearest */
  16014. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16015. /** mag = linear and min = nearest and mip = linear */
  16016. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16017. /** mag = linear and min = linear and mip = none */
  16018. static readonly LINEAR_LINEAR: number;
  16019. /** mag = linear and min = nearest and mip = none */
  16020. static readonly LINEAR_NEAREST: number;
  16021. /** Explicit coordinates mode */
  16022. static readonly EXPLICIT_MODE: number;
  16023. /** Spherical coordinates mode */
  16024. static readonly SPHERICAL_MODE: number;
  16025. /** Planar coordinates mode */
  16026. static readonly PLANAR_MODE: number;
  16027. /** Cubic coordinates mode */
  16028. static readonly CUBIC_MODE: number;
  16029. /** Projection coordinates mode */
  16030. static readonly PROJECTION_MODE: number;
  16031. /** Inverse Cubic coordinates mode */
  16032. static readonly SKYBOX_MODE: number;
  16033. /** Inverse Cubic coordinates mode */
  16034. static readonly INVCUBIC_MODE: number;
  16035. /** Equirectangular coordinates mode */
  16036. static readonly EQUIRECTANGULAR_MODE: number;
  16037. /** Equirectangular Fixed coordinates mode */
  16038. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16039. /** Equirectangular Fixed Mirrored coordinates mode */
  16040. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16041. /** Texture is not repeating outside of 0..1 UVs */
  16042. static readonly CLAMP_ADDRESSMODE: number;
  16043. /** Texture is repeating outside of 0..1 UVs */
  16044. static readonly WRAP_ADDRESSMODE: number;
  16045. /** Texture is repeating and mirrored */
  16046. static readonly MIRROR_ADDRESSMODE: number;
  16047. /**
  16048. * 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
  16049. */
  16050. static UseSerializedUrlIfAny: boolean;
  16051. /**
  16052. * Define the url of the texture.
  16053. */
  16054. url: Nullable<string>;
  16055. /**
  16056. * Define an offset on the texture to offset the u coordinates of the UVs
  16057. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16058. */
  16059. uOffset: number;
  16060. /**
  16061. * Define an offset on the texture to offset the v coordinates of the UVs
  16062. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16063. */
  16064. vOffset: number;
  16065. /**
  16066. * Define an offset on the texture to scale the u coordinates of the UVs
  16067. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16068. */
  16069. uScale: number;
  16070. /**
  16071. * Define an offset on the texture to scale the v coordinates of the UVs
  16072. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16073. */
  16074. vScale: number;
  16075. /**
  16076. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16077. * @see http://doc.babylonjs.com/how_to/more_materials
  16078. */
  16079. uAng: number;
  16080. /**
  16081. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16082. * @see http://doc.babylonjs.com/how_to/more_materials
  16083. */
  16084. vAng: number;
  16085. /**
  16086. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16087. * @see http://doc.babylonjs.com/how_to/more_materials
  16088. */
  16089. wAng: number;
  16090. /**
  16091. * Defines the center of rotation (U)
  16092. */
  16093. uRotationCenter: number;
  16094. /**
  16095. * Defines the center of rotation (V)
  16096. */
  16097. vRotationCenter: number;
  16098. /**
  16099. * Defines the center of rotation (W)
  16100. */
  16101. wRotationCenter: number;
  16102. /**
  16103. * Are mip maps generated for this texture or not.
  16104. */
  16105. get noMipmap(): boolean;
  16106. /**
  16107. * List of inspectable custom properties (used by the Inspector)
  16108. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16109. */
  16110. inspectableCustomProperties: Nullable<IInspectable[]>;
  16111. private _noMipmap;
  16112. /** @hidden */
  16113. _invertY: boolean;
  16114. private _rowGenerationMatrix;
  16115. private _cachedTextureMatrix;
  16116. private _projectionModeMatrix;
  16117. private _t0;
  16118. private _t1;
  16119. private _t2;
  16120. private _cachedUOffset;
  16121. private _cachedVOffset;
  16122. private _cachedUScale;
  16123. private _cachedVScale;
  16124. private _cachedUAng;
  16125. private _cachedVAng;
  16126. private _cachedWAng;
  16127. private _cachedProjectionMatrixId;
  16128. private _cachedCoordinatesMode;
  16129. /** @hidden */
  16130. protected _initialSamplingMode: number;
  16131. /** @hidden */
  16132. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16133. private _deleteBuffer;
  16134. protected _format: Nullable<number>;
  16135. private _delayedOnLoad;
  16136. private _delayedOnError;
  16137. private _mimeType?;
  16138. /**
  16139. * Observable triggered once the texture has been loaded.
  16140. */
  16141. onLoadObservable: Observable<Texture>;
  16142. protected _isBlocking: boolean;
  16143. /**
  16144. * Is the texture preventing material to render while loading.
  16145. * If false, a default texture will be used instead of the loading one during the preparation step.
  16146. */
  16147. set isBlocking(value: boolean);
  16148. get isBlocking(): boolean;
  16149. /**
  16150. * Get the current sampling mode associated with the texture.
  16151. */
  16152. get samplingMode(): number;
  16153. /**
  16154. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16155. */
  16156. get invertY(): boolean;
  16157. /**
  16158. * Instantiates a new texture.
  16159. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16160. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16161. * @param url defines the url of the picture to load as a texture
  16162. * @param scene defines the scene or engine the texture will belong to
  16163. * @param noMipmap defines if the texture will require mip maps or not
  16164. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16165. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16166. * @param onLoad defines a callback triggered when the texture has been loaded
  16167. * @param onError defines a callback triggered when an error occurred during the loading session
  16168. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16169. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16170. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16171. * @param mimeType defines an optional mime type information
  16172. */
  16173. 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);
  16174. /**
  16175. * Update the url (and optional buffer) of this texture if url was null during construction.
  16176. * @param url the url of the texture
  16177. * @param buffer the buffer of the texture (defaults to null)
  16178. * @param onLoad callback called when the texture is loaded (defaults to null)
  16179. */
  16180. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16181. /**
  16182. * Finish the loading sequence of a texture flagged as delayed load.
  16183. * @hidden
  16184. */
  16185. delayLoad(): void;
  16186. private _prepareRowForTextureGeneration;
  16187. /**
  16188. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16189. * @returns the transform matrix of the texture.
  16190. */
  16191. getTextureMatrix(uBase?: number): Matrix;
  16192. /**
  16193. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16194. * @returns The reflection texture transform
  16195. */
  16196. getReflectionTextureMatrix(): Matrix;
  16197. /**
  16198. * Clones the texture.
  16199. * @returns the cloned texture
  16200. */
  16201. clone(): Texture;
  16202. /**
  16203. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16204. * @returns The JSON representation of the texture
  16205. */
  16206. serialize(): any;
  16207. /**
  16208. * Get the current class name of the texture useful for serialization or dynamic coding.
  16209. * @returns "Texture"
  16210. */
  16211. getClassName(): string;
  16212. /**
  16213. * Dispose the texture and release its associated resources.
  16214. */
  16215. dispose(): void;
  16216. /**
  16217. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16218. * @param parsedTexture Define the JSON representation of the texture
  16219. * @param scene Define the scene the parsed texture should be instantiated in
  16220. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16221. * @returns The parsed texture if successful
  16222. */
  16223. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16224. /**
  16225. * Creates a texture from its base 64 representation.
  16226. * @param data Define the base64 payload without the data: prefix
  16227. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16228. * @param scene Define the scene the texture should belong to
  16229. * @param noMipmap Forces the texture to not create mip map information if true
  16230. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16231. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16232. * @param onLoad define a callback triggered when the texture has been loaded
  16233. * @param onError define a callback triggered when an error occurred during the loading session
  16234. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16235. * @returns the created texture
  16236. */
  16237. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16238. /**
  16239. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16240. * @param data Define the base64 payload without the data: prefix
  16241. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16242. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16243. * @param scene Define the scene the texture should belong to
  16244. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16245. * @param noMipmap Forces the texture to not create mip map information if true
  16246. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16247. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16248. * @param onLoad define a callback triggered when the texture has been loaded
  16249. * @param onError define a callback triggered when an error occurred during the loading session
  16250. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16251. * @returns the created texture
  16252. */
  16253. 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;
  16254. }
  16255. }
  16256. declare module BABYLON {
  16257. /**
  16258. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16259. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16260. */
  16261. export class PostProcessManager {
  16262. private _scene;
  16263. private _indexBuffer;
  16264. private _vertexBuffers;
  16265. /**
  16266. * Creates a new instance PostProcess
  16267. * @param scene The scene that the post process is associated with.
  16268. */
  16269. constructor(scene: Scene);
  16270. private _prepareBuffers;
  16271. private _buildIndexBuffer;
  16272. /**
  16273. * Rebuilds the vertex buffers of the manager.
  16274. * @hidden
  16275. */
  16276. _rebuild(): void;
  16277. /**
  16278. * Prepares a frame to be run through a post process.
  16279. * @param sourceTexture The input texture to the post procesess. (default: null)
  16280. * @param postProcesses An array of post processes to be run. (default: null)
  16281. * @returns True if the post processes were able to be run.
  16282. * @hidden
  16283. */
  16284. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16285. /**
  16286. * Manually render a set of post processes to a texture.
  16287. * @param postProcesses An array of post processes to be run.
  16288. * @param targetTexture The target texture to render to.
  16289. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16290. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16291. * @param lodLevel defines which lod of the texture to render to
  16292. */
  16293. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16294. /**
  16295. * Finalize the result of the output of the postprocesses.
  16296. * @param doNotPresent If true the result will not be displayed to the screen.
  16297. * @param targetTexture The target texture to render to.
  16298. * @param faceIndex The index of the face to bind the target texture to.
  16299. * @param postProcesses The array of post processes to render.
  16300. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16301. * @hidden
  16302. */
  16303. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16304. /**
  16305. * Disposes of the post process manager.
  16306. */
  16307. dispose(): void;
  16308. }
  16309. }
  16310. declare module BABYLON {
  16311. /** Interface used by value gradients (color, factor, ...) */
  16312. export interface IValueGradient {
  16313. /**
  16314. * Gets or sets the gradient value (between 0 and 1)
  16315. */
  16316. gradient: number;
  16317. }
  16318. /** Class used to store color4 gradient */
  16319. export class ColorGradient implements IValueGradient {
  16320. /**
  16321. * Gets or sets the gradient value (between 0 and 1)
  16322. */
  16323. gradient: number;
  16324. /**
  16325. * Gets or sets first associated color
  16326. */
  16327. color1: Color4;
  16328. /**
  16329. * Gets or sets second associated color
  16330. */
  16331. color2?: Color4;
  16332. /**
  16333. * Will get a color picked randomly between color1 and color2.
  16334. * If color2 is undefined then color1 will be used
  16335. * @param result defines the target Color4 to store the result in
  16336. */
  16337. getColorToRef(result: Color4): void;
  16338. }
  16339. /** Class used to store color 3 gradient */
  16340. export class Color3Gradient implements IValueGradient {
  16341. /**
  16342. * Gets or sets the gradient value (between 0 and 1)
  16343. */
  16344. gradient: number;
  16345. /**
  16346. * Gets or sets the associated color
  16347. */
  16348. color: Color3;
  16349. }
  16350. /** Class used to store factor gradient */
  16351. export class FactorGradient implements IValueGradient {
  16352. /**
  16353. * Gets or sets the gradient value (between 0 and 1)
  16354. */
  16355. gradient: number;
  16356. /**
  16357. * Gets or sets first associated factor
  16358. */
  16359. factor1: number;
  16360. /**
  16361. * Gets or sets second associated factor
  16362. */
  16363. factor2?: number;
  16364. /**
  16365. * Will get a number picked randomly between factor1 and factor2.
  16366. * If factor2 is undefined then factor1 will be used
  16367. * @returns the picked number
  16368. */
  16369. getFactor(): number;
  16370. }
  16371. /**
  16372. * Helper used to simplify some generic gradient tasks
  16373. */
  16374. export class GradientHelper {
  16375. /**
  16376. * Gets the current gradient from an array of IValueGradient
  16377. * @param ratio defines the current ratio to get
  16378. * @param gradients defines the array of IValueGradient
  16379. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16380. */
  16381. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16382. }
  16383. }
  16384. declare module BABYLON {
  16385. interface ThinEngine {
  16386. /**
  16387. * Creates a dynamic texture
  16388. * @param width defines the width of the texture
  16389. * @param height defines the height of the texture
  16390. * @param generateMipMaps defines if the engine should generate the mip levels
  16391. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16392. * @returns the dynamic texture inside an InternalTexture
  16393. */
  16394. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16395. /**
  16396. * Update the content of a dynamic texture
  16397. * @param texture defines the texture to update
  16398. * @param canvas defines the canvas containing the source
  16399. * @param invertY defines if data must be stored with Y axis inverted
  16400. * @param premulAlpha defines if alpha is stored as premultiplied
  16401. * @param format defines the format of the data
  16402. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16403. */
  16404. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16405. }
  16406. }
  16407. declare module BABYLON {
  16408. /**
  16409. * Helper class used to generate a canvas to manipulate images
  16410. */
  16411. export class CanvasGenerator {
  16412. /**
  16413. * Create a new canvas (or offscreen canvas depending on the context)
  16414. * @param width defines the expected width
  16415. * @param height defines the expected height
  16416. * @return a new canvas or offscreen canvas
  16417. */
  16418. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16419. }
  16420. }
  16421. declare module BABYLON {
  16422. /**
  16423. * A class extending Texture allowing drawing on a texture
  16424. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16425. */
  16426. export class DynamicTexture extends Texture {
  16427. private _generateMipMaps;
  16428. private _canvas;
  16429. private _context;
  16430. private _engine;
  16431. /**
  16432. * Creates a DynamicTexture
  16433. * @param name defines the name of the texture
  16434. * @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
  16435. * @param scene defines the scene where you want the texture
  16436. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16437. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16438. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16439. */
  16440. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16441. /**
  16442. * Get the current class name of the texture useful for serialization or dynamic coding.
  16443. * @returns "DynamicTexture"
  16444. */
  16445. getClassName(): string;
  16446. /**
  16447. * Gets the current state of canRescale
  16448. */
  16449. get canRescale(): boolean;
  16450. private _recreate;
  16451. /**
  16452. * Scales the texture
  16453. * @param ratio the scale factor to apply to both width and height
  16454. */
  16455. scale(ratio: number): void;
  16456. /**
  16457. * Resizes the texture
  16458. * @param width the new width
  16459. * @param height the new height
  16460. */
  16461. scaleTo(width: number, height: number): void;
  16462. /**
  16463. * Gets the context of the canvas used by the texture
  16464. * @returns the canvas context of the dynamic texture
  16465. */
  16466. getContext(): CanvasRenderingContext2D;
  16467. /**
  16468. * Clears the texture
  16469. */
  16470. clear(): void;
  16471. /**
  16472. * Updates the texture
  16473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16474. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16475. */
  16476. update(invertY?: boolean, premulAlpha?: boolean): void;
  16477. /**
  16478. * Draws text onto the texture
  16479. * @param text defines the text to be drawn
  16480. * @param x defines the placement of the text from the left
  16481. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16482. * @param font defines the font to be used with font-style, font-size, font-name
  16483. * @param color defines the color used for the text
  16484. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16485. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16486. * @param update defines whether texture is immediately update (default is true)
  16487. */
  16488. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16489. /**
  16490. * Clones the texture
  16491. * @returns the clone of the texture.
  16492. */
  16493. clone(): DynamicTexture;
  16494. /**
  16495. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16496. * @returns a serialized dynamic texture object
  16497. */
  16498. serialize(): any;
  16499. /** @hidden */
  16500. _rebuild(): void;
  16501. }
  16502. }
  16503. declare module BABYLON {
  16504. interface AbstractScene {
  16505. /**
  16506. * The list of procedural textures added to the scene
  16507. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16508. */
  16509. proceduralTextures: Array<ProceduralTexture>;
  16510. }
  16511. /**
  16512. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16513. * in a given scene.
  16514. */
  16515. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16516. /**
  16517. * The component name helpfull to identify the component in the list of scene components.
  16518. */
  16519. readonly name: string;
  16520. /**
  16521. * The scene the component belongs to.
  16522. */
  16523. scene: Scene;
  16524. /**
  16525. * Creates a new instance of the component for the given scene
  16526. * @param scene Defines the scene to register the component in
  16527. */
  16528. constructor(scene: Scene);
  16529. /**
  16530. * Registers the component in a given scene
  16531. */
  16532. register(): void;
  16533. /**
  16534. * Rebuilds the elements related to this component in case of
  16535. * context lost for instance.
  16536. */
  16537. rebuild(): void;
  16538. /**
  16539. * Disposes the component and the associated ressources.
  16540. */
  16541. dispose(): void;
  16542. private _beforeClear;
  16543. }
  16544. }
  16545. declare module BABYLON {
  16546. interface ThinEngine {
  16547. /**
  16548. * Creates a new render target cube texture
  16549. * @param size defines the size of the texture
  16550. * @param options defines the options used to create the texture
  16551. * @returns a new render target cube texture stored in an InternalTexture
  16552. */
  16553. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16554. }
  16555. }
  16556. declare module BABYLON {
  16557. /** @hidden */
  16558. export var proceduralVertexShader: {
  16559. name: string;
  16560. shader: string;
  16561. };
  16562. }
  16563. declare module BABYLON {
  16564. /**
  16565. * 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.
  16566. * This is the base class of any Procedural texture and contains most of the shareable code.
  16567. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16568. */
  16569. export class ProceduralTexture extends Texture {
  16570. isCube: boolean;
  16571. /**
  16572. * Define if the texture is enabled or not (disabled texture will not render)
  16573. */
  16574. isEnabled: boolean;
  16575. /**
  16576. * Define if the texture must be cleared before rendering (default is true)
  16577. */
  16578. autoClear: boolean;
  16579. /**
  16580. * Callback called when the texture is generated
  16581. */
  16582. onGenerated: () => void;
  16583. /**
  16584. * Event raised when the texture is generated
  16585. */
  16586. onGeneratedObservable: Observable<ProceduralTexture>;
  16587. /** @hidden */
  16588. _generateMipMaps: boolean;
  16589. /** @hidden **/
  16590. _effect: Effect;
  16591. /** @hidden */
  16592. _textures: {
  16593. [key: string]: Texture;
  16594. };
  16595. private _size;
  16596. private _currentRefreshId;
  16597. private _frameId;
  16598. private _refreshRate;
  16599. private _vertexBuffers;
  16600. private _indexBuffer;
  16601. private _uniforms;
  16602. private _samplers;
  16603. private _fragment;
  16604. private _floats;
  16605. private _ints;
  16606. private _floatsArrays;
  16607. private _colors3;
  16608. private _colors4;
  16609. private _vectors2;
  16610. private _vectors3;
  16611. private _matrices;
  16612. private _fallbackTexture;
  16613. private _fallbackTextureUsed;
  16614. private _engine;
  16615. private _cachedDefines;
  16616. private _contentUpdateId;
  16617. private _contentData;
  16618. /**
  16619. * Instantiates a new procedural texture.
  16620. * 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.
  16621. * This is the base class of any Procedural texture and contains most of the shareable code.
  16622. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16623. * @param name Define the name of the texture
  16624. * @param size Define the size of the texture to create
  16625. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16626. * @param scene Define the scene the texture belongs to
  16627. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16628. * @param generateMipMaps Define if the texture should creates mip maps or not
  16629. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16630. */
  16631. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16632. /**
  16633. * The effect that is created when initializing the post process.
  16634. * @returns The created effect corresponding the the postprocess.
  16635. */
  16636. getEffect(): Effect;
  16637. /**
  16638. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16639. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16640. */
  16641. getContent(): Nullable<ArrayBufferView>;
  16642. private _createIndexBuffer;
  16643. /** @hidden */
  16644. _rebuild(): void;
  16645. /**
  16646. * Resets the texture in order to recreate its associated resources.
  16647. * This can be called in case of context loss
  16648. */
  16649. reset(): void;
  16650. protected _getDefines(): string;
  16651. /**
  16652. * Is the texture ready to be used ? (rendered at least once)
  16653. * @returns true if ready, otherwise, false.
  16654. */
  16655. isReady(): boolean;
  16656. /**
  16657. * Resets the refresh counter of the texture and start bak from scratch.
  16658. * Could be useful to regenerate the texture if it is setup to render only once.
  16659. */
  16660. resetRefreshCounter(): void;
  16661. /**
  16662. * Set the fragment shader to use in order to render the texture.
  16663. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16664. */
  16665. setFragment(fragment: any): void;
  16666. /**
  16667. * Define the refresh rate of the texture or the rendering frequency.
  16668. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16669. */
  16670. get refreshRate(): number;
  16671. set refreshRate(value: number);
  16672. /** @hidden */
  16673. _shouldRender(): boolean;
  16674. /**
  16675. * Get the size the texture is rendering at.
  16676. * @returns the size (texture is always squared)
  16677. */
  16678. getRenderSize(): number;
  16679. /**
  16680. * Resize the texture to new value.
  16681. * @param size Define the new size the texture should have
  16682. * @param generateMipMaps Define whether the new texture should create mip maps
  16683. */
  16684. resize(size: number, generateMipMaps: boolean): void;
  16685. private _checkUniform;
  16686. /**
  16687. * Set a texture in the shader program used to render.
  16688. * @param name Define the name of the uniform samplers as defined in the shader
  16689. * @param texture Define the texture to bind to this sampler
  16690. * @return the texture itself allowing "fluent" like uniform updates
  16691. */
  16692. setTexture(name: string, texture: Texture): ProceduralTexture;
  16693. /**
  16694. * Set a float in the shader.
  16695. * @param name Define the name of the uniform as defined in the shader
  16696. * @param value Define the value to give to the uniform
  16697. * @return the texture itself allowing "fluent" like uniform updates
  16698. */
  16699. setFloat(name: string, value: number): ProceduralTexture;
  16700. /**
  16701. * Set a int in the shader.
  16702. * @param name Define the name of the uniform as defined in the shader
  16703. * @param value Define the value to give to the uniform
  16704. * @return the texture itself allowing "fluent" like uniform updates
  16705. */
  16706. setInt(name: string, value: number): ProceduralTexture;
  16707. /**
  16708. * Set an array of floats in the shader.
  16709. * @param name Define the name of the uniform as defined in the shader
  16710. * @param value Define the value to give to the uniform
  16711. * @return the texture itself allowing "fluent" like uniform updates
  16712. */
  16713. setFloats(name: string, value: number[]): ProceduralTexture;
  16714. /**
  16715. * Set a vec3 in the shader from a Color3.
  16716. * @param name Define the name of the uniform as defined in the shader
  16717. * @param value Define the value to give to the uniform
  16718. * @return the texture itself allowing "fluent" like uniform updates
  16719. */
  16720. setColor3(name: string, value: Color3): ProceduralTexture;
  16721. /**
  16722. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  16728. /**
  16729. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  16735. /**
  16736. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  16742. /**
  16743. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16749. /**
  16750. * Render the texture to its associated render target.
  16751. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16752. */
  16753. render(useCameraPostProcess?: boolean): void;
  16754. /**
  16755. * Clone the texture.
  16756. * @returns the cloned texture
  16757. */
  16758. clone(): ProceduralTexture;
  16759. /**
  16760. * Dispose the texture and release its asoociated resources.
  16761. */
  16762. dispose(): void;
  16763. }
  16764. }
  16765. declare module BABYLON {
  16766. /**
  16767. * This represents the base class for particle system in Babylon.
  16768. * 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.
  16769. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16770. * @example https://doc.babylonjs.com/babylon101/particles
  16771. */
  16772. export class BaseParticleSystem {
  16773. /**
  16774. * Source color is added to the destination color without alpha affecting the result
  16775. */
  16776. static BLENDMODE_ONEONE: number;
  16777. /**
  16778. * Blend current color and particle color using particle’s alpha
  16779. */
  16780. static BLENDMODE_STANDARD: number;
  16781. /**
  16782. * Add current color and particle color multiplied by particle’s alpha
  16783. */
  16784. static BLENDMODE_ADD: number;
  16785. /**
  16786. * Multiply current color with particle color
  16787. */
  16788. static BLENDMODE_MULTIPLY: number;
  16789. /**
  16790. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16791. */
  16792. static BLENDMODE_MULTIPLYADD: number;
  16793. /**
  16794. * List of animations used by the particle system.
  16795. */
  16796. animations: Animation[];
  16797. /**
  16798. * The id of the Particle system.
  16799. */
  16800. id: string;
  16801. /**
  16802. * The friendly name of the Particle system.
  16803. */
  16804. name: string;
  16805. /**
  16806. * The rendering group used by the Particle system to chose when to render.
  16807. */
  16808. renderingGroupId: number;
  16809. /**
  16810. * The emitter represents the Mesh or position we are attaching the particle system to.
  16811. */
  16812. emitter: Nullable<AbstractMesh | Vector3>;
  16813. /**
  16814. * The maximum number of particles to emit per frame
  16815. */
  16816. emitRate: number;
  16817. /**
  16818. * If you want to launch only a few particles at once, that can be done, as well.
  16819. */
  16820. manualEmitCount: number;
  16821. /**
  16822. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16823. */
  16824. updateSpeed: number;
  16825. /**
  16826. * The amount of time the particle system is running (depends of the overall update speed).
  16827. */
  16828. targetStopDuration: number;
  16829. /**
  16830. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16831. */
  16832. disposeOnStop: boolean;
  16833. /**
  16834. * Minimum power of emitting particles.
  16835. */
  16836. minEmitPower: number;
  16837. /**
  16838. * Maximum power of emitting particles.
  16839. */
  16840. maxEmitPower: number;
  16841. /**
  16842. * Minimum life time of emitting particles.
  16843. */
  16844. minLifeTime: number;
  16845. /**
  16846. * Maximum life time of emitting particles.
  16847. */
  16848. maxLifeTime: number;
  16849. /**
  16850. * Minimum Size of emitting particles.
  16851. */
  16852. minSize: number;
  16853. /**
  16854. * Maximum Size of emitting particles.
  16855. */
  16856. maxSize: number;
  16857. /**
  16858. * Minimum scale of emitting particles on X axis.
  16859. */
  16860. minScaleX: number;
  16861. /**
  16862. * Maximum scale of emitting particles on X axis.
  16863. */
  16864. maxScaleX: number;
  16865. /**
  16866. * Minimum scale of emitting particles on Y axis.
  16867. */
  16868. minScaleY: number;
  16869. /**
  16870. * Maximum scale of emitting particles on Y axis.
  16871. */
  16872. maxScaleY: number;
  16873. /**
  16874. * Gets or sets the minimal initial rotation in radians.
  16875. */
  16876. minInitialRotation: number;
  16877. /**
  16878. * Gets or sets the maximal initial rotation in radians.
  16879. */
  16880. maxInitialRotation: number;
  16881. /**
  16882. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16883. */
  16884. minAngularSpeed: number;
  16885. /**
  16886. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16887. */
  16888. maxAngularSpeed: number;
  16889. /**
  16890. * The texture used to render each particle. (this can be a spritesheet)
  16891. */
  16892. particleTexture: Nullable<Texture>;
  16893. /**
  16894. * The layer mask we are rendering the particles through.
  16895. */
  16896. layerMask: number;
  16897. /**
  16898. * This can help using your own shader to render the particle system.
  16899. * The according effect will be created
  16900. */
  16901. customShader: any;
  16902. /**
  16903. * By default particle system starts as soon as they are created. This prevents the
  16904. * automatic start to happen and let you decide when to start emitting particles.
  16905. */
  16906. preventAutoStart: boolean;
  16907. private _noiseTexture;
  16908. /**
  16909. * Gets or sets a texture used to add random noise to particle positions
  16910. */
  16911. get noiseTexture(): Nullable<ProceduralTexture>;
  16912. set noiseTexture(value: Nullable<ProceduralTexture>);
  16913. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16914. noiseStrength: Vector3;
  16915. /**
  16916. * Callback triggered when the particle animation is ending.
  16917. */
  16918. onAnimationEnd: Nullable<() => void>;
  16919. /**
  16920. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16921. */
  16922. blendMode: number;
  16923. /**
  16924. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16925. * to override the particles.
  16926. */
  16927. forceDepthWrite: boolean;
  16928. /** 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 */
  16929. preWarmCycles: number;
  16930. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16931. preWarmStepOffset: number;
  16932. /**
  16933. * 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)
  16934. */
  16935. spriteCellChangeSpeed: number;
  16936. /**
  16937. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16938. */
  16939. startSpriteCellID: number;
  16940. /**
  16941. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16942. */
  16943. endSpriteCellID: number;
  16944. /**
  16945. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16946. */
  16947. spriteCellWidth: number;
  16948. /**
  16949. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16950. */
  16951. spriteCellHeight: number;
  16952. /**
  16953. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16954. */
  16955. spriteRandomStartCell: boolean;
  16956. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16957. translationPivot: Vector2;
  16958. /** @hidden */
  16959. protected _isAnimationSheetEnabled: boolean;
  16960. /**
  16961. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16962. */
  16963. beginAnimationOnStart: boolean;
  16964. /**
  16965. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16966. */
  16967. beginAnimationFrom: number;
  16968. /**
  16969. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16970. */
  16971. beginAnimationTo: number;
  16972. /**
  16973. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16974. */
  16975. beginAnimationLoop: boolean;
  16976. /**
  16977. * Gets or sets a world offset applied to all particles
  16978. */
  16979. worldOffset: Vector3;
  16980. /**
  16981. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16982. */
  16983. get isAnimationSheetEnabled(): boolean;
  16984. set isAnimationSheetEnabled(value: boolean);
  16985. /**
  16986. * Get hosting scene
  16987. * @returns the scene
  16988. */
  16989. getScene(): Scene;
  16990. /**
  16991. * You can use gravity if you want to give an orientation to your particles.
  16992. */
  16993. gravity: Vector3;
  16994. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16995. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16996. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16997. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16998. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16999. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17000. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17001. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17002. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17003. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17004. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17005. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17006. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17007. /**
  17008. * Defines the delay in milliseconds before starting the system (0 by default)
  17009. */
  17010. startDelay: number;
  17011. /**
  17012. * Gets the current list of drag gradients.
  17013. * You must use addDragGradient and removeDragGradient to udpate this list
  17014. * @returns the list of drag gradients
  17015. */
  17016. getDragGradients(): Nullable<Array<FactorGradient>>;
  17017. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17018. limitVelocityDamping: number;
  17019. /**
  17020. * Gets the current list of limit velocity gradients.
  17021. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17022. * @returns the list of limit velocity gradients
  17023. */
  17024. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17025. /**
  17026. * Gets the current list of color gradients.
  17027. * You must use addColorGradient and removeColorGradient to udpate this list
  17028. * @returns the list of color gradients
  17029. */
  17030. getColorGradients(): Nullable<Array<ColorGradient>>;
  17031. /**
  17032. * Gets the current list of size gradients.
  17033. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17034. * @returns the list of size gradients
  17035. */
  17036. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17037. /**
  17038. * Gets the current list of color remap gradients.
  17039. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17040. * @returns the list of color remap gradients
  17041. */
  17042. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17043. /**
  17044. * Gets the current list of alpha remap gradients.
  17045. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17046. * @returns the list of alpha remap gradients
  17047. */
  17048. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17049. /**
  17050. * Gets the current list of life time gradients.
  17051. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17052. * @returns the list of life time gradients
  17053. */
  17054. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17055. /**
  17056. * Gets the current list of angular speed gradients.
  17057. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17058. * @returns the list of angular speed gradients
  17059. */
  17060. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17061. /**
  17062. * Gets the current list of velocity gradients.
  17063. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17064. * @returns the list of velocity gradients
  17065. */
  17066. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17067. /**
  17068. * Gets the current list of start size gradients.
  17069. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17070. * @returns the list of start size gradients
  17071. */
  17072. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17073. /**
  17074. * Gets the current list of emit rate gradients.
  17075. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17076. * @returns the list of emit rate gradients
  17077. */
  17078. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17079. /**
  17080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17081. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17082. */
  17083. get direction1(): Vector3;
  17084. set direction1(value: Vector3);
  17085. /**
  17086. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17087. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17088. */
  17089. get direction2(): Vector3;
  17090. set direction2(value: Vector3);
  17091. /**
  17092. * 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.
  17093. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17094. */
  17095. get minEmitBox(): Vector3;
  17096. set minEmitBox(value: Vector3);
  17097. /**
  17098. * 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.
  17099. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17100. */
  17101. get maxEmitBox(): Vector3;
  17102. set maxEmitBox(value: Vector3);
  17103. /**
  17104. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17105. */
  17106. color1: Color4;
  17107. /**
  17108. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17109. */
  17110. color2: Color4;
  17111. /**
  17112. * Color the particle will have at the end of its lifetime
  17113. */
  17114. colorDead: Color4;
  17115. /**
  17116. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17117. */
  17118. textureMask: Color4;
  17119. /**
  17120. * The particle emitter type defines the emitter used by the particle system.
  17121. * It can be for example box, sphere, or cone...
  17122. */
  17123. particleEmitterType: IParticleEmitterType;
  17124. /** @hidden */
  17125. _isSubEmitter: boolean;
  17126. /**
  17127. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17128. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17129. */
  17130. billboardMode: number;
  17131. protected _isBillboardBased: boolean;
  17132. /**
  17133. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17134. */
  17135. get isBillboardBased(): boolean;
  17136. set isBillboardBased(value: boolean);
  17137. /**
  17138. * The scene the particle system belongs to.
  17139. */
  17140. protected _scene: Scene;
  17141. /**
  17142. * Local cache of defines for image processing.
  17143. */
  17144. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17145. /**
  17146. * Default configuration related to image processing available in the standard Material.
  17147. */
  17148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17149. /**
  17150. * Gets the image processing configuration used either in this material.
  17151. */
  17152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17153. /**
  17154. * Sets the Default image processing configuration used either in the this material.
  17155. *
  17156. * If sets to null, the scene one is in use.
  17157. */
  17158. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17159. /**
  17160. * Attaches a new image processing configuration to the Standard Material.
  17161. * @param configuration
  17162. */
  17163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17164. /** @hidden */
  17165. protected _reset(): void;
  17166. /** @hidden */
  17167. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17168. /**
  17169. * Instantiates a particle system.
  17170. * 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.
  17171. * @param name The name of the particle system
  17172. */
  17173. constructor(name: string);
  17174. /**
  17175. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17176. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17177. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17178. * @returns the emitter
  17179. */
  17180. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17181. /**
  17182. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17183. * @param radius The radius of the hemisphere to emit from
  17184. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17185. * @returns the emitter
  17186. */
  17187. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17188. /**
  17189. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17190. * @param radius The radius of the sphere to emit from
  17191. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17192. * @returns the emitter
  17193. */
  17194. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17195. /**
  17196. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17197. * @param radius The radius of the sphere to emit from
  17198. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17199. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17200. * @returns the emitter
  17201. */
  17202. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17203. /**
  17204. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17205. * @param radius The radius of the emission cylinder
  17206. * @param height The height of the emission cylinder
  17207. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17208. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17209. * @returns the emitter
  17210. */
  17211. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17212. /**
  17213. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17214. * @param radius The radius of the cylinder to emit from
  17215. * @param height The height of the emission cylinder
  17216. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17217. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17218. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17219. * @returns the emitter
  17220. */
  17221. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17222. /**
  17223. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17224. * @param radius The radius of the cone to emit from
  17225. * @param angle The base angle of the cone
  17226. * @returns the emitter
  17227. */
  17228. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17229. /**
  17230. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17231. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17232. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17233. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17234. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17235. * @returns the emitter
  17236. */
  17237. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17238. }
  17239. }
  17240. declare module BABYLON {
  17241. /**
  17242. * Type of sub emitter
  17243. */
  17244. export enum SubEmitterType {
  17245. /**
  17246. * Attached to the particle over it's lifetime
  17247. */
  17248. ATTACHED = 0,
  17249. /**
  17250. * Created when the particle dies
  17251. */
  17252. END = 1
  17253. }
  17254. /**
  17255. * Sub emitter class used to emit particles from an existing particle
  17256. */
  17257. export class SubEmitter {
  17258. /**
  17259. * the particle system to be used by the sub emitter
  17260. */
  17261. particleSystem: ParticleSystem;
  17262. /**
  17263. * Type of the submitter (Default: END)
  17264. */
  17265. type: SubEmitterType;
  17266. /**
  17267. * 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)
  17268. * Note: This only is supported when using an emitter of type Mesh
  17269. */
  17270. inheritDirection: boolean;
  17271. /**
  17272. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17273. */
  17274. inheritedVelocityAmount: number;
  17275. /**
  17276. * Creates a sub emitter
  17277. * @param particleSystem the particle system to be used by the sub emitter
  17278. */
  17279. constructor(
  17280. /**
  17281. * the particle system to be used by the sub emitter
  17282. */
  17283. particleSystem: ParticleSystem);
  17284. /**
  17285. * Clones the sub emitter
  17286. * @returns the cloned sub emitter
  17287. */
  17288. clone(): SubEmitter;
  17289. /**
  17290. * Serialize current object to a JSON object
  17291. * @returns the serialized object
  17292. */
  17293. serialize(): any;
  17294. /** @hidden */
  17295. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17296. /**
  17297. * Creates a new SubEmitter from a serialized JSON version
  17298. * @param serializationObject defines the JSON object to read from
  17299. * @param scene defines the hosting scene
  17300. * @param rootUrl defines the rootUrl for data loading
  17301. * @returns a new SubEmitter
  17302. */
  17303. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17304. /** Release associated resources */
  17305. dispose(): void;
  17306. }
  17307. }
  17308. declare module BABYLON {
  17309. /** @hidden */
  17310. export var clipPlaneFragmentDeclaration: {
  17311. name: string;
  17312. shader: string;
  17313. };
  17314. }
  17315. declare module BABYLON {
  17316. /** @hidden */
  17317. export var imageProcessingDeclaration: {
  17318. name: string;
  17319. shader: string;
  17320. };
  17321. }
  17322. declare module BABYLON {
  17323. /** @hidden */
  17324. export var imageProcessingFunctions: {
  17325. name: string;
  17326. shader: string;
  17327. };
  17328. }
  17329. declare module BABYLON {
  17330. /** @hidden */
  17331. export var clipPlaneFragment: {
  17332. name: string;
  17333. shader: string;
  17334. };
  17335. }
  17336. declare module BABYLON {
  17337. /** @hidden */
  17338. export var particlesPixelShader: {
  17339. name: string;
  17340. shader: string;
  17341. };
  17342. }
  17343. declare module BABYLON {
  17344. /** @hidden */
  17345. export var clipPlaneVertexDeclaration: {
  17346. name: string;
  17347. shader: string;
  17348. };
  17349. }
  17350. declare module BABYLON {
  17351. /** @hidden */
  17352. export var clipPlaneVertex: {
  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. /** @hidden */
  25461. _cameraRigParams: any;
  25462. /** @hidden */
  25463. _rigCameras: Camera[];
  25464. /** @hidden */
  25465. _rigPostProcess: Nullable<PostProcess>;
  25466. protected _webvrViewMatrix: Matrix;
  25467. /** @hidden */
  25468. _skipRendering: boolean;
  25469. /** @hidden */
  25470. _projectionMatrix: Matrix;
  25471. /** @hidden */
  25472. _postProcesses: Nullable<PostProcess>[];
  25473. /** @hidden */
  25474. _activeMeshes: SmartArray<AbstractMesh>;
  25475. protected _globalPosition: Vector3;
  25476. /** @hidden */
  25477. _computedViewMatrix: Matrix;
  25478. private _doNotComputeProjectionMatrix;
  25479. private _transformMatrix;
  25480. private _frustumPlanes;
  25481. private _refreshFrustumPlanes;
  25482. private _storedFov;
  25483. private _stateStored;
  25484. /**
  25485. * Instantiates a new camera object.
  25486. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25487. * @see http://doc.babylonjs.com/features/cameras
  25488. * @param name Defines the name of the camera in the scene
  25489. * @param position Defines the position of the camera
  25490. * @param scene Defines the scene the camera belongs too
  25491. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25492. */
  25493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25494. /**
  25495. * Store current camera state (fov, position, etc..)
  25496. * @returns the camera
  25497. */
  25498. storeState(): Camera;
  25499. /**
  25500. * Restores the camera state values if it has been stored. You must call storeState() first
  25501. */
  25502. protected _restoreStateValues(): boolean;
  25503. /**
  25504. * Restored camera state. You must call storeState() first.
  25505. * @returns true if restored and false otherwise
  25506. */
  25507. restoreState(): boolean;
  25508. /**
  25509. * Gets the class name of the camera.
  25510. * @returns the class name
  25511. */
  25512. getClassName(): string;
  25513. /** @hidden */
  25514. readonly _isCamera: boolean;
  25515. /**
  25516. * Gets a string representation of the camera useful for debug purpose.
  25517. * @param fullDetails Defines that a more verboe level of logging is required
  25518. * @returns the string representation
  25519. */
  25520. toString(fullDetails?: boolean): string;
  25521. /**
  25522. * Gets the current world space position of the camera.
  25523. */
  25524. get globalPosition(): Vector3;
  25525. /**
  25526. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25527. * @returns the active meshe list
  25528. */
  25529. getActiveMeshes(): SmartArray<AbstractMesh>;
  25530. /**
  25531. * Check wether a mesh is part of the current active mesh list of the camera
  25532. * @param mesh Defines the mesh to check
  25533. * @returns true if active, false otherwise
  25534. */
  25535. isActiveMesh(mesh: Mesh): boolean;
  25536. /**
  25537. * Is this camera ready to be used/rendered
  25538. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25539. * @return true if the camera is ready
  25540. */
  25541. isReady(completeCheck?: boolean): boolean;
  25542. /** @hidden */
  25543. _initCache(): void;
  25544. /** @hidden */
  25545. _updateCache(ignoreParentClass?: boolean): void;
  25546. /** @hidden */
  25547. _isSynchronized(): boolean;
  25548. /** @hidden */
  25549. _isSynchronizedViewMatrix(): boolean;
  25550. /** @hidden */
  25551. _isSynchronizedProjectionMatrix(): boolean;
  25552. /**
  25553. * Attach the input controls to a specific dom element to get the input from.
  25554. * @param element Defines the element the controls should be listened from
  25555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25556. */
  25557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25558. /**
  25559. * Detach the current controls from the specified dom element.
  25560. * @param element Defines the element to stop listening the inputs from
  25561. */
  25562. detachControl(element: HTMLElement): void;
  25563. /**
  25564. * Update the camera state according to the different inputs gathered during the frame.
  25565. */
  25566. update(): void;
  25567. /** @hidden */
  25568. _checkInputs(): void;
  25569. /** @hidden */
  25570. get rigCameras(): Camera[];
  25571. /**
  25572. * Gets the post process used by the rig cameras
  25573. */
  25574. get rigPostProcess(): Nullable<PostProcess>;
  25575. /**
  25576. * Internal, gets the first post proces.
  25577. * @returns the first post process to be run on this camera.
  25578. */
  25579. _getFirstPostProcess(): Nullable<PostProcess>;
  25580. private _cascadePostProcessesToRigCams;
  25581. /**
  25582. * Attach a post process to the camera.
  25583. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25584. * @param postProcess The post process to attach to the camera
  25585. * @param insertAt The position of the post process in case several of them are in use in the scene
  25586. * @returns the position the post process has been inserted at
  25587. */
  25588. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25589. /**
  25590. * Detach a post process to the camera.
  25591. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25592. * @param postProcess The post process to detach from the camera
  25593. */
  25594. detachPostProcess(postProcess: PostProcess): void;
  25595. /**
  25596. * Gets the current world matrix of the camera
  25597. */
  25598. getWorldMatrix(): Matrix;
  25599. /** @hidden */
  25600. _getViewMatrix(): Matrix;
  25601. /**
  25602. * Gets the current view matrix of the camera.
  25603. * @param force forces the camera to recompute the matrix without looking at the cached state
  25604. * @returns the view matrix
  25605. */
  25606. getViewMatrix(force?: boolean): Matrix;
  25607. /**
  25608. * Freeze the projection matrix.
  25609. * It will prevent the cache check of the camera projection compute and can speed up perf
  25610. * if no parameter of the camera are meant to change
  25611. * @param projection Defines manually a projection if necessary
  25612. */
  25613. freezeProjectionMatrix(projection?: Matrix): void;
  25614. /**
  25615. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25616. */
  25617. unfreezeProjectionMatrix(): void;
  25618. /**
  25619. * Gets the current projection matrix of the camera.
  25620. * @param force forces the camera to recompute the matrix without looking at the cached state
  25621. * @returns the projection matrix
  25622. */
  25623. getProjectionMatrix(force?: boolean): Matrix;
  25624. /**
  25625. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25626. * @returns a Matrix
  25627. */
  25628. getTransformationMatrix(): Matrix;
  25629. private _updateFrustumPlanes;
  25630. /**
  25631. * Checks if a cullable object (mesh...) is in the camera frustum
  25632. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25633. * @param target The object to check
  25634. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25635. * @returns true if the object is in frustum otherwise false
  25636. */
  25637. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25638. /**
  25639. * Checks if a cullable object (mesh...) is in the camera frustum
  25640. * Unlike isInFrustum this cheks the full bounding box
  25641. * @param target The object to check
  25642. * @returns true if the object is in frustum otherwise false
  25643. */
  25644. isCompletelyInFrustum(target: ICullable): boolean;
  25645. /**
  25646. * Gets a ray in the forward direction from the camera.
  25647. * @param length Defines the length of the ray to create
  25648. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25649. * @param origin Defines the start point of the ray which defaults to the camera position
  25650. * @returns the forward ray
  25651. */
  25652. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25653. /**
  25654. * Releases resources associated with this node.
  25655. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25656. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25657. */
  25658. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25659. /** @hidden */
  25660. _isLeftCamera: boolean;
  25661. /**
  25662. * Gets the left camera of a rig setup in case of Rigged Camera
  25663. */
  25664. get isLeftCamera(): boolean;
  25665. /** @hidden */
  25666. _isRightCamera: boolean;
  25667. /**
  25668. * Gets the right camera of a rig setup in case of Rigged Camera
  25669. */
  25670. get isRightCamera(): boolean;
  25671. /**
  25672. * Gets the left camera of a rig setup in case of Rigged Camera
  25673. */
  25674. get leftCamera(): Nullable<FreeCamera>;
  25675. /**
  25676. * Gets the right camera of a rig setup in case of Rigged Camera
  25677. */
  25678. get rightCamera(): Nullable<FreeCamera>;
  25679. /**
  25680. * Gets the left camera target of a rig setup in case of Rigged Camera
  25681. * @returns the target position
  25682. */
  25683. getLeftTarget(): Nullable<Vector3>;
  25684. /**
  25685. * Gets the right camera target of a rig setup in case of Rigged Camera
  25686. * @returns the target position
  25687. */
  25688. getRightTarget(): Nullable<Vector3>;
  25689. /**
  25690. * @hidden
  25691. */
  25692. setCameraRigMode(mode: number, rigParams: any): void;
  25693. /** @hidden */
  25694. static _setStereoscopicRigMode(camera: Camera): void;
  25695. /** @hidden */
  25696. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25697. /** @hidden */
  25698. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25699. /** @hidden */
  25700. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25701. /** @hidden */
  25702. _getVRProjectionMatrix(): Matrix;
  25703. protected _updateCameraRotationMatrix(): void;
  25704. protected _updateWebVRCameraRotationMatrix(): void;
  25705. /**
  25706. * This function MUST be overwritten by the different WebVR cameras available.
  25707. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25708. * @hidden
  25709. */
  25710. _getWebVRProjectionMatrix(): Matrix;
  25711. /**
  25712. * This function MUST be overwritten by the different WebVR cameras available.
  25713. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25714. * @hidden
  25715. */
  25716. _getWebVRViewMatrix(): Matrix;
  25717. /** @hidden */
  25718. setCameraRigParameter(name: string, value: any): void;
  25719. /**
  25720. * needs to be overridden by children so sub has required properties to be copied
  25721. * @hidden
  25722. */
  25723. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25724. /**
  25725. * May need to be overridden by children
  25726. * @hidden
  25727. */
  25728. _updateRigCameras(): void;
  25729. /** @hidden */
  25730. _setupInputs(): void;
  25731. /**
  25732. * Serialiaze the camera setup to a json represention
  25733. * @returns the JSON representation
  25734. */
  25735. serialize(): any;
  25736. /**
  25737. * Clones the current camera.
  25738. * @param name The cloned camera name
  25739. * @returns the cloned camera
  25740. */
  25741. clone(name: string): Camera;
  25742. /**
  25743. * Gets the direction of the camera relative to a given local axis.
  25744. * @param localAxis Defines the reference axis to provide a relative direction.
  25745. * @return the direction
  25746. */
  25747. getDirection(localAxis: Vector3): Vector3;
  25748. /**
  25749. * Returns the current camera absolute rotation
  25750. */
  25751. get absoluteRotation(): Quaternion;
  25752. /**
  25753. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25754. * @param localAxis Defines the reference axis to provide a relative direction.
  25755. * @param result Defines the vector to store the result in
  25756. */
  25757. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25758. /**
  25759. * Gets a camera constructor for a given camera type
  25760. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25761. * @param name The name of the camera the result will be able to instantiate
  25762. * @param scene The scene the result will construct the camera in
  25763. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25764. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25765. * @returns a factory method to construc the camera
  25766. */
  25767. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25768. /**
  25769. * Compute the world matrix of the camera.
  25770. * @returns the camera world matrix
  25771. */
  25772. computeWorldMatrix(): Matrix;
  25773. /**
  25774. * Parse a JSON and creates the camera from the parsed information
  25775. * @param parsedCamera The JSON to parse
  25776. * @param scene The scene to instantiate the camera in
  25777. * @returns the newly constructed camera
  25778. */
  25779. static Parse(parsedCamera: any, scene: Scene): Camera;
  25780. }
  25781. }
  25782. declare module BABYLON {
  25783. /**
  25784. * Class containing static functions to help procedurally build meshes
  25785. */
  25786. export class DiscBuilder {
  25787. /**
  25788. * Creates a plane polygonal mesh. By default, this is a disc
  25789. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25790. * * 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
  25791. * * 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
  25792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25793. * * 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
  25794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25795. * @param name defines the name of the mesh
  25796. * @param options defines the options used to create the mesh
  25797. * @param scene defines the hosting scene
  25798. * @returns the plane polygonal mesh
  25799. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25800. */
  25801. static CreateDisc(name: string, options: {
  25802. radius?: number;
  25803. tessellation?: number;
  25804. arc?: number;
  25805. updatable?: boolean;
  25806. sideOrientation?: number;
  25807. frontUVs?: Vector4;
  25808. backUVs?: Vector4;
  25809. }, scene?: Nullable<Scene>): Mesh;
  25810. }
  25811. }
  25812. declare module BABYLON {
  25813. /**
  25814. * This represents all the required information to add a fresnel effect on a material:
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25816. */
  25817. export class FresnelParameters {
  25818. private _isEnabled;
  25819. /**
  25820. * Define if the fresnel effect is enable or not.
  25821. */
  25822. get isEnabled(): boolean;
  25823. set isEnabled(value: boolean);
  25824. /**
  25825. * Define the color used on edges (grazing angle)
  25826. */
  25827. leftColor: Color3;
  25828. /**
  25829. * Define the color used on center
  25830. */
  25831. rightColor: Color3;
  25832. /**
  25833. * Define bias applied to computed fresnel term
  25834. */
  25835. bias: number;
  25836. /**
  25837. * Defined the power exponent applied to fresnel term
  25838. */
  25839. power: number;
  25840. /**
  25841. * Clones the current fresnel and its valuues
  25842. * @returns a clone fresnel configuration
  25843. */
  25844. clone(): FresnelParameters;
  25845. /**
  25846. * Serializes the current fresnel parameters to a JSON representation.
  25847. * @return the JSON serialization
  25848. */
  25849. serialize(): any;
  25850. /**
  25851. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25852. * @param parsedFresnelParameters Define the JSON representation
  25853. * @returns the parsed parameters
  25854. */
  25855. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25856. }
  25857. }
  25858. declare module BABYLON {
  25859. /**
  25860. * Base class of materials working in push mode in babylon JS
  25861. * @hidden
  25862. */
  25863. export class PushMaterial extends Material {
  25864. protected _activeEffect: Effect;
  25865. protected _normalMatrix: Matrix;
  25866. /**
  25867. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25868. * This means that the material can keep using a previous shader while a new one is being compiled.
  25869. * This is mostly used when shader parallel compilation is supported (true by default)
  25870. */
  25871. allowShaderHotSwapping: boolean;
  25872. constructor(name: string, scene: Scene);
  25873. getEffect(): Effect;
  25874. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25875. /**
  25876. * Binds the given world matrix to the active effect
  25877. *
  25878. * @param world the matrix to bind
  25879. */
  25880. bindOnlyWorldMatrix(world: Matrix): void;
  25881. /**
  25882. * Binds the given normal matrix to the active effect
  25883. *
  25884. * @param normalMatrix the matrix to bind
  25885. */
  25886. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25887. bind(world: Matrix, mesh?: Mesh): void;
  25888. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25889. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25890. }
  25891. }
  25892. declare module BABYLON {
  25893. /**
  25894. * This groups all the flags used to control the materials channel.
  25895. */
  25896. export class MaterialFlags {
  25897. private static _DiffuseTextureEnabled;
  25898. /**
  25899. * Are diffuse textures enabled in the application.
  25900. */
  25901. static get DiffuseTextureEnabled(): boolean;
  25902. static set DiffuseTextureEnabled(value: boolean);
  25903. private static _AmbientTextureEnabled;
  25904. /**
  25905. * Are ambient textures enabled in the application.
  25906. */
  25907. static get AmbientTextureEnabled(): boolean;
  25908. static set AmbientTextureEnabled(value: boolean);
  25909. private static _OpacityTextureEnabled;
  25910. /**
  25911. * Are opacity textures enabled in the application.
  25912. */
  25913. static get OpacityTextureEnabled(): boolean;
  25914. static set OpacityTextureEnabled(value: boolean);
  25915. private static _ReflectionTextureEnabled;
  25916. /**
  25917. * Are reflection textures enabled in the application.
  25918. */
  25919. static get ReflectionTextureEnabled(): boolean;
  25920. static set ReflectionTextureEnabled(value: boolean);
  25921. private static _EmissiveTextureEnabled;
  25922. /**
  25923. * Are emissive textures enabled in the application.
  25924. */
  25925. static get EmissiveTextureEnabled(): boolean;
  25926. static set EmissiveTextureEnabled(value: boolean);
  25927. private static _SpecularTextureEnabled;
  25928. /**
  25929. * Are specular textures enabled in the application.
  25930. */
  25931. static get SpecularTextureEnabled(): boolean;
  25932. static set SpecularTextureEnabled(value: boolean);
  25933. private static _BumpTextureEnabled;
  25934. /**
  25935. * Are bump textures enabled in the application.
  25936. */
  25937. static get BumpTextureEnabled(): boolean;
  25938. static set BumpTextureEnabled(value: boolean);
  25939. private static _LightmapTextureEnabled;
  25940. /**
  25941. * Are lightmap textures enabled in the application.
  25942. */
  25943. static get LightmapTextureEnabled(): boolean;
  25944. static set LightmapTextureEnabled(value: boolean);
  25945. private static _RefractionTextureEnabled;
  25946. /**
  25947. * Are refraction textures enabled in the application.
  25948. */
  25949. static get RefractionTextureEnabled(): boolean;
  25950. static set RefractionTextureEnabled(value: boolean);
  25951. private static _ColorGradingTextureEnabled;
  25952. /**
  25953. * Are color grading textures enabled in the application.
  25954. */
  25955. static get ColorGradingTextureEnabled(): boolean;
  25956. static set ColorGradingTextureEnabled(value: boolean);
  25957. private static _FresnelEnabled;
  25958. /**
  25959. * Are fresnels enabled in the application.
  25960. */
  25961. static get FresnelEnabled(): boolean;
  25962. static set FresnelEnabled(value: boolean);
  25963. private static _ClearCoatTextureEnabled;
  25964. /**
  25965. * Are clear coat textures enabled in the application.
  25966. */
  25967. static get ClearCoatTextureEnabled(): boolean;
  25968. static set ClearCoatTextureEnabled(value: boolean);
  25969. private static _ClearCoatBumpTextureEnabled;
  25970. /**
  25971. * Are clear coat bump textures enabled in the application.
  25972. */
  25973. static get ClearCoatBumpTextureEnabled(): boolean;
  25974. static set ClearCoatBumpTextureEnabled(value: boolean);
  25975. private static _ClearCoatTintTextureEnabled;
  25976. /**
  25977. * Are clear coat tint textures enabled in the application.
  25978. */
  25979. static get ClearCoatTintTextureEnabled(): boolean;
  25980. static set ClearCoatTintTextureEnabled(value: boolean);
  25981. private static _SheenTextureEnabled;
  25982. /**
  25983. * Are sheen textures enabled in the application.
  25984. */
  25985. static get SheenTextureEnabled(): boolean;
  25986. static set SheenTextureEnabled(value: boolean);
  25987. private static _AnisotropicTextureEnabled;
  25988. /**
  25989. * Are anisotropic textures enabled in the application.
  25990. */
  25991. static get AnisotropicTextureEnabled(): boolean;
  25992. static set AnisotropicTextureEnabled(value: boolean);
  25993. private static _ThicknessTextureEnabled;
  25994. /**
  25995. * Are thickness textures enabled in the application.
  25996. */
  25997. static get ThicknessTextureEnabled(): boolean;
  25998. static set ThicknessTextureEnabled(value: boolean);
  25999. }
  26000. }
  26001. declare module BABYLON {
  26002. /** @hidden */
  26003. export var defaultFragmentDeclaration: {
  26004. name: string;
  26005. shader: string;
  26006. };
  26007. }
  26008. declare module BABYLON {
  26009. /** @hidden */
  26010. export var defaultUboDeclaration: {
  26011. name: string;
  26012. shader: string;
  26013. };
  26014. }
  26015. declare module BABYLON {
  26016. /** @hidden */
  26017. export var lightFragmentDeclaration: {
  26018. name: string;
  26019. shader: string;
  26020. };
  26021. }
  26022. declare module BABYLON {
  26023. /** @hidden */
  26024. export var lightUboDeclaration: {
  26025. name: string;
  26026. shader: string;
  26027. };
  26028. }
  26029. declare module BABYLON {
  26030. /** @hidden */
  26031. export var lightsFragmentFunctions: {
  26032. name: string;
  26033. shader: string;
  26034. };
  26035. }
  26036. declare module BABYLON {
  26037. /** @hidden */
  26038. export var shadowsFragmentFunctions: {
  26039. name: string;
  26040. shader: string;
  26041. };
  26042. }
  26043. declare module BABYLON {
  26044. /** @hidden */
  26045. export var fresnelFunction: {
  26046. name: string;
  26047. shader: string;
  26048. };
  26049. }
  26050. declare module BABYLON {
  26051. /** @hidden */
  26052. export var reflectionFunction: {
  26053. name: string;
  26054. shader: string;
  26055. };
  26056. }
  26057. declare module BABYLON {
  26058. /** @hidden */
  26059. export var bumpFragmentFunctions: {
  26060. name: string;
  26061. shader: string;
  26062. };
  26063. }
  26064. declare module BABYLON {
  26065. /** @hidden */
  26066. export var logDepthDeclaration: {
  26067. name: string;
  26068. shader: string;
  26069. };
  26070. }
  26071. declare module BABYLON {
  26072. /** @hidden */
  26073. export var bumpFragment: {
  26074. name: string;
  26075. shader: string;
  26076. };
  26077. }
  26078. declare module BABYLON {
  26079. /** @hidden */
  26080. export var depthPrePass: {
  26081. name: string;
  26082. shader: string;
  26083. };
  26084. }
  26085. declare module BABYLON {
  26086. /** @hidden */
  26087. export var lightFragment: {
  26088. name: string;
  26089. shader: string;
  26090. };
  26091. }
  26092. declare module BABYLON {
  26093. /** @hidden */
  26094. export var logDepthFragment: {
  26095. name: string;
  26096. shader: string;
  26097. };
  26098. }
  26099. declare module BABYLON {
  26100. /** @hidden */
  26101. export var defaultPixelShader: {
  26102. name: string;
  26103. shader: string;
  26104. };
  26105. }
  26106. declare module BABYLON {
  26107. /** @hidden */
  26108. export var defaultVertexDeclaration: {
  26109. name: string;
  26110. shader: string;
  26111. };
  26112. }
  26113. declare module BABYLON {
  26114. /** @hidden */
  26115. export var bumpVertexDeclaration: {
  26116. name: string;
  26117. shader: string;
  26118. };
  26119. }
  26120. declare module BABYLON {
  26121. /** @hidden */
  26122. export var bumpVertex: {
  26123. name: string;
  26124. shader: string;
  26125. };
  26126. }
  26127. declare module BABYLON {
  26128. /** @hidden */
  26129. export var fogVertex: {
  26130. name: string;
  26131. shader: string;
  26132. };
  26133. }
  26134. declare module BABYLON {
  26135. /** @hidden */
  26136. export var shadowsVertex: {
  26137. name: string;
  26138. shader: string;
  26139. };
  26140. }
  26141. declare module BABYLON {
  26142. /** @hidden */
  26143. export var pointCloudVertex: {
  26144. name: string;
  26145. shader: string;
  26146. };
  26147. }
  26148. declare module BABYLON {
  26149. /** @hidden */
  26150. export var logDepthVertex: {
  26151. name: string;
  26152. shader: string;
  26153. };
  26154. }
  26155. declare module BABYLON {
  26156. /** @hidden */
  26157. export var defaultVertexShader: {
  26158. name: string;
  26159. shader: string;
  26160. };
  26161. }
  26162. declare module BABYLON {
  26163. /** @hidden */
  26164. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26165. MAINUV1: boolean;
  26166. MAINUV2: boolean;
  26167. DIFFUSE: boolean;
  26168. DIFFUSEDIRECTUV: number;
  26169. AMBIENT: boolean;
  26170. AMBIENTDIRECTUV: number;
  26171. OPACITY: boolean;
  26172. OPACITYDIRECTUV: number;
  26173. OPACITYRGB: boolean;
  26174. REFLECTION: boolean;
  26175. EMISSIVE: boolean;
  26176. EMISSIVEDIRECTUV: number;
  26177. SPECULAR: boolean;
  26178. SPECULARDIRECTUV: number;
  26179. BUMP: boolean;
  26180. BUMPDIRECTUV: number;
  26181. PARALLAX: boolean;
  26182. PARALLAXOCCLUSION: boolean;
  26183. SPECULAROVERALPHA: boolean;
  26184. CLIPPLANE: boolean;
  26185. CLIPPLANE2: boolean;
  26186. CLIPPLANE3: boolean;
  26187. CLIPPLANE4: boolean;
  26188. CLIPPLANE5: boolean;
  26189. CLIPPLANE6: boolean;
  26190. ALPHATEST: boolean;
  26191. DEPTHPREPASS: boolean;
  26192. ALPHAFROMDIFFUSE: boolean;
  26193. POINTSIZE: boolean;
  26194. FOG: boolean;
  26195. SPECULARTERM: boolean;
  26196. DIFFUSEFRESNEL: boolean;
  26197. OPACITYFRESNEL: boolean;
  26198. REFLECTIONFRESNEL: boolean;
  26199. REFRACTIONFRESNEL: boolean;
  26200. EMISSIVEFRESNEL: boolean;
  26201. FRESNEL: boolean;
  26202. NORMAL: boolean;
  26203. UV1: boolean;
  26204. UV2: boolean;
  26205. VERTEXCOLOR: boolean;
  26206. VERTEXALPHA: boolean;
  26207. NUM_BONE_INFLUENCERS: number;
  26208. BonesPerMesh: number;
  26209. BONETEXTURE: boolean;
  26210. INSTANCES: boolean;
  26211. GLOSSINESS: boolean;
  26212. ROUGHNESS: boolean;
  26213. EMISSIVEASILLUMINATION: boolean;
  26214. LINKEMISSIVEWITHDIFFUSE: boolean;
  26215. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26216. LIGHTMAP: boolean;
  26217. LIGHTMAPDIRECTUV: number;
  26218. OBJECTSPACE_NORMALMAP: boolean;
  26219. USELIGHTMAPASSHADOWMAP: boolean;
  26220. REFLECTIONMAP_3D: boolean;
  26221. REFLECTIONMAP_SPHERICAL: boolean;
  26222. REFLECTIONMAP_PLANAR: boolean;
  26223. REFLECTIONMAP_CUBIC: boolean;
  26224. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26225. REFLECTIONMAP_PROJECTION: boolean;
  26226. REFLECTIONMAP_SKYBOX: boolean;
  26227. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26228. REFLECTIONMAP_EXPLICIT: boolean;
  26229. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26230. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26231. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26232. INVERTCUBICMAP: boolean;
  26233. LOGARITHMICDEPTH: boolean;
  26234. REFRACTION: boolean;
  26235. REFRACTIONMAP_3D: boolean;
  26236. REFLECTIONOVERALPHA: boolean;
  26237. TWOSIDEDLIGHTING: boolean;
  26238. SHADOWFLOAT: boolean;
  26239. MORPHTARGETS: boolean;
  26240. MORPHTARGETS_NORMAL: boolean;
  26241. MORPHTARGETS_TANGENT: boolean;
  26242. MORPHTARGETS_UV: boolean;
  26243. NUM_MORPH_INFLUENCERS: number;
  26244. NONUNIFORMSCALING: boolean;
  26245. PREMULTIPLYALPHA: boolean;
  26246. IMAGEPROCESSING: boolean;
  26247. VIGNETTE: boolean;
  26248. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26249. VIGNETTEBLENDMODEOPAQUE: boolean;
  26250. TONEMAPPING: boolean;
  26251. TONEMAPPING_ACES: boolean;
  26252. CONTRAST: boolean;
  26253. COLORCURVES: boolean;
  26254. COLORGRADING: boolean;
  26255. COLORGRADING3D: boolean;
  26256. SAMPLER3DGREENDEPTH: boolean;
  26257. SAMPLER3DBGRMAP: boolean;
  26258. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26259. MULTIVIEW: boolean;
  26260. /**
  26261. * If the reflection texture on this material is in linear color space
  26262. * @hidden
  26263. */
  26264. IS_REFLECTION_LINEAR: boolean;
  26265. /**
  26266. * If the refraction texture on this material is in linear color space
  26267. * @hidden
  26268. */
  26269. IS_REFRACTION_LINEAR: boolean;
  26270. EXPOSURE: boolean;
  26271. constructor();
  26272. setReflectionMode(modeToEnable: string): void;
  26273. }
  26274. /**
  26275. * This is the default material used in Babylon. It is the best trade off between quality
  26276. * and performances.
  26277. * @see http://doc.babylonjs.com/babylon101/materials
  26278. */
  26279. export class StandardMaterial extends PushMaterial {
  26280. private _diffuseTexture;
  26281. /**
  26282. * The basic texture of the material as viewed under a light.
  26283. */
  26284. diffuseTexture: Nullable<BaseTexture>;
  26285. private _ambientTexture;
  26286. /**
  26287. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26288. */
  26289. ambientTexture: Nullable<BaseTexture>;
  26290. private _opacityTexture;
  26291. /**
  26292. * Define the transparency of the material from a texture.
  26293. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26294. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26295. */
  26296. opacityTexture: Nullable<BaseTexture>;
  26297. private _reflectionTexture;
  26298. /**
  26299. * Define the texture used to display the reflection.
  26300. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26301. */
  26302. reflectionTexture: Nullable<BaseTexture>;
  26303. private _emissiveTexture;
  26304. /**
  26305. * Define texture of the material as if self lit.
  26306. * This will be mixed in the final result even in the absence of light.
  26307. */
  26308. emissiveTexture: Nullable<BaseTexture>;
  26309. private _specularTexture;
  26310. /**
  26311. * Define how the color and intensity of the highlight given by the light in the material.
  26312. */
  26313. specularTexture: Nullable<BaseTexture>;
  26314. private _bumpTexture;
  26315. /**
  26316. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26317. * 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.
  26318. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26319. */
  26320. bumpTexture: Nullable<BaseTexture>;
  26321. private _lightmapTexture;
  26322. /**
  26323. * Complex lighting can be computationally expensive to compute at runtime.
  26324. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26325. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26326. */
  26327. lightmapTexture: Nullable<BaseTexture>;
  26328. private _refractionTexture;
  26329. /**
  26330. * Define the texture used to display the refraction.
  26331. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26332. */
  26333. refractionTexture: Nullable<BaseTexture>;
  26334. /**
  26335. * The color of the material lit by the environmental background lighting.
  26336. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26337. */
  26338. ambientColor: Color3;
  26339. /**
  26340. * The basic color of the material as viewed under a light.
  26341. */
  26342. diffuseColor: Color3;
  26343. /**
  26344. * Define how the color and intensity of the highlight given by the light in the material.
  26345. */
  26346. specularColor: Color3;
  26347. /**
  26348. * Define the color of the material as if self lit.
  26349. * This will be mixed in the final result even in the absence of light.
  26350. */
  26351. emissiveColor: Color3;
  26352. /**
  26353. * Defines how sharp are the highlights in the material.
  26354. * The bigger the value the sharper giving a more glossy feeling to the result.
  26355. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26356. */
  26357. specularPower: number;
  26358. private _useAlphaFromDiffuseTexture;
  26359. /**
  26360. * Does the transparency come from the diffuse texture alpha channel.
  26361. */
  26362. useAlphaFromDiffuseTexture: boolean;
  26363. private _useEmissiveAsIllumination;
  26364. /**
  26365. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26366. */
  26367. useEmissiveAsIllumination: boolean;
  26368. private _linkEmissiveWithDiffuse;
  26369. /**
  26370. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26371. * the emissive level when the final color is close to one.
  26372. */
  26373. linkEmissiveWithDiffuse: boolean;
  26374. private _useSpecularOverAlpha;
  26375. /**
  26376. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26377. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26378. */
  26379. useSpecularOverAlpha: boolean;
  26380. private _useReflectionOverAlpha;
  26381. /**
  26382. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26383. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26384. */
  26385. useReflectionOverAlpha: boolean;
  26386. private _disableLighting;
  26387. /**
  26388. * Does lights from the scene impacts this material.
  26389. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26390. */
  26391. disableLighting: boolean;
  26392. private _useObjectSpaceNormalMap;
  26393. /**
  26394. * Allows using an object space normal map (instead of tangent space).
  26395. */
  26396. useObjectSpaceNormalMap: boolean;
  26397. private _useParallax;
  26398. /**
  26399. * Is parallax enabled or not.
  26400. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26401. */
  26402. useParallax: boolean;
  26403. private _useParallaxOcclusion;
  26404. /**
  26405. * Is parallax occlusion enabled or not.
  26406. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26407. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26408. */
  26409. useParallaxOcclusion: boolean;
  26410. /**
  26411. * 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.
  26412. */
  26413. parallaxScaleBias: number;
  26414. private _roughness;
  26415. /**
  26416. * Helps to define how blurry the reflections should appears in the material.
  26417. */
  26418. roughness: number;
  26419. /**
  26420. * In case of refraction, define the value of the index of refraction.
  26421. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26422. */
  26423. indexOfRefraction: number;
  26424. /**
  26425. * Invert the refraction texture alongside the y axis.
  26426. * It can be useful with procedural textures or probe for instance.
  26427. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26428. */
  26429. invertRefractionY: boolean;
  26430. /**
  26431. * Defines the alpha limits in alpha test mode.
  26432. */
  26433. alphaCutOff: number;
  26434. private _useLightmapAsShadowmap;
  26435. /**
  26436. * In case of light mapping, define whether the map contains light or shadow informations.
  26437. */
  26438. useLightmapAsShadowmap: boolean;
  26439. private _diffuseFresnelParameters;
  26440. /**
  26441. * Define the diffuse fresnel parameters of the material.
  26442. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26443. */
  26444. diffuseFresnelParameters: FresnelParameters;
  26445. private _opacityFresnelParameters;
  26446. /**
  26447. * Define the opacity fresnel parameters of the material.
  26448. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26449. */
  26450. opacityFresnelParameters: FresnelParameters;
  26451. private _reflectionFresnelParameters;
  26452. /**
  26453. * Define the reflection fresnel parameters of the material.
  26454. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26455. */
  26456. reflectionFresnelParameters: FresnelParameters;
  26457. private _refractionFresnelParameters;
  26458. /**
  26459. * Define the refraction fresnel parameters of the material.
  26460. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26461. */
  26462. refractionFresnelParameters: FresnelParameters;
  26463. private _emissiveFresnelParameters;
  26464. /**
  26465. * Define the emissive fresnel parameters of the material.
  26466. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26467. */
  26468. emissiveFresnelParameters: FresnelParameters;
  26469. private _useReflectionFresnelFromSpecular;
  26470. /**
  26471. * If true automatically deducts the fresnels values from the material specularity.
  26472. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26473. */
  26474. useReflectionFresnelFromSpecular: boolean;
  26475. private _useGlossinessFromSpecularMapAlpha;
  26476. /**
  26477. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26478. */
  26479. useGlossinessFromSpecularMapAlpha: boolean;
  26480. private _maxSimultaneousLights;
  26481. /**
  26482. * Defines the maximum number of lights that can be used in the material
  26483. */
  26484. maxSimultaneousLights: number;
  26485. private _invertNormalMapX;
  26486. /**
  26487. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26488. */
  26489. invertNormalMapX: boolean;
  26490. private _invertNormalMapY;
  26491. /**
  26492. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26493. */
  26494. invertNormalMapY: boolean;
  26495. private _twoSidedLighting;
  26496. /**
  26497. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26498. */
  26499. twoSidedLighting: boolean;
  26500. /**
  26501. * Default configuration related to image processing available in the standard Material.
  26502. */
  26503. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26504. /**
  26505. * Gets the image processing configuration used either in this material.
  26506. */
  26507. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26508. /**
  26509. * Sets the Default image processing configuration used either in the this material.
  26510. *
  26511. * If sets to null, the scene one is in use.
  26512. */
  26513. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26514. /**
  26515. * Keep track of the image processing observer to allow dispose and replace.
  26516. */
  26517. private _imageProcessingObserver;
  26518. /**
  26519. * Attaches a new image processing configuration to the Standard Material.
  26520. * @param configuration
  26521. */
  26522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26523. /**
  26524. * Gets wether the color curves effect is enabled.
  26525. */
  26526. get cameraColorCurvesEnabled(): boolean;
  26527. /**
  26528. * Sets wether the color curves effect is enabled.
  26529. */
  26530. set cameraColorCurvesEnabled(value: boolean);
  26531. /**
  26532. * Gets wether the color grading effect is enabled.
  26533. */
  26534. get cameraColorGradingEnabled(): boolean;
  26535. /**
  26536. * Gets wether the color grading effect is enabled.
  26537. */
  26538. set cameraColorGradingEnabled(value: boolean);
  26539. /**
  26540. * Gets wether tonemapping is enabled or not.
  26541. */
  26542. get cameraToneMappingEnabled(): boolean;
  26543. /**
  26544. * Sets wether tonemapping is enabled or not
  26545. */
  26546. set cameraToneMappingEnabled(value: boolean);
  26547. /**
  26548. * The camera exposure used on this material.
  26549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26550. * This corresponds to a photographic exposure.
  26551. */
  26552. get cameraExposure(): number;
  26553. /**
  26554. * The camera exposure used on this material.
  26555. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26556. * This corresponds to a photographic exposure.
  26557. */
  26558. set cameraExposure(value: number);
  26559. /**
  26560. * Gets The camera contrast used on this material.
  26561. */
  26562. get cameraContrast(): number;
  26563. /**
  26564. * Sets The camera contrast used on this material.
  26565. */
  26566. set cameraContrast(value: number);
  26567. /**
  26568. * Gets the Color Grading 2D Lookup Texture.
  26569. */
  26570. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26571. /**
  26572. * Sets the Color Grading 2D Lookup Texture.
  26573. */
  26574. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26575. /**
  26576. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26577. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26578. * 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;
  26579. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26580. */
  26581. get cameraColorCurves(): Nullable<ColorCurves>;
  26582. /**
  26583. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26584. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26585. * 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;
  26586. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26587. */
  26588. set cameraColorCurves(value: Nullable<ColorCurves>);
  26589. /**
  26590. * Custom callback helping to override the default shader used in the material.
  26591. */
  26592. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26593. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26594. protected _worldViewProjectionMatrix: Matrix;
  26595. protected _globalAmbientColor: Color3;
  26596. protected _useLogarithmicDepth: boolean;
  26597. protected _rebuildInParallel: boolean;
  26598. /**
  26599. * Instantiates a new standard material.
  26600. * This is the default material used in Babylon. It is the best trade off between quality
  26601. * and performances.
  26602. * @see http://doc.babylonjs.com/babylon101/materials
  26603. * @param name Define the name of the material in the scene
  26604. * @param scene Define the scene the material belong to
  26605. */
  26606. constructor(name: string, scene: Scene);
  26607. /**
  26608. * Gets a boolean indicating that current material needs to register RTT
  26609. */
  26610. get hasRenderTargetTextures(): boolean;
  26611. /**
  26612. * Gets the current class name of the material e.g. "StandardMaterial"
  26613. * Mainly use in serialization.
  26614. * @returns the class name
  26615. */
  26616. getClassName(): string;
  26617. /**
  26618. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26619. * You can try switching to logarithmic depth.
  26620. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26621. */
  26622. get useLogarithmicDepth(): boolean;
  26623. set useLogarithmicDepth(value: boolean);
  26624. /**
  26625. * Specifies if the material will require alpha blending
  26626. * @returns a boolean specifying if alpha blending is needed
  26627. */
  26628. needAlphaBlending(): boolean;
  26629. /**
  26630. * Specifies if this material should be rendered in alpha test mode
  26631. * @returns a boolean specifying if an alpha test is needed.
  26632. */
  26633. needAlphaTesting(): boolean;
  26634. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26635. /**
  26636. * Get the texture used for alpha test purpose.
  26637. * @returns the diffuse texture in case of the standard material.
  26638. */
  26639. getAlphaTestTexture(): Nullable<BaseTexture>;
  26640. /**
  26641. * Get if the submesh is ready to be used and all its information available.
  26642. * Child classes can use it to update shaders
  26643. * @param mesh defines the mesh to check
  26644. * @param subMesh defines which submesh to check
  26645. * @param useInstances specifies that instances should be used
  26646. * @returns a boolean indicating that the submesh is ready or not
  26647. */
  26648. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26649. /**
  26650. * Builds the material UBO layouts.
  26651. * Used internally during the effect preparation.
  26652. */
  26653. buildUniformLayout(): void;
  26654. /**
  26655. * Unbinds the material from the mesh
  26656. */
  26657. unbind(): void;
  26658. /**
  26659. * Binds the submesh to this material by preparing the effect and shader to draw
  26660. * @param world defines the world transformation matrix
  26661. * @param mesh defines the mesh containing the submesh
  26662. * @param subMesh defines the submesh to bind the material to
  26663. */
  26664. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26665. /**
  26666. * Get the list of animatables in the material.
  26667. * @returns the list of animatables object used in the material
  26668. */
  26669. getAnimatables(): IAnimatable[];
  26670. /**
  26671. * Gets the active textures from the material
  26672. * @returns an array of textures
  26673. */
  26674. getActiveTextures(): BaseTexture[];
  26675. /**
  26676. * Specifies if the material uses a texture
  26677. * @param texture defines the texture to check against the material
  26678. * @returns a boolean specifying if the material uses the texture
  26679. */
  26680. hasTexture(texture: BaseTexture): boolean;
  26681. /**
  26682. * Disposes the material
  26683. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26684. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26685. */
  26686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26687. /**
  26688. * Makes a duplicate of the material, and gives it a new name
  26689. * @param name defines the new name for the duplicated material
  26690. * @returns the cloned material
  26691. */
  26692. clone(name: string): StandardMaterial;
  26693. /**
  26694. * Serializes this material in a JSON representation
  26695. * @returns the serialized material object
  26696. */
  26697. serialize(): any;
  26698. /**
  26699. * Creates a standard material from parsed material data
  26700. * @param source defines the JSON representation of the material
  26701. * @param scene defines the hosting scene
  26702. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26703. * @returns a new standard material
  26704. */
  26705. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26706. /**
  26707. * Are diffuse textures enabled in the application.
  26708. */
  26709. static get DiffuseTextureEnabled(): boolean;
  26710. static set DiffuseTextureEnabled(value: boolean);
  26711. /**
  26712. * Are ambient textures enabled in the application.
  26713. */
  26714. static get AmbientTextureEnabled(): boolean;
  26715. static set AmbientTextureEnabled(value: boolean);
  26716. /**
  26717. * Are opacity textures enabled in the application.
  26718. */
  26719. static get OpacityTextureEnabled(): boolean;
  26720. static set OpacityTextureEnabled(value: boolean);
  26721. /**
  26722. * Are reflection textures enabled in the application.
  26723. */
  26724. static get ReflectionTextureEnabled(): boolean;
  26725. static set ReflectionTextureEnabled(value: boolean);
  26726. /**
  26727. * Are emissive textures enabled in the application.
  26728. */
  26729. static get EmissiveTextureEnabled(): boolean;
  26730. static set EmissiveTextureEnabled(value: boolean);
  26731. /**
  26732. * Are specular textures enabled in the application.
  26733. */
  26734. static get SpecularTextureEnabled(): boolean;
  26735. static set SpecularTextureEnabled(value: boolean);
  26736. /**
  26737. * Are bump textures enabled in the application.
  26738. */
  26739. static get BumpTextureEnabled(): boolean;
  26740. static set BumpTextureEnabled(value: boolean);
  26741. /**
  26742. * Are lightmap textures enabled in the application.
  26743. */
  26744. static get LightmapTextureEnabled(): boolean;
  26745. static set LightmapTextureEnabled(value: boolean);
  26746. /**
  26747. * Are refraction textures enabled in the application.
  26748. */
  26749. static get RefractionTextureEnabled(): boolean;
  26750. static set RefractionTextureEnabled(value: boolean);
  26751. /**
  26752. * Are color grading textures enabled in the application.
  26753. */
  26754. static get ColorGradingTextureEnabled(): boolean;
  26755. static set ColorGradingTextureEnabled(value: boolean);
  26756. /**
  26757. * Are fresnels enabled in the application.
  26758. */
  26759. static get FresnelEnabled(): boolean;
  26760. static set FresnelEnabled(value: boolean);
  26761. }
  26762. }
  26763. declare module BABYLON {
  26764. /**
  26765. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26766. *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.
  26767. * The SPS is also a particle system. It provides some methods to manage the particles.
  26768. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26769. *
  26770. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26771. */
  26772. export class SolidParticleSystem implements IDisposable {
  26773. /**
  26774. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26775. * Example : var p = SPS.particles[i];
  26776. */
  26777. particles: SolidParticle[];
  26778. /**
  26779. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26780. */
  26781. nbParticles: number;
  26782. /**
  26783. * If the particles must ever face the camera (default false). Useful for planar particles.
  26784. */
  26785. billboard: boolean;
  26786. /**
  26787. * Recompute normals when adding a shape
  26788. */
  26789. recomputeNormals: boolean;
  26790. /**
  26791. * This a counter ofr your own usage. It's not set by any SPS functions.
  26792. */
  26793. counter: number;
  26794. /**
  26795. * The SPS name. This name is also given to the underlying mesh.
  26796. */
  26797. name: string;
  26798. /**
  26799. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26800. */
  26801. mesh: Mesh;
  26802. /**
  26803. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26804. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26805. */
  26806. vars: any;
  26807. /**
  26808. * This array is populated when the SPS is set as 'pickable'.
  26809. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26810. * Each element of this array is an object `{idx: int, faceId: int}`.
  26811. * `idx` is the picked particle index in the `SPS.particles` array
  26812. * `faceId` is the picked face index counted within this particle.
  26813. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26814. */
  26815. pickedParticles: {
  26816. idx: number;
  26817. faceId: number;
  26818. }[];
  26819. /**
  26820. * This array is populated when `enableDepthSort` is set to true.
  26821. * Each element of this array is an instance of the class DepthSortedParticle.
  26822. */
  26823. depthSortedParticles: DepthSortedParticle[];
  26824. /**
  26825. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26826. * @hidden
  26827. */
  26828. _bSphereOnly: boolean;
  26829. /**
  26830. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26831. * @hidden
  26832. */
  26833. _bSphereRadiusFactor: number;
  26834. private _scene;
  26835. private _positions;
  26836. private _indices;
  26837. private _normals;
  26838. private _colors;
  26839. private _uvs;
  26840. private _indices32;
  26841. private _positions32;
  26842. private _normals32;
  26843. private _fixedNormal32;
  26844. private _colors32;
  26845. private _uvs32;
  26846. private _index;
  26847. private _updatable;
  26848. private _pickable;
  26849. private _isVisibilityBoxLocked;
  26850. private _alwaysVisible;
  26851. private _depthSort;
  26852. private _expandable;
  26853. private _shapeCounter;
  26854. private _copy;
  26855. private _color;
  26856. private _computeParticleColor;
  26857. private _computeParticleTexture;
  26858. private _computeParticleRotation;
  26859. private _computeParticleVertex;
  26860. private _computeBoundingBox;
  26861. private _depthSortParticles;
  26862. private _camera;
  26863. private _mustUnrotateFixedNormals;
  26864. private _particlesIntersect;
  26865. private _needs32Bits;
  26866. private _isNotBuilt;
  26867. private _lastParticleId;
  26868. private _idxOfId;
  26869. private _multimaterialEnabled;
  26870. private _useModelMaterial;
  26871. private _indicesByMaterial;
  26872. private _materialIndexes;
  26873. private _depthSortFunction;
  26874. private _materialSortFunction;
  26875. private _materials;
  26876. private _multimaterial;
  26877. private _materialIndexesById;
  26878. private _defaultMaterial;
  26879. private _autoUpdateSubMeshes;
  26880. /**
  26881. * Creates a SPS (Solid Particle System) object.
  26882. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26883. * @param scene (Scene) is the scene in which the SPS is added.
  26884. * @param options defines the options of the sps e.g.
  26885. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26886. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26887. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26888. * * 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.
  26889. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26890. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26891. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26892. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26893. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26894. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26895. */
  26896. constructor(name: string, scene: Scene, options?: {
  26897. updatable?: boolean;
  26898. isPickable?: boolean;
  26899. enableDepthSort?: boolean;
  26900. particleIntersection?: boolean;
  26901. boundingSphereOnly?: boolean;
  26902. bSphereRadiusFactor?: number;
  26903. expandable?: boolean;
  26904. useModelMaterial?: boolean;
  26905. enableMultiMaterial?: boolean;
  26906. });
  26907. /**
  26908. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26909. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26910. * @returns the created mesh
  26911. */
  26912. buildMesh(): Mesh;
  26913. /**
  26914. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26915. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26916. * Thus the particles generated from `digest()` have their property `position` set yet.
  26917. * @param mesh ( Mesh ) is the mesh to be digested
  26918. * @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
  26919. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26920. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26921. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26922. * @returns the current SPS
  26923. */
  26924. digest(mesh: Mesh, options?: {
  26925. facetNb?: number;
  26926. number?: number;
  26927. delta?: number;
  26928. storage?: [];
  26929. }): SolidParticleSystem;
  26930. /**
  26931. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26932. * @hidden
  26933. */
  26934. private _unrotateFixedNormals;
  26935. /**
  26936. * Resets the temporary working copy particle
  26937. * @hidden
  26938. */
  26939. private _resetCopy;
  26940. /**
  26941. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26942. * @param p the current index in the positions array to be updated
  26943. * @param ind the current index in the indices array
  26944. * @param shape a Vector3 array, the shape geometry
  26945. * @param positions the positions array to be updated
  26946. * @param meshInd the shape indices array
  26947. * @param indices the indices array to be updated
  26948. * @param meshUV the shape uv array
  26949. * @param uvs the uv array to be updated
  26950. * @param meshCol the shape color array
  26951. * @param colors the color array to be updated
  26952. * @param meshNor the shape normals array
  26953. * @param normals the normals array to be updated
  26954. * @param idx the particle index
  26955. * @param idxInShape the particle index in its shape
  26956. * @param options the addShape() method passed options
  26957. * @model the particle model
  26958. * @hidden
  26959. */
  26960. private _meshBuilder;
  26961. /**
  26962. * Returns a shape Vector3 array from positions float array
  26963. * @param positions float array
  26964. * @returns a vector3 array
  26965. * @hidden
  26966. */
  26967. private _posToShape;
  26968. /**
  26969. * Returns a shapeUV array from a float uvs (array deep copy)
  26970. * @param uvs as a float array
  26971. * @returns a shapeUV array
  26972. * @hidden
  26973. */
  26974. private _uvsToShapeUV;
  26975. /**
  26976. * Adds a new particle object in the particles array
  26977. * @param idx particle index in particles array
  26978. * @param id particle id
  26979. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26980. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26981. * @param model particle ModelShape object
  26982. * @param shapeId model shape identifier
  26983. * @param idxInShape index of the particle in the current model
  26984. * @param bInfo model bounding info object
  26985. * @param storage target storage array, if any
  26986. * @hidden
  26987. */
  26988. private _addParticle;
  26989. /**
  26990. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26991. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26992. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26993. * @param nb (positive integer) the number of particles to be created from this model
  26994. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26995. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26996. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26997. * @returns the number of shapes in the system
  26998. */
  26999. addShape(mesh: Mesh, nb: number, options?: {
  27000. positionFunction?: any;
  27001. vertexFunction?: any;
  27002. storage?: [];
  27003. }): number;
  27004. /**
  27005. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27006. * @hidden
  27007. */
  27008. private _rebuildParticle;
  27009. /**
  27010. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27011. * @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.
  27012. * @returns the SPS.
  27013. */
  27014. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27015. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27016. * Returns an array with the removed particles.
  27017. * 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.
  27018. * The SPS can't be empty so at least one particle needs to remain in place.
  27019. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27020. * @param start index of the first particle to remove
  27021. * @param end index of the last particle to remove (included)
  27022. * @returns an array populated with the removed particles
  27023. */
  27024. removeParticles(start: number, end: number): SolidParticle[];
  27025. /**
  27026. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27027. * @param solidParticleArray an array populated with Solid Particles objects
  27028. * @returns the SPS
  27029. */
  27030. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27031. /**
  27032. * Creates a new particle and modifies the SPS mesh geometry :
  27033. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27034. * - calls _addParticle() to populate the particle array
  27035. * factorized code from addShape() and insertParticlesFromArray()
  27036. * @param idx particle index in the particles array
  27037. * @param i particle index in its shape
  27038. * @param modelShape particle ModelShape object
  27039. * @param shape shape vertex array
  27040. * @param meshInd shape indices array
  27041. * @param meshUV shape uv array
  27042. * @param meshCol shape color array
  27043. * @param meshNor shape normals array
  27044. * @param bbInfo shape bounding info
  27045. * @param storage target particle storage
  27046. * @options addShape() passed options
  27047. * @hidden
  27048. */
  27049. private _insertNewParticle;
  27050. /**
  27051. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27052. * This method calls `updateParticle()` for each particle of the SPS.
  27053. * For an animated SPS, it is usually called within the render loop.
  27054. * 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.
  27055. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27056. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27057. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27058. * @returns the SPS.
  27059. */
  27060. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27061. /**
  27062. * Disposes the SPS.
  27063. */
  27064. dispose(): void;
  27065. /**
  27066. * Returns a SolidParticle object from its identifier : particle.id
  27067. * @param id (integer) the particle Id
  27068. * @returns the searched particle or null if not found in the SPS.
  27069. */
  27070. getParticleById(id: number): Nullable<SolidParticle>;
  27071. /**
  27072. * Returns a new array populated with the particles having the passed shapeId.
  27073. * @param shapeId (integer) the shape identifier
  27074. * @returns a new solid particle array
  27075. */
  27076. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27077. /**
  27078. * Populates the passed array "ref" with the particles having the passed shapeId.
  27079. * @param shapeId the shape identifier
  27080. * @returns the SPS
  27081. * @param ref
  27082. */
  27083. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27084. /**
  27085. * Computes the required SubMeshes according the materials assigned to the particles.
  27086. * @returns the solid particle system.
  27087. * Does nothing if called before the SPS mesh is built.
  27088. */
  27089. computeSubMeshes(): SolidParticleSystem;
  27090. /**
  27091. * Sorts the solid particles by material when MultiMaterial is enabled.
  27092. * Updates the indices32 array.
  27093. * Updates the indicesByMaterial array.
  27094. * Updates the mesh indices array.
  27095. * @returns the SPS
  27096. * @hidden
  27097. */
  27098. private _sortParticlesByMaterial;
  27099. /**
  27100. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27101. * @hidden
  27102. */
  27103. private _setMaterialIndexesById;
  27104. /**
  27105. * Returns an array with unique values of Materials from the passed array
  27106. * @param array the material array to be checked and filtered
  27107. * @hidden
  27108. */
  27109. private _filterUniqueMaterialId;
  27110. /**
  27111. * Sets a new Standard Material as _defaultMaterial if not already set.
  27112. * @hidden
  27113. */
  27114. private _setDefaultMaterial;
  27115. /**
  27116. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27117. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27118. * @returns the SPS.
  27119. */
  27120. refreshVisibleSize(): SolidParticleSystem;
  27121. /**
  27122. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27123. * @param size the size (float) of the visibility box
  27124. * note : this doesn't lock the SPS mesh bounding box.
  27125. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27126. */
  27127. setVisibilityBox(size: number): void;
  27128. /**
  27129. * Gets whether the SPS as always visible or not
  27130. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27131. */
  27132. get isAlwaysVisible(): boolean;
  27133. /**
  27134. * Sets the SPS as always visible or not
  27135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27136. */
  27137. set isAlwaysVisible(val: boolean);
  27138. /**
  27139. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27140. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27141. */
  27142. set isVisibilityBoxLocked(val: boolean);
  27143. /**
  27144. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27145. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27146. */
  27147. get isVisibilityBoxLocked(): boolean;
  27148. /**
  27149. * Tells to `setParticles()` to compute the particle rotations or not.
  27150. * Default value : true. The SPS is faster when it's set to false.
  27151. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27152. */
  27153. set computeParticleRotation(val: boolean);
  27154. /**
  27155. * Tells to `setParticles()` to compute the particle colors or not.
  27156. * Default value : true. The SPS is faster when it's set to false.
  27157. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27158. */
  27159. set computeParticleColor(val: boolean);
  27160. set computeParticleTexture(val: boolean);
  27161. /**
  27162. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27163. * Default value : false. The SPS is faster when it's set to false.
  27164. * Note : the particle custom vertex positions aren't stored values.
  27165. */
  27166. set computeParticleVertex(val: boolean);
  27167. /**
  27168. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27169. */
  27170. set computeBoundingBox(val: boolean);
  27171. /**
  27172. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27173. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27174. * Default : `true`
  27175. */
  27176. set depthSortParticles(val: boolean);
  27177. /**
  27178. * Gets if `setParticles()` computes the particle rotations or not.
  27179. * Default value : true. The SPS is faster when it's set to false.
  27180. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27181. */
  27182. get computeParticleRotation(): boolean;
  27183. /**
  27184. * Gets if `setParticles()` computes the particle colors or not.
  27185. * Default value : true. The SPS is faster when it's set to false.
  27186. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27187. */
  27188. get computeParticleColor(): boolean;
  27189. /**
  27190. * Gets if `setParticles()` computes the particle textures or not.
  27191. * Default value : true. The SPS is faster when it's set to false.
  27192. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27193. */
  27194. get computeParticleTexture(): boolean;
  27195. /**
  27196. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27197. * Default value : false. The SPS is faster when it's set to false.
  27198. * Note : the particle custom vertex positions aren't stored values.
  27199. */
  27200. get computeParticleVertex(): boolean;
  27201. /**
  27202. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27203. */
  27204. get computeBoundingBox(): boolean;
  27205. /**
  27206. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27207. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27208. * Default : `true`
  27209. */
  27210. get depthSortParticles(): boolean;
  27211. /**
  27212. * Gets if the SPS is created as expandable at construction time.
  27213. * Default : `false`
  27214. */
  27215. get expandable(): boolean;
  27216. /**
  27217. * Gets if the SPS supports the Multi Materials
  27218. */
  27219. get multimaterialEnabled(): boolean;
  27220. /**
  27221. * Gets if the SPS uses the model materials for its own multimaterial.
  27222. */
  27223. get useModelMaterial(): boolean;
  27224. /**
  27225. * The SPS used material array.
  27226. */
  27227. get materials(): Material[];
  27228. /**
  27229. * Sets the SPS MultiMaterial from the passed materials.
  27230. * Note : the passed array is internally copied and not used then by reference.
  27231. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27232. */
  27233. setMultiMaterial(materials: Material[]): void;
  27234. /**
  27235. * The SPS computed multimaterial object
  27236. */
  27237. get multimaterial(): MultiMaterial;
  27238. set multimaterial(mm: MultiMaterial);
  27239. /**
  27240. * If the subMeshes must be updated on the next call to setParticles()
  27241. */
  27242. get autoUpdateSubMeshes(): boolean;
  27243. set autoUpdateSubMeshes(val: boolean);
  27244. /**
  27245. * This function does nothing. It may be overwritten to set all the particle first values.
  27246. * The SPS doesn't call this function, you may have to call it by your own.
  27247. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27248. */
  27249. initParticles(): void;
  27250. /**
  27251. * This function does nothing. It may be overwritten to recycle a particle.
  27252. * The SPS doesn't call this function, you may have to call it by your own.
  27253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27254. * @param particle The particle to recycle
  27255. * @returns the recycled particle
  27256. */
  27257. recycleParticle(particle: SolidParticle): SolidParticle;
  27258. /**
  27259. * Updates a particle : this function should be overwritten by the user.
  27260. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27261. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27262. * @example : just set a particle position or velocity and recycle conditions
  27263. * @param particle The particle to update
  27264. * @returns the updated particle
  27265. */
  27266. updateParticle(particle: SolidParticle): SolidParticle;
  27267. /**
  27268. * Updates a vertex of a particle : it can be overwritten by the user.
  27269. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27270. * @param particle the current particle
  27271. * @param vertex the current index of the current particle
  27272. * @param pt the index of the current vertex in the particle shape
  27273. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27274. * @example : just set a vertex particle position
  27275. * @returns the updated vertex
  27276. */
  27277. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27278. /**
  27279. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27280. * This does nothing and may be overwritten by the user.
  27281. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27282. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27283. * @param update the boolean update value actually passed to setParticles()
  27284. */
  27285. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27286. /**
  27287. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27288. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27295. }
  27296. }
  27297. declare module BABYLON {
  27298. /**
  27299. * Represents one particle of a solid particle system.
  27300. */
  27301. export class SolidParticle {
  27302. /**
  27303. * particle global index
  27304. */
  27305. idx: number;
  27306. /**
  27307. * particle identifier
  27308. */
  27309. id: number;
  27310. /**
  27311. * The color of the particle
  27312. */
  27313. color: Nullable<Color4>;
  27314. /**
  27315. * The world space position of the particle.
  27316. */
  27317. position: Vector3;
  27318. /**
  27319. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27320. */
  27321. rotation: Vector3;
  27322. /**
  27323. * The world space rotation quaternion of the particle.
  27324. */
  27325. rotationQuaternion: Nullable<Quaternion>;
  27326. /**
  27327. * The scaling of the particle.
  27328. */
  27329. scaling: Vector3;
  27330. /**
  27331. * The uvs of the particle.
  27332. */
  27333. uvs: Vector4;
  27334. /**
  27335. * The current speed of the particle.
  27336. */
  27337. velocity: Vector3;
  27338. /**
  27339. * The pivot point in the particle local space.
  27340. */
  27341. pivot: Vector3;
  27342. /**
  27343. * Must the particle be translated from its pivot point in its local space ?
  27344. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27345. * Default : false
  27346. */
  27347. translateFromPivot: boolean;
  27348. /**
  27349. * Is the particle active or not ?
  27350. */
  27351. alive: boolean;
  27352. /**
  27353. * Is the particle visible or not ?
  27354. */
  27355. isVisible: boolean;
  27356. /**
  27357. * Index of this particle in the global "positions" array (Internal use)
  27358. * @hidden
  27359. */
  27360. _pos: number;
  27361. /**
  27362. * @hidden Index of this particle in the global "indices" array (Internal use)
  27363. */
  27364. _ind: number;
  27365. /**
  27366. * @hidden ModelShape of this particle (Internal use)
  27367. */
  27368. _model: ModelShape;
  27369. /**
  27370. * ModelShape id of this particle
  27371. */
  27372. shapeId: number;
  27373. /**
  27374. * Index of the particle in its shape id
  27375. */
  27376. idxInShape: number;
  27377. /**
  27378. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27379. */
  27380. _modelBoundingInfo: BoundingInfo;
  27381. /**
  27382. * @hidden Particle BoundingInfo object (Internal use)
  27383. */
  27384. _boundingInfo: BoundingInfo;
  27385. /**
  27386. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27387. */
  27388. _sps: SolidParticleSystem;
  27389. /**
  27390. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27391. */
  27392. _stillInvisible: boolean;
  27393. /**
  27394. * @hidden Last computed particle rotation matrix
  27395. */
  27396. _rotationMatrix: number[];
  27397. /**
  27398. * Parent particle Id, if any.
  27399. * Default null.
  27400. */
  27401. parentId: Nullable<number>;
  27402. /**
  27403. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27404. */
  27405. materialIndex: Nullable<number>;
  27406. /**
  27407. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27408. * The possible values are :
  27409. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27410. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27411. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27412. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27413. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27414. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27415. * */
  27416. cullingStrategy: number;
  27417. /**
  27418. * @hidden Internal global position in the SPS.
  27419. */
  27420. _globalPosition: Vector3;
  27421. /**
  27422. * Creates a Solid Particle object.
  27423. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27424. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27425. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27426. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27427. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27428. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27429. * @param shapeId (integer) is the model shape identifier in the SPS.
  27430. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27431. * @param sps defines the sps it is associated to
  27432. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27433. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27434. */
  27435. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27436. /**
  27437. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27438. * @param target the particle target
  27439. * @returns the current particle
  27440. */
  27441. copyToRef(target: SolidParticle): SolidParticle;
  27442. /**
  27443. * Legacy support, changed scale to scaling
  27444. */
  27445. get scale(): Vector3;
  27446. /**
  27447. * Legacy support, changed scale to scaling
  27448. */
  27449. set scale(scale: Vector3);
  27450. /**
  27451. * Legacy support, changed quaternion to rotationQuaternion
  27452. */
  27453. get quaternion(): Nullable<Quaternion>;
  27454. /**
  27455. * Legacy support, changed quaternion to rotationQuaternion
  27456. */
  27457. set quaternion(q: Nullable<Quaternion>);
  27458. /**
  27459. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27460. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27461. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27462. * @returns true if it intersects
  27463. */
  27464. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27465. /**
  27466. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27467. * A particle is in the frustum if its bounding box intersects the frustum
  27468. * @param frustumPlanes defines the frustum to test
  27469. * @returns true if the particle is in the frustum planes
  27470. */
  27471. isInFrustum(frustumPlanes: Plane[]): boolean;
  27472. /**
  27473. * get the rotation matrix of the particle
  27474. * @hidden
  27475. */
  27476. getRotationMatrix(m: Matrix): void;
  27477. }
  27478. /**
  27479. * Represents the shape of the model used by one particle of a solid particle system.
  27480. * SPS internal tool, don't use it manually.
  27481. */
  27482. export class ModelShape {
  27483. /**
  27484. * The shape id
  27485. * @hidden
  27486. */
  27487. shapeID: number;
  27488. /**
  27489. * flat array of model positions (internal use)
  27490. * @hidden
  27491. */
  27492. _shape: Vector3[];
  27493. /**
  27494. * flat array of model UVs (internal use)
  27495. * @hidden
  27496. */
  27497. _shapeUV: number[];
  27498. /**
  27499. * color array of the model
  27500. * @hidden
  27501. */
  27502. _shapeColors: number[];
  27503. /**
  27504. * indices array of the model
  27505. * @hidden
  27506. */
  27507. _indices: number[];
  27508. /**
  27509. * normals array of the model
  27510. * @hidden
  27511. */
  27512. _normals: number[];
  27513. /**
  27514. * length of the shape in the model indices array (internal use)
  27515. * @hidden
  27516. */
  27517. _indicesLength: number;
  27518. /**
  27519. * Custom position function (internal use)
  27520. * @hidden
  27521. */
  27522. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27523. /**
  27524. * Custom vertex function (internal use)
  27525. * @hidden
  27526. */
  27527. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27528. /**
  27529. * Model material (internal use)
  27530. * @hidden
  27531. */
  27532. _material: Nullable<Material>;
  27533. /**
  27534. * 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.
  27535. * SPS internal tool, don't use it manually.
  27536. * @hidden
  27537. */
  27538. 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>);
  27539. }
  27540. /**
  27541. * Represents a Depth Sorted Particle in the solid particle system.
  27542. * @hidden
  27543. */
  27544. export class DepthSortedParticle {
  27545. /**
  27546. * Index of the particle in the "indices" array
  27547. */
  27548. ind: number;
  27549. /**
  27550. * Length of the particle shape in the "indices" array
  27551. */
  27552. indicesLength: number;
  27553. /**
  27554. * Squared distance from the particle to the camera
  27555. */
  27556. sqDistance: number;
  27557. /**
  27558. * Material index when used with MultiMaterials
  27559. */
  27560. materialIndex: number;
  27561. /**
  27562. * Creates a new sorted particle
  27563. * @param materialIndex
  27564. */
  27565. constructor(ind: number, indLength: number, materialIndex: number);
  27566. }
  27567. }
  27568. declare module BABYLON {
  27569. /**
  27570. * @hidden
  27571. */
  27572. export class _MeshCollisionData {
  27573. _checkCollisions: boolean;
  27574. _collisionMask: number;
  27575. _collisionGroup: number;
  27576. _collider: Nullable<Collider>;
  27577. _oldPositionForCollisions: Vector3;
  27578. _diffPositionForCollisions: Vector3;
  27579. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27580. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27581. }
  27582. }
  27583. declare module BABYLON {
  27584. /** @hidden */
  27585. class _FacetDataStorage {
  27586. facetPositions: Vector3[];
  27587. facetNormals: Vector3[];
  27588. facetPartitioning: number[][];
  27589. facetNb: number;
  27590. partitioningSubdivisions: number;
  27591. partitioningBBoxRatio: number;
  27592. facetDataEnabled: boolean;
  27593. facetParameters: any;
  27594. bbSize: Vector3;
  27595. subDiv: {
  27596. max: number;
  27597. X: number;
  27598. Y: number;
  27599. Z: number;
  27600. };
  27601. facetDepthSort: boolean;
  27602. facetDepthSortEnabled: boolean;
  27603. depthSortedIndices: IndicesArray;
  27604. depthSortedFacets: {
  27605. ind: number;
  27606. sqDistance: number;
  27607. }[];
  27608. facetDepthSortFunction: (f1: {
  27609. ind: number;
  27610. sqDistance: number;
  27611. }, f2: {
  27612. ind: number;
  27613. sqDistance: number;
  27614. }) => number;
  27615. facetDepthSortFrom: Vector3;
  27616. facetDepthSortOrigin: Vector3;
  27617. invertedMatrix: Matrix;
  27618. }
  27619. /**
  27620. * @hidden
  27621. **/
  27622. class _InternalAbstractMeshDataInfo {
  27623. _hasVertexAlpha: boolean;
  27624. _useVertexColors: boolean;
  27625. _numBoneInfluencers: number;
  27626. _applyFog: boolean;
  27627. _receiveShadows: boolean;
  27628. _facetData: _FacetDataStorage;
  27629. _visibility: number;
  27630. _skeleton: Nullable<Skeleton>;
  27631. _layerMask: number;
  27632. _computeBonesUsingShaders: boolean;
  27633. _isActive: boolean;
  27634. _onlyForInstances: boolean;
  27635. _isActiveIntermediate: boolean;
  27636. _onlyForInstancesIntermediate: boolean;
  27637. _actAsRegularMesh: boolean;
  27638. }
  27639. /**
  27640. * Class used to store all common mesh properties
  27641. */
  27642. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27643. /** No occlusion */
  27644. static OCCLUSION_TYPE_NONE: number;
  27645. /** Occlusion set to optimisitic */
  27646. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27647. /** Occlusion set to strict */
  27648. static OCCLUSION_TYPE_STRICT: number;
  27649. /** Use an accurante occlusion algorithm */
  27650. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27651. /** Use a conservative occlusion algorithm */
  27652. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27653. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27654. * Test order :
  27655. * Is the bounding sphere outside the frustum ?
  27656. * If not, are the bounding box vertices outside the frustum ?
  27657. * It not, then the cullable object is in the frustum.
  27658. */
  27659. static readonly CULLINGSTRATEGY_STANDARD: number;
  27660. /** Culling strategy : Bounding Sphere Only.
  27661. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27662. * It's also less accurate than the standard because some not visible objects can still be selected.
  27663. * Test : is the bounding sphere outside the frustum ?
  27664. * If not, then the cullable object is in the frustum.
  27665. */
  27666. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27667. /** Culling strategy : Optimistic Inclusion.
  27668. * This in an inclusion test first, then the standard exclusion test.
  27669. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27670. * 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.
  27671. * Anyway, it's as accurate as the standard strategy.
  27672. * Test :
  27673. * Is the cullable object bounding sphere center in the frustum ?
  27674. * If not, apply the default culling strategy.
  27675. */
  27676. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27677. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27678. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27679. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27680. * 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.
  27681. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27682. * Test :
  27683. * Is the cullable object bounding sphere center in the frustum ?
  27684. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27685. */
  27686. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27687. /**
  27688. * No billboard
  27689. */
  27690. static get BILLBOARDMODE_NONE(): number;
  27691. /** Billboard on X axis */
  27692. static get BILLBOARDMODE_X(): number;
  27693. /** Billboard on Y axis */
  27694. static get BILLBOARDMODE_Y(): number;
  27695. /** Billboard on Z axis */
  27696. static get BILLBOARDMODE_Z(): number;
  27697. /** Billboard on all axes */
  27698. static get BILLBOARDMODE_ALL(): number;
  27699. /** Billboard on using position instead of orientation */
  27700. static get BILLBOARDMODE_USE_POSITION(): number;
  27701. /** @hidden */
  27702. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27703. /**
  27704. * The culling strategy to use to check whether the mesh must be rendered or not.
  27705. * This value can be changed at any time and will be used on the next render mesh selection.
  27706. * The possible values are :
  27707. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27708. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27709. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27710. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27711. * Please read each static variable documentation to get details about the culling process.
  27712. * */
  27713. cullingStrategy: number;
  27714. /**
  27715. * Gets the number of facets in the mesh
  27716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27717. */
  27718. get facetNb(): number;
  27719. /**
  27720. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27722. */
  27723. get partitioningSubdivisions(): number;
  27724. set partitioningSubdivisions(nb: number);
  27725. /**
  27726. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27727. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27729. */
  27730. get partitioningBBoxRatio(): number;
  27731. set partitioningBBoxRatio(ratio: number);
  27732. /**
  27733. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27734. * Works only for updatable meshes.
  27735. * Doesn't work with multi-materials
  27736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27737. */
  27738. get mustDepthSortFacets(): boolean;
  27739. set mustDepthSortFacets(sort: boolean);
  27740. /**
  27741. * The location (Vector3) where the facet depth sort must be computed from.
  27742. * By default, the active camera position.
  27743. * Used only when facet depth sort is enabled
  27744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27745. */
  27746. get facetDepthSortFrom(): Vector3;
  27747. set facetDepthSortFrom(location: Vector3);
  27748. /**
  27749. * gets a boolean indicating if facetData is enabled
  27750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27751. */
  27752. get isFacetDataEnabled(): boolean;
  27753. /** @hidden */
  27754. _updateNonUniformScalingState(value: boolean): boolean;
  27755. /**
  27756. * An event triggered when this mesh collides with another one
  27757. */
  27758. onCollideObservable: Observable<AbstractMesh>;
  27759. /** Set a function to call when this mesh collides with another one */
  27760. set onCollide(callback: () => void);
  27761. /**
  27762. * An event triggered when the collision's position changes
  27763. */
  27764. onCollisionPositionChangeObservable: Observable<Vector3>;
  27765. /** Set a function to call when the collision's position changes */
  27766. set onCollisionPositionChange(callback: () => void);
  27767. /**
  27768. * An event triggered when material is changed
  27769. */
  27770. onMaterialChangedObservable: Observable<AbstractMesh>;
  27771. /**
  27772. * Gets or sets the orientation for POV movement & rotation
  27773. */
  27774. definedFacingForward: boolean;
  27775. /** @hidden */
  27776. _occlusionQuery: Nullable<WebGLQuery>;
  27777. /** @hidden */
  27778. _renderingGroup: Nullable<RenderingGroup>;
  27779. /**
  27780. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27781. */
  27782. get visibility(): number;
  27783. /**
  27784. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27785. */
  27786. set visibility(value: number);
  27787. /** Gets or sets the alpha index used to sort transparent meshes
  27788. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27789. */
  27790. alphaIndex: number;
  27791. /**
  27792. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27793. */
  27794. isVisible: boolean;
  27795. /**
  27796. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27797. */
  27798. isPickable: boolean;
  27799. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27800. showSubMeshesBoundingBox: boolean;
  27801. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27802. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27803. */
  27804. isBlocker: boolean;
  27805. /**
  27806. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27807. */
  27808. enablePointerMoveEvents: boolean;
  27809. /**
  27810. * Specifies the rendering group id for this mesh (0 by default)
  27811. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27812. */
  27813. renderingGroupId: number;
  27814. private _material;
  27815. /** Gets or sets current material */
  27816. get material(): Nullable<Material>;
  27817. set material(value: Nullable<Material>);
  27818. /**
  27819. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27820. * @see http://doc.babylonjs.com/babylon101/shadows
  27821. */
  27822. get receiveShadows(): boolean;
  27823. set receiveShadows(value: boolean);
  27824. /** Defines color to use when rendering outline */
  27825. outlineColor: Color3;
  27826. /** Define width to use when rendering outline */
  27827. outlineWidth: number;
  27828. /** Defines color to use when rendering overlay */
  27829. overlayColor: Color3;
  27830. /** Defines alpha to use when rendering overlay */
  27831. overlayAlpha: number;
  27832. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27833. get hasVertexAlpha(): boolean;
  27834. set hasVertexAlpha(value: boolean);
  27835. /** 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) */
  27836. get useVertexColors(): boolean;
  27837. set useVertexColors(value: boolean);
  27838. /**
  27839. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27840. */
  27841. get computeBonesUsingShaders(): boolean;
  27842. set computeBonesUsingShaders(value: boolean);
  27843. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27844. get numBoneInfluencers(): number;
  27845. set numBoneInfluencers(value: number);
  27846. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27847. get applyFog(): boolean;
  27848. set applyFog(value: boolean);
  27849. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27850. useOctreeForRenderingSelection: boolean;
  27851. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27852. useOctreeForPicking: boolean;
  27853. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27854. useOctreeForCollisions: boolean;
  27855. /**
  27856. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27857. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27858. */
  27859. get layerMask(): number;
  27860. set layerMask(value: number);
  27861. /**
  27862. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27863. */
  27864. alwaysSelectAsActiveMesh: boolean;
  27865. /**
  27866. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27867. */
  27868. doNotSyncBoundingInfo: boolean;
  27869. /**
  27870. * Gets or sets the current action manager
  27871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27872. */
  27873. actionManager: Nullable<AbstractActionManager>;
  27874. private _meshCollisionData;
  27875. /**
  27876. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27877. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27878. */
  27879. ellipsoid: Vector3;
  27880. /**
  27881. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27882. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27883. */
  27884. ellipsoidOffset: Vector3;
  27885. /**
  27886. * Gets or sets a collision mask used to mask collisions (default is -1).
  27887. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27888. */
  27889. get collisionMask(): number;
  27890. set collisionMask(mask: number);
  27891. /**
  27892. * Gets or sets the current collision group mask (-1 by default).
  27893. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27894. */
  27895. get collisionGroup(): number;
  27896. set collisionGroup(mask: number);
  27897. /**
  27898. * Defines edge width used when edgesRenderer is enabled
  27899. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27900. */
  27901. edgesWidth: number;
  27902. /**
  27903. * Defines edge color used when edgesRenderer is enabled
  27904. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27905. */
  27906. edgesColor: Color4;
  27907. /** @hidden */
  27908. _edgesRenderer: Nullable<IEdgesRenderer>;
  27909. /** @hidden */
  27910. _masterMesh: Nullable<AbstractMesh>;
  27911. /** @hidden */
  27912. _boundingInfo: Nullable<BoundingInfo>;
  27913. /** @hidden */
  27914. _renderId: number;
  27915. /**
  27916. * Gets or sets the list of subMeshes
  27917. * @see http://doc.babylonjs.com/how_to/multi_materials
  27918. */
  27919. subMeshes: SubMesh[];
  27920. /** @hidden */
  27921. _intersectionsInProgress: AbstractMesh[];
  27922. /** @hidden */
  27923. _unIndexed: boolean;
  27924. /** @hidden */
  27925. _lightSources: Light[];
  27926. /** Gets the list of lights affecting that mesh */
  27927. get lightSources(): Light[];
  27928. /** @hidden */
  27929. get _positions(): Nullable<Vector3[]>;
  27930. /** @hidden */
  27931. _waitingData: {
  27932. lods: Nullable<any>;
  27933. actions: Nullable<any>;
  27934. freezeWorldMatrix: Nullable<boolean>;
  27935. };
  27936. /** @hidden */
  27937. _bonesTransformMatrices: Nullable<Float32Array>;
  27938. /** @hidden */
  27939. _transformMatrixTexture: Nullable<RawTexture>;
  27940. /**
  27941. * Gets or sets a skeleton to apply skining transformations
  27942. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27943. */
  27944. set skeleton(value: Nullable<Skeleton>);
  27945. get skeleton(): Nullable<Skeleton>;
  27946. /**
  27947. * An event triggered when the mesh is rebuilt.
  27948. */
  27949. onRebuildObservable: Observable<AbstractMesh>;
  27950. /**
  27951. * Creates a new AbstractMesh
  27952. * @param name defines the name of the mesh
  27953. * @param scene defines the hosting scene
  27954. */
  27955. constructor(name: string, scene?: Nullable<Scene>);
  27956. /**
  27957. * Returns the string "AbstractMesh"
  27958. * @returns "AbstractMesh"
  27959. */
  27960. getClassName(): string;
  27961. /**
  27962. * Gets a string representation of the current mesh
  27963. * @param fullDetails defines a boolean indicating if full details must be included
  27964. * @returns a string representation of the current mesh
  27965. */
  27966. toString(fullDetails?: boolean): string;
  27967. /**
  27968. * @hidden
  27969. */
  27970. protected _getEffectiveParent(): Nullable<Node>;
  27971. /** @hidden */
  27972. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27973. /** @hidden */
  27974. _rebuild(): void;
  27975. /** @hidden */
  27976. _resyncLightSources(): void;
  27977. /** @hidden */
  27978. _resyncLightSource(light: Light): void;
  27979. /** @hidden */
  27980. _unBindEffect(): void;
  27981. /** @hidden */
  27982. _removeLightSource(light: Light, dispose: boolean): void;
  27983. private _markSubMeshesAsDirty;
  27984. /** @hidden */
  27985. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27986. /** @hidden */
  27987. _markSubMeshesAsAttributesDirty(): void;
  27988. /** @hidden */
  27989. _markSubMeshesAsMiscDirty(): void;
  27990. /**
  27991. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27992. */
  27993. get scaling(): Vector3;
  27994. set scaling(newScaling: Vector3);
  27995. /**
  27996. * Returns true if the mesh is blocked. Implemented by child classes
  27997. */
  27998. get isBlocked(): boolean;
  27999. /**
  28000. * Returns the mesh itself by default. Implemented by child classes
  28001. * @param camera defines the camera to use to pick the right LOD level
  28002. * @returns the currentAbstractMesh
  28003. */
  28004. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28005. /**
  28006. * Returns 0 by default. Implemented by child classes
  28007. * @returns an integer
  28008. */
  28009. getTotalVertices(): number;
  28010. /**
  28011. * Returns a positive integer : the total number of indices in this mesh geometry.
  28012. * @returns the numner of indices or zero if the mesh has no geometry.
  28013. */
  28014. getTotalIndices(): number;
  28015. /**
  28016. * Returns null by default. Implemented by child classes
  28017. * @returns null
  28018. */
  28019. getIndices(): Nullable<IndicesArray>;
  28020. /**
  28021. * Returns the array of the requested vertex data kind. Implemented by child classes
  28022. * @param kind defines the vertex data kind to use
  28023. * @returns null
  28024. */
  28025. getVerticesData(kind: string): Nullable<FloatArray>;
  28026. /**
  28027. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28028. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28029. * Note that a new underlying VertexBuffer object is created each call.
  28030. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28031. * @param kind defines vertex data kind:
  28032. * * VertexBuffer.PositionKind
  28033. * * VertexBuffer.UVKind
  28034. * * VertexBuffer.UV2Kind
  28035. * * VertexBuffer.UV3Kind
  28036. * * VertexBuffer.UV4Kind
  28037. * * VertexBuffer.UV5Kind
  28038. * * VertexBuffer.UV6Kind
  28039. * * VertexBuffer.ColorKind
  28040. * * VertexBuffer.MatricesIndicesKind
  28041. * * VertexBuffer.MatricesIndicesExtraKind
  28042. * * VertexBuffer.MatricesWeightsKind
  28043. * * VertexBuffer.MatricesWeightsExtraKind
  28044. * @param data defines the data source
  28045. * @param updatable defines if the data must be flagged as updatable (or static)
  28046. * @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
  28047. * @returns the current mesh
  28048. */
  28049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28050. /**
  28051. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28052. * If the mesh has no geometry, it is simply returned as it is.
  28053. * @param kind defines vertex data kind:
  28054. * * VertexBuffer.PositionKind
  28055. * * VertexBuffer.UVKind
  28056. * * VertexBuffer.UV2Kind
  28057. * * VertexBuffer.UV3Kind
  28058. * * VertexBuffer.UV4Kind
  28059. * * VertexBuffer.UV5Kind
  28060. * * VertexBuffer.UV6Kind
  28061. * * VertexBuffer.ColorKind
  28062. * * VertexBuffer.MatricesIndicesKind
  28063. * * VertexBuffer.MatricesIndicesExtraKind
  28064. * * VertexBuffer.MatricesWeightsKind
  28065. * * VertexBuffer.MatricesWeightsExtraKind
  28066. * @param data defines the data source
  28067. * @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
  28068. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28069. * @returns the current mesh
  28070. */
  28071. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28072. /**
  28073. * Sets the mesh indices,
  28074. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28075. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28076. * @param totalVertices Defines the total number of vertices
  28077. * @returns the current mesh
  28078. */
  28079. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28080. /**
  28081. * Gets a boolean indicating if specific vertex data is present
  28082. * @param kind defines the vertex data kind to use
  28083. * @returns true is data kind is present
  28084. */
  28085. isVerticesDataPresent(kind: string): boolean;
  28086. /**
  28087. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28088. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28089. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28090. * @returns a BoundingInfo
  28091. */
  28092. getBoundingInfo(): BoundingInfo;
  28093. /**
  28094. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28095. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28096. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28097. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28098. * @returns the current mesh
  28099. */
  28100. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28101. /**
  28102. * Overwrite the current bounding info
  28103. * @param boundingInfo defines the new bounding info
  28104. * @returns the current mesh
  28105. */
  28106. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28107. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28108. get useBones(): boolean;
  28109. /** @hidden */
  28110. _preActivate(): void;
  28111. /** @hidden */
  28112. _preActivateForIntermediateRendering(renderId: number): void;
  28113. /** @hidden */
  28114. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28115. /** @hidden */
  28116. _postActivate(): void;
  28117. /** @hidden */
  28118. _freeze(): void;
  28119. /** @hidden */
  28120. _unFreeze(): void;
  28121. /**
  28122. * Gets the current world matrix
  28123. * @returns a Matrix
  28124. */
  28125. getWorldMatrix(): Matrix;
  28126. /** @hidden */
  28127. _getWorldMatrixDeterminant(): number;
  28128. /**
  28129. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28130. */
  28131. get isAnInstance(): boolean;
  28132. /**
  28133. * Gets a boolean indicating if this mesh has instances
  28134. */
  28135. get hasInstances(): boolean;
  28136. /**
  28137. * Perform relative position change from the point of view of behind the front of the mesh.
  28138. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28139. * Supports definition of mesh facing forward or backward
  28140. * @param amountRight defines the distance on the right axis
  28141. * @param amountUp defines the distance on the up axis
  28142. * @param amountForward defines the distance on the forward axis
  28143. * @returns the current mesh
  28144. */
  28145. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28146. /**
  28147. * Calculate relative position change from the point of view of behind the front of the mesh.
  28148. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28149. * Supports definition of mesh facing forward or backward
  28150. * @param amountRight defines the distance on the right axis
  28151. * @param amountUp defines the distance on the up axis
  28152. * @param amountForward defines the distance on the forward axis
  28153. * @returns the new displacement vector
  28154. */
  28155. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28156. /**
  28157. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28158. * Supports definition of mesh facing forward or backward
  28159. * @param flipBack defines the flip
  28160. * @param twirlClockwise defines the twirl
  28161. * @param tiltRight defines the tilt
  28162. * @returns the current mesh
  28163. */
  28164. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28165. /**
  28166. * Calculate 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 new rotation vector
  28172. */
  28173. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28174. /**
  28175. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28176. * This means the mesh underlying bounding box and sphere are recomputed.
  28177. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28178. * @returns the current mesh
  28179. */
  28180. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28181. /** @hidden */
  28182. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28183. /** @hidden */
  28184. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28185. /** @hidden */
  28186. _updateBoundingInfo(): AbstractMesh;
  28187. /** @hidden */
  28188. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28189. /** @hidden */
  28190. protected _afterComputeWorldMatrix(): void;
  28191. /** @hidden */
  28192. get _effectiveMesh(): AbstractMesh;
  28193. /**
  28194. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28195. * A mesh is in the frustum if its bounding box intersects the frustum
  28196. * @param frustumPlanes defines the frustum to test
  28197. * @returns true if the mesh is in the frustum planes
  28198. */
  28199. isInFrustum(frustumPlanes: Plane[]): boolean;
  28200. /**
  28201. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28202. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28203. * @param frustumPlanes defines the frustum to test
  28204. * @returns true if the mesh is completely in the frustum planes
  28205. */
  28206. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28207. /**
  28208. * True if the mesh intersects another mesh or a SolidParticle object
  28209. * @param mesh defines a target mesh or SolidParticle to test
  28210. * @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)
  28211. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28212. * @returns true if there is an intersection
  28213. */
  28214. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28215. /**
  28216. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28217. * @param point defines the point to test
  28218. * @returns true if there is an intersection
  28219. */
  28220. intersectsPoint(point: Vector3): boolean;
  28221. /**
  28222. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28224. */
  28225. get checkCollisions(): boolean;
  28226. set checkCollisions(collisionEnabled: boolean);
  28227. /**
  28228. * Gets Collider object used to compute collisions (not physics)
  28229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28230. */
  28231. get collider(): Nullable<Collider>;
  28232. /**
  28233. * Move the mesh using collision engine
  28234. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28235. * @param displacement defines the requested displacement vector
  28236. * @returns the current mesh
  28237. */
  28238. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28239. private _onCollisionPositionChange;
  28240. /** @hidden */
  28241. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28242. /** @hidden */
  28243. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28244. /** @hidden */
  28245. _checkCollision(collider: Collider): AbstractMesh;
  28246. /** @hidden */
  28247. _generatePointsArray(): boolean;
  28248. /**
  28249. * Checks if the passed Ray intersects with the mesh
  28250. * @param ray defines the ray to use
  28251. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28252. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28253. * @returns the picking info
  28254. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28255. */
  28256. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28257. /**
  28258. * Clones the current mesh
  28259. * @param name defines the mesh name
  28260. * @param newParent defines the new mesh parent
  28261. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28262. * @returns the new mesh
  28263. */
  28264. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28265. /**
  28266. * Disposes all the submeshes of the current meshnp
  28267. * @returns the current mesh
  28268. */
  28269. releaseSubMeshes(): AbstractMesh;
  28270. /**
  28271. * Releases resources associated with this abstract mesh.
  28272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28274. */
  28275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28276. /**
  28277. * Adds the passed mesh as a child to the current mesh
  28278. * @param mesh defines the child mesh
  28279. * @returns the current mesh
  28280. */
  28281. addChild(mesh: AbstractMesh): AbstractMesh;
  28282. /**
  28283. * Removes the passed mesh from the current mesh children list
  28284. * @param mesh defines the child mesh
  28285. * @returns the current mesh
  28286. */
  28287. removeChild(mesh: AbstractMesh): AbstractMesh;
  28288. /** @hidden */
  28289. private _initFacetData;
  28290. /**
  28291. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28292. * This method can be called within the render loop.
  28293. * 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
  28294. * @returns the current mesh
  28295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28296. */
  28297. updateFacetData(): AbstractMesh;
  28298. /**
  28299. * Returns the facetLocalNormals array.
  28300. * The normals are expressed in the mesh local spac
  28301. * @returns an array of Vector3
  28302. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28303. */
  28304. getFacetLocalNormals(): Vector3[];
  28305. /**
  28306. * Returns the facetLocalPositions array.
  28307. * The facet positions are expressed in the mesh local space
  28308. * @returns an array of Vector3
  28309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28310. */
  28311. getFacetLocalPositions(): Vector3[];
  28312. /**
  28313. * Returns the facetLocalPartioning array
  28314. * @returns an array of array of numbers
  28315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28316. */
  28317. getFacetLocalPartitioning(): number[][];
  28318. /**
  28319. * Returns the i-th facet position in the world system.
  28320. * This method allocates a new Vector3 per call
  28321. * @param i defines the facet index
  28322. * @returns a new Vector3
  28323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28324. */
  28325. getFacetPosition(i: number): Vector3;
  28326. /**
  28327. * Sets the reference Vector3 with the i-th facet position in the world system
  28328. * @param i defines the facet index
  28329. * @param ref defines the target vector
  28330. * @returns the current mesh
  28331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28332. */
  28333. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28334. /**
  28335. * Returns the i-th facet normal in the world system.
  28336. * This method allocates a new Vector3 per call
  28337. * @param i defines the facet index
  28338. * @returns a new Vector3
  28339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28340. */
  28341. getFacetNormal(i: number): Vector3;
  28342. /**
  28343. * Sets the reference Vector3 with the i-th facet normal in the world system
  28344. * @param i defines the facet index
  28345. * @param ref defines the target vector
  28346. * @returns the current mesh
  28347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28348. */
  28349. getFacetNormalToRef(i: number, ref: Vector3): this;
  28350. /**
  28351. * 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)
  28352. * @param x defines x coordinate
  28353. * @param y defines y coordinate
  28354. * @param z defines z coordinate
  28355. * @returns the array of facet indexes
  28356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28357. */
  28358. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28359. /**
  28360. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28361. * @param projected sets as the (x,y,z) world projection on the facet
  28362. * @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
  28363. * @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
  28364. * @param x defines x coordinate
  28365. * @param y defines y coordinate
  28366. * @param z defines z coordinate
  28367. * @returns the face index if found (or null instead)
  28368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28369. */
  28370. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28371. /**
  28372. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28373. * @param projected sets as the (x,y,z) local projection on the facet
  28374. * @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
  28375. * @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
  28376. * @param x defines x coordinate
  28377. * @param y defines y coordinate
  28378. * @param z defines z coordinate
  28379. * @returns the face index if found (or null instead)
  28380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28381. */
  28382. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28383. /**
  28384. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28385. * @returns the parameters
  28386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28387. */
  28388. getFacetDataParameters(): any;
  28389. /**
  28390. * Disables the feature FacetData and frees the related memory
  28391. * @returns the current mesh
  28392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28393. */
  28394. disableFacetData(): AbstractMesh;
  28395. /**
  28396. * Updates the AbstractMesh indices array
  28397. * @param indices defines the data source
  28398. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28399. * @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)
  28400. * @returns the current mesh
  28401. */
  28402. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28403. /**
  28404. * Creates new normals data for the mesh
  28405. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28406. * @returns the current mesh
  28407. */
  28408. createNormals(updatable: boolean): AbstractMesh;
  28409. /**
  28410. * Align the mesh with a normal
  28411. * @param normal defines the normal to use
  28412. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28413. * @returns the current mesh
  28414. */
  28415. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28416. /** @hidden */
  28417. _checkOcclusionQuery(): boolean;
  28418. /**
  28419. * Disables the mesh edge rendering mode
  28420. * @returns the currentAbstractMesh
  28421. */
  28422. disableEdgesRendering(): AbstractMesh;
  28423. /**
  28424. * Enables the edge rendering mode on the mesh.
  28425. * This mode makes the mesh edges visible
  28426. * @param epsilon defines the maximal distance between two angles to detect a face
  28427. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28428. * @returns the currentAbstractMesh
  28429. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28430. */
  28431. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28432. }
  28433. }
  28434. declare module BABYLON {
  28435. /**
  28436. * Interface used to define ActionEvent
  28437. */
  28438. export interface IActionEvent {
  28439. /** The mesh or sprite that triggered the action */
  28440. source: any;
  28441. /** The X mouse cursor position at the time of the event */
  28442. pointerX: number;
  28443. /** The Y mouse cursor position at the time of the event */
  28444. pointerY: number;
  28445. /** The mesh that is currently pointed at (can be null) */
  28446. meshUnderPointer: Nullable<AbstractMesh>;
  28447. /** the original (browser) event that triggered the ActionEvent */
  28448. sourceEvent?: any;
  28449. /** additional data for the event */
  28450. additionalData?: any;
  28451. }
  28452. /**
  28453. * ActionEvent is the event being sent when an action is triggered.
  28454. */
  28455. export class ActionEvent implements IActionEvent {
  28456. /** The mesh or sprite that triggered the action */
  28457. source: any;
  28458. /** The X mouse cursor position at the time of the event */
  28459. pointerX: number;
  28460. /** The Y mouse cursor position at the time of the event */
  28461. pointerY: number;
  28462. /** The mesh that is currently pointed at (can be null) */
  28463. meshUnderPointer: Nullable<AbstractMesh>;
  28464. /** the original (browser) event that triggered the ActionEvent */
  28465. sourceEvent?: any;
  28466. /** additional data for the event */
  28467. additionalData?: any;
  28468. /**
  28469. * Creates a new ActionEvent
  28470. * @param source The mesh or sprite that triggered the action
  28471. * @param pointerX The X mouse cursor position at the time of the event
  28472. * @param pointerY The Y mouse cursor position at the time of the event
  28473. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28474. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28475. * @param additionalData additional data for the event
  28476. */
  28477. constructor(
  28478. /** The mesh or sprite that triggered the action */
  28479. source: any,
  28480. /** The X mouse cursor position at the time of the event */
  28481. pointerX: number,
  28482. /** The Y mouse cursor position at the time of the event */
  28483. pointerY: number,
  28484. /** The mesh that is currently pointed at (can be null) */
  28485. meshUnderPointer: Nullable<AbstractMesh>,
  28486. /** the original (browser) event that triggered the ActionEvent */
  28487. sourceEvent?: any,
  28488. /** additional data for the event */
  28489. additionalData?: any);
  28490. /**
  28491. * Helper function to auto-create an ActionEvent from a source mesh.
  28492. * @param source The source mesh that triggered the event
  28493. * @param evt The original (browser) event
  28494. * @param additionalData additional data for the event
  28495. * @returns the new ActionEvent
  28496. */
  28497. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28498. /**
  28499. * Helper function to auto-create an ActionEvent from a source sprite
  28500. * @param source The source sprite that triggered the event
  28501. * @param scene Scene associated with the sprite
  28502. * @param evt The original (browser) event
  28503. * @param additionalData additional data for the event
  28504. * @returns the new ActionEvent
  28505. */
  28506. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28507. /**
  28508. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28509. * @param scene the scene where the event occurred
  28510. * @param evt The original (browser) event
  28511. * @returns the new ActionEvent
  28512. */
  28513. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28514. /**
  28515. * Helper function to auto-create an ActionEvent from a primitive
  28516. * @param prim defines the target primitive
  28517. * @param pointerPos defines the pointer position
  28518. * @param evt The original (browser) event
  28519. * @param additionalData additional data for the event
  28520. * @returns the new ActionEvent
  28521. */
  28522. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28523. }
  28524. }
  28525. declare module BABYLON {
  28526. /**
  28527. * Abstract class used to decouple action Manager from scene and meshes.
  28528. * Do not instantiate.
  28529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28530. */
  28531. export abstract class AbstractActionManager implements IDisposable {
  28532. /** Gets the list of active triggers */
  28533. static Triggers: {
  28534. [key: string]: number;
  28535. };
  28536. /** Gets the cursor to use when hovering items */
  28537. hoverCursor: string;
  28538. /** Gets the list of actions */
  28539. actions: IAction[];
  28540. /**
  28541. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28542. */
  28543. isRecursive: boolean;
  28544. /**
  28545. * Releases all associated resources
  28546. */
  28547. abstract dispose(): void;
  28548. /**
  28549. * Does this action manager has pointer triggers
  28550. */
  28551. abstract get hasPointerTriggers(): boolean;
  28552. /**
  28553. * Does this action manager has pick triggers
  28554. */
  28555. abstract get hasPickTriggers(): boolean;
  28556. /**
  28557. * Process a specific trigger
  28558. * @param trigger defines the trigger to process
  28559. * @param evt defines the event details to be processed
  28560. */
  28561. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28562. /**
  28563. * Does this action manager handles actions of any of the given triggers
  28564. * @param triggers defines the triggers to be tested
  28565. * @return a boolean indicating whether one (or more) of the triggers is handled
  28566. */
  28567. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28568. /**
  28569. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28570. * speed.
  28571. * @param triggerA defines the trigger to be tested
  28572. * @param triggerB defines the trigger to be tested
  28573. * @return a boolean indicating whether one (or more) of the triggers is handled
  28574. */
  28575. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28576. /**
  28577. * Does this action manager handles actions of a given trigger
  28578. * @param trigger defines the trigger to be tested
  28579. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28580. * @return whether the trigger is handled
  28581. */
  28582. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28583. /**
  28584. * Serialize this manager to a JSON object
  28585. * @param name defines the property name to store this manager
  28586. * @returns a JSON representation of this manager
  28587. */
  28588. abstract serialize(name: string): any;
  28589. /**
  28590. * Registers an action to this action manager
  28591. * @param action defines the action to be registered
  28592. * @return the action amended (prepared) after registration
  28593. */
  28594. abstract registerAction(action: IAction): Nullable<IAction>;
  28595. /**
  28596. * Unregisters an action to this action manager
  28597. * @param action defines the action to be unregistered
  28598. * @return a boolean indicating whether the action has been unregistered
  28599. */
  28600. abstract unregisterAction(action: IAction): Boolean;
  28601. /**
  28602. * Does exist one action manager with at least one trigger
  28603. **/
  28604. static get HasTriggers(): boolean;
  28605. /**
  28606. * Does exist one action manager with at least one pick trigger
  28607. **/
  28608. static get HasPickTriggers(): boolean;
  28609. /**
  28610. * Does exist one action manager that handles actions of a given trigger
  28611. * @param trigger defines the trigger to be tested
  28612. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28613. **/
  28614. static HasSpecificTrigger(trigger: number): boolean;
  28615. }
  28616. }
  28617. declare module BABYLON {
  28618. /**
  28619. * Defines how a node can be built from a string name.
  28620. */
  28621. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28622. /**
  28623. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28624. */
  28625. export class Node implements IBehaviorAware<Node> {
  28626. /** @hidden */
  28627. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28628. private static _NodeConstructors;
  28629. /**
  28630. * Add a new node constructor
  28631. * @param type defines the type name of the node to construct
  28632. * @param constructorFunc defines the constructor function
  28633. */
  28634. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28635. /**
  28636. * Returns a node constructor based on type name
  28637. * @param type defines the type name
  28638. * @param name defines the new node name
  28639. * @param scene defines the hosting scene
  28640. * @param options defines optional options to transmit to constructors
  28641. * @returns the new constructor or null
  28642. */
  28643. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28644. /**
  28645. * Gets or sets the name of the node
  28646. */
  28647. name: string;
  28648. /**
  28649. * Gets or sets the id of the node
  28650. */
  28651. id: string;
  28652. /**
  28653. * Gets or sets the unique id of the node
  28654. */
  28655. uniqueId: number;
  28656. /**
  28657. * Gets or sets a string used to store user defined state for the node
  28658. */
  28659. state: string;
  28660. /**
  28661. * Gets or sets an object used to store user defined information for the node
  28662. */
  28663. metadata: any;
  28664. /**
  28665. * For internal use only. Please do not use.
  28666. */
  28667. reservedDataStore: any;
  28668. /**
  28669. * List of inspectable custom properties (used by the Inspector)
  28670. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28671. */
  28672. inspectableCustomProperties: IInspectable[];
  28673. private _doNotSerialize;
  28674. /**
  28675. * Gets or sets a boolean used to define if the node must be serialized
  28676. */
  28677. get doNotSerialize(): boolean;
  28678. set doNotSerialize(value: boolean);
  28679. /** @hidden */
  28680. _isDisposed: boolean;
  28681. /**
  28682. * Gets a list of Animations associated with the node
  28683. */
  28684. animations: Animation[];
  28685. protected _ranges: {
  28686. [name: string]: Nullable<AnimationRange>;
  28687. };
  28688. /**
  28689. * Callback raised when the node is ready to be used
  28690. */
  28691. onReady: Nullable<(node: Node) => void>;
  28692. private _isEnabled;
  28693. private _isParentEnabled;
  28694. private _isReady;
  28695. /** @hidden */
  28696. _currentRenderId: number;
  28697. private _parentUpdateId;
  28698. /** @hidden */
  28699. _childUpdateId: number;
  28700. /** @hidden */
  28701. _waitingParentId: Nullable<string>;
  28702. /** @hidden */
  28703. _scene: Scene;
  28704. /** @hidden */
  28705. _cache: any;
  28706. private _parentNode;
  28707. private _children;
  28708. /** @hidden */
  28709. _worldMatrix: Matrix;
  28710. /** @hidden */
  28711. _worldMatrixDeterminant: number;
  28712. /** @hidden */
  28713. _worldMatrixDeterminantIsDirty: boolean;
  28714. /** @hidden */
  28715. private _sceneRootNodesIndex;
  28716. /**
  28717. * Gets a boolean indicating if the node has been disposed
  28718. * @returns true if the node was disposed
  28719. */
  28720. isDisposed(): boolean;
  28721. /**
  28722. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28723. * @see https://doc.babylonjs.com/how_to/parenting
  28724. */
  28725. set parent(parent: Nullable<Node>);
  28726. get parent(): Nullable<Node>;
  28727. /** @hidden */
  28728. _addToSceneRootNodes(): void;
  28729. /** @hidden */
  28730. _removeFromSceneRootNodes(): void;
  28731. private _animationPropertiesOverride;
  28732. /**
  28733. * Gets or sets the animation properties override
  28734. */
  28735. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28736. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28737. /**
  28738. * Gets a string idenfifying the name of the class
  28739. * @returns "Node" string
  28740. */
  28741. getClassName(): string;
  28742. /** @hidden */
  28743. readonly _isNode: boolean;
  28744. /**
  28745. * An event triggered when the mesh is disposed
  28746. */
  28747. onDisposeObservable: Observable<Node>;
  28748. private _onDisposeObserver;
  28749. /**
  28750. * Sets a callback that will be raised when the node will be disposed
  28751. */
  28752. set onDispose(callback: () => void);
  28753. /**
  28754. * Creates a new Node
  28755. * @param name the name and id to be given to this node
  28756. * @param scene the scene this node will be added to
  28757. */
  28758. constructor(name: string, scene?: Nullable<Scene>);
  28759. /**
  28760. * Gets the scene of the node
  28761. * @returns a scene
  28762. */
  28763. getScene(): Scene;
  28764. /**
  28765. * Gets the engine of the node
  28766. * @returns a Engine
  28767. */
  28768. getEngine(): Engine;
  28769. private _behaviors;
  28770. /**
  28771. * Attach a behavior to the node
  28772. * @see http://doc.babylonjs.com/features/behaviour
  28773. * @param behavior defines the behavior to attach
  28774. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28775. * @returns the current Node
  28776. */
  28777. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28778. /**
  28779. * Remove an attached behavior
  28780. * @see http://doc.babylonjs.com/features/behaviour
  28781. * @param behavior defines the behavior to attach
  28782. * @returns the current Node
  28783. */
  28784. removeBehavior(behavior: Behavior<Node>): Node;
  28785. /**
  28786. * Gets the list of attached behaviors
  28787. * @see http://doc.babylonjs.com/features/behaviour
  28788. */
  28789. get behaviors(): Behavior<Node>[];
  28790. /**
  28791. * Gets an attached behavior by name
  28792. * @param name defines the name of the behavior to look for
  28793. * @see http://doc.babylonjs.com/features/behaviour
  28794. * @returns null if behavior was not found else the requested behavior
  28795. */
  28796. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28797. /**
  28798. * Returns the latest update of the World matrix
  28799. * @returns a Matrix
  28800. */
  28801. getWorldMatrix(): Matrix;
  28802. /** @hidden */
  28803. _getWorldMatrixDeterminant(): number;
  28804. /**
  28805. * Returns directly the latest state of the mesh World matrix.
  28806. * A Matrix is returned.
  28807. */
  28808. get worldMatrixFromCache(): Matrix;
  28809. /** @hidden */
  28810. _initCache(): void;
  28811. /** @hidden */
  28812. updateCache(force?: boolean): void;
  28813. /** @hidden */
  28814. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28815. /** @hidden */
  28816. _updateCache(ignoreParentClass?: boolean): void;
  28817. /** @hidden */
  28818. _isSynchronized(): boolean;
  28819. /** @hidden */
  28820. _markSyncedWithParent(): void;
  28821. /** @hidden */
  28822. isSynchronizedWithParent(): boolean;
  28823. /** @hidden */
  28824. isSynchronized(): boolean;
  28825. /**
  28826. * Is this node ready to be used/rendered
  28827. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28828. * @return true if the node is ready
  28829. */
  28830. isReady(completeCheck?: boolean): boolean;
  28831. /**
  28832. * Is this node enabled?
  28833. * 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
  28834. * @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
  28835. * @return whether this node (and its parent) is enabled
  28836. */
  28837. isEnabled(checkAncestors?: boolean): boolean;
  28838. /** @hidden */
  28839. protected _syncParentEnabledState(): void;
  28840. /**
  28841. * Set the enabled state of this node
  28842. * @param value defines the new enabled state
  28843. */
  28844. setEnabled(value: boolean): void;
  28845. /**
  28846. * Is this node a descendant of the given node?
  28847. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28848. * @param ancestor defines the parent node to inspect
  28849. * @returns a boolean indicating if this node is a descendant of the given node
  28850. */
  28851. isDescendantOf(ancestor: Node): boolean;
  28852. /** @hidden */
  28853. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28854. /**
  28855. * Will return all nodes that have this node as ascendant
  28856. * @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
  28857. * @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
  28858. * @return all children nodes of all types
  28859. */
  28860. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28861. /**
  28862. * Get all child-meshes of this node
  28863. * @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)
  28864. * @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
  28865. * @returns an array of AbstractMesh
  28866. */
  28867. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28868. /**
  28869. * Get all direct children of this node
  28870. * @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
  28871. * @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)
  28872. * @returns an array of Node
  28873. */
  28874. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28875. /** @hidden */
  28876. _setReady(state: boolean): void;
  28877. /**
  28878. * Get an animation by name
  28879. * @param name defines the name of the animation to look for
  28880. * @returns null if not found else the requested animation
  28881. */
  28882. getAnimationByName(name: string): Nullable<Animation>;
  28883. /**
  28884. * Creates an animation range for this node
  28885. * @param name defines the name of the range
  28886. * @param from defines the starting key
  28887. * @param to defines the end key
  28888. */
  28889. createAnimationRange(name: string, from: number, to: number): void;
  28890. /**
  28891. * Delete a specific animation range
  28892. * @param name defines the name of the range to delete
  28893. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28894. */
  28895. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28896. /**
  28897. * Get an animation range by name
  28898. * @param name defines the name of the animation range to look for
  28899. * @returns null if not found else the requested animation range
  28900. */
  28901. getAnimationRange(name: string): Nullable<AnimationRange>;
  28902. /**
  28903. * Gets the list of all animation ranges defined on this node
  28904. * @returns an array
  28905. */
  28906. getAnimationRanges(): Nullable<AnimationRange>[];
  28907. /**
  28908. * Will start the animation sequence
  28909. * @param name defines the range frames for animation sequence
  28910. * @param loop defines if the animation should loop (false by default)
  28911. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28912. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28913. * @returns the object created for this animation. If range does not exist, it will return null
  28914. */
  28915. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28916. /**
  28917. * Serialize animation ranges into a JSON compatible object
  28918. * @returns serialization object
  28919. */
  28920. serializeAnimationRanges(): any;
  28921. /**
  28922. * Computes the world matrix of the node
  28923. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28924. * @returns the world matrix
  28925. */
  28926. computeWorldMatrix(force?: boolean): Matrix;
  28927. /**
  28928. * Releases resources associated with this node.
  28929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28931. */
  28932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28933. /**
  28934. * Parse animation range data from a serialization object and store them into a given node
  28935. * @param node defines where to store the animation ranges
  28936. * @param parsedNode defines the serialization object to read data from
  28937. * @param scene defines the hosting scene
  28938. */
  28939. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28940. /**
  28941. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28942. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28943. * @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
  28944. * @returns the new bounding vectors
  28945. */
  28946. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28947. min: Vector3;
  28948. max: Vector3;
  28949. };
  28950. }
  28951. }
  28952. declare module BABYLON {
  28953. /**
  28954. * @hidden
  28955. */
  28956. export class _IAnimationState {
  28957. key: number;
  28958. repeatCount: number;
  28959. workValue?: any;
  28960. loopMode?: number;
  28961. offsetValue?: any;
  28962. highLimitValue?: any;
  28963. }
  28964. /**
  28965. * Class used to store any kind of animation
  28966. */
  28967. export class Animation {
  28968. /**Name of the animation */
  28969. name: string;
  28970. /**Property to animate */
  28971. targetProperty: string;
  28972. /**The frames per second of the animation */
  28973. framePerSecond: number;
  28974. /**The data type of the animation */
  28975. dataType: number;
  28976. /**The loop mode of the animation */
  28977. loopMode?: number | undefined;
  28978. /**Specifies if blending should be enabled */
  28979. enableBlending?: boolean | undefined;
  28980. /**
  28981. * Use matrix interpolation instead of using direct key value when animating matrices
  28982. */
  28983. static AllowMatricesInterpolation: boolean;
  28984. /**
  28985. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28986. */
  28987. static AllowMatrixDecomposeForInterpolation: boolean;
  28988. /**
  28989. * Stores the key frames of the animation
  28990. */
  28991. private _keys;
  28992. /**
  28993. * Stores the easing function of the animation
  28994. */
  28995. private _easingFunction;
  28996. /**
  28997. * @hidden Internal use only
  28998. */
  28999. _runtimeAnimations: RuntimeAnimation[];
  29000. /**
  29001. * The set of event that will be linked to this animation
  29002. */
  29003. private _events;
  29004. /**
  29005. * Stores an array of target property paths
  29006. */
  29007. targetPropertyPath: string[];
  29008. /**
  29009. * Stores the blending speed of the animation
  29010. */
  29011. blendingSpeed: number;
  29012. /**
  29013. * Stores the animation ranges for the animation
  29014. */
  29015. private _ranges;
  29016. /**
  29017. * @hidden Internal use
  29018. */
  29019. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29020. /**
  29021. * Sets up an animation
  29022. * @param property The property to animate
  29023. * @param animationType The animation type to apply
  29024. * @param framePerSecond The frames per second of the animation
  29025. * @param easingFunction The easing function used in the animation
  29026. * @returns The created animation
  29027. */
  29028. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29029. /**
  29030. * Create and start an animation on a node
  29031. * @param name defines the name of the global animation that will be run on all nodes
  29032. * @param node defines the root node where the animation will take place
  29033. * @param targetProperty defines property to animate
  29034. * @param framePerSecond defines the number of frame per second yo use
  29035. * @param totalFrame defines the number of frames in total
  29036. * @param from defines the initial value
  29037. * @param to defines the final value
  29038. * @param loopMode defines which loop mode you want to use (off by default)
  29039. * @param easingFunction defines the easing function to use (linear by default)
  29040. * @param onAnimationEnd defines the callback to call when animation end
  29041. * @returns the animatable created for this animation
  29042. */
  29043. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29044. /**
  29045. * Create and start an animation on a node and its descendants
  29046. * @param name defines the name of the global animation that will be run on all nodes
  29047. * @param node defines the root node where the animation will take place
  29048. * @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
  29049. * @param targetProperty defines property to animate
  29050. * @param framePerSecond defines the number of frame per second to use
  29051. * @param totalFrame defines the number of frames in total
  29052. * @param from defines the initial value
  29053. * @param to defines the final value
  29054. * @param loopMode defines which loop mode you want to use (off by default)
  29055. * @param easingFunction defines the easing function to use (linear by default)
  29056. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29057. * @returns the list of animatables created for all nodes
  29058. * @example https://www.babylonjs-playground.com/#MH0VLI
  29059. */
  29060. 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[]>;
  29061. /**
  29062. * Creates a new animation, merges it with the existing animations and starts it
  29063. * @param name Name of the animation
  29064. * @param node Node which contains the scene that begins the animations
  29065. * @param targetProperty Specifies which property to animate
  29066. * @param framePerSecond The frames per second of the animation
  29067. * @param totalFrame The total number of frames
  29068. * @param from The frame at the beginning of the animation
  29069. * @param to The frame at the end of the animation
  29070. * @param loopMode Specifies the loop mode of the animation
  29071. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29072. * @param onAnimationEnd Callback to run once the animation is complete
  29073. * @returns Nullable animation
  29074. */
  29075. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29076. /**
  29077. * Transition property of an host to the target Value
  29078. * @param property The property to transition
  29079. * @param targetValue The target Value of the property
  29080. * @param host The object where the property to animate belongs
  29081. * @param scene Scene used to run the animation
  29082. * @param frameRate Framerate (in frame/s) to use
  29083. * @param transition The transition type we want to use
  29084. * @param duration The duration of the animation, in milliseconds
  29085. * @param onAnimationEnd Callback trigger at the end of the animation
  29086. * @returns Nullable animation
  29087. */
  29088. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29089. /**
  29090. * Return the array of runtime animations currently using this animation
  29091. */
  29092. get runtimeAnimations(): RuntimeAnimation[];
  29093. /**
  29094. * Specifies if any of the runtime animations are currently running
  29095. */
  29096. get hasRunningRuntimeAnimations(): boolean;
  29097. /**
  29098. * Initializes the animation
  29099. * @param name Name of the animation
  29100. * @param targetProperty Property to animate
  29101. * @param framePerSecond The frames per second of the animation
  29102. * @param dataType The data type of the animation
  29103. * @param loopMode The loop mode of the animation
  29104. * @param enableBlending Specifies if blending should be enabled
  29105. */
  29106. constructor(
  29107. /**Name of the animation */
  29108. name: string,
  29109. /**Property to animate */
  29110. targetProperty: string,
  29111. /**The frames per second of the animation */
  29112. framePerSecond: number,
  29113. /**The data type of the animation */
  29114. dataType: number,
  29115. /**The loop mode of the animation */
  29116. loopMode?: number | undefined,
  29117. /**Specifies if blending should be enabled */
  29118. enableBlending?: boolean | undefined);
  29119. /**
  29120. * Converts the animation to a string
  29121. * @param fullDetails support for multiple levels of logging within scene loading
  29122. * @returns String form of the animation
  29123. */
  29124. toString(fullDetails?: boolean): string;
  29125. /**
  29126. * Add an event to this animation
  29127. * @param event Event to add
  29128. */
  29129. addEvent(event: AnimationEvent): void;
  29130. /**
  29131. * Remove all events found at the given frame
  29132. * @param frame The frame to remove events from
  29133. */
  29134. removeEvents(frame: number): void;
  29135. /**
  29136. * Retrieves all the events from the animation
  29137. * @returns Events from the animation
  29138. */
  29139. getEvents(): AnimationEvent[];
  29140. /**
  29141. * Creates an animation range
  29142. * @param name Name of the animation range
  29143. * @param from Starting frame of the animation range
  29144. * @param to Ending frame of the animation
  29145. */
  29146. createRange(name: string, from: number, to: number): void;
  29147. /**
  29148. * Deletes an animation range by name
  29149. * @param name Name of the animation range to delete
  29150. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29151. */
  29152. deleteRange(name: string, deleteFrames?: boolean): void;
  29153. /**
  29154. * Gets the animation range by name, or null if not defined
  29155. * @param name Name of the animation range
  29156. * @returns Nullable animation range
  29157. */
  29158. getRange(name: string): Nullable<AnimationRange>;
  29159. /**
  29160. * Gets the key frames from the animation
  29161. * @returns The key frames of the animation
  29162. */
  29163. getKeys(): Array<IAnimationKey>;
  29164. /**
  29165. * Gets the highest frame rate of the animation
  29166. * @returns Highest frame rate of the animation
  29167. */
  29168. getHighestFrame(): number;
  29169. /**
  29170. * Gets the easing function of the animation
  29171. * @returns Easing function of the animation
  29172. */
  29173. getEasingFunction(): IEasingFunction;
  29174. /**
  29175. * Sets the easing function of the animation
  29176. * @param easingFunction A custom mathematical formula for animation
  29177. */
  29178. setEasingFunction(easingFunction: EasingFunction): void;
  29179. /**
  29180. * Interpolates a scalar linearly
  29181. * @param startValue Start value of the animation curve
  29182. * @param endValue End value of the animation curve
  29183. * @param gradient Scalar amount to interpolate
  29184. * @returns Interpolated scalar value
  29185. */
  29186. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29187. /**
  29188. * Interpolates a scalar cubically
  29189. * @param startValue Start value of the animation curve
  29190. * @param outTangent End tangent of the animation
  29191. * @param endValue End value of the animation curve
  29192. * @param inTangent Start tangent of the animation curve
  29193. * @param gradient Scalar amount to interpolate
  29194. * @returns Interpolated scalar value
  29195. */
  29196. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29197. /**
  29198. * Interpolates a quaternion using a spherical linear interpolation
  29199. * @param startValue Start value of the animation curve
  29200. * @param endValue End value of the animation curve
  29201. * @param gradient Scalar amount to interpolate
  29202. * @returns Interpolated quaternion value
  29203. */
  29204. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29205. /**
  29206. * Interpolates a quaternion cubically
  29207. * @param startValue Start value of the animation curve
  29208. * @param outTangent End tangent of the animation curve
  29209. * @param endValue End value of the animation curve
  29210. * @param inTangent Start tangent of the animation curve
  29211. * @param gradient Scalar amount to interpolate
  29212. * @returns Interpolated quaternion value
  29213. */
  29214. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29215. /**
  29216. * Interpolates a Vector3 linearl
  29217. * @param startValue Start value of the animation curve
  29218. * @param endValue End value of the animation curve
  29219. * @param gradient Scalar amount to interpolate
  29220. * @returns Interpolated scalar value
  29221. */
  29222. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29223. /**
  29224. * Interpolates a Vector3 cubically
  29225. * @param startValue Start value of the animation curve
  29226. * @param outTangent End tangent of the animation
  29227. * @param endValue End value of the animation curve
  29228. * @param inTangent Start tangent of the animation curve
  29229. * @param gradient Scalar amount to interpolate
  29230. * @returns InterpolatedVector3 value
  29231. */
  29232. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29233. /**
  29234. * Interpolates a Vector2 linearly
  29235. * @param startValue Start value of the animation curve
  29236. * @param endValue End value of the animation curve
  29237. * @param gradient Scalar amount to interpolate
  29238. * @returns Interpolated Vector2 value
  29239. */
  29240. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29241. /**
  29242. * Interpolates a Vector2 cubically
  29243. * @param startValue Start value of the animation curve
  29244. * @param outTangent End tangent of the animation
  29245. * @param endValue End value of the animation curve
  29246. * @param inTangent Start tangent of the animation curve
  29247. * @param gradient Scalar amount to interpolate
  29248. * @returns Interpolated Vector2 value
  29249. */
  29250. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29251. /**
  29252. * Interpolates a size linearly
  29253. * @param startValue Start value of the animation curve
  29254. * @param endValue End value of the animation curve
  29255. * @param gradient Scalar amount to interpolate
  29256. * @returns Interpolated Size value
  29257. */
  29258. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29259. /**
  29260. * Interpolates a Color3 linearly
  29261. * @param startValue Start value of the animation curve
  29262. * @param endValue End value of the animation curve
  29263. * @param gradient Scalar amount to interpolate
  29264. * @returns Interpolated Color3 value
  29265. */
  29266. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29267. /**
  29268. * Interpolates a Color4 linearly
  29269. * @param startValue Start value of the animation curve
  29270. * @param endValue End value of the animation curve
  29271. * @param gradient Scalar amount to interpolate
  29272. * @returns Interpolated Color3 value
  29273. */
  29274. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29275. /**
  29276. * @hidden Internal use only
  29277. */
  29278. _getKeyValue(value: any): any;
  29279. /**
  29280. * @hidden Internal use only
  29281. */
  29282. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29283. /**
  29284. * Defines the function to use to interpolate matrices
  29285. * @param startValue defines the start matrix
  29286. * @param endValue defines the end matrix
  29287. * @param gradient defines the gradient between both matrices
  29288. * @param result defines an optional target matrix where to store the interpolation
  29289. * @returns the interpolated matrix
  29290. */
  29291. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29292. /**
  29293. * Makes a copy of the animation
  29294. * @returns Cloned animation
  29295. */
  29296. clone(): Animation;
  29297. /**
  29298. * Sets the key frames of the animation
  29299. * @param values The animation key frames to set
  29300. */
  29301. setKeys(values: Array<IAnimationKey>): void;
  29302. /**
  29303. * Serializes the animation to an object
  29304. * @returns Serialized object
  29305. */
  29306. serialize(): any;
  29307. /**
  29308. * Float animation type
  29309. */
  29310. static readonly ANIMATIONTYPE_FLOAT: number;
  29311. /**
  29312. * Vector3 animation type
  29313. */
  29314. static readonly ANIMATIONTYPE_VECTOR3: number;
  29315. /**
  29316. * Quaternion animation type
  29317. */
  29318. static readonly ANIMATIONTYPE_QUATERNION: number;
  29319. /**
  29320. * Matrix animation type
  29321. */
  29322. static readonly ANIMATIONTYPE_MATRIX: number;
  29323. /**
  29324. * Color3 animation type
  29325. */
  29326. static readonly ANIMATIONTYPE_COLOR3: number;
  29327. /**
  29328. * Color3 animation type
  29329. */
  29330. static readonly ANIMATIONTYPE_COLOR4: number;
  29331. /**
  29332. * Vector2 animation type
  29333. */
  29334. static readonly ANIMATIONTYPE_VECTOR2: number;
  29335. /**
  29336. * Size animation type
  29337. */
  29338. static readonly ANIMATIONTYPE_SIZE: number;
  29339. /**
  29340. * Relative Loop Mode
  29341. */
  29342. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29343. /**
  29344. * Cycle Loop Mode
  29345. */
  29346. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29347. /**
  29348. * Constant Loop Mode
  29349. */
  29350. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29351. /** @hidden */
  29352. static _UniversalLerp(left: any, right: any, amount: number): any;
  29353. /**
  29354. * Parses an animation object and creates an animation
  29355. * @param parsedAnimation Parsed animation object
  29356. * @returns Animation object
  29357. */
  29358. static Parse(parsedAnimation: any): Animation;
  29359. /**
  29360. * Appends the serialized animations from the source animations
  29361. * @param source Source containing the animations
  29362. * @param destination Target to store the animations
  29363. */
  29364. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29365. }
  29366. }
  29367. declare module BABYLON {
  29368. /**
  29369. * Interface containing an array of animations
  29370. */
  29371. export interface IAnimatable {
  29372. /**
  29373. * Array of animations
  29374. */
  29375. animations: Nullable<Array<Animation>>;
  29376. }
  29377. }
  29378. declare module BABYLON {
  29379. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29380. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29381. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29382. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29383. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29384. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29385. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29386. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29387. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29388. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29389. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29390. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29391. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29392. /**
  29393. * Decorator used to define property that can be serialized as reference to a camera
  29394. * @param sourceName defines the name of the property to decorate
  29395. */
  29396. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29397. /**
  29398. * Class used to help serialization objects
  29399. */
  29400. export class SerializationHelper {
  29401. /** @hidden */
  29402. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29403. /** @hidden */
  29404. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29405. /** @hidden */
  29406. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29407. /** @hidden */
  29408. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29409. /**
  29410. * Appends the serialized animations from the source animations
  29411. * @param source Source containing the animations
  29412. * @param destination Target to store the animations
  29413. */
  29414. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29415. /**
  29416. * Static function used to serialized a specific entity
  29417. * @param entity defines the entity to serialize
  29418. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29419. * @returns a JSON compatible object representing the serialization of the entity
  29420. */
  29421. static Serialize<T>(entity: T, serializationObject?: any): any;
  29422. /**
  29423. * Creates a new entity from a serialization data object
  29424. * @param creationFunction defines a function used to instanciated the new entity
  29425. * @param source defines the source serialization data
  29426. * @param scene defines the hosting scene
  29427. * @param rootUrl defines the root url for resources
  29428. * @returns a new entity
  29429. */
  29430. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29431. /**
  29432. * Clones an object
  29433. * @param creationFunction defines the function used to instanciate the new object
  29434. * @param source defines the source object
  29435. * @returns the cloned object
  29436. */
  29437. static Clone<T>(creationFunction: () => T, source: T): T;
  29438. /**
  29439. * Instanciates a new object based on a source one (some data will be shared between both object)
  29440. * @param creationFunction defines the function used to instanciate the new object
  29441. * @param source defines the source object
  29442. * @returns the new object
  29443. */
  29444. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29445. }
  29446. }
  29447. declare module BABYLON {
  29448. /**
  29449. * Class used to manipulate GUIDs
  29450. */
  29451. export class GUID {
  29452. /**
  29453. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29454. * Be aware Math.random() could cause collisions, but:
  29455. * "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"
  29456. * @returns a pseudo random id
  29457. */
  29458. static RandomId(): string;
  29459. }
  29460. }
  29461. declare module BABYLON {
  29462. /**
  29463. * Base class of all the textures in babylon.
  29464. * It groups all the common properties the materials, post process, lights... might need
  29465. * in order to make a correct use of the texture.
  29466. */
  29467. export class BaseTexture implements IAnimatable {
  29468. /**
  29469. * Default anisotropic filtering level for the application.
  29470. * It is set to 4 as a good tradeoff between perf and quality.
  29471. */
  29472. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29473. /**
  29474. * Gets or sets the unique id of the texture
  29475. */
  29476. uniqueId: number;
  29477. /**
  29478. * Define the name of the texture.
  29479. */
  29480. name: string;
  29481. /**
  29482. * Gets or sets an object used to store user defined information.
  29483. */
  29484. metadata: any;
  29485. /**
  29486. * For internal use only. Please do not use.
  29487. */
  29488. reservedDataStore: any;
  29489. private _hasAlpha;
  29490. /**
  29491. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29492. */
  29493. set hasAlpha(value: boolean);
  29494. get hasAlpha(): boolean;
  29495. /**
  29496. * Defines if the alpha value should be determined via the rgb values.
  29497. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29498. */
  29499. getAlphaFromRGB: boolean;
  29500. /**
  29501. * Intensity or strength of the texture.
  29502. * It is commonly used by materials to fine tune the intensity of the texture
  29503. */
  29504. level: number;
  29505. /**
  29506. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29507. * This is part of the texture as textures usually maps to one uv set.
  29508. */
  29509. coordinatesIndex: number;
  29510. private _coordinatesMode;
  29511. /**
  29512. * How a texture is mapped.
  29513. *
  29514. * | Value | Type | Description |
  29515. * | ----- | ----------------------------------- | ----------- |
  29516. * | 0 | EXPLICIT_MODE | |
  29517. * | 1 | SPHERICAL_MODE | |
  29518. * | 2 | PLANAR_MODE | |
  29519. * | 3 | CUBIC_MODE | |
  29520. * | 4 | PROJECTION_MODE | |
  29521. * | 5 | SKYBOX_MODE | |
  29522. * | 6 | INVCUBIC_MODE | |
  29523. * | 7 | EQUIRECTANGULAR_MODE | |
  29524. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29525. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29526. */
  29527. set coordinatesMode(value: number);
  29528. get coordinatesMode(): number;
  29529. /**
  29530. * | Value | Type | Description |
  29531. * | ----- | ------------------ | ----------- |
  29532. * | 0 | CLAMP_ADDRESSMODE | |
  29533. * | 1 | WRAP_ADDRESSMODE | |
  29534. * | 2 | MIRROR_ADDRESSMODE | |
  29535. */
  29536. wrapU: number;
  29537. /**
  29538. * | Value | Type | Description |
  29539. * | ----- | ------------------ | ----------- |
  29540. * | 0 | CLAMP_ADDRESSMODE | |
  29541. * | 1 | WRAP_ADDRESSMODE | |
  29542. * | 2 | MIRROR_ADDRESSMODE | |
  29543. */
  29544. wrapV: number;
  29545. /**
  29546. * | Value | Type | Description |
  29547. * | ----- | ------------------ | ----------- |
  29548. * | 0 | CLAMP_ADDRESSMODE | |
  29549. * | 1 | WRAP_ADDRESSMODE | |
  29550. * | 2 | MIRROR_ADDRESSMODE | |
  29551. */
  29552. wrapR: number;
  29553. /**
  29554. * With compliant hardware and browser (supporting anisotropic filtering)
  29555. * this defines the level of anisotropic filtering in the texture.
  29556. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29557. */
  29558. anisotropicFilteringLevel: number;
  29559. /**
  29560. * Define if the texture is a cube texture or if false a 2d texture.
  29561. */
  29562. get isCube(): boolean;
  29563. set isCube(value: boolean);
  29564. /**
  29565. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29566. */
  29567. get is3D(): boolean;
  29568. set is3D(value: boolean);
  29569. /**
  29570. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29571. */
  29572. get is2DArray(): boolean;
  29573. set is2DArray(value: boolean);
  29574. /**
  29575. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29576. * HDR texture are usually stored in linear space.
  29577. * This only impacts the PBR and Background materials
  29578. */
  29579. gammaSpace: boolean;
  29580. /**
  29581. * Gets or sets whether or not the texture contains RGBD data.
  29582. */
  29583. get isRGBD(): boolean;
  29584. set isRGBD(value: boolean);
  29585. /**
  29586. * Is Z inverted in the texture (useful in a cube texture).
  29587. */
  29588. invertZ: boolean;
  29589. /**
  29590. * Are mip maps generated for this texture or not.
  29591. */
  29592. get noMipmap(): boolean;
  29593. /**
  29594. * @hidden
  29595. */
  29596. lodLevelInAlpha: boolean;
  29597. /**
  29598. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29599. */
  29600. get lodGenerationOffset(): number;
  29601. set lodGenerationOffset(value: number);
  29602. /**
  29603. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29604. */
  29605. get lodGenerationScale(): number;
  29606. set lodGenerationScale(value: number);
  29607. /**
  29608. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29609. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29610. * average roughness values.
  29611. */
  29612. get linearSpecularLOD(): boolean;
  29613. set linearSpecularLOD(value: boolean);
  29614. /**
  29615. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29616. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29617. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29618. */
  29619. get irradianceTexture(): Nullable<BaseTexture>;
  29620. set irradianceTexture(value: Nullable<BaseTexture>);
  29621. /**
  29622. * Define if the texture is a render target.
  29623. */
  29624. isRenderTarget: boolean;
  29625. /**
  29626. * Define the unique id of the texture in the scene.
  29627. */
  29628. get uid(): string;
  29629. /**
  29630. * Return a string representation of the texture.
  29631. * @returns the texture as a string
  29632. */
  29633. toString(): string;
  29634. /**
  29635. * Get the class name of the texture.
  29636. * @returns "BaseTexture"
  29637. */
  29638. getClassName(): string;
  29639. /**
  29640. * Define the list of animation attached to the texture.
  29641. */
  29642. animations: Animation[];
  29643. /**
  29644. * An event triggered when the texture is disposed.
  29645. */
  29646. onDisposeObservable: Observable<BaseTexture>;
  29647. private _onDisposeObserver;
  29648. /**
  29649. * Callback triggered when the texture has been disposed.
  29650. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29651. */
  29652. set onDispose(callback: () => void);
  29653. /**
  29654. * Define the current state of the loading sequence when in delayed load mode.
  29655. */
  29656. delayLoadState: number;
  29657. private _scene;
  29658. /** @hidden */
  29659. _texture: Nullable<InternalTexture>;
  29660. private _uid;
  29661. /**
  29662. * Define if the texture is preventinga material to render or not.
  29663. * If not and the texture is not ready, the engine will use a default black texture instead.
  29664. */
  29665. get isBlocking(): boolean;
  29666. /**
  29667. * Instantiates a new BaseTexture.
  29668. * Base class of all the textures in babylon.
  29669. * It groups all the common properties the materials, post process, lights... might need
  29670. * in order to make a correct use of the texture.
  29671. * @param scene Define the scene the texture blongs to
  29672. */
  29673. constructor(scene: Nullable<Scene>);
  29674. /**
  29675. * Get the scene the texture belongs to.
  29676. * @returns the scene or null if undefined
  29677. */
  29678. getScene(): Nullable<Scene>;
  29679. /**
  29680. * Get the texture transform matrix used to offset tile the texture for istance.
  29681. * @returns the transformation matrix
  29682. */
  29683. getTextureMatrix(): Matrix;
  29684. /**
  29685. * Get the texture reflection matrix used to rotate/transform the reflection.
  29686. * @returns the reflection matrix
  29687. */
  29688. getReflectionTextureMatrix(): Matrix;
  29689. /**
  29690. * Get the underlying lower level texture from Babylon.
  29691. * @returns the insternal texture
  29692. */
  29693. getInternalTexture(): Nullable<InternalTexture>;
  29694. /**
  29695. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29696. * @returns true if ready or not blocking
  29697. */
  29698. isReadyOrNotBlocking(): boolean;
  29699. /**
  29700. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29701. * @returns true if fully ready
  29702. */
  29703. isReady(): boolean;
  29704. private _cachedSize;
  29705. /**
  29706. * Get the size of the texture.
  29707. * @returns the texture size.
  29708. */
  29709. getSize(): ISize;
  29710. /**
  29711. * Get the base size of the texture.
  29712. * It can be different from the size if the texture has been resized for POT for instance
  29713. * @returns the base size
  29714. */
  29715. getBaseSize(): ISize;
  29716. /**
  29717. * Update the sampling mode of the texture.
  29718. * Default is Trilinear mode.
  29719. *
  29720. * | Value | Type | Description |
  29721. * | ----- | ------------------ | ----------- |
  29722. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29723. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29724. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29725. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29726. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29727. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29728. * | 7 | NEAREST_LINEAR | |
  29729. * | 8 | NEAREST_NEAREST | |
  29730. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29731. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29732. * | 11 | LINEAR_LINEAR | |
  29733. * | 12 | LINEAR_NEAREST | |
  29734. *
  29735. * > _mag_: magnification filter (close to the viewer)
  29736. * > _min_: minification filter (far from the viewer)
  29737. * > _mip_: filter used between mip map levels
  29738. *@param samplingMode Define the new sampling mode of the texture
  29739. */
  29740. updateSamplingMode(samplingMode: number): void;
  29741. /**
  29742. * Scales the texture if is `canRescale()`
  29743. * @param ratio the resize factor we want to use to rescale
  29744. */
  29745. scale(ratio: number): void;
  29746. /**
  29747. * Get if the texture can rescale.
  29748. */
  29749. get canRescale(): boolean;
  29750. /** @hidden */
  29751. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29752. /** @hidden */
  29753. _rebuild(): void;
  29754. /**
  29755. * Triggers the load sequence in delayed load mode.
  29756. */
  29757. delayLoad(): void;
  29758. /**
  29759. * Clones the texture.
  29760. * @returns the cloned texture
  29761. */
  29762. clone(): Nullable<BaseTexture>;
  29763. /**
  29764. * Get the texture underlying type (INT, FLOAT...)
  29765. */
  29766. get textureType(): number;
  29767. /**
  29768. * Get the texture underlying format (RGB, RGBA...)
  29769. */
  29770. get textureFormat(): number;
  29771. /**
  29772. * Indicates that textures need to be re-calculated for all materials
  29773. */
  29774. protected _markAllSubMeshesAsTexturesDirty(): void;
  29775. /**
  29776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29777. * This will returns an RGBA array buffer containing either in values (0-255) or
  29778. * float values (0-1) depending of the underlying buffer type.
  29779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29781. * @param buffer defines a user defined buffer to fill with data (can be null)
  29782. * @returns The Array buffer containing the pixels data.
  29783. */
  29784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29785. /**
  29786. * Release and destroy the underlying lower level texture aka internalTexture.
  29787. */
  29788. releaseInternalTexture(): void;
  29789. /** @hidden */
  29790. get _lodTextureHigh(): Nullable<BaseTexture>;
  29791. /** @hidden */
  29792. get _lodTextureMid(): Nullable<BaseTexture>;
  29793. /** @hidden */
  29794. get _lodTextureLow(): Nullable<BaseTexture>;
  29795. /**
  29796. * Dispose the texture and release its associated resources.
  29797. */
  29798. dispose(): void;
  29799. /**
  29800. * Serialize the texture into a JSON representation that can be parsed later on.
  29801. * @returns the JSON representation of the texture
  29802. */
  29803. serialize(): any;
  29804. /**
  29805. * Helper function to be called back once a list of texture contains only ready textures.
  29806. * @param textures Define the list of textures to wait for
  29807. * @param callback Define the callback triggered once the entire list will be ready
  29808. */
  29809. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29810. }
  29811. }
  29812. declare module BABYLON {
  29813. /**
  29814. * Options to be used when creating an effect.
  29815. */
  29816. export interface IEffectCreationOptions {
  29817. /**
  29818. * Atrributes that will be used in the shader.
  29819. */
  29820. attributes: string[];
  29821. /**
  29822. * Uniform varible names that will be set in the shader.
  29823. */
  29824. uniformsNames: string[];
  29825. /**
  29826. * Uniform buffer variable names that will be set in the shader.
  29827. */
  29828. uniformBuffersNames: string[];
  29829. /**
  29830. * Sampler texture variable names that will be set in the shader.
  29831. */
  29832. samplers: string[];
  29833. /**
  29834. * Define statements that will be set in the shader.
  29835. */
  29836. defines: any;
  29837. /**
  29838. * Possible fallbacks for this effect to improve performance when needed.
  29839. */
  29840. fallbacks: Nullable<IEffectFallbacks>;
  29841. /**
  29842. * Callback that will be called when the shader is compiled.
  29843. */
  29844. onCompiled: Nullable<(effect: Effect) => void>;
  29845. /**
  29846. * Callback that will be called if an error occurs during shader compilation.
  29847. */
  29848. onError: Nullable<(effect: Effect, errors: string) => void>;
  29849. /**
  29850. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29851. */
  29852. indexParameters?: any;
  29853. /**
  29854. * Max number of lights that can be used in the shader.
  29855. */
  29856. maxSimultaneousLights?: number;
  29857. /**
  29858. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29859. */
  29860. transformFeedbackVaryings?: Nullable<string[]>;
  29861. }
  29862. /**
  29863. * Effect containing vertex and fragment shader that can be executed on an object.
  29864. */
  29865. export class Effect implements IDisposable {
  29866. /**
  29867. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29868. */
  29869. static ShadersRepository: string;
  29870. /**
  29871. * Name of the effect.
  29872. */
  29873. name: any;
  29874. /**
  29875. * String container all the define statements that should be set on the shader.
  29876. */
  29877. defines: string;
  29878. /**
  29879. * Callback that will be called when the shader is compiled.
  29880. */
  29881. onCompiled: Nullable<(effect: Effect) => void>;
  29882. /**
  29883. * Callback that will be called if an error occurs during shader compilation.
  29884. */
  29885. onError: Nullable<(effect: Effect, errors: string) => void>;
  29886. /**
  29887. * Callback that will be called when effect is bound.
  29888. */
  29889. onBind: Nullable<(effect: Effect) => void>;
  29890. /**
  29891. * Unique ID of the effect.
  29892. */
  29893. uniqueId: number;
  29894. /**
  29895. * Observable that will be called when the shader is compiled.
  29896. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29897. */
  29898. onCompileObservable: Observable<Effect>;
  29899. /**
  29900. * Observable that will be called if an error occurs during shader compilation.
  29901. */
  29902. onErrorObservable: Observable<Effect>;
  29903. /** @hidden */
  29904. _onBindObservable: Nullable<Observable<Effect>>;
  29905. /**
  29906. * @hidden
  29907. * Specifies if the effect was previously ready
  29908. */
  29909. _wasPreviouslyReady: boolean;
  29910. /**
  29911. * Observable that will be called when effect is bound.
  29912. */
  29913. get onBindObservable(): Observable<Effect>;
  29914. /** @hidden */
  29915. _bonesComputationForcedToCPU: boolean;
  29916. private static _uniqueIdSeed;
  29917. private _engine;
  29918. private _uniformBuffersNames;
  29919. private _uniformsNames;
  29920. private _samplerList;
  29921. private _samplers;
  29922. private _isReady;
  29923. private _compilationError;
  29924. private _allFallbacksProcessed;
  29925. private _attributesNames;
  29926. private _attributes;
  29927. private _attributeLocationByName;
  29928. private _uniforms;
  29929. /**
  29930. * Key for the effect.
  29931. * @hidden
  29932. */
  29933. _key: string;
  29934. private _indexParameters;
  29935. private _fallbacks;
  29936. private _vertexSourceCode;
  29937. private _fragmentSourceCode;
  29938. private _vertexSourceCodeOverride;
  29939. private _fragmentSourceCodeOverride;
  29940. private _transformFeedbackVaryings;
  29941. /**
  29942. * Compiled shader to webGL program.
  29943. * @hidden
  29944. */
  29945. _pipelineContext: Nullable<IPipelineContext>;
  29946. private _valueCache;
  29947. private static _baseCache;
  29948. /**
  29949. * Instantiates an effect.
  29950. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29951. * @param baseName Name of the effect.
  29952. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29953. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29954. * @param samplers List of sampler variables that will be passed to the shader.
  29955. * @param engine Engine to be used to render the effect
  29956. * @param defines Define statements to be added to the shader.
  29957. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29958. * @param onCompiled Callback that will be called when the shader is compiled.
  29959. * @param onError Callback that will be called if an error occurs during shader compilation.
  29960. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29961. */
  29962. 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);
  29963. private _useFinalCode;
  29964. /**
  29965. * Unique key for this effect
  29966. */
  29967. get key(): string;
  29968. /**
  29969. * If the effect has been compiled and prepared.
  29970. * @returns if the effect is compiled and prepared.
  29971. */
  29972. isReady(): boolean;
  29973. private _isReadyInternal;
  29974. /**
  29975. * The engine the effect was initialized with.
  29976. * @returns the engine.
  29977. */
  29978. getEngine(): Engine;
  29979. /**
  29980. * The pipeline context for this effect
  29981. * @returns the associated pipeline context
  29982. */
  29983. getPipelineContext(): Nullable<IPipelineContext>;
  29984. /**
  29985. * The set of names of attribute variables for the shader.
  29986. * @returns An array of attribute names.
  29987. */
  29988. getAttributesNames(): string[];
  29989. /**
  29990. * Returns the attribute at the given index.
  29991. * @param index The index of the attribute.
  29992. * @returns The location of the attribute.
  29993. */
  29994. getAttributeLocation(index: number): number;
  29995. /**
  29996. * Returns the attribute based on the name of the variable.
  29997. * @param name of the attribute to look up.
  29998. * @returns the attribute location.
  29999. */
  30000. getAttributeLocationByName(name: string): number;
  30001. /**
  30002. * The number of attributes.
  30003. * @returns the numnber of attributes.
  30004. */
  30005. getAttributesCount(): number;
  30006. /**
  30007. * Gets the index of a uniform variable.
  30008. * @param uniformName of the uniform to look up.
  30009. * @returns the index.
  30010. */
  30011. getUniformIndex(uniformName: string): number;
  30012. /**
  30013. * Returns the attribute based on the name of the variable.
  30014. * @param uniformName of the uniform to look up.
  30015. * @returns the location of the uniform.
  30016. */
  30017. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30018. /**
  30019. * Returns an array of sampler variable names
  30020. * @returns The array of sampler variable neames.
  30021. */
  30022. getSamplers(): string[];
  30023. /**
  30024. * The error from the last compilation.
  30025. * @returns the error string.
  30026. */
  30027. getCompilationError(): string;
  30028. /**
  30029. * Gets a boolean indicating that all fallbacks were used during compilation
  30030. * @returns true if all fallbacks were used
  30031. */
  30032. allFallbacksProcessed(): boolean;
  30033. /**
  30034. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30035. * @param func The callback to be used.
  30036. */
  30037. executeWhenCompiled(func: (effect: Effect) => void): void;
  30038. private _checkIsReady;
  30039. private _loadShader;
  30040. /**
  30041. * Recompiles the webGL program
  30042. * @param vertexSourceCode The source code for the vertex shader.
  30043. * @param fragmentSourceCode The source code for the fragment shader.
  30044. * @param onCompiled Callback called when completed.
  30045. * @param onError Callback called on error.
  30046. * @hidden
  30047. */
  30048. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30049. /**
  30050. * Prepares the effect
  30051. * @hidden
  30052. */
  30053. _prepareEffect(): void;
  30054. private _processCompilationErrors;
  30055. /**
  30056. * Checks if the effect is supported. (Must be called after compilation)
  30057. */
  30058. get isSupported(): boolean;
  30059. /**
  30060. * Binds a texture to the engine to be used as output of the shader.
  30061. * @param channel Name of the output variable.
  30062. * @param texture Texture to bind.
  30063. * @hidden
  30064. */
  30065. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30066. /**
  30067. * Sets a texture on the engine to be used in the shader.
  30068. * @param channel Name of the sampler variable.
  30069. * @param texture Texture to set.
  30070. */
  30071. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30072. /**
  30073. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30074. * @param channel Name of the sampler variable.
  30075. * @param texture Texture to set.
  30076. */
  30077. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30078. /**
  30079. * Sets an array of textures on the engine to be used in the shader.
  30080. * @param channel Name of the variable.
  30081. * @param textures Textures to set.
  30082. */
  30083. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30084. /**
  30085. * 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)
  30086. * @param channel Name of the sampler variable.
  30087. * @param postProcess Post process to get the input texture from.
  30088. */
  30089. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30090. /**
  30091. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30092. * 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)
  30093. * @param channel Name of the sampler variable.
  30094. * @param postProcess Post process to get the output texture from.
  30095. */
  30096. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30097. /** @hidden */
  30098. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30099. /** @hidden */
  30100. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30101. /** @hidden */
  30102. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30103. /** @hidden */
  30104. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30105. /**
  30106. * Binds a buffer to a uniform.
  30107. * @param buffer Buffer to bind.
  30108. * @param name Name of the uniform variable to bind to.
  30109. */
  30110. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30111. /**
  30112. * Binds block to a uniform.
  30113. * @param blockName Name of the block to bind.
  30114. * @param index Index to bind.
  30115. */
  30116. bindUniformBlock(blockName: string, index: number): void;
  30117. /**
  30118. * Sets an interger value on a uniform variable.
  30119. * @param uniformName Name of the variable.
  30120. * @param value Value to be set.
  30121. * @returns this effect.
  30122. */
  30123. setInt(uniformName: string, value: number): Effect;
  30124. /**
  30125. * Sets an int array on a uniform variable.
  30126. * @param uniformName Name of the variable.
  30127. * @param array array to be set.
  30128. * @returns this effect.
  30129. */
  30130. setIntArray(uniformName: string, array: Int32Array): Effect;
  30131. /**
  30132. * 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)
  30133. * @param uniformName Name of the variable.
  30134. * @param array array to be set.
  30135. * @returns this effect.
  30136. */
  30137. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30138. /**
  30139. * 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)
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30145. /**
  30146. * 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)
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30152. /**
  30153. * Sets an float array on a uniform variable.
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30166. /**
  30167. * 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)
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30173. /**
  30174. * 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)
  30175. * @param uniformName Name of the variable.
  30176. * @param array array to be set.
  30177. * @returns this effect.
  30178. */
  30179. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30180. /**
  30181. * Sets an array on a uniform variable.
  30182. * @param uniformName Name of the variable.
  30183. * @param array array to be set.
  30184. * @returns this effect.
  30185. */
  30186. setArray(uniformName: string, array: number[]): Effect;
  30187. /**
  30188. * 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)
  30189. * @param uniformName Name of the variable.
  30190. * @param array array to be set.
  30191. * @returns this effect.
  30192. */
  30193. setArray2(uniformName: string, array: number[]): Effect;
  30194. /**
  30195. * 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)
  30196. * @param uniformName Name of the variable.
  30197. * @param array array to be set.
  30198. * @returns this effect.
  30199. */
  30200. setArray3(uniformName: string, array: number[]): Effect;
  30201. /**
  30202. * 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)
  30203. * @param uniformName Name of the variable.
  30204. * @param array array to be set.
  30205. * @returns this effect.
  30206. */
  30207. setArray4(uniformName: string, array: number[]): Effect;
  30208. /**
  30209. * Sets matrices on a uniform variable.
  30210. * @param uniformName Name of the variable.
  30211. * @param matrices matrices to be set.
  30212. * @returns this effect.
  30213. */
  30214. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30215. /**
  30216. * Sets matrix on a uniform variable.
  30217. * @param uniformName Name of the variable.
  30218. * @param matrix matrix to be set.
  30219. * @returns this effect.
  30220. */
  30221. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30222. /**
  30223. * 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)
  30224. * @param uniformName Name of the variable.
  30225. * @param matrix matrix to be set.
  30226. * @returns this effect.
  30227. */
  30228. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30229. /**
  30230. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30231. * @param uniformName Name of the variable.
  30232. * @param matrix matrix to be set.
  30233. * @returns this effect.
  30234. */
  30235. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30236. /**
  30237. * Sets a float on a uniform variable.
  30238. * @param uniformName Name of the variable.
  30239. * @param value value to be set.
  30240. * @returns this effect.
  30241. */
  30242. setFloat(uniformName: string, value: number): Effect;
  30243. /**
  30244. * Sets a boolean on a uniform variable.
  30245. * @param uniformName Name of the variable.
  30246. * @param bool value to be set.
  30247. * @returns this effect.
  30248. */
  30249. setBool(uniformName: string, bool: boolean): Effect;
  30250. /**
  30251. * Sets a Vector2 on a uniform variable.
  30252. * @param uniformName Name of the variable.
  30253. * @param vector2 vector2 to be set.
  30254. * @returns this effect.
  30255. */
  30256. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30257. /**
  30258. * Sets a float2 on a uniform variable.
  30259. * @param uniformName Name of the variable.
  30260. * @param x First float in float2.
  30261. * @param y Second float in float2.
  30262. * @returns this effect.
  30263. */
  30264. setFloat2(uniformName: string, x: number, y: number): Effect;
  30265. /**
  30266. * Sets a Vector3 on a uniform variable.
  30267. * @param uniformName Name of the variable.
  30268. * @param vector3 Value to be set.
  30269. * @returns this effect.
  30270. */
  30271. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30272. /**
  30273. * Sets a float3 on a uniform variable.
  30274. * @param uniformName Name of the variable.
  30275. * @param x First float in float3.
  30276. * @param y Second float in float3.
  30277. * @param z Third float in float3.
  30278. * @returns this effect.
  30279. */
  30280. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30281. /**
  30282. * Sets a Vector4 on a uniform variable.
  30283. * @param uniformName Name of the variable.
  30284. * @param vector4 Value to be set.
  30285. * @returns this effect.
  30286. */
  30287. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30288. /**
  30289. * Sets a float4 on a uniform variable.
  30290. * @param uniformName Name of the variable.
  30291. * @param x First float in float4.
  30292. * @param y Second float in float4.
  30293. * @param z Third float in float4.
  30294. * @param w Fourth float in float4.
  30295. * @returns this effect.
  30296. */
  30297. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30298. /**
  30299. * Sets a Color3 on a uniform variable.
  30300. * @param uniformName Name of the variable.
  30301. * @param color3 Value to be set.
  30302. * @returns this effect.
  30303. */
  30304. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30305. /**
  30306. * Sets a Color4 on a uniform variable.
  30307. * @param uniformName Name of the variable.
  30308. * @param color3 Value to be set.
  30309. * @param alpha Alpha value to be set.
  30310. * @returns this effect.
  30311. */
  30312. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30313. /**
  30314. * Sets a Color4 on a uniform variable
  30315. * @param uniformName defines the name of the variable
  30316. * @param color4 defines the value to be set
  30317. * @returns this effect.
  30318. */
  30319. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30320. /** Release all associated resources */
  30321. dispose(): void;
  30322. /**
  30323. * This function will add a new shader to the shader store
  30324. * @param name the name of the shader
  30325. * @param pixelShader optional pixel shader content
  30326. * @param vertexShader optional vertex shader content
  30327. */
  30328. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30329. /**
  30330. * Store of each shader (The can be looked up using effect.key)
  30331. */
  30332. static ShadersStore: {
  30333. [key: string]: string;
  30334. };
  30335. /**
  30336. * Store of each included file for a shader (The can be looked up using effect.key)
  30337. */
  30338. static IncludesShadersStore: {
  30339. [key: string]: string;
  30340. };
  30341. /**
  30342. * Resets the cache of effects.
  30343. */
  30344. static ResetCache(): void;
  30345. }
  30346. }
  30347. declare module BABYLON {
  30348. /**
  30349. * Interface used to describe the capabilities of the engine relatively to the current browser
  30350. */
  30351. export interface EngineCapabilities {
  30352. /** Maximum textures units per fragment shader */
  30353. maxTexturesImageUnits: number;
  30354. /** Maximum texture units per vertex shader */
  30355. maxVertexTextureImageUnits: number;
  30356. /** Maximum textures units in the entire pipeline */
  30357. maxCombinedTexturesImageUnits: number;
  30358. /** Maximum texture size */
  30359. maxTextureSize: number;
  30360. /** Maximum texture samples */
  30361. maxSamples?: number;
  30362. /** Maximum cube texture size */
  30363. maxCubemapTextureSize: number;
  30364. /** Maximum render texture size */
  30365. maxRenderTextureSize: number;
  30366. /** Maximum number of vertex attributes */
  30367. maxVertexAttribs: number;
  30368. /** Maximum number of varyings */
  30369. maxVaryingVectors: number;
  30370. /** Maximum number of uniforms per vertex shader */
  30371. maxVertexUniformVectors: number;
  30372. /** Maximum number of uniforms per fragment shader */
  30373. maxFragmentUniformVectors: number;
  30374. /** Defines if standard derivates (dx/dy) are supported */
  30375. standardDerivatives: boolean;
  30376. /** Defines if s3tc texture compression is supported */
  30377. s3tc?: WEBGL_compressed_texture_s3tc;
  30378. /** Defines if pvrtc texture compression is supported */
  30379. pvrtc: any;
  30380. /** Defines if etc1 texture compression is supported */
  30381. etc1: any;
  30382. /** Defines if etc2 texture compression is supported */
  30383. etc2: any;
  30384. /** Defines if astc texture compression is supported */
  30385. astc: any;
  30386. /** Defines if float textures are supported */
  30387. textureFloat: boolean;
  30388. /** Defines if vertex array objects are supported */
  30389. vertexArrayObject: boolean;
  30390. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30391. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30392. /** Gets the maximum level of anisotropy supported */
  30393. maxAnisotropy: number;
  30394. /** Defines if instancing is supported */
  30395. instancedArrays: boolean;
  30396. /** Defines if 32 bits indices are supported */
  30397. uintIndices: boolean;
  30398. /** Defines if high precision shaders are supported */
  30399. highPrecisionShaderSupported: boolean;
  30400. /** Defines if depth reading in the fragment shader is supported */
  30401. fragmentDepthSupported: boolean;
  30402. /** Defines if float texture linear filtering is supported*/
  30403. textureFloatLinearFiltering: boolean;
  30404. /** Defines if rendering to float textures is supported */
  30405. textureFloatRender: boolean;
  30406. /** Defines if half float textures are supported*/
  30407. textureHalfFloat: boolean;
  30408. /** Defines if half float texture linear filtering is supported*/
  30409. textureHalfFloatLinearFiltering: boolean;
  30410. /** Defines if rendering to half float textures is supported */
  30411. textureHalfFloatRender: boolean;
  30412. /** Defines if textureLOD shader command is supported */
  30413. textureLOD: boolean;
  30414. /** Defines if draw buffers extension is supported */
  30415. drawBuffersExtension: boolean;
  30416. /** Defines if depth textures are supported */
  30417. depthTextureExtension: boolean;
  30418. /** Defines if float color buffer are supported */
  30419. colorBufferFloat: boolean;
  30420. /** Gets disjoint timer query extension (null if not supported) */
  30421. timerQuery?: EXT_disjoint_timer_query;
  30422. /** Defines if timestamp can be used with timer query */
  30423. canUseTimestampForTimerQuery: boolean;
  30424. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30425. multiview?: any;
  30426. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30427. oculusMultiview?: any;
  30428. /** Function used to let the system compiles shaders in background */
  30429. parallelShaderCompile?: {
  30430. COMPLETION_STATUS_KHR: number;
  30431. };
  30432. /** Max number of texture samples for MSAA */
  30433. maxMSAASamples: number;
  30434. /** Defines if the blend min max extension is supported */
  30435. blendMinMax: boolean;
  30436. }
  30437. }
  30438. declare module BABYLON {
  30439. /**
  30440. * @hidden
  30441. **/
  30442. export class DepthCullingState {
  30443. private _isDepthTestDirty;
  30444. private _isDepthMaskDirty;
  30445. private _isDepthFuncDirty;
  30446. private _isCullFaceDirty;
  30447. private _isCullDirty;
  30448. private _isZOffsetDirty;
  30449. private _isFrontFaceDirty;
  30450. private _depthTest;
  30451. private _depthMask;
  30452. private _depthFunc;
  30453. private _cull;
  30454. private _cullFace;
  30455. private _zOffset;
  30456. private _frontFace;
  30457. /**
  30458. * Initializes the state.
  30459. */
  30460. constructor();
  30461. get isDirty(): boolean;
  30462. get zOffset(): number;
  30463. set zOffset(value: number);
  30464. get cullFace(): Nullable<number>;
  30465. set cullFace(value: Nullable<number>);
  30466. get cull(): Nullable<boolean>;
  30467. set cull(value: Nullable<boolean>);
  30468. get depthFunc(): Nullable<number>;
  30469. set depthFunc(value: Nullable<number>);
  30470. get depthMask(): boolean;
  30471. set depthMask(value: boolean);
  30472. get depthTest(): boolean;
  30473. set depthTest(value: boolean);
  30474. get frontFace(): Nullable<number>;
  30475. set frontFace(value: Nullable<number>);
  30476. reset(): void;
  30477. apply(gl: WebGLRenderingContext): void;
  30478. }
  30479. }
  30480. declare module BABYLON {
  30481. /**
  30482. * @hidden
  30483. **/
  30484. export class StencilState {
  30485. /** 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 */
  30486. static readonly ALWAYS: number;
  30487. /** Passed to stencilOperation to specify that stencil value must be kept */
  30488. static readonly KEEP: number;
  30489. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30490. static readonly REPLACE: number;
  30491. private _isStencilTestDirty;
  30492. private _isStencilMaskDirty;
  30493. private _isStencilFuncDirty;
  30494. private _isStencilOpDirty;
  30495. private _stencilTest;
  30496. private _stencilMask;
  30497. private _stencilFunc;
  30498. private _stencilFuncRef;
  30499. private _stencilFuncMask;
  30500. private _stencilOpStencilFail;
  30501. private _stencilOpDepthFail;
  30502. private _stencilOpStencilDepthPass;
  30503. get isDirty(): boolean;
  30504. get stencilFunc(): number;
  30505. set stencilFunc(value: number);
  30506. get stencilFuncRef(): number;
  30507. set stencilFuncRef(value: number);
  30508. get stencilFuncMask(): number;
  30509. set stencilFuncMask(value: number);
  30510. get stencilOpStencilFail(): number;
  30511. set stencilOpStencilFail(value: number);
  30512. get stencilOpDepthFail(): number;
  30513. set stencilOpDepthFail(value: number);
  30514. get stencilOpStencilDepthPass(): number;
  30515. set stencilOpStencilDepthPass(value: number);
  30516. get stencilMask(): number;
  30517. set stencilMask(value: number);
  30518. get stencilTest(): boolean;
  30519. set stencilTest(value: boolean);
  30520. constructor();
  30521. reset(): void;
  30522. apply(gl: WebGLRenderingContext): void;
  30523. }
  30524. }
  30525. declare module BABYLON {
  30526. /**
  30527. * @hidden
  30528. **/
  30529. export class AlphaState {
  30530. private _isAlphaBlendDirty;
  30531. private _isBlendFunctionParametersDirty;
  30532. private _isBlendEquationParametersDirty;
  30533. private _isBlendConstantsDirty;
  30534. private _alphaBlend;
  30535. private _blendFunctionParameters;
  30536. private _blendEquationParameters;
  30537. private _blendConstants;
  30538. /**
  30539. * Initializes the state.
  30540. */
  30541. constructor();
  30542. get isDirty(): boolean;
  30543. get alphaBlend(): boolean;
  30544. set alphaBlend(value: boolean);
  30545. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30546. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30547. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30548. reset(): void;
  30549. apply(gl: WebGLRenderingContext): void;
  30550. }
  30551. }
  30552. declare module BABYLON {
  30553. /** @hidden */
  30554. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30555. attributeProcessor(attribute: string): string;
  30556. varyingProcessor(varying: string, isFragment: boolean): string;
  30557. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30558. }
  30559. }
  30560. declare module BABYLON {
  30561. /**
  30562. * Interface for attribute information associated with buffer instanciation
  30563. */
  30564. export interface InstancingAttributeInfo {
  30565. /**
  30566. * Name of the GLSL attribute
  30567. * if attribute index is not specified, this is used to retrieve the index from the effect
  30568. */
  30569. attributeName: string;
  30570. /**
  30571. * Index/offset of the attribute in the vertex shader
  30572. * if not specified, this will be computes from the name.
  30573. */
  30574. index?: number;
  30575. /**
  30576. * size of the attribute, 1, 2, 3 or 4
  30577. */
  30578. attributeSize: number;
  30579. /**
  30580. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30581. */
  30582. offset: number;
  30583. /**
  30584. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30585. * default to 1
  30586. */
  30587. divisor?: number;
  30588. /**
  30589. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30590. * default is FLOAT
  30591. */
  30592. attributeType?: number;
  30593. /**
  30594. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30595. */
  30596. normalized?: boolean;
  30597. }
  30598. }
  30599. declare module BABYLON {
  30600. interface ThinEngine {
  30601. /**
  30602. * Update a video texture
  30603. * @param texture defines the texture to update
  30604. * @param video defines the video element to use
  30605. * @param invertY defines if data must be stored with Y axis inverted
  30606. */
  30607. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30608. }
  30609. }
  30610. declare module BABYLON {
  30611. /**
  30612. * Settings for finer control over video usage
  30613. */
  30614. export interface VideoTextureSettings {
  30615. /**
  30616. * Applies `autoplay` to video, if specified
  30617. */
  30618. autoPlay?: boolean;
  30619. /**
  30620. * Applies `loop` to video, if specified
  30621. */
  30622. loop?: boolean;
  30623. /**
  30624. * Automatically updates internal texture from video at every frame in the render loop
  30625. */
  30626. autoUpdateTexture: boolean;
  30627. /**
  30628. * Image src displayed during the video loading or until the user interacts with the video.
  30629. */
  30630. poster?: string;
  30631. }
  30632. /**
  30633. * If you want to display a video in your scene, this is the special texture for that.
  30634. * This special texture works similar to other textures, with the exception of a few parameters.
  30635. * @see https://doc.babylonjs.com/how_to/video_texture
  30636. */
  30637. export class VideoTexture extends Texture {
  30638. /**
  30639. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30640. */
  30641. readonly autoUpdateTexture: boolean;
  30642. /**
  30643. * The video instance used by the texture internally
  30644. */
  30645. readonly video: HTMLVideoElement;
  30646. private _onUserActionRequestedObservable;
  30647. /**
  30648. * Event triggerd when a dom action is required by the user to play the video.
  30649. * This happens due to recent changes in browser policies preventing video to auto start.
  30650. */
  30651. get onUserActionRequestedObservable(): Observable<Texture>;
  30652. private _generateMipMaps;
  30653. private _engine;
  30654. private _stillImageCaptured;
  30655. private _displayingPosterTexture;
  30656. private _settings;
  30657. private _createInternalTextureOnEvent;
  30658. private _frameId;
  30659. private _currentSrc;
  30660. /**
  30661. * Creates a video texture.
  30662. * If you want to display a video in your scene, this is the special texture for that.
  30663. * This special texture works similar to other textures, with the exception of a few parameters.
  30664. * @see https://doc.babylonjs.com/how_to/video_texture
  30665. * @param name optional name, will detect from video source, if not defined
  30666. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30667. * @param scene is obviously the current scene.
  30668. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30669. * @param invertY is false by default but can be used to invert video on Y axis
  30670. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30671. * @param settings allows finer control over video usage
  30672. */
  30673. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30674. private _getName;
  30675. private _getVideo;
  30676. private _createInternalTexture;
  30677. private reset;
  30678. /**
  30679. * @hidden Internal method to initiate `update`.
  30680. */
  30681. _rebuild(): void;
  30682. /**
  30683. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30684. */
  30685. update(): void;
  30686. /**
  30687. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30688. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30689. */
  30690. updateTexture(isVisible: boolean): void;
  30691. protected _updateInternalTexture: () => void;
  30692. /**
  30693. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30694. * @param url New url.
  30695. */
  30696. updateURL(url: string): void;
  30697. /**
  30698. * Clones the texture.
  30699. * @returns the cloned texture
  30700. */
  30701. clone(): VideoTexture;
  30702. /**
  30703. * Dispose the texture and release its associated resources.
  30704. */
  30705. dispose(): void;
  30706. /**
  30707. * Creates a video texture straight from a stream.
  30708. * @param scene Define the scene the texture should be created in
  30709. * @param stream Define the stream the texture should be created from
  30710. * @returns The created video texture as a promise
  30711. */
  30712. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30713. /**
  30714. * Creates a video texture straight from your WebCam video feed.
  30715. * @param scene Define the scene the texture should be created in
  30716. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30717. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30718. * @returns The created video texture as a promise
  30719. */
  30720. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30721. minWidth: number;
  30722. maxWidth: number;
  30723. minHeight: number;
  30724. maxHeight: number;
  30725. deviceId: string;
  30726. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30727. /**
  30728. * Creates a video texture straight from your WebCam video feed.
  30729. * @param scene Define the scene the texture should be created in
  30730. * @param onReady Define a callback to triggered once the texture will be ready
  30731. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30732. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30733. */
  30734. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30735. minWidth: number;
  30736. maxWidth: number;
  30737. minHeight: number;
  30738. maxHeight: number;
  30739. deviceId: string;
  30740. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30741. }
  30742. }
  30743. declare module BABYLON {
  30744. /**
  30745. * Defines the interface used by objects working like Scene
  30746. * @hidden
  30747. */
  30748. interface ISceneLike {
  30749. _addPendingData(data: any): void;
  30750. _removePendingData(data: any): void;
  30751. offlineProvider: IOfflineProvider;
  30752. }
  30753. /** Interface defining initialization parameters for Engine class */
  30754. export interface EngineOptions extends WebGLContextAttributes {
  30755. /**
  30756. * Defines if the engine should no exceed a specified device ratio
  30757. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30758. */
  30759. limitDeviceRatio?: number;
  30760. /**
  30761. * Defines if webvr should be enabled automatically
  30762. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30763. */
  30764. autoEnableWebVR?: boolean;
  30765. /**
  30766. * Defines if webgl2 should be turned off even if supported
  30767. * @see http://doc.babylonjs.com/features/webgl2
  30768. */
  30769. disableWebGL2Support?: boolean;
  30770. /**
  30771. * Defines if webaudio should be initialized as well
  30772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30773. */
  30774. audioEngine?: boolean;
  30775. /**
  30776. * Defines if animations should run using a deterministic lock step
  30777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30778. */
  30779. deterministicLockstep?: boolean;
  30780. /** Defines the maximum steps to use with deterministic lock step mode */
  30781. lockstepMaxSteps?: number;
  30782. /** Defines the seconds between each deterministic lock step */
  30783. timeStep?: number;
  30784. /**
  30785. * Defines that engine should ignore context lost events
  30786. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30787. */
  30788. doNotHandleContextLost?: boolean;
  30789. /**
  30790. * Defines that engine should ignore modifying touch action attribute and style
  30791. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30792. */
  30793. doNotHandleTouchAction?: boolean;
  30794. /**
  30795. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30796. */
  30797. useHighPrecisionFloats?: boolean;
  30798. }
  30799. /**
  30800. * The base engine class (root of all engines)
  30801. */
  30802. export class ThinEngine {
  30803. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30804. static ExceptionList: ({
  30805. key: string;
  30806. capture: string;
  30807. captureConstraint: number;
  30808. targets: string[];
  30809. } | {
  30810. key: string;
  30811. capture: null;
  30812. captureConstraint: null;
  30813. targets: string[];
  30814. })[];
  30815. /** @hidden */
  30816. static _TextureLoaders: IInternalTextureLoader[];
  30817. /**
  30818. * Returns the current npm package of the sdk
  30819. */
  30820. static get NpmPackage(): string;
  30821. /**
  30822. * Returns the current version of the framework
  30823. */
  30824. static get Version(): string;
  30825. /**
  30826. * Returns a string describing the current engine
  30827. */
  30828. get description(): string;
  30829. /**
  30830. * Gets or sets the epsilon value used by collision engine
  30831. */
  30832. static CollisionsEpsilon: number;
  30833. /**
  30834. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30835. */
  30836. static get ShadersRepository(): string;
  30837. static set ShadersRepository(value: string);
  30838. /**
  30839. * Gets or sets the textures that the engine should not attempt to load as compressed
  30840. */
  30841. protected _excludedCompressedTextures: string[];
  30842. /**
  30843. * Filters the compressed texture formats to only include
  30844. * files that are not included in the skippable list
  30845. *
  30846. * @param url the current extension
  30847. * @param textureFormatInUse the current compressed texture format
  30848. * @returns "format" string
  30849. */
  30850. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30851. /** @hidden */
  30852. _shaderProcessor: IShaderProcessor;
  30853. /**
  30854. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30855. */
  30856. forcePOTTextures: boolean;
  30857. /**
  30858. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30859. */
  30860. isFullscreen: boolean;
  30861. /**
  30862. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30863. */
  30864. cullBackFaces: boolean;
  30865. /**
  30866. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30867. */
  30868. renderEvenInBackground: boolean;
  30869. /**
  30870. * Gets or sets a boolean indicating that cache can be kept between frames
  30871. */
  30872. preventCacheWipeBetweenFrames: boolean;
  30873. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30874. validateShaderPrograms: boolean;
  30875. /**
  30876. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30877. * This can provide greater z depth for distant objects.
  30878. */
  30879. useReverseDepthBuffer: boolean;
  30880. /**
  30881. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30882. */
  30883. disableUniformBuffers: boolean;
  30884. /** @hidden */
  30885. _uniformBuffers: UniformBuffer[];
  30886. /**
  30887. * Gets a boolean indicating that the engine supports uniform buffers
  30888. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30889. */
  30890. get supportsUniformBuffers(): boolean;
  30891. /** @hidden */
  30892. _gl: WebGLRenderingContext;
  30893. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30894. protected _windowIsBackground: boolean;
  30895. protected _webGLVersion: number;
  30896. protected _creationOptions: EngineOptions;
  30897. protected _highPrecisionShadersAllowed: boolean;
  30898. /** @hidden */
  30899. get _shouldUseHighPrecisionShader(): boolean;
  30900. /**
  30901. * Gets a boolean indicating that only power of 2 textures are supported
  30902. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30903. */
  30904. get needPOTTextures(): boolean;
  30905. /** @hidden */
  30906. _badOS: boolean;
  30907. /** @hidden */
  30908. _badDesktopOS: boolean;
  30909. private _hardwareScalingLevel;
  30910. /** @hidden */
  30911. _caps: EngineCapabilities;
  30912. private _isStencilEnable;
  30913. private _glVersion;
  30914. private _glRenderer;
  30915. private _glVendor;
  30916. /** @hidden */
  30917. _videoTextureSupported: boolean;
  30918. protected _renderingQueueLaunched: boolean;
  30919. protected _activeRenderLoops: (() => void)[];
  30920. /**
  30921. * Observable signaled when a context lost event is raised
  30922. */
  30923. onContextLostObservable: Observable<ThinEngine>;
  30924. /**
  30925. * Observable signaled when a context restored event is raised
  30926. */
  30927. onContextRestoredObservable: Observable<ThinEngine>;
  30928. private _onContextLost;
  30929. private _onContextRestored;
  30930. protected _contextWasLost: boolean;
  30931. /** @hidden */
  30932. _doNotHandleContextLost: boolean;
  30933. /**
  30934. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30936. */
  30937. get doNotHandleContextLost(): boolean;
  30938. set doNotHandleContextLost(value: boolean);
  30939. /**
  30940. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30941. */
  30942. disableVertexArrayObjects: boolean;
  30943. /** @hidden */
  30944. protected _colorWrite: boolean;
  30945. /** @hidden */
  30946. protected _colorWriteChanged: boolean;
  30947. /** @hidden */
  30948. protected _depthCullingState: DepthCullingState;
  30949. /** @hidden */
  30950. protected _stencilState: StencilState;
  30951. /** @hidden */
  30952. _alphaState: AlphaState;
  30953. /** @hidden */
  30954. _alphaMode: number;
  30955. /** @hidden */
  30956. _alphaEquation: number;
  30957. /** @hidden */
  30958. _internalTexturesCache: InternalTexture[];
  30959. /** @hidden */
  30960. protected _activeChannel: number;
  30961. private _currentTextureChannel;
  30962. /** @hidden */
  30963. protected _boundTexturesCache: {
  30964. [key: string]: Nullable<InternalTexture>;
  30965. };
  30966. /** @hidden */
  30967. protected _currentEffect: Nullable<Effect>;
  30968. /** @hidden */
  30969. protected _currentProgram: Nullable<WebGLProgram>;
  30970. private _compiledEffects;
  30971. private _vertexAttribArraysEnabled;
  30972. /** @hidden */
  30973. protected _cachedViewport: Nullable<IViewportLike>;
  30974. private _cachedVertexArrayObject;
  30975. /** @hidden */
  30976. protected _cachedVertexBuffers: any;
  30977. /** @hidden */
  30978. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30979. /** @hidden */
  30980. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30981. /** @hidden */
  30982. _currentRenderTarget: Nullable<InternalTexture>;
  30983. private _uintIndicesCurrentlySet;
  30984. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30985. /** @hidden */
  30986. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30987. private _currentBufferPointers;
  30988. private _currentInstanceLocations;
  30989. private _currentInstanceBuffers;
  30990. private _textureUnits;
  30991. /** @hidden */
  30992. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30993. /** @hidden */
  30994. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30995. /** @hidden */
  30996. _boundRenderFunction: any;
  30997. private _vaoRecordInProgress;
  30998. private _mustWipeVertexAttributes;
  30999. private _emptyTexture;
  31000. private _emptyCubeTexture;
  31001. private _emptyTexture3D;
  31002. private _emptyTexture2DArray;
  31003. /** @hidden */
  31004. _frameHandler: number;
  31005. private _nextFreeTextureSlots;
  31006. private _maxSimultaneousTextures;
  31007. private _activeRequests;
  31008. protected _texturesSupported: string[];
  31009. /** @hidden */
  31010. _textureFormatInUse: Nullable<string>;
  31011. protected get _supportsHardwareTextureRescaling(): boolean;
  31012. /**
  31013. * Gets the list of texture formats supported
  31014. */
  31015. get texturesSupported(): Array<string>;
  31016. /**
  31017. * Gets the list of texture formats in use
  31018. */
  31019. get textureFormatInUse(): Nullable<string>;
  31020. /**
  31021. * Gets the current viewport
  31022. */
  31023. get currentViewport(): Nullable<IViewportLike>;
  31024. /**
  31025. * Gets the default empty texture
  31026. */
  31027. get emptyTexture(): InternalTexture;
  31028. /**
  31029. * Gets the default empty 3D texture
  31030. */
  31031. get emptyTexture3D(): InternalTexture;
  31032. /**
  31033. * Gets the default empty 2D array texture
  31034. */
  31035. get emptyTexture2DArray(): InternalTexture;
  31036. /**
  31037. * Gets the default empty cube texture
  31038. */
  31039. get emptyCubeTexture(): InternalTexture;
  31040. /**
  31041. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31042. */
  31043. readonly premultipliedAlpha: boolean;
  31044. /**
  31045. * Observable event triggered before each texture is initialized
  31046. */
  31047. onBeforeTextureInitObservable: Observable<Texture>;
  31048. /**
  31049. * Creates a new engine
  31050. * @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
  31051. * @param antialias defines enable antialiasing (default: false)
  31052. * @param options defines further options to be sent to the getContext() function
  31053. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31054. */
  31055. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31056. private _rebuildInternalTextures;
  31057. private _rebuildEffects;
  31058. /**
  31059. * Gets a boolean indicating if all created effects are ready
  31060. * @returns true if all effects are ready
  31061. */
  31062. areAllEffectsReady(): boolean;
  31063. protected _rebuildBuffers(): void;
  31064. private _initGLContext;
  31065. /**
  31066. * Gets version of the current webGL context
  31067. */
  31068. get webGLVersion(): number;
  31069. /**
  31070. * Gets a string idenfifying the name of the class
  31071. * @returns "Engine" string
  31072. */
  31073. getClassName(): string;
  31074. /**
  31075. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31076. */
  31077. get isStencilEnable(): boolean;
  31078. /** @hidden */
  31079. _prepareWorkingCanvas(): void;
  31080. /**
  31081. * Reset the texture cache to empty state
  31082. */
  31083. resetTextureCache(): void;
  31084. /**
  31085. * Gets an object containing information about the current webGL context
  31086. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31087. */
  31088. getGlInfo(): {
  31089. vendor: string;
  31090. renderer: string;
  31091. version: string;
  31092. };
  31093. /**
  31094. * Defines the hardware scaling level.
  31095. * By default the hardware scaling level is computed from the window device ratio.
  31096. * 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.
  31097. * @param level defines the level to use
  31098. */
  31099. setHardwareScalingLevel(level: number): void;
  31100. /**
  31101. * Gets the current hardware scaling level.
  31102. * By default the hardware scaling level is computed from the window device ratio.
  31103. * 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.
  31104. * @returns a number indicating the current hardware scaling level
  31105. */
  31106. getHardwareScalingLevel(): number;
  31107. /**
  31108. * Gets the list of loaded textures
  31109. * @returns an array containing all loaded textures
  31110. */
  31111. getLoadedTexturesCache(): InternalTexture[];
  31112. /**
  31113. * Gets the object containing all engine capabilities
  31114. * @returns the EngineCapabilities object
  31115. */
  31116. getCaps(): EngineCapabilities;
  31117. /**
  31118. * stop executing a render loop function and remove it from the execution array
  31119. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31120. */
  31121. stopRenderLoop(renderFunction?: () => void): void;
  31122. /** @hidden */
  31123. _renderLoop(): void;
  31124. /**
  31125. * Gets the HTML canvas attached with the current webGL context
  31126. * @returns a HTML canvas
  31127. */
  31128. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31129. /**
  31130. * Gets host window
  31131. * @returns the host window object
  31132. */
  31133. getHostWindow(): Nullable<Window>;
  31134. /**
  31135. * Gets the current render width
  31136. * @param useScreen defines if screen size must be used (or the current render target if any)
  31137. * @returns a number defining the current render width
  31138. */
  31139. getRenderWidth(useScreen?: boolean): number;
  31140. /**
  31141. * Gets the current render height
  31142. * @param useScreen defines if screen size must be used (or the current render target if any)
  31143. * @returns a number defining the current render height
  31144. */
  31145. getRenderHeight(useScreen?: boolean): number;
  31146. /**
  31147. * Can be used to override the current requestAnimationFrame requester.
  31148. * @hidden
  31149. */
  31150. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31151. /**
  31152. * Register and execute a render loop. The engine can have more than one render function
  31153. * @param renderFunction defines the function to continuously execute
  31154. */
  31155. runRenderLoop(renderFunction: () => void): void;
  31156. /**
  31157. * Clear the current render buffer or the current render target (if any is set up)
  31158. * @param color defines the color to use
  31159. * @param backBuffer defines if the back buffer must be cleared
  31160. * @param depth defines if the depth buffer must be cleared
  31161. * @param stencil defines if the stencil buffer must be cleared
  31162. */
  31163. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31164. private _viewportCached;
  31165. /** @hidden */
  31166. _viewport(x: number, y: number, width: number, height: number): void;
  31167. /**
  31168. * Set the WebGL's viewport
  31169. * @param viewport defines the viewport element to be used
  31170. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31171. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31172. */
  31173. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31174. /**
  31175. * Begin a new frame
  31176. */
  31177. beginFrame(): void;
  31178. /**
  31179. * Enf the current frame
  31180. */
  31181. endFrame(): void;
  31182. /**
  31183. * Resize the view according to the canvas' size
  31184. */
  31185. resize(): void;
  31186. /**
  31187. * Force a specific size of the canvas
  31188. * @param width defines the new canvas' width
  31189. * @param height defines the new canvas' height
  31190. */
  31191. setSize(width: number, height: number): void;
  31192. /**
  31193. * Binds the frame buffer to the specified texture.
  31194. * @param texture The texture to render to or null for the default canvas
  31195. * @param faceIndex The face of the texture to render to in case of cube texture
  31196. * @param requiredWidth The width of the target to render to
  31197. * @param requiredHeight The height of the target to render to
  31198. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31199. * @param lodLevel defines the lod level to bind to the frame buffer
  31200. * @param layer defines the 2d array index to bind to frame buffer to
  31201. */
  31202. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31203. /** @hidden */
  31204. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31205. /**
  31206. * Unbind the current render target texture from the webGL context
  31207. * @param texture defines the render target texture to unbind
  31208. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31209. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31210. */
  31211. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31212. /**
  31213. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31214. */
  31215. flushFramebuffer(): void;
  31216. /**
  31217. * Unbind the current render target and bind the default framebuffer
  31218. */
  31219. restoreDefaultFramebuffer(): void;
  31220. /** @hidden */
  31221. protected _resetVertexBufferBinding(): void;
  31222. /**
  31223. * Creates a vertex buffer
  31224. * @param data the data for the vertex buffer
  31225. * @returns the new WebGL static buffer
  31226. */
  31227. createVertexBuffer(data: DataArray): DataBuffer;
  31228. private _createVertexBuffer;
  31229. /**
  31230. * Creates a dynamic vertex buffer
  31231. * @param data the data for the dynamic vertex buffer
  31232. * @returns the new WebGL dynamic buffer
  31233. */
  31234. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31235. protected _resetIndexBufferBinding(): void;
  31236. /**
  31237. * Creates a new index buffer
  31238. * @param indices defines the content of the index buffer
  31239. * @param updatable defines if the index buffer must be updatable
  31240. * @returns a new webGL buffer
  31241. */
  31242. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31243. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31244. /**
  31245. * Bind a webGL buffer to the webGL context
  31246. * @param buffer defines the buffer to bind
  31247. */
  31248. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31249. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31250. private bindBuffer;
  31251. /**
  31252. * update the bound buffer with the given data
  31253. * @param data defines the data to update
  31254. */
  31255. updateArrayBuffer(data: Float32Array): void;
  31256. private _vertexAttribPointer;
  31257. /** @hidden */
  31258. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31259. private _bindVertexBuffersAttributes;
  31260. /**
  31261. * Records a vertex array object
  31262. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31263. * @param vertexBuffers defines the list of vertex buffers to store
  31264. * @param indexBuffer defines the index buffer to store
  31265. * @param effect defines the effect to store
  31266. * @returns the new vertex array object
  31267. */
  31268. recordVertexArrayObject(vertexBuffers: {
  31269. [key: string]: VertexBuffer;
  31270. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31271. /**
  31272. * Bind a specific vertex array object
  31273. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31274. * @param vertexArrayObject defines the vertex array object to bind
  31275. * @param indexBuffer defines the index buffer to bind
  31276. */
  31277. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31278. /**
  31279. * Bind webGl buffers directly to the webGL context
  31280. * @param vertexBuffer defines the vertex buffer to bind
  31281. * @param indexBuffer defines the index buffer to bind
  31282. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31283. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31284. * @param effect defines the effect associated with the vertex buffer
  31285. */
  31286. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31287. private _unbindVertexArrayObject;
  31288. /**
  31289. * Bind a list of vertex buffers to the webGL context
  31290. * @param vertexBuffers defines the list of vertex buffers to bind
  31291. * @param indexBuffer defines the index buffer to bind
  31292. * @param effect defines the effect associated with the vertex buffers
  31293. */
  31294. bindBuffers(vertexBuffers: {
  31295. [key: string]: Nullable<VertexBuffer>;
  31296. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31297. /**
  31298. * Unbind all instance attributes
  31299. */
  31300. unbindInstanceAttributes(): void;
  31301. /**
  31302. * Release and free the memory of a vertex array object
  31303. * @param vao defines the vertex array object to delete
  31304. */
  31305. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31306. /** @hidden */
  31307. _releaseBuffer(buffer: DataBuffer): boolean;
  31308. protected _deleteBuffer(buffer: DataBuffer): void;
  31309. /**
  31310. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31311. * @param instancesBuffer defines the webGL buffer to update and bind
  31312. * @param data defines the data to store in the buffer
  31313. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31314. */
  31315. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31316. /**
  31317. * Bind the content of a webGL buffer used with instanciation
  31318. * @param instancesBuffer defines the webGL buffer to bind
  31319. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31320. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31321. */
  31322. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31323. /**
  31324. * Disable the instance attribute corresponding to the name in parameter
  31325. * @param name defines the name of the attribute to disable
  31326. */
  31327. disableInstanceAttributeByName(name: string): void;
  31328. /**
  31329. * Disable the instance attribute corresponding to the location in parameter
  31330. * @param attributeLocation defines the attribute location of the attribute to disable
  31331. */
  31332. disableInstanceAttribute(attributeLocation: number): void;
  31333. /**
  31334. * Disable the attribute corresponding to the location in parameter
  31335. * @param attributeLocation defines the attribute location of the attribute to disable
  31336. */
  31337. disableAttributeByIndex(attributeLocation: number): void;
  31338. /**
  31339. * Send a draw order
  31340. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31341. * @param indexStart defines the starting index
  31342. * @param indexCount defines the number of index to draw
  31343. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31344. */
  31345. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31346. /**
  31347. * Draw a list of points
  31348. * @param verticesStart defines the index of first vertex to draw
  31349. * @param verticesCount defines the count of vertices to draw
  31350. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31351. */
  31352. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31353. /**
  31354. * Draw a list of unindexed primitives
  31355. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31356. * @param verticesStart defines the index of first vertex to draw
  31357. * @param verticesCount defines the count of vertices to draw
  31358. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31359. */
  31360. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31361. /**
  31362. * Draw a list of indexed primitives
  31363. * @param fillMode defines the primitive to use
  31364. * @param indexStart defines the starting index
  31365. * @param indexCount defines the number of index to draw
  31366. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31367. */
  31368. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31369. /**
  31370. * Draw a list of unindexed primitives
  31371. * @param fillMode defines the primitive to use
  31372. * @param verticesStart defines the index of first vertex to draw
  31373. * @param verticesCount defines the count of vertices to draw
  31374. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31375. */
  31376. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31377. private _drawMode;
  31378. /** @hidden */
  31379. protected _reportDrawCall(): void;
  31380. /** @hidden */
  31381. _releaseEffect(effect: Effect): void;
  31382. /** @hidden */
  31383. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31384. /**
  31385. * Create a new effect (used to store vertex/fragment shaders)
  31386. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31387. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31388. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31389. * @param samplers defines an array of string used to represent textures
  31390. * @param defines defines the string containing the defines to use to compile the shaders
  31391. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31392. * @param onCompiled defines a function to call when the effect creation is successful
  31393. * @param onError defines a function to call when the effect creation has failed
  31394. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31395. * @returns the new Effect
  31396. */
  31397. 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;
  31398. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31399. private _compileShader;
  31400. private _compileRawShader;
  31401. /**
  31402. * Directly creates a webGL program
  31403. * @param pipelineContext defines the pipeline context to attach to
  31404. * @param vertexCode defines the vertex shader code to use
  31405. * @param fragmentCode defines the fragment shader code to use
  31406. * @param context defines the webGL context to use (if not set, the current one will be used)
  31407. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31408. * @returns the new webGL program
  31409. */
  31410. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31411. /**
  31412. * Creates a webGL program
  31413. * @param pipelineContext defines the pipeline context to attach to
  31414. * @param vertexCode defines the vertex shader code to use
  31415. * @param fragmentCode defines the fragment shader code to use
  31416. * @param defines defines the string containing the defines to use to compile the shaders
  31417. * @param context defines the webGL context to use (if not set, the current one will be used)
  31418. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31419. * @returns the new webGL program
  31420. */
  31421. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31422. /**
  31423. * Creates a new pipeline context
  31424. * @returns the new pipeline
  31425. */
  31426. createPipelineContext(): IPipelineContext;
  31427. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31428. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31429. /** @hidden */
  31430. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31431. /** @hidden */
  31432. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31433. /** @hidden */
  31434. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31435. /**
  31436. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31437. * @param pipelineContext defines the pipeline context to use
  31438. * @param uniformsNames defines the list of uniform names
  31439. * @returns an array of webGL uniform locations
  31440. */
  31441. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31442. /**
  31443. * Gets the lsit of active attributes for a given webGL program
  31444. * @param pipelineContext defines the pipeline context to use
  31445. * @param attributesNames defines the list of attribute names to get
  31446. * @returns an array of indices indicating the offset of each attribute
  31447. */
  31448. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31449. /**
  31450. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31451. * @param effect defines the effect to activate
  31452. */
  31453. enableEffect(effect: Nullable<Effect>): void;
  31454. /**
  31455. * Set the value of an uniform to a number (int)
  31456. * @param uniform defines the webGL uniform location where to store the value
  31457. * @param value defines the int number to store
  31458. */
  31459. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31460. /**
  31461. * Set the value of an uniform to an array of int32
  31462. * @param uniform defines the webGL uniform location where to store the value
  31463. * @param array defines the array of int32 to store
  31464. */
  31465. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31466. /**
  31467. * Set the value of an uniform to an array of int32 (stored as vec2)
  31468. * @param uniform defines the webGL uniform location where to store the value
  31469. * @param array defines the array of int32 to store
  31470. */
  31471. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31472. /**
  31473. * Set the value of an uniform to an array of int32 (stored as vec3)
  31474. * @param uniform defines the webGL uniform location where to store the value
  31475. * @param array defines the array of int32 to store
  31476. */
  31477. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31478. /**
  31479. * Set the value of an uniform to an array of int32 (stored as vec4)
  31480. * @param uniform defines the webGL uniform location where to store the value
  31481. * @param array defines the array of int32 to store
  31482. */
  31483. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31484. /**
  31485. * Set the value of an uniform to an array of number
  31486. * @param uniform defines the webGL uniform location where to store the value
  31487. * @param array defines the array of number to store
  31488. */
  31489. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31490. /**
  31491. * Set the value of an uniform to an array of number (stored as vec2)
  31492. * @param uniform defines the webGL uniform location where to store the value
  31493. * @param array defines the array of number to store
  31494. */
  31495. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31496. /**
  31497. * Set the value of an uniform to an array of number (stored as vec3)
  31498. * @param uniform defines the webGL uniform location where to store the value
  31499. * @param array defines the array of number to store
  31500. */
  31501. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31502. /**
  31503. * Set the value of an uniform to an array of number (stored as vec4)
  31504. * @param uniform defines the webGL uniform location where to store the value
  31505. * @param array defines the array of number to store
  31506. */
  31507. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31508. /**
  31509. * Set the value of an uniform to an array of float32 (stored as matrices)
  31510. * @param uniform defines the webGL uniform location where to store the value
  31511. * @param matrices defines the array of float32 to store
  31512. */
  31513. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31514. /**
  31515. * Set the value of an uniform to a matrix (3x3)
  31516. * @param uniform defines the webGL uniform location where to store the value
  31517. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31518. */
  31519. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31520. /**
  31521. * Set the value of an uniform to a matrix (2x2)
  31522. * @param uniform defines the webGL uniform location where to store the value
  31523. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31524. */
  31525. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31526. /**
  31527. * Set the value of an uniform to a number (float)
  31528. * @param uniform defines the webGL uniform location where to store the value
  31529. * @param value defines the float number to store
  31530. */
  31531. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31532. /**
  31533. * Set the value of an uniform to a vec2
  31534. * @param uniform defines the webGL uniform location where to store the value
  31535. * @param x defines the 1st component of the value
  31536. * @param y defines the 2nd component of the value
  31537. */
  31538. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31539. /**
  31540. * Set the value of an uniform to a vec3
  31541. * @param uniform defines the webGL uniform location where to store the value
  31542. * @param x defines the 1st component of the value
  31543. * @param y defines the 2nd component of the value
  31544. * @param z defines the 3rd component of the value
  31545. */
  31546. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31547. /**
  31548. * Set the value of an uniform to a vec4
  31549. * @param uniform defines the webGL uniform location where to store the value
  31550. * @param x defines the 1st component of the value
  31551. * @param y defines the 2nd component of the value
  31552. * @param z defines the 3rd component of the value
  31553. * @param w defines the 4th component of the value
  31554. */
  31555. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31556. /**
  31557. * Apply all cached states (depth, culling, stencil and alpha)
  31558. */
  31559. applyStates(): void;
  31560. /**
  31561. * Enable or disable color writing
  31562. * @param enable defines the state to set
  31563. */
  31564. setColorWrite(enable: boolean): void;
  31565. /**
  31566. * Gets a boolean indicating if color writing is enabled
  31567. * @returns the current color writing state
  31568. */
  31569. getColorWrite(): boolean;
  31570. /**
  31571. * Gets the depth culling state manager
  31572. */
  31573. get depthCullingState(): DepthCullingState;
  31574. /**
  31575. * Gets the alpha state manager
  31576. */
  31577. get alphaState(): AlphaState;
  31578. /**
  31579. * Gets the stencil state manager
  31580. */
  31581. get stencilState(): StencilState;
  31582. /**
  31583. * Clears the list of texture accessible through engine.
  31584. * This can help preventing texture load conflict due to name collision.
  31585. */
  31586. clearInternalTexturesCache(): void;
  31587. /**
  31588. * Force the entire cache to be cleared
  31589. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31590. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31591. */
  31592. wipeCaches(bruteForce?: boolean): void;
  31593. /** @hidden */
  31594. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31595. min: number;
  31596. mag: number;
  31597. };
  31598. /** @hidden */
  31599. _createTexture(): WebGLTexture;
  31600. /**
  31601. * Usually called from Texture.ts.
  31602. * Passed information to create a WebGLTexture
  31603. * @param urlArg defines a value which contains one of the following:
  31604. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31605. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31606. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31607. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31608. * @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)
  31609. * @param scene needed for loading to the correct scene
  31610. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31611. * @param onLoad optional callback to be called upon successful completion
  31612. * @param onError optional callback to be called upon failure
  31613. * @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
  31614. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31615. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31616. * @param forcedExtension defines the extension to use to pick the right loader
  31617. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31618. * @param mimeType defines an optional mime type
  31619. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31620. */
  31621. 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;
  31622. /**
  31623. * Loads an image as an HTMLImageElement.
  31624. * @param input url string, ArrayBuffer, or Blob to load
  31625. * @param onLoad callback called when the image successfully loads
  31626. * @param onError callback called when the image fails to load
  31627. * @param offlineProvider offline provider for caching
  31628. * @param mimeType optional mime type
  31629. * @returns the HTMLImageElement of the loaded image
  31630. * @hidden
  31631. */
  31632. 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>;
  31633. /**
  31634. * @hidden
  31635. */
  31636. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31637. /**
  31638. * Creates a raw texture
  31639. * @param data defines the data to store in the texture
  31640. * @param width defines the width of the texture
  31641. * @param height defines the height of the texture
  31642. * @param format defines the format of the data
  31643. * @param generateMipMaps defines if the engine should generate the mip levels
  31644. * @param invertY defines if data must be stored with Y axis inverted
  31645. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31646. * @param compression defines the compression used (null by default)
  31647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31648. * @returns the raw texture inside an InternalTexture
  31649. */
  31650. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31651. /**
  31652. * Creates a new raw cube texture
  31653. * @param data defines the array of data to use to create each face
  31654. * @param size defines the size of the textures
  31655. * @param format defines the format of the data
  31656. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31657. * @param generateMipMaps defines if the engine should generate the mip levels
  31658. * @param invertY defines if data must be stored with Y axis inverted
  31659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31660. * @param compression defines the compression used (null by default)
  31661. * @returns the cube texture as an InternalTexture
  31662. */
  31663. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31664. /**
  31665. * Creates a new raw 3D texture
  31666. * @param data defines the data used to create the texture
  31667. * @param width defines the width of the texture
  31668. * @param height defines the height of the texture
  31669. * @param depth defines the depth of the texture
  31670. * @param format defines the format of the texture
  31671. * @param generateMipMaps defines if the engine must generate mip levels
  31672. * @param invertY defines if data must be stored with Y axis inverted
  31673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31674. * @param compression defines the compressed used (can be null)
  31675. * @param textureType defines the compressed used (can be null)
  31676. * @returns a new raw 3D texture (stored in an InternalTexture)
  31677. */
  31678. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31679. /**
  31680. * Creates a new raw 2D array texture
  31681. * @param data defines the data used to create the texture
  31682. * @param width defines the width of the texture
  31683. * @param height defines the height of the texture
  31684. * @param depth defines the number of layers of the texture
  31685. * @param format defines the format of the texture
  31686. * @param generateMipMaps defines if the engine must generate mip levels
  31687. * @param invertY defines if data must be stored with Y axis inverted
  31688. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31689. * @param compression defines the compressed used (can be null)
  31690. * @param textureType defines the compressed used (can be null)
  31691. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31692. */
  31693. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31694. private _unpackFlipYCached;
  31695. /**
  31696. * In case you are sharing the context with other applications, it might
  31697. * be interested to not cache the unpack flip y state to ensure a consistent
  31698. * value would be set.
  31699. */
  31700. enableUnpackFlipYCached: boolean;
  31701. /** @hidden */
  31702. _unpackFlipY(value: boolean): void;
  31703. /** @hidden */
  31704. _getUnpackAlignement(): number;
  31705. private _getTextureTarget;
  31706. /**
  31707. * Update the sampling mode of a given texture
  31708. * @param samplingMode defines the required sampling mode
  31709. * @param texture defines the texture to update
  31710. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31711. */
  31712. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31713. /**
  31714. * Update the sampling mode of a given texture
  31715. * @param texture defines the texture to update
  31716. * @param wrapU defines the texture wrap mode of the u coordinates
  31717. * @param wrapV defines the texture wrap mode of the v coordinates
  31718. * @param wrapR defines the texture wrap mode of the r coordinates
  31719. */
  31720. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31721. /** @hidden */
  31722. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31723. width: number;
  31724. height: number;
  31725. layers?: number;
  31726. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31727. /** @hidden */
  31728. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31729. /** @hidden */
  31730. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31731. /**
  31732. * Update a portion of an internal texture
  31733. * @param texture defines the texture to update
  31734. * @param imageData defines the data to store into the texture
  31735. * @param xOffset defines the x coordinates of the update rectangle
  31736. * @param yOffset defines the y coordinates of the update rectangle
  31737. * @param width defines the width of the update rectangle
  31738. * @param height defines the height of the update rectangle
  31739. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31740. * @param lod defines the lod level to update (0 by default)
  31741. */
  31742. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31743. /** @hidden */
  31744. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31745. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31746. private _prepareWebGLTexture;
  31747. /** @hidden */
  31748. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31749. private _getDepthStencilBuffer;
  31750. /** @hidden */
  31751. _releaseFramebufferObjects(texture: InternalTexture): void;
  31752. /** @hidden */
  31753. _releaseTexture(texture: InternalTexture): void;
  31754. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31755. protected _setProgram(program: WebGLProgram): void;
  31756. protected _boundUniforms: {
  31757. [key: number]: WebGLUniformLocation;
  31758. };
  31759. /**
  31760. * Binds an effect to the webGL context
  31761. * @param effect defines the effect to bind
  31762. */
  31763. bindSamplers(effect: Effect): void;
  31764. private _activateCurrentTexture;
  31765. /** @hidden */
  31766. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31767. /** @hidden */
  31768. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31769. /**
  31770. * Unbind all textures from the webGL context
  31771. */
  31772. unbindAllTextures(): void;
  31773. /**
  31774. * Sets a texture to the according uniform.
  31775. * @param channel The texture channel
  31776. * @param uniform The uniform to set
  31777. * @param texture The texture to apply
  31778. */
  31779. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31780. private _bindSamplerUniformToChannel;
  31781. private _getTextureWrapMode;
  31782. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31783. /**
  31784. * Sets an array of texture to the webGL context
  31785. * @param channel defines the channel where the texture array must be set
  31786. * @param uniform defines the associated uniform location
  31787. * @param textures defines the array of textures to bind
  31788. */
  31789. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31790. /** @hidden */
  31791. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31792. private _setTextureParameterFloat;
  31793. private _setTextureParameterInteger;
  31794. /**
  31795. * Unbind all vertex attributes from the webGL context
  31796. */
  31797. unbindAllAttributes(): void;
  31798. /**
  31799. * 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
  31800. */
  31801. releaseEffects(): void;
  31802. /**
  31803. * Dispose and release all associated resources
  31804. */
  31805. dispose(): void;
  31806. /**
  31807. * Attach a new callback raised when context lost event is fired
  31808. * @param callback defines the callback to call
  31809. */
  31810. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31811. /**
  31812. * Attach a new callback raised when context restored event is fired
  31813. * @param callback defines the callback to call
  31814. */
  31815. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31816. /**
  31817. * Get the current error code of the webGL context
  31818. * @returns the error code
  31819. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31820. */
  31821. getError(): number;
  31822. private _canRenderToFloatFramebuffer;
  31823. private _canRenderToHalfFloatFramebuffer;
  31824. private _canRenderToFramebuffer;
  31825. /** @hidden */
  31826. _getWebGLTextureType(type: number): number;
  31827. /** @hidden */
  31828. _getInternalFormat(format: number): number;
  31829. /** @hidden */
  31830. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31831. /** @hidden */
  31832. _getRGBAMultiSampleBufferFormat(type: number): number;
  31833. /** @hidden */
  31834. _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;
  31835. /**
  31836. * Loads a file from a url
  31837. * @param url url to load
  31838. * @param onSuccess callback called when the file successfully loads
  31839. * @param onProgress callback called while file is loading (if the server supports this mode)
  31840. * @param offlineProvider defines the offline provider for caching
  31841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31842. * @param onError callback called when the file fails to load
  31843. * @returns a file request object
  31844. * @hidden
  31845. */
  31846. 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;
  31847. /**
  31848. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31849. * @param x defines the x coordinate of the rectangle where pixels must be read
  31850. * @param y defines the y coordinate of the rectangle where pixels must be read
  31851. * @param width defines the width of the rectangle where pixels must be read
  31852. * @param height defines the height of the rectangle where pixels must be read
  31853. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31854. * @returns a Uint8Array containing RGBA colors
  31855. */
  31856. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31857. private static _isSupported;
  31858. /**
  31859. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31860. * @returns true if the engine can be created
  31861. * @ignorenaming
  31862. */
  31863. static isSupported(): boolean;
  31864. /**
  31865. * Find the next highest power of two.
  31866. * @param x Number to start search from.
  31867. * @return Next highest power of two.
  31868. */
  31869. static CeilingPOT(x: number): number;
  31870. /**
  31871. * Find the next lowest power of two.
  31872. * @param x Number to start search from.
  31873. * @return Next lowest power of two.
  31874. */
  31875. static FloorPOT(x: number): number;
  31876. /**
  31877. * Find the nearest power of two.
  31878. * @param x Number to start search from.
  31879. * @return Next nearest power of two.
  31880. */
  31881. static NearestPOT(x: number): number;
  31882. /**
  31883. * Get the closest exponent of two
  31884. * @param value defines the value to approximate
  31885. * @param max defines the maximum value to return
  31886. * @param mode defines how to define the closest value
  31887. * @returns closest exponent of two of the given value
  31888. */
  31889. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31890. /**
  31891. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31892. * @param func - the function to be called
  31893. * @param requester - the object that will request the next frame. Falls back to window.
  31894. * @returns frame number
  31895. */
  31896. static QueueNewFrame(func: () => void, requester?: any): number;
  31897. /**
  31898. * Gets host document
  31899. * @returns the host document object
  31900. */
  31901. getHostDocument(): Nullable<Document>;
  31902. }
  31903. }
  31904. declare module BABYLON {
  31905. /**
  31906. * Class representing spherical harmonics coefficients to the 3rd degree
  31907. */
  31908. export class SphericalHarmonics {
  31909. /**
  31910. * Defines whether or not the harmonics have been prescaled for rendering.
  31911. */
  31912. preScaled: boolean;
  31913. /**
  31914. * The l0,0 coefficients of the spherical harmonics
  31915. */
  31916. l00: Vector3;
  31917. /**
  31918. * The l1,-1 coefficients of the spherical harmonics
  31919. */
  31920. l1_1: Vector3;
  31921. /**
  31922. * The l1,0 coefficients of the spherical harmonics
  31923. */
  31924. l10: Vector3;
  31925. /**
  31926. * The l1,1 coefficients of the spherical harmonics
  31927. */
  31928. l11: Vector3;
  31929. /**
  31930. * The l2,-2 coefficients of the spherical harmonics
  31931. */
  31932. l2_2: Vector3;
  31933. /**
  31934. * The l2,-1 coefficients of the spherical harmonics
  31935. */
  31936. l2_1: Vector3;
  31937. /**
  31938. * The l2,0 coefficients of the spherical harmonics
  31939. */
  31940. l20: Vector3;
  31941. /**
  31942. * The l2,1 coefficients of the spherical harmonics
  31943. */
  31944. l21: Vector3;
  31945. /**
  31946. * The l2,2 coefficients of the spherical harmonics
  31947. */
  31948. l22: Vector3;
  31949. /**
  31950. * Adds a light to the spherical harmonics
  31951. * @param direction the direction of the light
  31952. * @param color the color of the light
  31953. * @param deltaSolidAngle the delta solid angle of the light
  31954. */
  31955. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31956. /**
  31957. * Scales the spherical harmonics by the given amount
  31958. * @param scale the amount to scale
  31959. */
  31960. scaleInPlace(scale: number): void;
  31961. /**
  31962. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31963. *
  31964. * ```
  31965. * E_lm = A_l * L_lm
  31966. * ```
  31967. *
  31968. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31969. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31970. * the scaling factors are given in equation 9.
  31971. */
  31972. convertIncidentRadianceToIrradiance(): void;
  31973. /**
  31974. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31975. *
  31976. * ```
  31977. * L = (1/pi) * E * rho
  31978. * ```
  31979. *
  31980. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31981. */
  31982. convertIrradianceToLambertianRadiance(): void;
  31983. /**
  31984. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31985. * required operations at run time.
  31986. *
  31987. * This is simply done by scaling back the SH with Ylm constants parameter.
  31988. * The trigonometric part being applied by the shader at run time.
  31989. */
  31990. preScaleForRendering(): void;
  31991. /**
  31992. * Constructs a spherical harmonics from an array.
  31993. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31994. * @returns the spherical harmonics
  31995. */
  31996. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31997. /**
  31998. * Gets the spherical harmonics from polynomial
  31999. * @param polynomial the spherical polynomial
  32000. * @returns the spherical harmonics
  32001. */
  32002. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32003. }
  32004. /**
  32005. * Class representing spherical polynomial coefficients to the 3rd degree
  32006. */
  32007. export class SphericalPolynomial {
  32008. private _harmonics;
  32009. /**
  32010. * The spherical harmonics used to create the polynomials.
  32011. */
  32012. get preScaledHarmonics(): SphericalHarmonics;
  32013. /**
  32014. * The x coefficients of the spherical polynomial
  32015. */
  32016. x: Vector3;
  32017. /**
  32018. * The y coefficients of the spherical polynomial
  32019. */
  32020. y: Vector3;
  32021. /**
  32022. * The z coefficients of the spherical polynomial
  32023. */
  32024. z: Vector3;
  32025. /**
  32026. * The xx coefficients of the spherical polynomial
  32027. */
  32028. xx: Vector3;
  32029. /**
  32030. * The yy coefficients of the spherical polynomial
  32031. */
  32032. yy: Vector3;
  32033. /**
  32034. * The zz coefficients of the spherical polynomial
  32035. */
  32036. zz: Vector3;
  32037. /**
  32038. * The xy coefficients of the spherical polynomial
  32039. */
  32040. xy: Vector3;
  32041. /**
  32042. * The yz coefficients of the spherical polynomial
  32043. */
  32044. yz: Vector3;
  32045. /**
  32046. * The zx coefficients of the spherical polynomial
  32047. */
  32048. zx: Vector3;
  32049. /**
  32050. * Adds an ambient color to the spherical polynomial
  32051. * @param color the color to add
  32052. */
  32053. addAmbient(color: Color3): void;
  32054. /**
  32055. * Scales the spherical polynomial by the given amount
  32056. * @param scale the amount to scale
  32057. */
  32058. scaleInPlace(scale: number): void;
  32059. /**
  32060. * Gets the spherical polynomial from harmonics
  32061. * @param harmonics the spherical harmonics
  32062. * @returns the spherical polynomial
  32063. */
  32064. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32065. /**
  32066. * Constructs a spherical polynomial from an array.
  32067. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32068. * @returns the spherical polynomial
  32069. */
  32070. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32071. }
  32072. }
  32073. declare module BABYLON {
  32074. /**
  32075. * Defines the source of the internal texture
  32076. */
  32077. export enum InternalTextureSource {
  32078. /**
  32079. * The source of the texture data is unknown
  32080. */
  32081. Unknown = 0,
  32082. /**
  32083. * Texture data comes from an URL
  32084. */
  32085. Url = 1,
  32086. /**
  32087. * Texture data is only used for temporary storage
  32088. */
  32089. Temp = 2,
  32090. /**
  32091. * Texture data comes from raw data (ArrayBuffer)
  32092. */
  32093. Raw = 3,
  32094. /**
  32095. * Texture content is dynamic (video or dynamic texture)
  32096. */
  32097. Dynamic = 4,
  32098. /**
  32099. * Texture content is generated by rendering to it
  32100. */
  32101. RenderTarget = 5,
  32102. /**
  32103. * Texture content is part of a multi render target process
  32104. */
  32105. MultiRenderTarget = 6,
  32106. /**
  32107. * Texture data comes from a cube data file
  32108. */
  32109. Cube = 7,
  32110. /**
  32111. * Texture data comes from a raw cube data
  32112. */
  32113. CubeRaw = 8,
  32114. /**
  32115. * Texture data come from a prefiltered cube data file
  32116. */
  32117. CubePrefiltered = 9,
  32118. /**
  32119. * Texture content is raw 3D data
  32120. */
  32121. Raw3D = 10,
  32122. /**
  32123. * Texture content is raw 2D array data
  32124. */
  32125. Raw2DArray = 11,
  32126. /**
  32127. * Texture content is a depth texture
  32128. */
  32129. Depth = 12,
  32130. /**
  32131. * Texture data comes from a raw cube data encoded with RGBD
  32132. */
  32133. CubeRawRGBD = 13
  32134. }
  32135. /**
  32136. * Class used to store data associated with WebGL texture data for the engine
  32137. * This class should not be used directly
  32138. */
  32139. export class InternalTexture {
  32140. /** @hidden */
  32141. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32142. /**
  32143. * Defines if the texture is ready
  32144. */
  32145. isReady: boolean;
  32146. /**
  32147. * Defines if the texture is a cube texture
  32148. */
  32149. isCube: boolean;
  32150. /**
  32151. * Defines if the texture contains 3D data
  32152. */
  32153. is3D: boolean;
  32154. /**
  32155. * Defines if the texture contains 2D array data
  32156. */
  32157. is2DArray: boolean;
  32158. /**
  32159. * Defines if the texture contains multiview data
  32160. */
  32161. isMultiview: boolean;
  32162. /**
  32163. * Gets the URL used to load this texture
  32164. */
  32165. url: string;
  32166. /**
  32167. * Gets the sampling mode of the texture
  32168. */
  32169. samplingMode: number;
  32170. /**
  32171. * Gets a boolean indicating if the texture needs mipmaps generation
  32172. */
  32173. generateMipMaps: boolean;
  32174. /**
  32175. * Gets the number of samples used by the texture (WebGL2+ only)
  32176. */
  32177. samples: number;
  32178. /**
  32179. * Gets the type of the texture (int, float...)
  32180. */
  32181. type: number;
  32182. /**
  32183. * Gets the format of the texture (RGB, RGBA...)
  32184. */
  32185. format: number;
  32186. /**
  32187. * Observable called when the texture is loaded
  32188. */
  32189. onLoadedObservable: Observable<InternalTexture>;
  32190. /**
  32191. * Gets the width of the texture
  32192. */
  32193. width: number;
  32194. /**
  32195. * Gets the height of the texture
  32196. */
  32197. height: number;
  32198. /**
  32199. * Gets the depth of the texture
  32200. */
  32201. depth: number;
  32202. /**
  32203. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32204. */
  32205. baseWidth: number;
  32206. /**
  32207. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32208. */
  32209. baseHeight: number;
  32210. /**
  32211. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32212. */
  32213. baseDepth: number;
  32214. /**
  32215. * Gets a boolean indicating if the texture is inverted on Y axis
  32216. */
  32217. invertY: boolean;
  32218. /** @hidden */
  32219. _invertVScale: boolean;
  32220. /** @hidden */
  32221. _associatedChannel: number;
  32222. /** @hidden */
  32223. _source: InternalTextureSource;
  32224. /** @hidden */
  32225. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32226. /** @hidden */
  32227. _bufferView: Nullable<ArrayBufferView>;
  32228. /** @hidden */
  32229. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32230. /** @hidden */
  32231. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32232. /** @hidden */
  32233. _size: number;
  32234. /** @hidden */
  32235. _extension: string;
  32236. /** @hidden */
  32237. _files: Nullable<string[]>;
  32238. /** @hidden */
  32239. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32240. /** @hidden */
  32241. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32242. /** @hidden */
  32243. _framebuffer: Nullable<WebGLFramebuffer>;
  32244. /** @hidden */
  32245. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32246. /** @hidden */
  32247. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32248. /** @hidden */
  32249. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32250. /** @hidden */
  32251. _attachments: Nullable<number[]>;
  32252. /** @hidden */
  32253. _cachedCoordinatesMode: Nullable<number>;
  32254. /** @hidden */
  32255. _cachedWrapU: Nullable<number>;
  32256. /** @hidden */
  32257. _cachedWrapV: Nullable<number>;
  32258. /** @hidden */
  32259. _cachedWrapR: Nullable<number>;
  32260. /** @hidden */
  32261. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32262. /** @hidden */
  32263. _isDisabled: boolean;
  32264. /** @hidden */
  32265. _compression: Nullable<string>;
  32266. /** @hidden */
  32267. _generateStencilBuffer: boolean;
  32268. /** @hidden */
  32269. _generateDepthBuffer: boolean;
  32270. /** @hidden */
  32271. _comparisonFunction: number;
  32272. /** @hidden */
  32273. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32274. /** @hidden */
  32275. _lodGenerationScale: number;
  32276. /** @hidden */
  32277. _lodGenerationOffset: number;
  32278. /** @hidden */
  32279. _depthStencilTexture: Nullable<InternalTexture>;
  32280. /** @hidden */
  32281. _colorTextureArray: Nullable<WebGLTexture>;
  32282. /** @hidden */
  32283. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32284. /** @hidden */
  32285. _lodTextureHigh: Nullable<BaseTexture>;
  32286. /** @hidden */
  32287. _lodTextureMid: Nullable<BaseTexture>;
  32288. /** @hidden */
  32289. _lodTextureLow: Nullable<BaseTexture>;
  32290. /** @hidden */
  32291. _isRGBD: boolean;
  32292. /** @hidden */
  32293. _linearSpecularLOD: boolean;
  32294. /** @hidden */
  32295. _irradianceTexture: Nullable<BaseTexture>;
  32296. /** @hidden */
  32297. _webGLTexture: Nullable<WebGLTexture>;
  32298. /** @hidden */
  32299. _references: number;
  32300. private _engine;
  32301. /**
  32302. * Gets the Engine the texture belongs to.
  32303. * @returns The babylon engine
  32304. */
  32305. getEngine(): ThinEngine;
  32306. /**
  32307. * Gets the data source type of the texture
  32308. */
  32309. get source(): InternalTextureSource;
  32310. /**
  32311. * Creates a new InternalTexture
  32312. * @param engine defines the engine to use
  32313. * @param source defines the type of data that will be used
  32314. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32315. */
  32316. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32317. /**
  32318. * Increments the number of references (ie. the number of Texture that point to it)
  32319. */
  32320. incrementReferences(): void;
  32321. /**
  32322. * Change the size of the texture (not the size of the content)
  32323. * @param width defines the new width
  32324. * @param height defines the new height
  32325. * @param depth defines the new depth (1 by default)
  32326. */
  32327. updateSize(width: int, height: int, depth?: int): void;
  32328. /** @hidden */
  32329. _rebuild(): void;
  32330. /** @hidden */
  32331. _swapAndDie(target: InternalTexture): void;
  32332. /**
  32333. * Dispose the current allocated resources
  32334. */
  32335. dispose(): void;
  32336. }
  32337. }
  32338. declare module BABYLON {
  32339. /**
  32340. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32342. */
  32343. export class Analyser {
  32344. /**
  32345. * Gets or sets the smoothing
  32346. * @ignorenaming
  32347. */
  32348. SMOOTHING: number;
  32349. /**
  32350. * Gets or sets the FFT table size
  32351. * @ignorenaming
  32352. */
  32353. FFT_SIZE: number;
  32354. /**
  32355. * Gets or sets the bar graph amplitude
  32356. * @ignorenaming
  32357. */
  32358. BARGRAPHAMPLITUDE: number;
  32359. /**
  32360. * Gets or sets the position of the debug canvas
  32361. * @ignorenaming
  32362. */
  32363. DEBUGCANVASPOS: {
  32364. x: number;
  32365. y: number;
  32366. };
  32367. /**
  32368. * Gets or sets the debug canvas size
  32369. * @ignorenaming
  32370. */
  32371. DEBUGCANVASSIZE: {
  32372. width: number;
  32373. height: number;
  32374. };
  32375. private _byteFreqs;
  32376. private _byteTime;
  32377. private _floatFreqs;
  32378. private _webAudioAnalyser;
  32379. private _debugCanvas;
  32380. private _debugCanvasContext;
  32381. private _scene;
  32382. private _registerFunc;
  32383. private _audioEngine;
  32384. /**
  32385. * Creates a new analyser
  32386. * @param scene defines hosting scene
  32387. */
  32388. constructor(scene: Scene);
  32389. /**
  32390. * Get the number of data values you will have to play with for the visualization
  32391. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32392. * @returns a number
  32393. */
  32394. getFrequencyBinCount(): number;
  32395. /**
  32396. * Gets the current frequency data as a byte array
  32397. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32398. * @returns a Uint8Array
  32399. */
  32400. getByteFrequencyData(): Uint8Array;
  32401. /**
  32402. * Gets the current waveform as a byte array
  32403. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32404. * @returns a Uint8Array
  32405. */
  32406. getByteTimeDomainData(): Uint8Array;
  32407. /**
  32408. * Gets the current frequency data as a float array
  32409. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32410. * @returns a Float32Array
  32411. */
  32412. getFloatFrequencyData(): Float32Array;
  32413. /**
  32414. * Renders the debug canvas
  32415. */
  32416. drawDebugCanvas(): void;
  32417. /**
  32418. * Stops rendering the debug canvas and removes it
  32419. */
  32420. stopDebugCanvas(): void;
  32421. /**
  32422. * Connects two audio nodes
  32423. * @param inputAudioNode defines first node to connect
  32424. * @param outputAudioNode defines second node to connect
  32425. */
  32426. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32427. /**
  32428. * Releases all associated resources
  32429. */
  32430. dispose(): void;
  32431. }
  32432. }
  32433. declare module BABYLON {
  32434. /**
  32435. * This represents an audio engine and it is responsible
  32436. * to play, synchronize and analyse sounds throughout the application.
  32437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32438. */
  32439. export interface IAudioEngine extends IDisposable {
  32440. /**
  32441. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32442. */
  32443. readonly canUseWebAudio: boolean;
  32444. /**
  32445. * Gets the current AudioContext if available.
  32446. */
  32447. readonly audioContext: Nullable<AudioContext>;
  32448. /**
  32449. * The master gain node defines the global audio volume of your audio engine.
  32450. */
  32451. readonly masterGain: GainNode;
  32452. /**
  32453. * Gets whether or not mp3 are supported by your browser.
  32454. */
  32455. readonly isMP3supported: boolean;
  32456. /**
  32457. * Gets whether or not ogg are supported by your browser.
  32458. */
  32459. readonly isOGGsupported: boolean;
  32460. /**
  32461. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32462. * @ignoreNaming
  32463. */
  32464. WarnedWebAudioUnsupported: boolean;
  32465. /**
  32466. * Defines if the audio engine relies on a custom unlocked button.
  32467. * In this case, the embedded button will not be displayed.
  32468. */
  32469. useCustomUnlockedButton: boolean;
  32470. /**
  32471. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32472. */
  32473. readonly unlocked: boolean;
  32474. /**
  32475. * Event raised when audio has been unlocked on the browser.
  32476. */
  32477. onAudioUnlockedObservable: Observable<AudioEngine>;
  32478. /**
  32479. * Event raised when audio has been locked on the browser.
  32480. */
  32481. onAudioLockedObservable: Observable<AudioEngine>;
  32482. /**
  32483. * Flags the audio engine in Locked state.
  32484. * This happens due to new browser policies preventing audio to autoplay.
  32485. */
  32486. lock(): void;
  32487. /**
  32488. * Unlocks the audio engine once a user action has been done on the dom.
  32489. * This is helpful to resume play once browser policies have been satisfied.
  32490. */
  32491. unlock(): void;
  32492. }
  32493. /**
  32494. * This represents the default audio engine used in babylon.
  32495. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32497. */
  32498. export class AudioEngine implements IAudioEngine {
  32499. private _audioContext;
  32500. private _audioContextInitialized;
  32501. private _muteButton;
  32502. private _hostElement;
  32503. /**
  32504. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32505. */
  32506. canUseWebAudio: boolean;
  32507. /**
  32508. * The master gain node defines the global audio volume of your audio engine.
  32509. */
  32510. masterGain: GainNode;
  32511. /**
  32512. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32513. * @ignoreNaming
  32514. */
  32515. WarnedWebAudioUnsupported: boolean;
  32516. /**
  32517. * Gets whether or not mp3 are supported by your browser.
  32518. */
  32519. isMP3supported: boolean;
  32520. /**
  32521. * Gets whether or not ogg are supported by your browser.
  32522. */
  32523. isOGGsupported: boolean;
  32524. /**
  32525. * Gets whether audio has been unlocked on the device.
  32526. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32527. * a user interaction has happened.
  32528. */
  32529. unlocked: boolean;
  32530. /**
  32531. * Defines if the audio engine relies on a custom unlocked button.
  32532. * In this case, the embedded button will not be displayed.
  32533. */
  32534. useCustomUnlockedButton: boolean;
  32535. /**
  32536. * Event raised when audio has been unlocked on the browser.
  32537. */
  32538. onAudioUnlockedObservable: Observable<AudioEngine>;
  32539. /**
  32540. * Event raised when audio has been locked on the browser.
  32541. */
  32542. onAudioLockedObservable: Observable<AudioEngine>;
  32543. /**
  32544. * Gets the current AudioContext if available.
  32545. */
  32546. get audioContext(): Nullable<AudioContext>;
  32547. private _connectedAnalyser;
  32548. /**
  32549. * Instantiates a new audio engine.
  32550. *
  32551. * There should be only one per page as some browsers restrict the number
  32552. * of audio contexts you can create.
  32553. * @param hostElement defines the host element where to display the mute icon if necessary
  32554. */
  32555. constructor(hostElement?: Nullable<HTMLElement>);
  32556. /**
  32557. * Flags the audio engine in Locked state.
  32558. * This happens due to new browser policies preventing audio to autoplay.
  32559. */
  32560. lock(): void;
  32561. /**
  32562. * Unlocks the audio engine once a user action has been done on the dom.
  32563. * This is helpful to resume play once browser policies have been satisfied.
  32564. */
  32565. unlock(): void;
  32566. private _resumeAudioContext;
  32567. private _initializeAudioContext;
  32568. private _tryToRun;
  32569. private _triggerRunningState;
  32570. private _triggerSuspendedState;
  32571. private _displayMuteButton;
  32572. private _moveButtonToTopLeft;
  32573. private _onResize;
  32574. private _hideMuteButton;
  32575. /**
  32576. * Destroy and release the resources associated with the audio ccontext.
  32577. */
  32578. dispose(): void;
  32579. /**
  32580. * Gets the global volume sets on the master gain.
  32581. * @returns the global volume if set or -1 otherwise
  32582. */
  32583. getGlobalVolume(): number;
  32584. /**
  32585. * Sets the global volume of your experience (sets on the master gain).
  32586. * @param newVolume Defines the new global volume of the application
  32587. */
  32588. setGlobalVolume(newVolume: number): void;
  32589. /**
  32590. * Connect the audio engine to an audio analyser allowing some amazing
  32591. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32593. * @param analyser The analyser to connect to the engine
  32594. */
  32595. connectToAnalyser(analyser: Analyser): void;
  32596. }
  32597. }
  32598. declare module BABYLON {
  32599. /**
  32600. * Interface used to present a loading screen while loading a scene
  32601. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32602. */
  32603. export interface ILoadingScreen {
  32604. /**
  32605. * Function called to display the loading screen
  32606. */
  32607. displayLoadingUI: () => void;
  32608. /**
  32609. * Function called to hide the loading screen
  32610. */
  32611. hideLoadingUI: () => void;
  32612. /**
  32613. * Gets or sets the color to use for the background
  32614. */
  32615. loadingUIBackgroundColor: string;
  32616. /**
  32617. * Gets or sets the text to display while loading
  32618. */
  32619. loadingUIText: string;
  32620. }
  32621. /**
  32622. * Class used for the default loading screen
  32623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32624. */
  32625. export class DefaultLoadingScreen implements ILoadingScreen {
  32626. private _renderingCanvas;
  32627. private _loadingText;
  32628. private _loadingDivBackgroundColor;
  32629. private _loadingDiv;
  32630. private _loadingTextDiv;
  32631. /** Gets or sets the logo url to use for the default loading screen */
  32632. static DefaultLogoUrl: string;
  32633. /** Gets or sets the spinner url to use for the default loading screen */
  32634. static DefaultSpinnerUrl: string;
  32635. /**
  32636. * Creates a new default loading screen
  32637. * @param _renderingCanvas defines the canvas used to render the scene
  32638. * @param _loadingText defines the default text to display
  32639. * @param _loadingDivBackgroundColor defines the default background color
  32640. */
  32641. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32642. /**
  32643. * Function called to display the loading screen
  32644. */
  32645. displayLoadingUI(): void;
  32646. /**
  32647. * Function called to hide the loading screen
  32648. */
  32649. hideLoadingUI(): void;
  32650. /**
  32651. * Gets or sets the text to display while loading
  32652. */
  32653. set loadingUIText(text: string);
  32654. get loadingUIText(): string;
  32655. /**
  32656. * Gets or sets the color to use for the background
  32657. */
  32658. get loadingUIBackgroundColor(): string;
  32659. set loadingUIBackgroundColor(color: string);
  32660. private _resizeLoadingUI;
  32661. }
  32662. }
  32663. declare module BABYLON {
  32664. /**
  32665. * Interface for any object that can request an animation frame
  32666. */
  32667. export interface ICustomAnimationFrameRequester {
  32668. /**
  32669. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32670. */
  32671. renderFunction?: Function;
  32672. /**
  32673. * Called to request the next frame to render to
  32674. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32675. */
  32676. requestAnimationFrame: Function;
  32677. /**
  32678. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32679. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32680. */
  32681. requestID?: number;
  32682. }
  32683. }
  32684. declare module BABYLON {
  32685. /**
  32686. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32687. */
  32688. export class PerformanceMonitor {
  32689. private _enabled;
  32690. private _rollingFrameTime;
  32691. private _lastFrameTimeMs;
  32692. /**
  32693. * constructor
  32694. * @param frameSampleSize The number of samples required to saturate the sliding window
  32695. */
  32696. constructor(frameSampleSize?: number);
  32697. /**
  32698. * Samples current frame
  32699. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32700. */
  32701. sampleFrame(timeMs?: number): void;
  32702. /**
  32703. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32704. */
  32705. get averageFrameTime(): number;
  32706. /**
  32707. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32708. */
  32709. get averageFrameTimeVariance(): number;
  32710. /**
  32711. * Returns the frame time of the most recent frame
  32712. */
  32713. get instantaneousFrameTime(): number;
  32714. /**
  32715. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32716. */
  32717. get averageFPS(): number;
  32718. /**
  32719. * Returns the average framerate in frames per second using the most recent frame time
  32720. */
  32721. get instantaneousFPS(): number;
  32722. /**
  32723. * Returns true if enough samples have been taken to completely fill the sliding window
  32724. */
  32725. get isSaturated(): boolean;
  32726. /**
  32727. * Enables contributions to the sliding window sample set
  32728. */
  32729. enable(): void;
  32730. /**
  32731. * Disables contributions to the sliding window sample set
  32732. * Samples will not be interpolated over the disabled period
  32733. */
  32734. disable(): void;
  32735. /**
  32736. * Returns true if sampling is enabled
  32737. */
  32738. get isEnabled(): boolean;
  32739. /**
  32740. * Resets performance monitor
  32741. */
  32742. reset(): void;
  32743. }
  32744. /**
  32745. * RollingAverage
  32746. *
  32747. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32748. */
  32749. export class RollingAverage {
  32750. /**
  32751. * Current average
  32752. */
  32753. average: number;
  32754. /**
  32755. * Current variance
  32756. */
  32757. variance: number;
  32758. protected _samples: Array<number>;
  32759. protected _sampleCount: number;
  32760. protected _pos: number;
  32761. protected _m2: number;
  32762. /**
  32763. * constructor
  32764. * @param length The number of samples required to saturate the sliding window
  32765. */
  32766. constructor(length: number);
  32767. /**
  32768. * Adds a sample to the sample set
  32769. * @param v The sample value
  32770. */
  32771. add(v: number): void;
  32772. /**
  32773. * Returns previously added values or null if outside of history or outside the sliding window domain
  32774. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32775. * @return Value previously recorded with add() or null if outside of range
  32776. */
  32777. history(i: number): number;
  32778. /**
  32779. * Returns true if enough samples have been taken to completely fill the sliding window
  32780. * @return true if sample-set saturated
  32781. */
  32782. isSaturated(): boolean;
  32783. /**
  32784. * Resets the rolling average (equivalent to 0 samples taken so far)
  32785. */
  32786. reset(): void;
  32787. /**
  32788. * Wraps a value around the sample range boundaries
  32789. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32790. * @return Wrapped position in sample range
  32791. */
  32792. protected _wrapPosition(i: number): number;
  32793. }
  32794. }
  32795. declare module BABYLON {
  32796. /**
  32797. * This class is used to track a performance counter which is number based.
  32798. * The user has access to many properties which give statistics of different nature.
  32799. *
  32800. * The implementer can track two kinds of Performance Counter: time and count.
  32801. * 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.
  32802. * 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.
  32803. */
  32804. export class PerfCounter {
  32805. /**
  32806. * Gets or sets a global boolean to turn on and off all the counters
  32807. */
  32808. static Enabled: boolean;
  32809. /**
  32810. * Returns the smallest value ever
  32811. */
  32812. get min(): number;
  32813. /**
  32814. * Returns the biggest value ever
  32815. */
  32816. get max(): number;
  32817. /**
  32818. * Returns the average value since the performance counter is running
  32819. */
  32820. get average(): number;
  32821. /**
  32822. * Returns the average value of the last second the counter was monitored
  32823. */
  32824. get lastSecAverage(): number;
  32825. /**
  32826. * Returns the current value
  32827. */
  32828. get current(): number;
  32829. /**
  32830. * Gets the accumulated total
  32831. */
  32832. get total(): number;
  32833. /**
  32834. * Gets the total value count
  32835. */
  32836. get count(): number;
  32837. /**
  32838. * Creates a new counter
  32839. */
  32840. constructor();
  32841. /**
  32842. * Call this method to start monitoring a new frame.
  32843. * 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.
  32844. */
  32845. fetchNewFrame(): void;
  32846. /**
  32847. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32848. * @param newCount the count value to add to the monitored count
  32849. * @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.
  32850. */
  32851. addCount(newCount: number, fetchResult: boolean): void;
  32852. /**
  32853. * Start monitoring this performance counter
  32854. */
  32855. beginMonitoring(): void;
  32856. /**
  32857. * Compute the time lapsed since the previous beginMonitoring() call.
  32858. * @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
  32859. */
  32860. endMonitoring(newFrame?: boolean): void;
  32861. private _fetchResult;
  32862. private _startMonitoringTime;
  32863. private _min;
  32864. private _max;
  32865. private _average;
  32866. private _current;
  32867. private _totalValueCount;
  32868. private _totalAccumulated;
  32869. private _lastSecAverage;
  32870. private _lastSecAccumulated;
  32871. private _lastSecTime;
  32872. private _lastSecValueCount;
  32873. }
  32874. }
  32875. declare module BABYLON {
  32876. interface ThinEngine {
  32877. /**
  32878. * Sets alpha constants used by some alpha blending modes
  32879. * @param r defines the red component
  32880. * @param g defines the green component
  32881. * @param b defines the blue component
  32882. * @param a defines the alpha component
  32883. */
  32884. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32885. /**
  32886. * Sets the current alpha mode
  32887. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32888. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32890. */
  32891. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32892. /**
  32893. * Gets the current alpha mode
  32894. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32895. * @returns the current alpha mode
  32896. */
  32897. getAlphaMode(): number;
  32898. /**
  32899. * Sets the current alpha equation
  32900. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32901. */
  32902. setAlphaEquation(equation: number): void;
  32903. /**
  32904. * Gets the current alpha equation.
  32905. * @returns the current alpha equation
  32906. */
  32907. getAlphaEquation(): number;
  32908. }
  32909. }
  32910. declare module BABYLON {
  32911. /**
  32912. * Defines the interface used by display changed events
  32913. */
  32914. export interface IDisplayChangedEventArgs {
  32915. /** Gets the vrDisplay object (if any) */
  32916. vrDisplay: Nullable<any>;
  32917. /** Gets a boolean indicating if webVR is supported */
  32918. vrSupported: boolean;
  32919. }
  32920. /**
  32921. * Defines the interface used by objects containing a viewport (like a camera)
  32922. */
  32923. interface IViewportOwnerLike {
  32924. /**
  32925. * Gets or sets the viewport
  32926. */
  32927. viewport: IViewportLike;
  32928. }
  32929. /**
  32930. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32931. */
  32932. export class Engine extends ThinEngine {
  32933. /** Defines that alpha blending is disabled */
  32934. static readonly ALPHA_DISABLE: number;
  32935. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32936. static readonly ALPHA_ADD: number;
  32937. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32938. static readonly ALPHA_COMBINE: number;
  32939. /** Defines that alpha blending to DEST - SRC * DEST */
  32940. static readonly ALPHA_SUBTRACT: number;
  32941. /** Defines that alpha blending to SRC * DEST */
  32942. static readonly ALPHA_MULTIPLY: number;
  32943. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32944. static readonly ALPHA_MAXIMIZED: number;
  32945. /** Defines that alpha blending to SRC + DEST */
  32946. static readonly ALPHA_ONEONE: number;
  32947. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32948. static readonly ALPHA_PREMULTIPLIED: number;
  32949. /**
  32950. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32951. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32952. */
  32953. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32954. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32955. static readonly ALPHA_INTERPOLATE: number;
  32956. /**
  32957. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32958. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32959. */
  32960. static readonly ALPHA_SCREENMODE: number;
  32961. /** Defines that the ressource is not delayed*/
  32962. static readonly DELAYLOADSTATE_NONE: number;
  32963. /** Defines that the ressource was successfully delay loaded */
  32964. static readonly DELAYLOADSTATE_LOADED: number;
  32965. /** Defines that the ressource is currently delay loading */
  32966. static readonly DELAYLOADSTATE_LOADING: number;
  32967. /** Defines that the ressource is delayed and has not started loading */
  32968. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32969. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32970. static readonly NEVER: number;
  32971. /** 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 */
  32972. static readonly ALWAYS: number;
  32973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32974. static readonly LESS: number;
  32975. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32976. static readonly EQUAL: number;
  32977. /** 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 */
  32978. static readonly LEQUAL: number;
  32979. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32980. static readonly GREATER: number;
  32981. /** 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 */
  32982. static readonly GEQUAL: number;
  32983. /** 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 */
  32984. static readonly NOTEQUAL: number;
  32985. /** Passed to stencilOperation to specify that stencil value must be kept */
  32986. static readonly KEEP: number;
  32987. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32988. static readonly REPLACE: number;
  32989. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32990. static readonly INCR: number;
  32991. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32992. static readonly DECR: number;
  32993. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32994. static readonly INVERT: number;
  32995. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32996. static readonly INCR_WRAP: number;
  32997. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32998. static readonly DECR_WRAP: number;
  32999. /** Texture is not repeating outside of 0..1 UVs */
  33000. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33001. /** Texture is repeating outside of 0..1 UVs */
  33002. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33003. /** Texture is repeating and mirrored */
  33004. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33005. /** ALPHA */
  33006. static readonly TEXTUREFORMAT_ALPHA: number;
  33007. /** LUMINANCE */
  33008. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33009. /** LUMINANCE_ALPHA */
  33010. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33011. /** RGB */
  33012. static readonly TEXTUREFORMAT_RGB: number;
  33013. /** RGBA */
  33014. static readonly TEXTUREFORMAT_RGBA: number;
  33015. /** RED */
  33016. static readonly TEXTUREFORMAT_RED: number;
  33017. /** RED (2nd reference) */
  33018. static readonly TEXTUREFORMAT_R: number;
  33019. /** RG */
  33020. static readonly TEXTUREFORMAT_RG: number;
  33021. /** RED_INTEGER */
  33022. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33023. /** RED_INTEGER (2nd reference) */
  33024. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33025. /** RG_INTEGER */
  33026. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33027. /** RGB_INTEGER */
  33028. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33029. /** RGBA_INTEGER */
  33030. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33031. /** UNSIGNED_BYTE */
  33032. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33033. /** UNSIGNED_BYTE (2nd reference) */
  33034. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33035. /** FLOAT */
  33036. static readonly TEXTURETYPE_FLOAT: number;
  33037. /** HALF_FLOAT */
  33038. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33039. /** BYTE */
  33040. static readonly TEXTURETYPE_BYTE: number;
  33041. /** SHORT */
  33042. static readonly TEXTURETYPE_SHORT: number;
  33043. /** UNSIGNED_SHORT */
  33044. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33045. /** INT */
  33046. static readonly TEXTURETYPE_INT: number;
  33047. /** UNSIGNED_INT */
  33048. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33049. /** UNSIGNED_SHORT_4_4_4_4 */
  33050. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33051. /** UNSIGNED_SHORT_5_5_5_1 */
  33052. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33053. /** UNSIGNED_SHORT_5_6_5 */
  33054. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33055. /** UNSIGNED_INT_2_10_10_10_REV */
  33056. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33057. /** UNSIGNED_INT_24_8 */
  33058. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33059. /** UNSIGNED_INT_10F_11F_11F_REV */
  33060. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33061. /** UNSIGNED_INT_5_9_9_9_REV */
  33062. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33063. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33064. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33065. /** nearest is mag = nearest and min = nearest and mip = linear */
  33066. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33067. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33068. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33069. /** Trilinear is mag = linear and min = linear and mip = linear */
  33070. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33071. /** nearest is mag = nearest and min = nearest and mip = linear */
  33072. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33073. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33074. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33075. /** Trilinear is mag = linear and min = linear and mip = linear */
  33076. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33077. /** mag = nearest and min = nearest and mip = nearest */
  33078. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33079. /** mag = nearest and min = linear and mip = nearest */
  33080. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33081. /** mag = nearest and min = linear and mip = linear */
  33082. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33083. /** mag = nearest and min = linear and mip = none */
  33084. static readonly TEXTURE_NEAREST_LINEAR: number;
  33085. /** mag = nearest and min = nearest and mip = none */
  33086. static readonly TEXTURE_NEAREST_NEAREST: number;
  33087. /** mag = linear and min = nearest and mip = nearest */
  33088. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33089. /** mag = linear and min = nearest and mip = linear */
  33090. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33091. /** mag = linear and min = linear and mip = none */
  33092. static readonly TEXTURE_LINEAR_LINEAR: number;
  33093. /** mag = linear and min = nearest and mip = none */
  33094. static readonly TEXTURE_LINEAR_NEAREST: number;
  33095. /** Explicit coordinates mode */
  33096. static readonly TEXTURE_EXPLICIT_MODE: number;
  33097. /** Spherical coordinates mode */
  33098. static readonly TEXTURE_SPHERICAL_MODE: number;
  33099. /** Planar coordinates mode */
  33100. static readonly TEXTURE_PLANAR_MODE: number;
  33101. /** Cubic coordinates mode */
  33102. static readonly TEXTURE_CUBIC_MODE: number;
  33103. /** Projection coordinates mode */
  33104. static readonly TEXTURE_PROJECTION_MODE: number;
  33105. /** Skybox coordinates mode */
  33106. static readonly TEXTURE_SKYBOX_MODE: number;
  33107. /** Inverse Cubic coordinates mode */
  33108. static readonly TEXTURE_INVCUBIC_MODE: number;
  33109. /** Equirectangular coordinates mode */
  33110. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33111. /** Equirectangular Fixed coordinates mode */
  33112. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33113. /** Equirectangular Fixed Mirrored coordinates mode */
  33114. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33115. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33116. static readonly SCALEMODE_FLOOR: number;
  33117. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33118. static readonly SCALEMODE_NEAREST: number;
  33119. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33120. static readonly SCALEMODE_CEILING: number;
  33121. /**
  33122. * Returns the current npm package of the sdk
  33123. */
  33124. static get NpmPackage(): string;
  33125. /**
  33126. * Returns the current version of the framework
  33127. */
  33128. static get Version(): string;
  33129. /** Gets the list of created engines */
  33130. static get Instances(): Engine[];
  33131. /**
  33132. * Gets the latest created engine
  33133. */
  33134. static get LastCreatedEngine(): Nullable<Engine>;
  33135. /**
  33136. * Gets the latest created scene
  33137. */
  33138. static get LastCreatedScene(): Nullable<Scene>;
  33139. /**
  33140. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33141. * @param flag defines which part of the materials must be marked as dirty
  33142. * @param predicate defines a predicate used to filter which materials should be affected
  33143. */
  33144. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33145. /**
  33146. * Method called to create the default loading screen.
  33147. * This can be overriden in your own app.
  33148. * @param canvas The rendering canvas element
  33149. * @returns The loading screen
  33150. */
  33151. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33152. /**
  33153. * Method called to create the default rescale post process on each engine.
  33154. */
  33155. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33156. /**
  33157. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33158. **/
  33159. enableOfflineSupport: boolean;
  33160. /**
  33161. * 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)
  33162. **/
  33163. disableManifestCheck: boolean;
  33164. /**
  33165. * Gets the list of created scenes
  33166. */
  33167. scenes: Scene[];
  33168. /**
  33169. * Event raised when a new scene is created
  33170. */
  33171. onNewSceneAddedObservable: Observable<Scene>;
  33172. /**
  33173. * Gets the list of created postprocesses
  33174. */
  33175. postProcesses: PostProcess[];
  33176. /**
  33177. * Gets a boolean indicating if the pointer is currently locked
  33178. */
  33179. isPointerLock: boolean;
  33180. /**
  33181. * Observable event triggered each time the rendering canvas is resized
  33182. */
  33183. onResizeObservable: Observable<Engine>;
  33184. /**
  33185. * Observable event triggered each time the canvas loses focus
  33186. */
  33187. onCanvasBlurObservable: Observable<Engine>;
  33188. /**
  33189. * Observable event triggered each time the canvas gains focus
  33190. */
  33191. onCanvasFocusObservable: Observable<Engine>;
  33192. /**
  33193. * Observable event triggered each time the canvas receives pointerout event
  33194. */
  33195. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33196. /**
  33197. * Observable raised when the engine begins a new frame
  33198. */
  33199. onBeginFrameObservable: Observable<Engine>;
  33200. /**
  33201. * If set, will be used to request the next animation frame for the render loop
  33202. */
  33203. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33204. /**
  33205. * Observable raised when the engine ends the current frame
  33206. */
  33207. onEndFrameObservable: Observable<Engine>;
  33208. /**
  33209. * Observable raised when the engine is about to compile a shader
  33210. */
  33211. onBeforeShaderCompilationObservable: Observable<Engine>;
  33212. /**
  33213. * Observable raised when the engine has jsut compiled a shader
  33214. */
  33215. onAfterShaderCompilationObservable: Observable<Engine>;
  33216. /**
  33217. * Gets the audio engine
  33218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33219. * @ignorenaming
  33220. */
  33221. static audioEngine: IAudioEngine;
  33222. /**
  33223. * Default AudioEngine factory responsible of creating the Audio Engine.
  33224. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33225. */
  33226. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33227. /**
  33228. * Default offline support factory responsible of creating a tool used to store data locally.
  33229. * By default, this will create a Database object if the workload has been embedded.
  33230. */
  33231. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33232. private _loadingScreen;
  33233. private _pointerLockRequested;
  33234. private _dummyFramebuffer;
  33235. private _rescalePostProcess;
  33236. private _deterministicLockstep;
  33237. private _lockstepMaxSteps;
  33238. private _timeStep;
  33239. protected get _supportsHardwareTextureRescaling(): boolean;
  33240. private _fps;
  33241. private _deltaTime;
  33242. /** @hidden */
  33243. _drawCalls: PerfCounter;
  33244. /** 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 */
  33245. canvasTabIndex: number;
  33246. /**
  33247. * Turn this value on if you want to pause FPS computation when in background
  33248. */
  33249. disablePerformanceMonitorInBackground: boolean;
  33250. private _performanceMonitor;
  33251. /**
  33252. * Gets the performance monitor attached to this engine
  33253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33254. */
  33255. get performanceMonitor(): PerformanceMonitor;
  33256. private _onFocus;
  33257. private _onBlur;
  33258. private _onCanvasPointerOut;
  33259. private _onCanvasBlur;
  33260. private _onCanvasFocus;
  33261. private _onFullscreenChange;
  33262. private _onPointerLockChange;
  33263. /**
  33264. * Gets the HTML element used to attach event listeners
  33265. * @returns a HTML element
  33266. */
  33267. getInputElement(): Nullable<HTMLElement>;
  33268. /**
  33269. * Creates a new engine
  33270. * @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
  33271. * @param antialias defines enable antialiasing (default: false)
  33272. * @param options defines further options to be sent to the getContext() function
  33273. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33274. */
  33275. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33276. /**
  33277. * Gets current aspect ratio
  33278. * @param viewportOwner defines the camera to use to get the aspect ratio
  33279. * @param useScreen defines if screen size must be used (or the current render target if any)
  33280. * @returns a number defining the aspect ratio
  33281. */
  33282. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33283. /**
  33284. * Gets current screen aspect ratio
  33285. * @returns a number defining the aspect ratio
  33286. */
  33287. getScreenAspectRatio(): number;
  33288. /**
  33289. * Gets the client rect of the HTML canvas attached with the current webGL context
  33290. * @returns a client rectanglee
  33291. */
  33292. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33293. /**
  33294. * Gets the client rect of the HTML element used for events
  33295. * @returns a client rectanglee
  33296. */
  33297. getInputElementClientRect(): Nullable<ClientRect>;
  33298. /**
  33299. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33301. * @returns true if engine is in deterministic lock step mode
  33302. */
  33303. isDeterministicLockStep(): boolean;
  33304. /**
  33305. * Gets the max steps when engine is running in deterministic lock step
  33306. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33307. * @returns the max steps
  33308. */
  33309. getLockstepMaxSteps(): number;
  33310. /**
  33311. * Returns the time in ms between steps when using deterministic lock step.
  33312. * @returns time step in (ms)
  33313. */
  33314. getTimeStep(): number;
  33315. /**
  33316. * Force the mipmap generation for the given render target texture
  33317. * @param texture defines the render target texture to use
  33318. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33319. */
  33320. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33321. /** States */
  33322. /**
  33323. * Set various states to the webGL context
  33324. * @param culling defines backface culling state
  33325. * @param zOffset defines the value to apply to zOffset (0 by default)
  33326. * @param force defines if states must be applied even if cache is up to date
  33327. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33328. */
  33329. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33330. /**
  33331. * Set the z offset to apply to current rendering
  33332. * @param value defines the offset to apply
  33333. */
  33334. setZOffset(value: number): void;
  33335. /**
  33336. * Gets the current value of the zOffset
  33337. * @returns the current zOffset state
  33338. */
  33339. getZOffset(): number;
  33340. /**
  33341. * Enable or disable depth buffering
  33342. * @param enable defines the state to set
  33343. */
  33344. setDepthBuffer(enable: boolean): void;
  33345. /**
  33346. * Gets a boolean indicating if depth writing is enabled
  33347. * @returns the current depth writing state
  33348. */
  33349. getDepthWrite(): boolean;
  33350. /**
  33351. * Enable or disable depth writing
  33352. * @param enable defines the state to set
  33353. */
  33354. setDepthWrite(enable: boolean): void;
  33355. /**
  33356. * Gets a boolean indicating if stencil buffer is enabled
  33357. * @returns the current stencil buffer state
  33358. */
  33359. getStencilBuffer(): boolean;
  33360. /**
  33361. * Enable or disable the stencil buffer
  33362. * @param enable defines if the stencil buffer must be enabled or disabled
  33363. */
  33364. setStencilBuffer(enable: boolean): void;
  33365. /**
  33366. * Gets the current stencil mask
  33367. * @returns a number defining the new stencil mask to use
  33368. */
  33369. getStencilMask(): number;
  33370. /**
  33371. * Sets the current stencil mask
  33372. * @param mask defines the new stencil mask to use
  33373. */
  33374. setStencilMask(mask: number): void;
  33375. /**
  33376. * Gets the current stencil function
  33377. * @returns a number defining the stencil function to use
  33378. */
  33379. getStencilFunction(): number;
  33380. /**
  33381. * Gets the current stencil reference value
  33382. * @returns a number defining the stencil reference value to use
  33383. */
  33384. getStencilFunctionReference(): number;
  33385. /**
  33386. * Gets the current stencil mask
  33387. * @returns a number defining the stencil mask to use
  33388. */
  33389. getStencilFunctionMask(): number;
  33390. /**
  33391. * Sets the current stencil function
  33392. * @param stencilFunc defines the new stencil function to use
  33393. */
  33394. setStencilFunction(stencilFunc: number): void;
  33395. /**
  33396. * Sets the current stencil reference
  33397. * @param reference defines the new stencil reference to use
  33398. */
  33399. setStencilFunctionReference(reference: number): void;
  33400. /**
  33401. * Sets the current stencil mask
  33402. * @param mask defines the new stencil mask to use
  33403. */
  33404. setStencilFunctionMask(mask: number): void;
  33405. /**
  33406. * Gets the current stencil operation when stencil fails
  33407. * @returns a number defining stencil operation to use when stencil fails
  33408. */
  33409. getStencilOperationFail(): number;
  33410. /**
  33411. * Gets the current stencil operation when depth fails
  33412. * @returns a number defining stencil operation to use when depth fails
  33413. */
  33414. getStencilOperationDepthFail(): number;
  33415. /**
  33416. * Gets the current stencil operation when stencil passes
  33417. * @returns a number defining stencil operation to use when stencil passes
  33418. */
  33419. getStencilOperationPass(): number;
  33420. /**
  33421. * Sets the stencil operation to use when stencil fails
  33422. * @param operation defines the stencil operation to use when stencil fails
  33423. */
  33424. setStencilOperationFail(operation: number): void;
  33425. /**
  33426. * Sets the stencil operation to use when depth fails
  33427. * @param operation defines the stencil operation to use when depth fails
  33428. */
  33429. setStencilOperationDepthFail(operation: number): void;
  33430. /**
  33431. * Sets the stencil operation to use when stencil passes
  33432. * @param operation defines the stencil operation to use when stencil passes
  33433. */
  33434. setStencilOperationPass(operation: number): void;
  33435. /**
  33436. * Sets a boolean indicating if the dithering state is enabled or disabled
  33437. * @param value defines the dithering state
  33438. */
  33439. setDitheringState(value: boolean): void;
  33440. /**
  33441. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33442. * @param value defines the rasterizer state
  33443. */
  33444. setRasterizerState(value: boolean): void;
  33445. /**
  33446. * Gets the current depth function
  33447. * @returns a number defining the depth function
  33448. */
  33449. getDepthFunction(): Nullable<number>;
  33450. /**
  33451. * Sets the current depth function
  33452. * @param depthFunc defines the function to use
  33453. */
  33454. setDepthFunction(depthFunc: number): void;
  33455. /**
  33456. * Sets the current depth function to GREATER
  33457. */
  33458. setDepthFunctionToGreater(): void;
  33459. /**
  33460. * Sets the current depth function to GEQUAL
  33461. */
  33462. setDepthFunctionToGreaterOrEqual(): void;
  33463. /**
  33464. * Sets the current depth function to LESS
  33465. */
  33466. setDepthFunctionToLess(): void;
  33467. /**
  33468. * Sets the current depth function to LEQUAL
  33469. */
  33470. setDepthFunctionToLessOrEqual(): void;
  33471. private _cachedStencilBuffer;
  33472. private _cachedStencilFunction;
  33473. private _cachedStencilMask;
  33474. private _cachedStencilOperationPass;
  33475. private _cachedStencilOperationFail;
  33476. private _cachedStencilOperationDepthFail;
  33477. private _cachedStencilReference;
  33478. /**
  33479. * Caches the the state of the stencil buffer
  33480. */
  33481. cacheStencilState(): void;
  33482. /**
  33483. * Restores the state of the stencil buffer
  33484. */
  33485. restoreStencilState(): void;
  33486. /**
  33487. * Directly set the WebGL Viewport
  33488. * @param x defines the x coordinate of the viewport (in screen space)
  33489. * @param y defines the y coordinate of the viewport (in screen space)
  33490. * @param width defines the width of the viewport (in screen space)
  33491. * @param height defines the height of the viewport (in screen space)
  33492. * @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
  33493. */
  33494. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33495. /**
  33496. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33497. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33498. * @param y defines the y-coordinate of the corner of the clear rectangle
  33499. * @param width defines the width of the clear rectangle
  33500. * @param height defines the height of the clear rectangle
  33501. * @param clearColor defines the clear color
  33502. */
  33503. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33504. /**
  33505. * Enable scissor test on a specific rectangle (ie. render will only be executed 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. */
  33511. enableScissor(x: number, y: number, width: number, height: number): void;
  33512. /**
  33513. * Disable previously set scissor test rectangle
  33514. */
  33515. disableScissor(): void;
  33516. protected _reportDrawCall(): void;
  33517. /**
  33518. * Initializes a webVR display and starts listening to display change events
  33519. * The onVRDisplayChangedObservable will be notified upon these changes
  33520. * @returns The onVRDisplayChangedObservable
  33521. */
  33522. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33523. /** @hidden */
  33524. _prepareVRComponent(): void;
  33525. /** @hidden */
  33526. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33527. /** @hidden */
  33528. _submitVRFrame(): void;
  33529. /**
  33530. * Call this function to leave webVR mode
  33531. * Will do nothing if webVR is not supported or if there is no webVR device
  33532. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33533. */
  33534. disableVR(): void;
  33535. /**
  33536. * Gets a boolean indicating that the system is in VR mode and is presenting
  33537. * @returns true if VR mode is engaged
  33538. */
  33539. isVRPresenting(): boolean;
  33540. /** @hidden */
  33541. _requestVRFrame(): void;
  33542. /** @hidden */
  33543. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33544. /**
  33545. * Gets the source code of the vertex shader associated with a specific webGL program
  33546. * @param program defines the program to use
  33547. * @returns a string containing the source code of the vertex shader associated with the program
  33548. */
  33549. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33550. /**
  33551. * Gets the source code of the fragment shader associated with a specific webGL program
  33552. * @param program defines the program to use
  33553. * @returns a string containing the source code of the fragment shader associated with the program
  33554. */
  33555. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33556. /**
  33557. * Sets a depth stencil texture from a render target to the according uniform.
  33558. * @param channel The texture channel
  33559. * @param uniform The uniform to set
  33560. * @param texture The render target texture containing the depth stencil texture to apply
  33561. */
  33562. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33563. /**
  33564. * Sets a texture to the webGL context from a postprocess
  33565. * @param channel defines the channel to use
  33566. * @param postProcess defines the source postprocess
  33567. */
  33568. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33569. /**
  33570. * Binds the output of the passed in post process to the texture channel specified
  33571. * @param channel The channel the texture should be bound to
  33572. * @param postProcess The post process which's output should be bound
  33573. */
  33574. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33575. /** @hidden */
  33576. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33577. protected _rebuildBuffers(): void;
  33578. /** @hidden */
  33579. _renderFrame(): void;
  33580. _renderLoop(): void;
  33581. /** @hidden */
  33582. _renderViews(): boolean;
  33583. /**
  33584. * Toggle full screen mode
  33585. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33586. */
  33587. switchFullscreen(requestPointerLock: boolean): void;
  33588. /**
  33589. * Enters full screen mode
  33590. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33591. */
  33592. enterFullscreen(requestPointerLock: boolean): void;
  33593. /**
  33594. * Exits full screen mode
  33595. */
  33596. exitFullscreen(): void;
  33597. /**
  33598. * Enters Pointerlock mode
  33599. */
  33600. enterPointerlock(): void;
  33601. /**
  33602. * Exits Pointerlock mode
  33603. */
  33604. exitPointerlock(): void;
  33605. /**
  33606. * Begin a new frame
  33607. */
  33608. beginFrame(): void;
  33609. /**
  33610. * Enf the current frame
  33611. */
  33612. endFrame(): void;
  33613. resize(): void;
  33614. /**
  33615. * Set the compressed texture format to use, based on the formats you have, and the formats
  33616. * supported by the hardware / browser.
  33617. *
  33618. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33619. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33620. * to API arguments needed to compressed textures. This puts the burden on the container
  33621. * generator to house the arcane code for determining these for current & future formats.
  33622. *
  33623. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33624. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33625. *
  33626. * Note: The result of this call is not taken into account when a texture is base64.
  33627. *
  33628. * @param formatsAvailable defines the list of those format families you have created
  33629. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33630. *
  33631. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33632. * @returns The extension selected.
  33633. */
  33634. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33635. /**
  33636. * Set the compressed texture extensions or file names to skip.
  33637. *
  33638. * @param skippedFiles defines the list of those texture files you want to skip
  33639. * Example: [".dds", ".env", "myfile.png"]
  33640. */
  33641. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33642. /**
  33643. * Force a specific size of the canvas
  33644. * @param width defines the new canvas' width
  33645. * @param height defines the new canvas' height
  33646. */
  33647. setSize(width: number, height: number): void;
  33648. /**
  33649. * Updates a dynamic vertex buffer.
  33650. * @param vertexBuffer the vertex buffer to update
  33651. * @param data the data used to update the vertex buffer
  33652. * @param byteOffset the byte offset of the data
  33653. * @param byteLength the byte length of the data
  33654. */
  33655. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33656. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33657. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33658. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33659. _releaseTexture(texture: InternalTexture): void;
  33660. /**
  33661. * @hidden
  33662. * Rescales a texture
  33663. * @param source input texutre
  33664. * @param destination destination texture
  33665. * @param scene scene to use to render the resize
  33666. * @param internalFormat format to use when resizing
  33667. * @param onComplete callback to be called when resize has completed
  33668. */
  33669. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33670. /**
  33671. * Gets the current framerate
  33672. * @returns a number representing the framerate
  33673. */
  33674. getFps(): number;
  33675. /**
  33676. * Gets the time spent between current and previous frame
  33677. * @returns a number representing the delta time in ms
  33678. */
  33679. getDeltaTime(): number;
  33680. private _measureFps;
  33681. /** @hidden */
  33682. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33683. /**
  33684. * Update a dynamic index buffer
  33685. * @param indexBuffer defines the target index buffer
  33686. * @param indices defines the data to update
  33687. * @param offset defines the offset in the target index buffer where update should start
  33688. */
  33689. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33690. /**
  33691. * Updates the sample count of a render target texture
  33692. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33693. * @param texture defines the texture to update
  33694. * @param samples defines the sample count to set
  33695. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33696. */
  33697. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33698. /**
  33699. * Updates a depth texture Comparison Mode and Function.
  33700. * If the comparison Function is equal to 0, the mode will be set to none.
  33701. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33702. * @param texture The texture to set the comparison function for
  33703. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33704. */
  33705. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33706. /**
  33707. * Creates a webGL buffer to use with instanciation
  33708. * @param capacity defines the size of the buffer
  33709. * @returns the webGL buffer
  33710. */
  33711. createInstancesBuffer(capacity: number): DataBuffer;
  33712. /**
  33713. * Delete a webGL buffer used with instanciation
  33714. * @param buffer defines the webGL buffer to delete
  33715. */
  33716. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33717. /** @hidden */
  33718. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33719. dispose(): void;
  33720. private _disableTouchAction;
  33721. /**
  33722. * Display the loading screen
  33723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33724. */
  33725. displayLoadingUI(): void;
  33726. /**
  33727. * Hide the loading screen
  33728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33729. */
  33730. hideLoadingUI(): void;
  33731. /**
  33732. * Gets the current loading screen object
  33733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33734. */
  33735. get loadingScreen(): ILoadingScreen;
  33736. /**
  33737. * Sets the current loading screen object
  33738. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33739. */
  33740. set loadingScreen(loadingScreen: ILoadingScreen);
  33741. /**
  33742. * Sets the current loading screen text
  33743. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33744. */
  33745. set loadingUIText(text: string);
  33746. /**
  33747. * Sets the current loading screen background color
  33748. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33749. */
  33750. set loadingUIBackgroundColor(color: string);
  33751. /** Pointerlock and fullscreen */
  33752. /**
  33753. * Ask the browser to promote the current element to pointerlock mode
  33754. * @param element defines the DOM element to promote
  33755. */
  33756. static _RequestPointerlock(element: HTMLElement): void;
  33757. /**
  33758. * Asks the browser to exit pointerlock mode
  33759. */
  33760. static _ExitPointerlock(): void;
  33761. /**
  33762. * Ask the browser to promote the current element to fullscreen rendering mode
  33763. * @param element defines the DOM element to promote
  33764. */
  33765. static _RequestFullscreen(element: HTMLElement): void;
  33766. /**
  33767. * Asks the browser to exit fullscreen mode
  33768. */
  33769. static _ExitFullscreen(): void;
  33770. }
  33771. }
  33772. declare module BABYLON {
  33773. /**
  33774. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33775. * during the life time of the application.
  33776. */
  33777. export class EngineStore {
  33778. /** Gets the list of created engines */
  33779. static Instances: Engine[];
  33780. /** @hidden */
  33781. static _LastCreatedScene: Nullable<Scene>;
  33782. /**
  33783. * Gets the latest created engine
  33784. */
  33785. static get LastCreatedEngine(): Nullable<Engine>;
  33786. /**
  33787. * Gets the latest created scene
  33788. */
  33789. static get LastCreatedScene(): Nullable<Scene>;
  33790. /**
  33791. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33792. * @ignorenaming
  33793. */
  33794. static UseFallbackTexture: boolean;
  33795. /**
  33796. * Texture content used if a texture cannot loaded
  33797. * @ignorenaming
  33798. */
  33799. static FallbackTexture: string;
  33800. }
  33801. }
  33802. declare module BABYLON {
  33803. /**
  33804. * Helper class that provides a small promise polyfill
  33805. */
  33806. export class PromisePolyfill {
  33807. /**
  33808. * Static function used to check if the polyfill is required
  33809. * If this is the case then the function will inject the polyfill to window.Promise
  33810. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33811. */
  33812. static Apply(force?: boolean): void;
  33813. }
  33814. }
  33815. declare module BABYLON {
  33816. /**
  33817. * Interface for screenshot methods with describe argument called `size` as object with options
  33818. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33819. */
  33820. export interface IScreenshotSize {
  33821. /**
  33822. * number in pixels for canvas height
  33823. */
  33824. height?: number;
  33825. /**
  33826. * multiplier allowing render at a higher or lower resolution
  33827. * If value is defined then height and width will be ignored and taken from camera
  33828. */
  33829. precision?: number;
  33830. /**
  33831. * number in pixels for canvas width
  33832. */
  33833. width?: number;
  33834. }
  33835. }
  33836. declare module BABYLON {
  33837. interface IColor4Like {
  33838. r: float;
  33839. g: float;
  33840. b: float;
  33841. a: float;
  33842. }
  33843. /**
  33844. * Class containing a set of static utilities functions
  33845. */
  33846. export class Tools {
  33847. /**
  33848. * Gets or sets the base URL to use to load assets
  33849. */
  33850. static get BaseUrl(): string;
  33851. static set BaseUrl(value: string);
  33852. /**
  33853. * Enable/Disable Custom HTTP Request Headers globally.
  33854. * default = false
  33855. * @see CustomRequestHeaders
  33856. */
  33857. static UseCustomRequestHeaders: boolean;
  33858. /**
  33859. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33860. * i.e. when loading files, where the server/service expects an Authorization header
  33861. */
  33862. static CustomRequestHeaders: {
  33863. [key: string]: string;
  33864. };
  33865. /**
  33866. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33867. */
  33868. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33869. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33870. /**
  33871. * Default behaviour for cors in the application.
  33872. * It can be a string if the expected behavior is identical in the entire app.
  33873. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33874. */
  33875. static CorsBehavior: string | ((url: string | string[]) => string);
  33876. /**
  33877. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33878. * @ignorenaming
  33879. */
  33880. static get UseFallbackTexture(): boolean;
  33881. static set UseFallbackTexture(value: boolean);
  33882. /**
  33883. * Use this object to register external classes like custom textures or material
  33884. * to allow the laoders to instantiate them
  33885. */
  33886. static get RegisteredExternalClasses(): {
  33887. [key: string]: Object;
  33888. };
  33889. static set RegisteredExternalClasses(classes: {
  33890. [key: string]: Object;
  33891. });
  33892. /**
  33893. * Texture content used if a texture cannot loaded
  33894. * @ignorenaming
  33895. */
  33896. static get fallbackTexture(): string;
  33897. static set fallbackTexture(value: string);
  33898. /**
  33899. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33900. * @param u defines the coordinate on X axis
  33901. * @param v defines the coordinate on Y axis
  33902. * @param width defines the width of the source data
  33903. * @param height defines the height of the source data
  33904. * @param pixels defines the source byte array
  33905. * @param color defines the output color
  33906. */
  33907. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33908. /**
  33909. * Interpolates between a and b via alpha
  33910. * @param a The lower value (returned when alpha = 0)
  33911. * @param b The upper value (returned when alpha = 1)
  33912. * @param alpha The interpolation-factor
  33913. * @return The mixed value
  33914. */
  33915. static Mix(a: number, b: number, alpha: number): number;
  33916. /**
  33917. * Tries to instantiate a new object from a given class name
  33918. * @param className defines the class name to instantiate
  33919. * @returns the new object or null if the system was not able to do the instantiation
  33920. */
  33921. static Instantiate(className: string): any;
  33922. /**
  33923. * Provides a slice function that will work even on IE
  33924. * @param data defines the array to slice
  33925. * @param start defines the start of the data (optional)
  33926. * @param end defines the end of the data (optional)
  33927. * @returns the new sliced array
  33928. */
  33929. static Slice<T>(data: T, start?: number, end?: number): T;
  33930. /**
  33931. * Polyfill for setImmediate
  33932. * @param action defines the action to execute after the current execution block
  33933. */
  33934. static SetImmediate(action: () => void): void;
  33935. /**
  33936. * Function indicating if a number is an exponent of 2
  33937. * @param value defines the value to test
  33938. * @returns true if the value is an exponent of 2
  33939. */
  33940. static IsExponentOfTwo(value: number): boolean;
  33941. private static _tmpFloatArray;
  33942. /**
  33943. * Returns the nearest 32-bit single precision float representation of a Number
  33944. * @param value A Number. If the parameter is of a different type, it will get converted
  33945. * to a number or to NaN if it cannot be converted
  33946. * @returns number
  33947. */
  33948. static FloatRound(value: number): number;
  33949. /**
  33950. * Extracts the filename from a path
  33951. * @param path defines the path to use
  33952. * @returns the filename
  33953. */
  33954. static GetFilename(path: string): string;
  33955. /**
  33956. * Extracts the "folder" part of a path (everything before the filename).
  33957. * @param uri The URI to extract the info from
  33958. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33959. * @returns The "folder" part of the path
  33960. */
  33961. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33962. /**
  33963. * Extracts text content from a DOM element hierarchy
  33964. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33965. */
  33966. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33967. /**
  33968. * Convert an angle in radians to degrees
  33969. * @param angle defines the angle to convert
  33970. * @returns the angle in degrees
  33971. */
  33972. static ToDegrees(angle: number): number;
  33973. /**
  33974. * Convert an angle in degrees to radians
  33975. * @param angle defines the angle to convert
  33976. * @returns the angle in radians
  33977. */
  33978. static ToRadians(angle: number): number;
  33979. /**
  33980. * Returns an array if obj is not an array
  33981. * @param obj defines the object to evaluate as an array
  33982. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33983. * @returns either obj directly if obj is an array or a new array containing obj
  33984. */
  33985. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33986. /**
  33987. * Gets the pointer prefix to use
  33988. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33989. */
  33990. static GetPointerPrefix(): string;
  33991. /**
  33992. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33993. * @param url define the url we are trying
  33994. * @param element define the dom element where to configure the cors policy
  33995. */
  33996. static SetCorsBehavior(url: string | string[], element: {
  33997. crossOrigin: string | null;
  33998. }): void;
  33999. /**
  34000. * Removes unwanted characters from an url
  34001. * @param url defines the url to clean
  34002. * @returns the cleaned url
  34003. */
  34004. static CleanUrl(url: string): string;
  34005. /**
  34006. * Gets or sets a function used to pre-process url before using them to load assets
  34007. */
  34008. static get PreprocessUrl(): (url: string) => string;
  34009. static set PreprocessUrl(processor: (url: string) => string);
  34010. /**
  34011. * Loads an image as an HTMLImageElement.
  34012. * @param input url string, ArrayBuffer, or Blob to load
  34013. * @param onLoad callback called when the image successfully loads
  34014. * @param onError callback called when the image fails to load
  34015. * @param offlineProvider offline provider for caching
  34016. * @param mimeType optional mime type
  34017. * @returns the HTMLImageElement of the loaded image
  34018. */
  34019. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34020. /**
  34021. * Loads a file from a url
  34022. * @param url url string, ArrayBuffer, or Blob to load
  34023. * @param onSuccess callback called when the file successfully loads
  34024. * @param onProgress callback called while file is loading (if the server supports this mode)
  34025. * @param offlineProvider defines the offline provider for caching
  34026. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34027. * @param onError callback called when the file fails to load
  34028. * @returns a file request object
  34029. */
  34030. 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;
  34031. /**
  34032. * Loads a file from a url
  34033. * @param url the file url to load
  34034. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34035. */
  34036. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34037. /**
  34038. * Load a script (identified by an url). When the url returns, the
  34039. * content of this file is added into a new script element, attached to the DOM (body element)
  34040. * @param scriptUrl defines the url of the script to laod
  34041. * @param onSuccess defines the callback called when the script is loaded
  34042. * @param onError defines the callback to call if an error occurs
  34043. * @param scriptId defines the id of the script element
  34044. */
  34045. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34046. /**
  34047. * Load an asynchronous script (identified by an url). When the url returns, the
  34048. * content of this file is added into a new script element, attached to the DOM (body element)
  34049. * @param scriptUrl defines the url of the script to laod
  34050. * @param scriptId defines the id of the script element
  34051. * @returns a promise request object
  34052. */
  34053. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34054. /**
  34055. * Loads a file from a blob
  34056. * @param fileToLoad defines the blob to use
  34057. * @param callback defines the callback to call when data is loaded
  34058. * @param progressCallback defines the callback to call during loading process
  34059. * @returns a file request object
  34060. */
  34061. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34062. /**
  34063. * Reads a file from a File object
  34064. * @param file defines the file to load
  34065. * @param onSuccess defines the callback to call when data is loaded
  34066. * @param onProgress defines the callback to call during loading process
  34067. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34068. * @param onError defines the callback to call when an error occurs
  34069. * @returns a file request object
  34070. */
  34071. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34072. /**
  34073. * Creates a data url from a given string content
  34074. * @param content defines the content to convert
  34075. * @returns the new data url link
  34076. */
  34077. static FileAsURL(content: string): string;
  34078. /**
  34079. * Format the given number to a specific decimal format
  34080. * @param value defines the number to format
  34081. * @param decimals defines the number of decimals to use
  34082. * @returns the formatted string
  34083. */
  34084. static Format(value: number, decimals?: number): string;
  34085. /**
  34086. * Tries to copy an object by duplicating every property
  34087. * @param source defines the source object
  34088. * @param destination defines the target object
  34089. * @param doNotCopyList defines a list of properties to avoid
  34090. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34091. */
  34092. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34093. /**
  34094. * Gets a boolean indicating if the given object has no own property
  34095. * @param obj defines the object to test
  34096. * @returns true if object has no own property
  34097. */
  34098. static IsEmpty(obj: any): boolean;
  34099. /**
  34100. * Function used to register events at window level
  34101. * @param windowElement defines the Window object to use
  34102. * @param events defines the events to register
  34103. */
  34104. static RegisterTopRootEvents(windowElement: Window, events: {
  34105. name: string;
  34106. handler: Nullable<(e: FocusEvent) => any>;
  34107. }[]): void;
  34108. /**
  34109. * Function used to unregister events from window level
  34110. * @param windowElement defines the Window object to use
  34111. * @param events defines the events to unregister
  34112. */
  34113. static UnregisterTopRootEvents(windowElement: Window, events: {
  34114. name: string;
  34115. handler: Nullable<(e: FocusEvent) => any>;
  34116. }[]): void;
  34117. /**
  34118. * @ignore
  34119. */
  34120. static _ScreenshotCanvas: HTMLCanvasElement;
  34121. /**
  34122. * Dumps the current bound framebuffer
  34123. * @param width defines the rendering width
  34124. * @param height defines the rendering height
  34125. * @param engine defines the hosting engine
  34126. * @param successCallback defines the callback triggered once the data are available
  34127. * @param mimeType defines the mime type of the result
  34128. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34129. */
  34130. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34131. /**
  34132. * Converts the canvas data to blob.
  34133. * This acts as a polyfill for browsers not supporting the to blob function.
  34134. * @param canvas Defines the canvas to extract the data from
  34135. * @param successCallback Defines the callback triggered once the data are available
  34136. * @param mimeType Defines the mime type of the result
  34137. */
  34138. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34139. /**
  34140. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34141. * @param successCallback defines the callback triggered once the data are available
  34142. * @param mimeType defines the mime type of the result
  34143. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34144. */
  34145. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34146. /**
  34147. * Downloads a blob in the browser
  34148. * @param blob defines the blob to download
  34149. * @param fileName defines the name of the downloaded file
  34150. */
  34151. static Download(blob: Blob, fileName: string): void;
  34152. /**
  34153. * Captures a screenshot of the current rendering
  34154. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34155. * @param engine defines the rendering engine
  34156. * @param camera defines the source camera
  34157. * @param size This parameter can be set to a single number or to an object with the
  34158. * following (optional) properties: precision, width, height. If a single number is passed,
  34159. * it will be used for both width and height. If an object is passed, the screenshot size
  34160. * will be derived from the parameters. The precision property is a multiplier allowing
  34161. * rendering at a higher or lower resolution
  34162. * @param successCallback defines the callback receives a single parameter which contains the
  34163. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34164. * src parameter of an <img> to display it
  34165. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34166. * Check your browser for supported MIME types
  34167. */
  34168. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34169. /**
  34170. * Captures a screenshot of the current rendering
  34171. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34172. * @param engine defines the rendering engine
  34173. * @param camera defines the source camera
  34174. * @param size This parameter can be set to a single number or to an object with the
  34175. * following (optional) properties: precision, width, height. If a single number is passed,
  34176. * it will be used for both width and height. If an object is passed, the screenshot size
  34177. * will be derived from the parameters. The precision property is a multiplier allowing
  34178. * rendering at a higher or lower resolution
  34179. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34180. * Check your browser for supported MIME types
  34181. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34182. * to the src parameter of an <img> to display it
  34183. */
  34184. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34185. /**
  34186. * Generates an image screenshot from the specified camera.
  34187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34188. * @param engine The engine to use for rendering
  34189. * @param camera The camera to use for rendering
  34190. * @param size This parameter can be set to a single number or to an object with the
  34191. * following (optional) properties: precision, width, height. If a single number is passed,
  34192. * it will be used for both width and height. If an object is passed, the screenshot size
  34193. * will be derived from the parameters. The precision property is a multiplier allowing
  34194. * rendering at a higher or lower resolution
  34195. * @param successCallback The callback receives a single parameter which contains the
  34196. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34197. * src parameter of an <img> to display it
  34198. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34199. * Check your browser for supported MIME types
  34200. * @param samples Texture samples (default: 1)
  34201. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34202. * @param fileName A name for for the downloaded file.
  34203. */
  34204. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34205. /**
  34206. * Generates an image screenshot from the specified camera.
  34207. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34208. * @param engine The engine to use for rendering
  34209. * @param camera The camera to use for rendering
  34210. * @param size This parameter can be set to a single number or to an object with the
  34211. * following (optional) properties: precision, width, height. If a single number is passed,
  34212. * it will be used for both width and height. If an object is passed, the screenshot size
  34213. * will be derived from the parameters. The precision property is a multiplier allowing
  34214. * rendering at a higher or lower resolution
  34215. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34216. * Check your browser for supported MIME types
  34217. * @param samples Texture samples (default: 1)
  34218. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34219. * @param fileName A name for for the downloaded file.
  34220. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34221. * to the src parameter of an <img> to display it
  34222. */
  34223. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34224. /**
  34225. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34226. * Be aware Math.random() could cause collisions, but:
  34227. * "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"
  34228. * @returns a pseudo random id
  34229. */
  34230. static RandomId(): string;
  34231. /**
  34232. * Test if the given uri is a base64 string
  34233. * @param uri The uri to test
  34234. * @return True if the uri is a base64 string or false otherwise
  34235. */
  34236. static IsBase64(uri: string): boolean;
  34237. /**
  34238. * Decode the given base64 uri.
  34239. * @param uri The uri to decode
  34240. * @return The decoded base64 data.
  34241. */
  34242. static DecodeBase64(uri: string): ArrayBuffer;
  34243. /**
  34244. * Gets the absolute url.
  34245. * @param url the input url
  34246. * @return the absolute url
  34247. */
  34248. static GetAbsoluteUrl(url: string): string;
  34249. /**
  34250. * No log
  34251. */
  34252. static readonly NoneLogLevel: number;
  34253. /**
  34254. * Only message logs
  34255. */
  34256. static readonly MessageLogLevel: number;
  34257. /**
  34258. * Only warning logs
  34259. */
  34260. static readonly WarningLogLevel: number;
  34261. /**
  34262. * Only error logs
  34263. */
  34264. static readonly ErrorLogLevel: number;
  34265. /**
  34266. * All logs
  34267. */
  34268. static readonly AllLogLevel: number;
  34269. /**
  34270. * Gets a value indicating the number of loading errors
  34271. * @ignorenaming
  34272. */
  34273. static get errorsCount(): number;
  34274. /**
  34275. * Callback called when a new log is added
  34276. */
  34277. static OnNewCacheEntry: (entry: string) => void;
  34278. /**
  34279. * Log a message to the console
  34280. * @param message defines the message to log
  34281. */
  34282. static Log(message: string): void;
  34283. /**
  34284. * Write a warning message to the console
  34285. * @param message defines the message to log
  34286. */
  34287. static Warn(message: string): void;
  34288. /**
  34289. * Write an error message to the console
  34290. * @param message defines the message to log
  34291. */
  34292. static Error(message: string): void;
  34293. /**
  34294. * Gets current log cache (list of logs)
  34295. */
  34296. static get LogCache(): string;
  34297. /**
  34298. * Clears the log cache
  34299. */
  34300. static ClearLogCache(): void;
  34301. /**
  34302. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34303. */
  34304. static set LogLevels(level: number);
  34305. /**
  34306. * Checks if the window object exists
  34307. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34308. */
  34309. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34310. /**
  34311. * No performance log
  34312. */
  34313. static readonly PerformanceNoneLogLevel: number;
  34314. /**
  34315. * Use user marks to log performance
  34316. */
  34317. static readonly PerformanceUserMarkLogLevel: number;
  34318. /**
  34319. * Log performance to the console
  34320. */
  34321. static readonly PerformanceConsoleLogLevel: number;
  34322. private static _performance;
  34323. /**
  34324. * Sets the current performance log level
  34325. */
  34326. static set PerformanceLogLevel(level: number);
  34327. private static _StartPerformanceCounterDisabled;
  34328. private static _EndPerformanceCounterDisabled;
  34329. private static _StartUserMark;
  34330. private static _EndUserMark;
  34331. private static _StartPerformanceConsole;
  34332. private static _EndPerformanceConsole;
  34333. /**
  34334. * Starts a performance counter
  34335. */
  34336. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34337. /**
  34338. * Ends a specific performance coutner
  34339. */
  34340. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34341. /**
  34342. * Gets either window.performance.now() if supported or Date.now() else
  34343. */
  34344. static get Now(): number;
  34345. /**
  34346. * This method will return the name of the class used to create the instance of the given object.
  34347. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34348. * @param object the object to get the class name from
  34349. * @param isType defines if the object is actually a type
  34350. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34351. */
  34352. static GetClassName(object: any, isType?: boolean): string;
  34353. /**
  34354. * Gets the first element of an array satisfying a given predicate
  34355. * @param array defines the array to browse
  34356. * @param predicate defines the predicate to use
  34357. * @returns null if not found or the element
  34358. */
  34359. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34360. /**
  34361. * This method will return the name of the full name of the class, including its owning module (if any).
  34362. * 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).
  34363. * @param object the object to get the class name from
  34364. * @param isType defines if the object is actually a type
  34365. * @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.
  34366. * @ignorenaming
  34367. */
  34368. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34369. /**
  34370. * Returns a promise that resolves after the given amount of time.
  34371. * @param delay Number of milliseconds to delay
  34372. * @returns Promise that resolves after the given amount of time
  34373. */
  34374. static DelayAsync(delay: number): Promise<void>;
  34375. /**
  34376. * Utility function to detect if the current user agent is Safari
  34377. * @returns whether or not the current user agent is safari
  34378. */
  34379. static IsSafari(): boolean;
  34380. }
  34381. /**
  34382. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34383. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34384. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34385. * @param name The name of the class, case should be preserved
  34386. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34387. */
  34388. export function className(name: string, module?: string): (target: Object) => void;
  34389. /**
  34390. * An implementation of a loop for asynchronous functions.
  34391. */
  34392. export class AsyncLoop {
  34393. /**
  34394. * Defines the number of iterations for the loop
  34395. */
  34396. iterations: number;
  34397. /**
  34398. * Defines the current index of the loop.
  34399. */
  34400. index: number;
  34401. private _done;
  34402. private _fn;
  34403. private _successCallback;
  34404. /**
  34405. * Constructor.
  34406. * @param iterations the number of iterations.
  34407. * @param func the function to run each iteration
  34408. * @param successCallback the callback that will be called upon succesful execution
  34409. * @param offset starting offset.
  34410. */
  34411. constructor(
  34412. /**
  34413. * Defines the number of iterations for the loop
  34414. */
  34415. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34416. /**
  34417. * Execute the next iteration. Must be called after the last iteration was finished.
  34418. */
  34419. executeNext(): void;
  34420. /**
  34421. * Break the loop and run the success callback.
  34422. */
  34423. breakLoop(): void;
  34424. /**
  34425. * Create and run an async loop.
  34426. * @param iterations the number of iterations.
  34427. * @param fn the function to run each iteration
  34428. * @param successCallback the callback that will be called upon succesful execution
  34429. * @param offset starting offset.
  34430. * @returns the created async loop object
  34431. */
  34432. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34433. /**
  34434. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34435. * @param iterations total number of iterations
  34436. * @param syncedIterations number of synchronous iterations in each async iteration.
  34437. * @param fn the function to call each iteration.
  34438. * @param callback a success call back that will be called when iterating stops.
  34439. * @param breakFunction a break condition (optional)
  34440. * @param timeout timeout settings for the setTimeout function. default - 0.
  34441. * @returns the created async loop object
  34442. */
  34443. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34444. }
  34445. }
  34446. declare module BABYLON {
  34447. /**
  34448. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34449. * The underlying implementation relies on an associative array to ensure the best performances.
  34450. * The value can be anything including 'null' but except 'undefined'
  34451. */
  34452. export class StringDictionary<T> {
  34453. /**
  34454. * This will clear this dictionary and copy the content from the 'source' one.
  34455. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34456. * @param source the dictionary to take the content from and copy to this dictionary
  34457. */
  34458. copyFrom(source: StringDictionary<T>): void;
  34459. /**
  34460. * Get a value based from its key
  34461. * @param key the given key to get the matching value from
  34462. * @return the value if found, otherwise undefined is returned
  34463. */
  34464. get(key: string): T | undefined;
  34465. /**
  34466. * Get a value from its key or add it if it doesn't exist.
  34467. * This method will ensure you that a given key/data will be present in the dictionary.
  34468. * @param key the given key to get the matching value from
  34469. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34470. * The factory will only be invoked if there's no data for the given key.
  34471. * @return the value corresponding to the key.
  34472. */
  34473. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34474. /**
  34475. * Get a value from its key if present in the dictionary otherwise add it
  34476. * @param key the key to get the value from
  34477. * @param val if there's no such key/value pair in the dictionary add it with this value
  34478. * @return the value corresponding to the key
  34479. */
  34480. getOrAdd(key: string, val: T): T;
  34481. /**
  34482. * Check if there's a given key in the dictionary
  34483. * @param key the key to check for
  34484. * @return true if the key is present, false otherwise
  34485. */
  34486. contains(key: string): boolean;
  34487. /**
  34488. * Add a new key and its corresponding value
  34489. * @param key the key to add
  34490. * @param value the value corresponding to the key
  34491. * @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
  34492. */
  34493. add(key: string, value: T): boolean;
  34494. /**
  34495. * Update a specific value associated to a key
  34496. * @param key defines the key to use
  34497. * @param value defines the value to store
  34498. * @returns true if the value was updated (or false if the key was not found)
  34499. */
  34500. set(key: string, value: T): boolean;
  34501. /**
  34502. * Get the element of the given key and remove it from the dictionary
  34503. * @param key defines the key to search
  34504. * @returns the value associated with the key or null if not found
  34505. */
  34506. getAndRemove(key: string): Nullable<T>;
  34507. /**
  34508. * Remove a key/value from the dictionary.
  34509. * @param key the key to remove
  34510. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34511. */
  34512. remove(key: string): boolean;
  34513. /**
  34514. * Clear the whole content of the dictionary
  34515. */
  34516. clear(): void;
  34517. /**
  34518. * Gets the current count
  34519. */
  34520. get count(): number;
  34521. /**
  34522. * Execute a callback on each key/val of the dictionary.
  34523. * Note that you can remove any element in this dictionary in the callback implementation
  34524. * @param callback the callback to execute on a given key/value pair
  34525. */
  34526. forEach(callback: (key: string, val: T) => void): void;
  34527. /**
  34528. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34529. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34530. * Note that you can remove any element in this dictionary in the callback implementation
  34531. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34532. * @returns the first item
  34533. */
  34534. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34535. private _count;
  34536. private _data;
  34537. }
  34538. }
  34539. declare module BABYLON {
  34540. /** @hidden */
  34541. export interface ICollisionCoordinator {
  34542. createCollider(): Collider;
  34543. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34544. init(scene: Scene): void;
  34545. }
  34546. /** @hidden */
  34547. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34548. private _scene;
  34549. private _scaledPosition;
  34550. private _scaledVelocity;
  34551. private _finalPosition;
  34552. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34553. createCollider(): Collider;
  34554. init(scene: Scene): void;
  34555. private _collideWithWorld;
  34556. }
  34557. }
  34558. declare module BABYLON {
  34559. /**
  34560. * Class used to manage all inputs for the scene.
  34561. */
  34562. export class InputManager {
  34563. /** The distance in pixel that you have to move to prevent some events */
  34564. static DragMovementThreshold: number;
  34565. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34566. static LongPressDelay: number;
  34567. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34568. static DoubleClickDelay: number;
  34569. /** If you need to check double click without raising a single click at first click, enable this flag */
  34570. static ExclusiveDoubleClickMode: boolean;
  34571. private _wheelEventName;
  34572. private _onPointerMove;
  34573. private _onPointerDown;
  34574. private _onPointerUp;
  34575. private _initClickEvent;
  34576. private _initActionManager;
  34577. private _delayedSimpleClick;
  34578. private _delayedSimpleClickTimeout;
  34579. private _previousDelayedSimpleClickTimeout;
  34580. private _meshPickProceed;
  34581. private _previousButtonPressed;
  34582. private _currentPickResult;
  34583. private _previousPickResult;
  34584. private _totalPointersPressed;
  34585. private _doubleClickOccured;
  34586. private _pointerOverMesh;
  34587. private _pickedDownMesh;
  34588. private _pickedUpMesh;
  34589. private _pointerX;
  34590. private _pointerY;
  34591. private _unTranslatedPointerX;
  34592. private _unTranslatedPointerY;
  34593. private _startingPointerPosition;
  34594. private _previousStartingPointerPosition;
  34595. private _startingPointerTime;
  34596. private _previousStartingPointerTime;
  34597. private _pointerCaptures;
  34598. private _onKeyDown;
  34599. private _onKeyUp;
  34600. private _onCanvasFocusObserver;
  34601. private _onCanvasBlurObserver;
  34602. private _scene;
  34603. /**
  34604. * Creates a new InputManager
  34605. * @param scene defines the hosting scene
  34606. */
  34607. constructor(scene: Scene);
  34608. /**
  34609. * Gets the mesh that is currently under the pointer
  34610. */
  34611. get meshUnderPointer(): Nullable<AbstractMesh>;
  34612. /**
  34613. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34614. */
  34615. get unTranslatedPointer(): Vector2;
  34616. /**
  34617. * Gets or sets the current on-screen X position of the pointer
  34618. */
  34619. get pointerX(): number;
  34620. set pointerX(value: number);
  34621. /**
  34622. * Gets or sets the current on-screen Y position of the pointer
  34623. */
  34624. get pointerY(): number;
  34625. set pointerY(value: number);
  34626. private _updatePointerPosition;
  34627. private _processPointerMove;
  34628. private _setRayOnPointerInfo;
  34629. private _checkPrePointerObservable;
  34630. /**
  34631. * Use this method to simulate a pointer move on a mesh
  34632. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34633. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34634. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34635. */
  34636. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34637. /**
  34638. * Use this method to simulate a pointer down on a mesh
  34639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34642. */
  34643. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34644. private _processPointerDown;
  34645. /** @hidden */
  34646. _isPointerSwiping(): boolean;
  34647. /**
  34648. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34653. */
  34654. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34655. private _processPointerUp;
  34656. /**
  34657. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34658. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34659. * @returns true if the pointer was captured
  34660. */
  34661. isPointerCaptured(pointerId?: number): boolean;
  34662. /**
  34663. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34664. * @param attachUp defines if you want to attach events to pointerup
  34665. * @param attachDown defines if you want to attach events to pointerdown
  34666. * @param attachMove defines if you want to attach events to pointermove
  34667. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34668. */
  34669. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34670. /**
  34671. * Detaches all event handlers
  34672. */
  34673. detachControl(): void;
  34674. /**
  34675. * Force the value of meshUnderPointer
  34676. * @param mesh defines the mesh to use
  34677. */
  34678. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34679. /**
  34680. * Gets the mesh under the pointer
  34681. * @returns a Mesh or null if no mesh is under the pointer
  34682. */
  34683. getPointerOverMesh(): Nullable<AbstractMesh>;
  34684. }
  34685. }
  34686. declare module BABYLON {
  34687. /**
  34688. * Helper class used to generate session unique ID
  34689. */
  34690. export class UniqueIdGenerator {
  34691. private static _UniqueIdCounter;
  34692. /**
  34693. * Gets an unique (relatively to the current scene) Id
  34694. */
  34695. static get UniqueId(): number;
  34696. }
  34697. }
  34698. declare module BABYLON {
  34699. /**
  34700. * This class defines the direct association between an animation and a target
  34701. */
  34702. export class TargetedAnimation {
  34703. /**
  34704. * Animation to perform
  34705. */
  34706. animation: Animation;
  34707. /**
  34708. * Target to animate
  34709. */
  34710. target: any;
  34711. /**
  34712. * Serialize the object
  34713. * @returns the JSON object representing the current entity
  34714. */
  34715. serialize(): any;
  34716. }
  34717. /**
  34718. * Use this class to create coordinated animations on multiple targets
  34719. */
  34720. export class AnimationGroup implements IDisposable {
  34721. /** The name of the animation group */
  34722. name: string;
  34723. private _scene;
  34724. private _targetedAnimations;
  34725. private _animatables;
  34726. private _from;
  34727. private _to;
  34728. private _isStarted;
  34729. private _isPaused;
  34730. private _speedRatio;
  34731. private _loopAnimation;
  34732. /**
  34733. * Gets or sets the unique id of the node
  34734. */
  34735. uniqueId: number;
  34736. /**
  34737. * This observable will notify when one animation have ended
  34738. */
  34739. onAnimationEndObservable: Observable<TargetedAnimation>;
  34740. /**
  34741. * Observer raised when one animation loops
  34742. */
  34743. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34744. /**
  34745. * Observer raised when all animations have looped
  34746. */
  34747. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34748. /**
  34749. * This observable will notify when all animations have ended.
  34750. */
  34751. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34752. /**
  34753. * This observable will notify when all animations have paused.
  34754. */
  34755. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34756. /**
  34757. * This observable will notify when all animations are playing.
  34758. */
  34759. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34760. /**
  34761. * Gets the first frame
  34762. */
  34763. get from(): number;
  34764. /**
  34765. * Gets the last frame
  34766. */
  34767. get to(): number;
  34768. /**
  34769. * Define if the animations are started
  34770. */
  34771. get isStarted(): boolean;
  34772. /**
  34773. * Gets a value indicating that the current group is playing
  34774. */
  34775. get isPlaying(): boolean;
  34776. /**
  34777. * Gets or sets the speed ratio to use for all animations
  34778. */
  34779. get speedRatio(): number;
  34780. /**
  34781. * Gets or sets the speed ratio to use for all animations
  34782. */
  34783. set speedRatio(value: number);
  34784. /**
  34785. * Gets or sets if all animations should loop or not
  34786. */
  34787. get loopAnimation(): boolean;
  34788. set loopAnimation(value: boolean);
  34789. /**
  34790. * Gets the targeted animations for this animation group
  34791. */
  34792. get targetedAnimations(): Array<TargetedAnimation>;
  34793. /**
  34794. * returning the list of animatables controlled by this animation group.
  34795. */
  34796. get animatables(): Array<Animatable>;
  34797. /**
  34798. * Instantiates a new Animation Group.
  34799. * This helps managing several animations at once.
  34800. * @see http://doc.babylonjs.com/how_to/group
  34801. * @param name Defines the name of the group
  34802. * @param scene Defines the scene the group belongs to
  34803. */
  34804. constructor(
  34805. /** The name of the animation group */
  34806. name: string, scene?: Nullable<Scene>);
  34807. /**
  34808. * Add an animation (with its target) in the group
  34809. * @param animation defines the animation we want to add
  34810. * @param target defines the target of the animation
  34811. * @returns the TargetedAnimation object
  34812. */
  34813. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34814. /**
  34815. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34816. * It can add constant keys at begin or end
  34817. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34818. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34819. * @returns the animation group
  34820. */
  34821. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34822. private _animationLoopCount;
  34823. private _animationLoopFlags;
  34824. private _processLoop;
  34825. /**
  34826. * Start all animations on given targets
  34827. * @param loop defines if animations must loop
  34828. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34829. * @param from defines the from key (optional)
  34830. * @param to defines the to key (optional)
  34831. * @returns the current animation group
  34832. */
  34833. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34834. /**
  34835. * Pause all animations
  34836. * @returns the animation group
  34837. */
  34838. pause(): AnimationGroup;
  34839. /**
  34840. * Play all animations to initial state
  34841. * This function will start() the animations if they were not started or will restart() them if they were paused
  34842. * @param loop defines if animations must loop
  34843. * @returns the animation group
  34844. */
  34845. play(loop?: boolean): AnimationGroup;
  34846. /**
  34847. * Reset all animations to initial state
  34848. * @returns the animation group
  34849. */
  34850. reset(): AnimationGroup;
  34851. /**
  34852. * Restart animations from key 0
  34853. * @returns the animation group
  34854. */
  34855. restart(): AnimationGroup;
  34856. /**
  34857. * Stop all animations
  34858. * @returns the animation group
  34859. */
  34860. stop(): AnimationGroup;
  34861. /**
  34862. * Set animation weight for all animatables
  34863. * @param weight defines the weight to use
  34864. * @return the animationGroup
  34865. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34866. */
  34867. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34868. /**
  34869. * Synchronize and normalize all animatables with a source animatable
  34870. * @param root defines the root animatable to synchronize with
  34871. * @return the animationGroup
  34872. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34873. */
  34874. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34875. /**
  34876. * Goes to a specific frame in this animation group
  34877. * @param frame the frame number to go to
  34878. * @return the animationGroup
  34879. */
  34880. goToFrame(frame: number): AnimationGroup;
  34881. /**
  34882. * Dispose all associated resources
  34883. */
  34884. dispose(): void;
  34885. private _checkAnimationGroupEnded;
  34886. /**
  34887. * Clone the current animation group and returns a copy
  34888. * @param newName defines the name of the new group
  34889. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34890. * @returns the new aniamtion group
  34891. */
  34892. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34893. /**
  34894. * Serializes the animationGroup to an object
  34895. * @returns Serialized object
  34896. */
  34897. serialize(): any;
  34898. /**
  34899. * Returns a new AnimationGroup object parsed from the source provided.
  34900. * @param parsedAnimationGroup defines the source
  34901. * @param scene defines the scene that will receive the animationGroup
  34902. * @returns a new AnimationGroup
  34903. */
  34904. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34905. /**
  34906. * Returns the string "AnimationGroup"
  34907. * @returns "AnimationGroup"
  34908. */
  34909. getClassName(): string;
  34910. /**
  34911. * Creates a detailled string about the object
  34912. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34913. * @returns a string representing the object
  34914. */
  34915. toString(fullDetails?: boolean): string;
  34916. }
  34917. }
  34918. declare module BABYLON {
  34919. /**
  34920. * Define an interface for all classes that will hold resources
  34921. */
  34922. export interface IDisposable {
  34923. /**
  34924. * Releases all held resources
  34925. */
  34926. dispose(): void;
  34927. }
  34928. /** Interface defining initialization parameters for Scene class */
  34929. export interface SceneOptions {
  34930. /**
  34931. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34932. * It will improve performance when the number of geometries becomes important.
  34933. */
  34934. useGeometryUniqueIdsMap?: boolean;
  34935. /**
  34936. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34937. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34938. */
  34939. useMaterialMeshMap?: boolean;
  34940. /**
  34941. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34942. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34943. */
  34944. useClonedMeshMap?: boolean;
  34945. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34946. virtual?: boolean;
  34947. }
  34948. /**
  34949. * Represents a scene to be rendered by the engine.
  34950. * @see http://doc.babylonjs.com/features/scene
  34951. */
  34952. export class Scene extends AbstractScene implements IAnimatable {
  34953. /** The fog is deactivated */
  34954. static readonly FOGMODE_NONE: number;
  34955. /** The fog density is following an exponential function */
  34956. static readonly FOGMODE_EXP: number;
  34957. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34958. static readonly FOGMODE_EXP2: number;
  34959. /** The fog density is following a linear function. */
  34960. static readonly FOGMODE_LINEAR: number;
  34961. /**
  34962. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34963. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34964. */
  34965. static MinDeltaTime: number;
  34966. /**
  34967. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34968. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34969. */
  34970. static MaxDeltaTime: number;
  34971. /**
  34972. * Factory used to create the default material.
  34973. * @param name The name of the material to create
  34974. * @param scene The scene to create the material for
  34975. * @returns The default material
  34976. */
  34977. static DefaultMaterialFactory(scene: Scene): Material;
  34978. /**
  34979. * Factory used to create the a collision coordinator.
  34980. * @returns The collision coordinator
  34981. */
  34982. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34983. /** @hidden */
  34984. _inputManager: InputManager;
  34985. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34986. cameraToUseForPointers: Nullable<Camera>;
  34987. /** @hidden */
  34988. readonly _isScene: boolean;
  34989. /**
  34990. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34991. */
  34992. autoClear: boolean;
  34993. /**
  34994. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34995. */
  34996. autoClearDepthAndStencil: boolean;
  34997. /**
  34998. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34999. */
  35000. clearColor: Color4;
  35001. /**
  35002. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35003. */
  35004. ambientColor: Color3;
  35005. /**
  35006. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35007. * It should only be one of the following (if not the default embedded one):
  35008. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35009. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35010. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35011. * The material properties need to be setup according to the type of texture in use.
  35012. */
  35013. environmentBRDFTexture: BaseTexture;
  35014. /** @hidden */
  35015. protected _environmentTexture: Nullable<BaseTexture>;
  35016. /**
  35017. * Texture used in all pbr material as the reflection texture.
  35018. * As in the majority of the scene they are the same (exception for multi room and so on),
  35019. * this is easier to reference from here than from all the materials.
  35020. */
  35021. get environmentTexture(): Nullable<BaseTexture>;
  35022. /**
  35023. * Texture used in all pbr material as the reflection texture.
  35024. * As in the majority of the scene they are the same (exception for multi room and so on),
  35025. * this is easier to set here than in all the materials.
  35026. */
  35027. set environmentTexture(value: Nullable<BaseTexture>);
  35028. /** @hidden */
  35029. protected _environmentIntensity: number;
  35030. /**
  35031. * Intensity of the environment in all pbr material.
  35032. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35033. * As in the majority of the scene they are the same (exception for multi room and so on),
  35034. * this is easier to reference from here than from all the materials.
  35035. */
  35036. get environmentIntensity(): number;
  35037. /**
  35038. * Intensity of the environment in all pbr material.
  35039. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35040. * As in the majority of the scene they are the same (exception for multi room and so on),
  35041. * this is easier to set here than in all the materials.
  35042. */
  35043. set environmentIntensity(value: number);
  35044. /** @hidden */
  35045. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35046. /**
  35047. * Default image processing configuration used either in the rendering
  35048. * Forward main pass or through the imageProcessingPostProcess if present.
  35049. * As in the majority of the scene they are the same (exception for multi camera),
  35050. * this is easier to reference from here than from all the materials and post process.
  35051. *
  35052. * No setter as we it is a shared configuration, you can set the values instead.
  35053. */
  35054. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35055. private _forceWireframe;
  35056. /**
  35057. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35058. */
  35059. set forceWireframe(value: boolean);
  35060. get forceWireframe(): boolean;
  35061. private _skipFrustumClipping;
  35062. /**
  35063. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35064. */
  35065. set skipFrustumClipping(value: boolean);
  35066. get skipFrustumClipping(): boolean;
  35067. private _forcePointsCloud;
  35068. /**
  35069. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35070. */
  35071. set forcePointsCloud(value: boolean);
  35072. get forcePointsCloud(): boolean;
  35073. /**
  35074. * Gets or sets the active clipplane 1
  35075. */
  35076. clipPlane: Nullable<Plane>;
  35077. /**
  35078. * Gets or sets the active clipplane 2
  35079. */
  35080. clipPlane2: Nullable<Plane>;
  35081. /**
  35082. * Gets or sets the active clipplane 3
  35083. */
  35084. clipPlane3: Nullable<Plane>;
  35085. /**
  35086. * Gets or sets the active clipplane 4
  35087. */
  35088. clipPlane4: Nullable<Plane>;
  35089. /**
  35090. * Gets or sets the active clipplane 5
  35091. */
  35092. clipPlane5: Nullable<Plane>;
  35093. /**
  35094. * Gets or sets the active clipplane 6
  35095. */
  35096. clipPlane6: Nullable<Plane>;
  35097. /**
  35098. * Gets or sets a boolean indicating if animations are enabled
  35099. */
  35100. animationsEnabled: boolean;
  35101. private _animationPropertiesOverride;
  35102. /**
  35103. * Gets or sets the animation properties override
  35104. */
  35105. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35106. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35107. /**
  35108. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35109. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35110. */
  35111. useConstantAnimationDeltaTime: boolean;
  35112. /**
  35113. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35114. * Please note that it requires to run a ray cast through the scene on every frame
  35115. */
  35116. constantlyUpdateMeshUnderPointer: boolean;
  35117. /**
  35118. * Defines the HTML cursor to use when hovering over interactive elements
  35119. */
  35120. hoverCursor: string;
  35121. /**
  35122. * Defines the HTML default cursor to use (empty by default)
  35123. */
  35124. defaultCursor: string;
  35125. /**
  35126. * Defines wether cursors are handled by the scene.
  35127. */
  35128. doNotHandleCursors: boolean;
  35129. /**
  35130. * This is used to call preventDefault() on pointer down
  35131. * in order to block unwanted artifacts like system double clicks
  35132. */
  35133. preventDefaultOnPointerDown: boolean;
  35134. /**
  35135. * This is used to call preventDefault() on pointer up
  35136. * in order to block unwanted artifacts like system double clicks
  35137. */
  35138. preventDefaultOnPointerUp: boolean;
  35139. /**
  35140. * Gets or sets user defined metadata
  35141. */
  35142. metadata: any;
  35143. /**
  35144. * For internal use only. Please do not use.
  35145. */
  35146. reservedDataStore: any;
  35147. /**
  35148. * Gets the name of the plugin used to load this scene (null by default)
  35149. */
  35150. loadingPluginName: string;
  35151. /**
  35152. * Use this array to add regular expressions used to disable offline support for specific urls
  35153. */
  35154. disableOfflineSupportExceptionRules: RegExp[];
  35155. /**
  35156. * An event triggered when the scene is disposed.
  35157. */
  35158. onDisposeObservable: Observable<Scene>;
  35159. private _onDisposeObserver;
  35160. /** Sets a function to be executed when this scene is disposed. */
  35161. set onDispose(callback: () => void);
  35162. /**
  35163. * An event triggered before rendering the scene (right after animations and physics)
  35164. */
  35165. onBeforeRenderObservable: Observable<Scene>;
  35166. private _onBeforeRenderObserver;
  35167. /** Sets a function to be executed before rendering this scene */
  35168. set beforeRender(callback: Nullable<() => void>);
  35169. /**
  35170. * An event triggered after rendering the scene
  35171. */
  35172. onAfterRenderObservable: Observable<Scene>;
  35173. /**
  35174. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35175. */
  35176. onAfterRenderCameraObservable: Observable<Camera>;
  35177. private _onAfterRenderObserver;
  35178. /** Sets a function to be executed after rendering this scene */
  35179. set afterRender(callback: Nullable<() => void>);
  35180. /**
  35181. * An event triggered before animating the scene
  35182. */
  35183. onBeforeAnimationsObservable: Observable<Scene>;
  35184. /**
  35185. * An event triggered after animations processing
  35186. */
  35187. onAfterAnimationsObservable: Observable<Scene>;
  35188. /**
  35189. * An event triggered before draw calls are ready to be sent
  35190. */
  35191. onBeforeDrawPhaseObservable: Observable<Scene>;
  35192. /**
  35193. * An event triggered after draw calls have been sent
  35194. */
  35195. onAfterDrawPhaseObservable: Observable<Scene>;
  35196. /**
  35197. * An event triggered when the scene is ready
  35198. */
  35199. onReadyObservable: Observable<Scene>;
  35200. /**
  35201. * An event triggered before rendering a camera
  35202. */
  35203. onBeforeCameraRenderObservable: Observable<Camera>;
  35204. private _onBeforeCameraRenderObserver;
  35205. /** Sets a function to be executed before rendering a camera*/
  35206. set beforeCameraRender(callback: () => void);
  35207. /**
  35208. * An event triggered after rendering a camera
  35209. */
  35210. onAfterCameraRenderObservable: Observable<Camera>;
  35211. private _onAfterCameraRenderObserver;
  35212. /** Sets a function to be executed after rendering a camera*/
  35213. set afterCameraRender(callback: () => void);
  35214. /**
  35215. * An event triggered when active meshes evaluation is about to start
  35216. */
  35217. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35218. /**
  35219. * An event triggered when active meshes evaluation is done
  35220. */
  35221. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35222. /**
  35223. * An event triggered when particles rendering is about to start
  35224. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35225. */
  35226. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35227. /**
  35228. * An event triggered when particles rendering is done
  35229. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35230. */
  35231. onAfterParticlesRenderingObservable: Observable<Scene>;
  35232. /**
  35233. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35234. */
  35235. onDataLoadedObservable: Observable<Scene>;
  35236. /**
  35237. * An event triggered when a camera is created
  35238. */
  35239. onNewCameraAddedObservable: Observable<Camera>;
  35240. /**
  35241. * An event triggered when a camera is removed
  35242. */
  35243. onCameraRemovedObservable: Observable<Camera>;
  35244. /**
  35245. * An event triggered when a light is created
  35246. */
  35247. onNewLightAddedObservable: Observable<Light>;
  35248. /**
  35249. * An event triggered when a light is removed
  35250. */
  35251. onLightRemovedObservable: Observable<Light>;
  35252. /**
  35253. * An event triggered when a geometry is created
  35254. */
  35255. onNewGeometryAddedObservable: Observable<Geometry>;
  35256. /**
  35257. * An event triggered when a geometry is removed
  35258. */
  35259. onGeometryRemovedObservable: Observable<Geometry>;
  35260. /**
  35261. * An event triggered when a transform node is created
  35262. */
  35263. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35264. /**
  35265. * An event triggered when a transform node is removed
  35266. */
  35267. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35268. /**
  35269. * An event triggered when a mesh is created
  35270. */
  35271. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35272. /**
  35273. * An event triggered when a mesh is removed
  35274. */
  35275. onMeshRemovedObservable: Observable<AbstractMesh>;
  35276. /**
  35277. * An event triggered when a skeleton is created
  35278. */
  35279. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35280. /**
  35281. * An event triggered when a skeleton is removed
  35282. */
  35283. onSkeletonRemovedObservable: Observable<Skeleton>;
  35284. /**
  35285. * An event triggered when a material is created
  35286. */
  35287. onNewMaterialAddedObservable: Observable<Material>;
  35288. /**
  35289. * An event triggered when a material is removed
  35290. */
  35291. onMaterialRemovedObservable: Observable<Material>;
  35292. /**
  35293. * An event triggered when a texture is created
  35294. */
  35295. onNewTextureAddedObservable: Observable<BaseTexture>;
  35296. /**
  35297. * An event triggered when a texture is removed
  35298. */
  35299. onTextureRemovedObservable: Observable<BaseTexture>;
  35300. /**
  35301. * An event triggered when render targets are about to be rendered
  35302. * Can happen multiple times per frame.
  35303. */
  35304. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35305. /**
  35306. * An event triggered when render targets were rendered.
  35307. * Can happen multiple times per frame.
  35308. */
  35309. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35310. /**
  35311. * An event triggered before calculating deterministic simulation step
  35312. */
  35313. onBeforeStepObservable: Observable<Scene>;
  35314. /**
  35315. * An event triggered after calculating deterministic simulation step
  35316. */
  35317. onAfterStepObservable: Observable<Scene>;
  35318. /**
  35319. * An event triggered when the activeCamera property is updated
  35320. */
  35321. onActiveCameraChanged: Observable<Scene>;
  35322. /**
  35323. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35324. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35325. * 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)
  35326. */
  35327. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35328. /**
  35329. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35330. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35331. * 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)
  35332. */
  35333. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35334. /**
  35335. * This Observable will when a mesh has been imported into the scene.
  35336. */
  35337. onMeshImportedObservable: Observable<AbstractMesh>;
  35338. /**
  35339. * This Observable will when an animation file has been imported into the scene.
  35340. */
  35341. onAnimationFileImportedObservable: Observable<Scene>;
  35342. /**
  35343. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35344. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35345. */
  35346. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35347. /** @hidden */
  35348. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35349. /**
  35350. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35351. */
  35352. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35353. /**
  35354. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35355. */
  35356. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35357. /**
  35358. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35359. */
  35360. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35361. /** Callback called when a pointer move is detected */
  35362. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35363. /** Callback called when a pointer down is detected */
  35364. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35365. /** Callback called when a pointer up is detected */
  35366. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35367. /** Callback called when a pointer pick is detected */
  35368. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35369. /**
  35370. * 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).
  35371. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35372. */
  35373. onPrePointerObservable: Observable<PointerInfoPre>;
  35374. /**
  35375. * Observable event triggered each time an input event is received from the rendering canvas
  35376. */
  35377. onPointerObservable: Observable<PointerInfo>;
  35378. /**
  35379. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35380. */
  35381. get unTranslatedPointer(): Vector2;
  35382. /**
  35383. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35384. */
  35385. static get DragMovementThreshold(): number;
  35386. static set DragMovementThreshold(value: number);
  35387. /**
  35388. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35389. */
  35390. static get LongPressDelay(): number;
  35391. static set LongPressDelay(value: number);
  35392. /**
  35393. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35394. */
  35395. static get DoubleClickDelay(): number;
  35396. static set DoubleClickDelay(value: number);
  35397. /** If you need to check double click without raising a single click at first click, enable this flag */
  35398. static get ExclusiveDoubleClickMode(): boolean;
  35399. static set ExclusiveDoubleClickMode(value: boolean);
  35400. /** @hidden */
  35401. _mirroredCameraPosition: Nullable<Vector3>;
  35402. /**
  35403. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35404. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35405. */
  35406. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35407. /**
  35408. * Observable event triggered each time an keyboard event is received from the hosting window
  35409. */
  35410. onKeyboardObservable: Observable<KeyboardInfo>;
  35411. private _useRightHandedSystem;
  35412. /**
  35413. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35414. */
  35415. set useRightHandedSystem(value: boolean);
  35416. get useRightHandedSystem(): boolean;
  35417. private _timeAccumulator;
  35418. private _currentStepId;
  35419. private _currentInternalStep;
  35420. /**
  35421. * Sets the step Id used by deterministic lock step
  35422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35423. * @param newStepId defines the step Id
  35424. */
  35425. setStepId(newStepId: number): void;
  35426. /**
  35427. * Gets the step Id used by deterministic lock step
  35428. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35429. * @returns the step Id
  35430. */
  35431. getStepId(): number;
  35432. /**
  35433. * Gets the internal step used by deterministic lock step
  35434. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35435. * @returns the internal step
  35436. */
  35437. getInternalStep(): number;
  35438. private _fogEnabled;
  35439. /**
  35440. * Gets or sets a boolean indicating if fog is enabled on this scene
  35441. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35442. * (Default is true)
  35443. */
  35444. set fogEnabled(value: boolean);
  35445. get fogEnabled(): boolean;
  35446. private _fogMode;
  35447. /**
  35448. * Gets or sets the fog mode to use
  35449. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35450. * | mode | value |
  35451. * | --- | --- |
  35452. * | FOGMODE_NONE | 0 |
  35453. * | FOGMODE_EXP | 1 |
  35454. * | FOGMODE_EXP2 | 2 |
  35455. * | FOGMODE_LINEAR | 3 |
  35456. */
  35457. set fogMode(value: number);
  35458. get fogMode(): number;
  35459. /**
  35460. * Gets or sets the fog color to use
  35461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35462. * (Default is Color3(0.2, 0.2, 0.3))
  35463. */
  35464. fogColor: Color3;
  35465. /**
  35466. * Gets or sets the fog density to use
  35467. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35468. * (Default is 0.1)
  35469. */
  35470. fogDensity: number;
  35471. /**
  35472. * Gets or sets the fog start distance to use
  35473. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35474. * (Default is 0)
  35475. */
  35476. fogStart: number;
  35477. /**
  35478. * Gets or sets the fog end distance to use
  35479. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35480. * (Default is 1000)
  35481. */
  35482. fogEnd: number;
  35483. private _shadowsEnabled;
  35484. /**
  35485. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35486. */
  35487. set shadowsEnabled(value: boolean);
  35488. get shadowsEnabled(): boolean;
  35489. private _lightsEnabled;
  35490. /**
  35491. * Gets or sets a boolean indicating if lights are enabled on this scene
  35492. */
  35493. set lightsEnabled(value: boolean);
  35494. get lightsEnabled(): boolean;
  35495. /** All of the active cameras added to this scene. */
  35496. activeCameras: Camera[];
  35497. /** @hidden */
  35498. _activeCamera: Nullable<Camera>;
  35499. /** Gets or sets the current active camera */
  35500. get activeCamera(): Nullable<Camera>;
  35501. set activeCamera(value: Nullable<Camera>);
  35502. private _defaultMaterial;
  35503. /** The default material used on meshes when no material is affected */
  35504. get defaultMaterial(): Material;
  35505. /** The default material used on meshes when no material is affected */
  35506. set defaultMaterial(value: Material);
  35507. private _texturesEnabled;
  35508. /**
  35509. * Gets or sets a boolean indicating if textures are enabled on this scene
  35510. */
  35511. set texturesEnabled(value: boolean);
  35512. get texturesEnabled(): boolean;
  35513. /**
  35514. * Gets or sets a boolean indicating if particles are enabled on this scene
  35515. */
  35516. particlesEnabled: boolean;
  35517. /**
  35518. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35519. */
  35520. spritesEnabled: boolean;
  35521. private _skeletonsEnabled;
  35522. /**
  35523. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35524. */
  35525. set skeletonsEnabled(value: boolean);
  35526. get skeletonsEnabled(): boolean;
  35527. /**
  35528. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35529. */
  35530. lensFlaresEnabled: boolean;
  35531. /**
  35532. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35533. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35534. */
  35535. collisionsEnabled: boolean;
  35536. private _collisionCoordinator;
  35537. /** @hidden */
  35538. get collisionCoordinator(): ICollisionCoordinator;
  35539. /**
  35540. * Defines the gravity applied to this scene (used only for collisions)
  35541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35542. */
  35543. gravity: Vector3;
  35544. /**
  35545. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35546. */
  35547. postProcessesEnabled: boolean;
  35548. /**
  35549. * The list of postprocesses added to the scene
  35550. */
  35551. postProcesses: PostProcess[];
  35552. /**
  35553. * Gets the current postprocess manager
  35554. */
  35555. postProcessManager: PostProcessManager;
  35556. /**
  35557. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35558. */
  35559. renderTargetsEnabled: boolean;
  35560. /**
  35561. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35562. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35563. */
  35564. dumpNextRenderTargets: boolean;
  35565. /**
  35566. * The list of user defined render targets added to the scene
  35567. */
  35568. customRenderTargets: RenderTargetTexture[];
  35569. /**
  35570. * Defines if texture loading must be delayed
  35571. * If true, textures will only be loaded when they need to be rendered
  35572. */
  35573. useDelayedTextureLoading: boolean;
  35574. /**
  35575. * Gets the list of meshes imported to the scene through SceneLoader
  35576. */
  35577. importedMeshesFiles: String[];
  35578. /**
  35579. * Gets or sets a boolean indicating if probes are enabled on this scene
  35580. */
  35581. probesEnabled: boolean;
  35582. /**
  35583. * Gets or sets the current offline provider to use to store scene data
  35584. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35585. */
  35586. offlineProvider: IOfflineProvider;
  35587. /**
  35588. * Gets or sets the action manager associated with the scene
  35589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35590. */
  35591. actionManager: AbstractActionManager;
  35592. private _meshesForIntersections;
  35593. /**
  35594. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35595. */
  35596. proceduralTexturesEnabled: boolean;
  35597. private _engine;
  35598. private _totalVertices;
  35599. /** @hidden */
  35600. _activeIndices: PerfCounter;
  35601. /** @hidden */
  35602. _activeParticles: PerfCounter;
  35603. /** @hidden */
  35604. _activeBones: PerfCounter;
  35605. private _animationRatio;
  35606. /** @hidden */
  35607. _animationTimeLast: number;
  35608. /** @hidden */
  35609. _animationTime: number;
  35610. /**
  35611. * Gets or sets a general scale for animation speed
  35612. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35613. */
  35614. animationTimeScale: number;
  35615. /** @hidden */
  35616. _cachedMaterial: Nullable<Material>;
  35617. /** @hidden */
  35618. _cachedEffect: Nullable<Effect>;
  35619. /** @hidden */
  35620. _cachedVisibility: Nullable<number>;
  35621. private _renderId;
  35622. private _frameId;
  35623. private _executeWhenReadyTimeoutId;
  35624. private _intermediateRendering;
  35625. private _viewUpdateFlag;
  35626. private _projectionUpdateFlag;
  35627. /** @hidden */
  35628. _toBeDisposed: Nullable<IDisposable>[];
  35629. private _activeRequests;
  35630. /** @hidden */
  35631. _pendingData: any[];
  35632. private _isDisposed;
  35633. /**
  35634. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35635. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35636. */
  35637. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35638. private _activeMeshes;
  35639. private _processedMaterials;
  35640. private _renderTargets;
  35641. /** @hidden */
  35642. _activeParticleSystems: SmartArray<IParticleSystem>;
  35643. private _activeSkeletons;
  35644. private _softwareSkinnedMeshes;
  35645. private _renderingManager;
  35646. /** @hidden */
  35647. _activeAnimatables: Animatable[];
  35648. private _transformMatrix;
  35649. private _sceneUbo;
  35650. /** @hidden */
  35651. _viewMatrix: Matrix;
  35652. private _projectionMatrix;
  35653. /** @hidden */
  35654. _forcedViewPosition: Nullable<Vector3>;
  35655. /** @hidden */
  35656. _frustumPlanes: Plane[];
  35657. /**
  35658. * Gets the list of frustum planes (built from the active camera)
  35659. */
  35660. get frustumPlanes(): Plane[];
  35661. /**
  35662. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35663. * This is useful if there are more lights that the maximum simulteanous authorized
  35664. */
  35665. requireLightSorting: boolean;
  35666. /** @hidden */
  35667. readonly useMaterialMeshMap: boolean;
  35668. /** @hidden */
  35669. readonly useClonedMeshMap: boolean;
  35670. private _externalData;
  35671. private _uid;
  35672. /**
  35673. * @hidden
  35674. * Backing store of defined scene components.
  35675. */
  35676. _components: ISceneComponent[];
  35677. /**
  35678. * @hidden
  35679. * Backing store of defined scene components.
  35680. */
  35681. _serializableComponents: ISceneSerializableComponent[];
  35682. /**
  35683. * List of components to register on the next registration step.
  35684. */
  35685. private _transientComponents;
  35686. /**
  35687. * Registers the transient components if needed.
  35688. */
  35689. private _registerTransientComponents;
  35690. /**
  35691. * @hidden
  35692. * Add a component to the scene.
  35693. * Note that the ccomponent could be registered on th next frame if this is called after
  35694. * the register component stage.
  35695. * @param component Defines the component to add to the scene
  35696. */
  35697. _addComponent(component: ISceneComponent): void;
  35698. /**
  35699. * @hidden
  35700. * Gets a component from the scene.
  35701. * @param name defines the name of the component to retrieve
  35702. * @returns the component or null if not present
  35703. */
  35704. _getComponent(name: string): Nullable<ISceneComponent>;
  35705. /**
  35706. * @hidden
  35707. * Defines the actions happening before camera updates.
  35708. */
  35709. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35710. /**
  35711. * @hidden
  35712. * Defines the actions happening before clear the canvas.
  35713. */
  35714. _beforeClearStage: Stage<SimpleStageAction>;
  35715. /**
  35716. * @hidden
  35717. * Defines the actions when collecting render targets for the frame.
  35718. */
  35719. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35720. /**
  35721. * @hidden
  35722. * Defines the actions happening for one camera in the frame.
  35723. */
  35724. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35725. /**
  35726. * @hidden
  35727. * Defines the actions happening during the per mesh ready checks.
  35728. */
  35729. _isReadyForMeshStage: Stage<MeshStageAction>;
  35730. /**
  35731. * @hidden
  35732. * Defines the actions happening before evaluate active mesh checks.
  35733. */
  35734. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35735. /**
  35736. * @hidden
  35737. * Defines the actions happening during the evaluate sub mesh checks.
  35738. */
  35739. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35740. /**
  35741. * @hidden
  35742. * Defines the actions happening during the active mesh stage.
  35743. */
  35744. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35745. /**
  35746. * @hidden
  35747. * Defines the actions happening during the per camera render target step.
  35748. */
  35749. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35750. /**
  35751. * @hidden
  35752. * Defines the actions happening just before the active camera is drawing.
  35753. */
  35754. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35755. /**
  35756. * @hidden
  35757. * Defines the actions happening just before a render target is drawing.
  35758. */
  35759. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35760. /**
  35761. * @hidden
  35762. * Defines the actions happening just before a rendering group is drawing.
  35763. */
  35764. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35765. /**
  35766. * @hidden
  35767. * Defines the actions happening just before a mesh is drawing.
  35768. */
  35769. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35770. /**
  35771. * @hidden
  35772. * Defines the actions happening just after a mesh has been drawn.
  35773. */
  35774. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35775. /**
  35776. * @hidden
  35777. * Defines the actions happening just after a rendering group has been drawn.
  35778. */
  35779. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35780. /**
  35781. * @hidden
  35782. * Defines the actions happening just after the active camera has been drawn.
  35783. */
  35784. _afterCameraDrawStage: Stage<CameraStageAction>;
  35785. /**
  35786. * @hidden
  35787. * Defines the actions happening just after a render target has been drawn.
  35788. */
  35789. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35790. /**
  35791. * @hidden
  35792. * Defines the actions happening just after rendering all cameras and computing intersections.
  35793. */
  35794. _afterRenderStage: Stage<SimpleStageAction>;
  35795. /**
  35796. * @hidden
  35797. * Defines the actions happening when a pointer move event happens.
  35798. */
  35799. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35800. /**
  35801. * @hidden
  35802. * Defines the actions happening when a pointer down event happens.
  35803. */
  35804. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35805. /**
  35806. * @hidden
  35807. * Defines the actions happening when a pointer up event happens.
  35808. */
  35809. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35810. /**
  35811. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35812. */
  35813. private geometriesByUniqueId;
  35814. /**
  35815. * Creates a new Scene
  35816. * @param engine defines the engine to use to render this scene
  35817. * @param options defines the scene options
  35818. */
  35819. constructor(engine: Engine, options?: SceneOptions);
  35820. /**
  35821. * Gets a string idenfifying the name of the class
  35822. * @returns "Scene" string
  35823. */
  35824. getClassName(): string;
  35825. private _defaultMeshCandidates;
  35826. /**
  35827. * @hidden
  35828. */
  35829. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35830. private _defaultSubMeshCandidates;
  35831. /**
  35832. * @hidden
  35833. */
  35834. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35835. /**
  35836. * Sets the default candidate providers for the scene.
  35837. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35838. * and getCollidingSubMeshCandidates to their default function
  35839. */
  35840. setDefaultCandidateProviders(): void;
  35841. /**
  35842. * Gets the mesh that is currently under the pointer
  35843. */
  35844. get meshUnderPointer(): Nullable<AbstractMesh>;
  35845. /**
  35846. * Gets or sets the current on-screen X position of the pointer
  35847. */
  35848. get pointerX(): number;
  35849. set pointerX(value: number);
  35850. /**
  35851. * Gets or sets the current on-screen Y position of the pointer
  35852. */
  35853. get pointerY(): number;
  35854. set pointerY(value: number);
  35855. /**
  35856. * Gets the cached material (ie. the latest rendered one)
  35857. * @returns the cached material
  35858. */
  35859. getCachedMaterial(): Nullable<Material>;
  35860. /**
  35861. * Gets the cached effect (ie. the latest rendered one)
  35862. * @returns the cached effect
  35863. */
  35864. getCachedEffect(): Nullable<Effect>;
  35865. /**
  35866. * Gets the cached visibility state (ie. the latest rendered one)
  35867. * @returns the cached visibility state
  35868. */
  35869. getCachedVisibility(): Nullable<number>;
  35870. /**
  35871. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35872. * @param material defines the current material
  35873. * @param effect defines the current effect
  35874. * @param visibility defines the current visibility state
  35875. * @returns true if one parameter is not cached
  35876. */
  35877. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35878. /**
  35879. * Gets the engine associated with the scene
  35880. * @returns an Engine
  35881. */
  35882. getEngine(): Engine;
  35883. /**
  35884. * Gets the total number of vertices rendered per frame
  35885. * @returns the total number of vertices rendered per frame
  35886. */
  35887. getTotalVertices(): number;
  35888. /**
  35889. * Gets the performance counter for total vertices
  35890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35891. */
  35892. get totalVerticesPerfCounter(): PerfCounter;
  35893. /**
  35894. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35895. * @returns the total number of active indices rendered per frame
  35896. */
  35897. getActiveIndices(): number;
  35898. /**
  35899. * Gets the performance counter for active indices
  35900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35901. */
  35902. get totalActiveIndicesPerfCounter(): PerfCounter;
  35903. /**
  35904. * Gets the total number of active particles rendered per frame
  35905. * @returns the total number of active particles rendered per frame
  35906. */
  35907. getActiveParticles(): number;
  35908. /**
  35909. * Gets the performance counter for active particles
  35910. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35911. */
  35912. get activeParticlesPerfCounter(): PerfCounter;
  35913. /**
  35914. * Gets the total number of active bones rendered per frame
  35915. * @returns the total number of active bones rendered per frame
  35916. */
  35917. getActiveBones(): number;
  35918. /**
  35919. * Gets the performance counter for active bones
  35920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35921. */
  35922. get activeBonesPerfCounter(): PerfCounter;
  35923. /**
  35924. * Gets the array of active meshes
  35925. * @returns an array of AbstractMesh
  35926. */
  35927. getActiveMeshes(): SmartArray<AbstractMesh>;
  35928. /**
  35929. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35930. * @returns a number
  35931. */
  35932. getAnimationRatio(): number;
  35933. /**
  35934. * Gets an unique Id for the current render phase
  35935. * @returns a number
  35936. */
  35937. getRenderId(): number;
  35938. /**
  35939. * Gets an unique Id for the current frame
  35940. * @returns a number
  35941. */
  35942. getFrameId(): number;
  35943. /** Call this function if you want to manually increment the render Id*/
  35944. incrementRenderId(): void;
  35945. private _createUbo;
  35946. /**
  35947. * Use this method to simulate a pointer move on a mesh
  35948. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35949. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35950. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35951. * @returns the current scene
  35952. */
  35953. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35954. /**
  35955. * Use this method to simulate a pointer down on a mesh
  35956. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35957. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35958. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35959. * @returns the current scene
  35960. */
  35961. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35962. /**
  35963. * Use this method to simulate a pointer up on a mesh
  35964. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35965. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35966. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35967. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35968. * @returns the current scene
  35969. */
  35970. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35971. /**
  35972. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35973. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35974. * @returns true if the pointer was captured
  35975. */
  35976. isPointerCaptured(pointerId?: number): boolean;
  35977. /**
  35978. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35979. * @param attachUp defines if you want to attach events to pointerup
  35980. * @param attachDown defines if you want to attach events to pointerdown
  35981. * @param attachMove defines if you want to attach events to pointermove
  35982. */
  35983. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35984. /** Detaches all event handlers*/
  35985. detachControl(): void;
  35986. /**
  35987. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35988. * Delay loaded resources are not taking in account
  35989. * @return true if all required resources are ready
  35990. */
  35991. isReady(): boolean;
  35992. /** Resets all cached information relative to material (including effect and visibility) */
  35993. resetCachedMaterial(): void;
  35994. /**
  35995. * Registers a function to be called before every frame render
  35996. * @param func defines the function to register
  35997. */
  35998. registerBeforeRender(func: () => void): void;
  35999. /**
  36000. * Unregisters a function called before every frame render
  36001. * @param func defines the function to unregister
  36002. */
  36003. unregisterBeforeRender(func: () => void): void;
  36004. /**
  36005. * Registers a function to be called after every frame render
  36006. * @param func defines the function to register
  36007. */
  36008. registerAfterRender(func: () => void): void;
  36009. /**
  36010. * Unregisters a function called after every frame render
  36011. * @param func defines the function to unregister
  36012. */
  36013. unregisterAfterRender(func: () => void): void;
  36014. private _executeOnceBeforeRender;
  36015. /**
  36016. * The provided function will run before render once and will be disposed afterwards.
  36017. * A timeout delay can be provided so that the function will be executed in N ms.
  36018. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36019. * @param func The function to be executed.
  36020. * @param timeout optional delay in ms
  36021. */
  36022. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36023. /** @hidden */
  36024. _addPendingData(data: any): void;
  36025. /** @hidden */
  36026. _removePendingData(data: any): void;
  36027. /**
  36028. * Returns the number of items waiting to be loaded
  36029. * @returns the number of items waiting to be loaded
  36030. */
  36031. getWaitingItemsCount(): number;
  36032. /**
  36033. * Returns a boolean indicating if the scene is still loading data
  36034. */
  36035. get isLoading(): boolean;
  36036. /**
  36037. * Registers a function to be executed when the scene is ready
  36038. * @param {Function} func - the function to be executed
  36039. */
  36040. executeWhenReady(func: () => void): void;
  36041. /**
  36042. * Returns a promise that resolves when the scene is ready
  36043. * @returns A promise that resolves when the scene is ready
  36044. */
  36045. whenReadyAsync(): Promise<void>;
  36046. /** @hidden */
  36047. _checkIsReady(): void;
  36048. /**
  36049. * Gets all animatable attached to the scene
  36050. */
  36051. get animatables(): Animatable[];
  36052. /**
  36053. * Resets the last animation time frame.
  36054. * Useful to override when animations start running when loading a scene for the first time.
  36055. */
  36056. resetLastAnimationTimeFrame(): void;
  36057. /**
  36058. * Gets the current view matrix
  36059. * @returns a Matrix
  36060. */
  36061. getViewMatrix(): Matrix;
  36062. /**
  36063. * Gets the current projection matrix
  36064. * @returns a Matrix
  36065. */
  36066. getProjectionMatrix(): Matrix;
  36067. /**
  36068. * Gets the current transform matrix
  36069. * @returns a Matrix made of View * Projection
  36070. */
  36071. getTransformMatrix(): Matrix;
  36072. /**
  36073. * Sets the current transform matrix
  36074. * @param viewL defines the View matrix to use
  36075. * @param projectionL defines the Projection matrix to use
  36076. * @param viewR defines the right View matrix to use (if provided)
  36077. * @param projectionR defines the right Projection matrix to use (if provided)
  36078. */
  36079. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36080. /**
  36081. * Gets the uniform buffer used to store scene data
  36082. * @returns a UniformBuffer
  36083. */
  36084. getSceneUniformBuffer(): UniformBuffer;
  36085. /**
  36086. * Gets an unique (relatively to the current scene) Id
  36087. * @returns an unique number for the scene
  36088. */
  36089. getUniqueId(): number;
  36090. /**
  36091. * Add a mesh to the list of scene's meshes
  36092. * @param newMesh defines the mesh to add
  36093. * @param recursive if all child meshes should also be added to the scene
  36094. */
  36095. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36096. /**
  36097. * Remove a mesh for the list of scene's meshes
  36098. * @param toRemove defines the mesh to remove
  36099. * @param recursive if all child meshes should also be removed from the scene
  36100. * @returns the index where the mesh was in the mesh list
  36101. */
  36102. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36103. /**
  36104. * Add a transform node to the list of scene's transform nodes
  36105. * @param newTransformNode defines the transform node to add
  36106. */
  36107. addTransformNode(newTransformNode: TransformNode): void;
  36108. /**
  36109. * Remove a transform node for the list of scene's transform nodes
  36110. * @param toRemove defines the transform node to remove
  36111. * @returns the index where the transform node was in the transform node list
  36112. */
  36113. removeTransformNode(toRemove: TransformNode): number;
  36114. /**
  36115. * Remove a skeleton for the list of scene's skeletons
  36116. * @param toRemove defines the skeleton to remove
  36117. * @returns the index where the skeleton was in the skeleton list
  36118. */
  36119. removeSkeleton(toRemove: Skeleton): number;
  36120. /**
  36121. * Remove a morph target for the list of scene's morph targets
  36122. * @param toRemove defines the morph target to remove
  36123. * @returns the index where the morph target was in the morph target list
  36124. */
  36125. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36126. /**
  36127. * Remove a light for the list of scene's lights
  36128. * @param toRemove defines the light to remove
  36129. * @returns the index where the light was in the light list
  36130. */
  36131. removeLight(toRemove: Light): number;
  36132. /**
  36133. * Remove a camera for the list of scene's cameras
  36134. * @param toRemove defines the camera to remove
  36135. * @returns the index where the camera was in the camera list
  36136. */
  36137. removeCamera(toRemove: Camera): number;
  36138. /**
  36139. * Remove a particle system for the list of scene's particle systems
  36140. * @param toRemove defines the particle system to remove
  36141. * @returns the index where the particle system was in the particle system list
  36142. */
  36143. removeParticleSystem(toRemove: IParticleSystem): number;
  36144. /**
  36145. * Remove a animation for the list of scene's animations
  36146. * @param toRemove defines the animation to remove
  36147. * @returns the index where the animation was in the animation list
  36148. */
  36149. removeAnimation(toRemove: Animation): number;
  36150. /**
  36151. * Will stop the animation of the given target
  36152. * @param target - the target
  36153. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36154. * @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)
  36155. */
  36156. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36157. /**
  36158. * Removes the given animation group from this scene.
  36159. * @param toRemove The animation group to remove
  36160. * @returns The index of the removed animation group
  36161. */
  36162. removeAnimationGroup(toRemove: AnimationGroup): number;
  36163. /**
  36164. * Removes the given multi-material from this scene.
  36165. * @param toRemove The multi-material to remove
  36166. * @returns The index of the removed multi-material
  36167. */
  36168. removeMultiMaterial(toRemove: MultiMaterial): number;
  36169. /**
  36170. * Removes the given material from this scene.
  36171. * @param toRemove The material to remove
  36172. * @returns The index of the removed material
  36173. */
  36174. removeMaterial(toRemove: Material): number;
  36175. /**
  36176. * Removes the given action manager from this scene.
  36177. * @param toRemove The action manager to remove
  36178. * @returns The index of the removed action manager
  36179. */
  36180. removeActionManager(toRemove: AbstractActionManager): number;
  36181. /**
  36182. * Removes the given texture from this scene.
  36183. * @param toRemove The texture to remove
  36184. * @returns The index of the removed texture
  36185. */
  36186. removeTexture(toRemove: BaseTexture): number;
  36187. /**
  36188. * Adds the given light to this scene
  36189. * @param newLight The light to add
  36190. */
  36191. addLight(newLight: Light): void;
  36192. /**
  36193. * Sorts the list list based on light priorities
  36194. */
  36195. sortLightsByPriority(): void;
  36196. /**
  36197. * Adds the given camera to this scene
  36198. * @param newCamera The camera to add
  36199. */
  36200. addCamera(newCamera: Camera): void;
  36201. /**
  36202. * Adds the given skeleton to this scene
  36203. * @param newSkeleton The skeleton to add
  36204. */
  36205. addSkeleton(newSkeleton: Skeleton): void;
  36206. /**
  36207. * Adds the given particle system to this scene
  36208. * @param newParticleSystem The particle system to add
  36209. */
  36210. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36211. /**
  36212. * Adds the given animation to this scene
  36213. * @param newAnimation The animation to add
  36214. */
  36215. addAnimation(newAnimation: Animation): void;
  36216. /**
  36217. * Adds the given animation group to this scene.
  36218. * @param newAnimationGroup The animation group to add
  36219. */
  36220. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36221. /**
  36222. * Adds the given multi-material to this scene
  36223. * @param newMultiMaterial The multi-material to add
  36224. */
  36225. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36226. /**
  36227. * Adds the given material to this scene
  36228. * @param newMaterial The material to add
  36229. */
  36230. addMaterial(newMaterial: Material): void;
  36231. /**
  36232. * Adds the given morph target to this scene
  36233. * @param newMorphTargetManager The morph target to add
  36234. */
  36235. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36236. /**
  36237. * Adds the given geometry to this scene
  36238. * @param newGeometry The geometry to add
  36239. */
  36240. addGeometry(newGeometry: Geometry): void;
  36241. /**
  36242. * Adds the given action manager to this scene
  36243. * @param newActionManager The action manager to add
  36244. */
  36245. addActionManager(newActionManager: AbstractActionManager): void;
  36246. /**
  36247. * Adds the given texture to this scene.
  36248. * @param newTexture The texture to add
  36249. */
  36250. addTexture(newTexture: BaseTexture): void;
  36251. /**
  36252. * Switch active camera
  36253. * @param newCamera defines the new active camera
  36254. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36255. */
  36256. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36257. /**
  36258. * sets the active camera of the scene using its ID
  36259. * @param id defines the camera's ID
  36260. * @return the new active camera or null if none found.
  36261. */
  36262. setActiveCameraByID(id: string): Nullable<Camera>;
  36263. /**
  36264. * sets the active camera of the scene using its name
  36265. * @param name defines the camera's name
  36266. * @returns the new active camera or null if none found.
  36267. */
  36268. setActiveCameraByName(name: string): Nullable<Camera>;
  36269. /**
  36270. * get an animation group using its name
  36271. * @param name defines the material's name
  36272. * @return the animation group or null if none found.
  36273. */
  36274. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36275. /**
  36276. * Get a material using its unique id
  36277. * @param uniqueId defines the material's unique id
  36278. * @return the material or null if none found.
  36279. */
  36280. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36281. /**
  36282. * get a material using its id
  36283. * @param id defines the material's ID
  36284. * @return the material or null if none found.
  36285. */
  36286. getMaterialByID(id: string): Nullable<Material>;
  36287. /**
  36288. * Gets a the last added material using a given id
  36289. * @param id defines the material's ID
  36290. * @return the last material with the given id or null if none found.
  36291. */
  36292. getLastMaterialByID(id: string): Nullable<Material>;
  36293. /**
  36294. * Gets a material using its name
  36295. * @param name defines the material's name
  36296. * @return the material or null if none found.
  36297. */
  36298. getMaterialByName(name: string): Nullable<Material>;
  36299. /**
  36300. * Get a texture using its unique id
  36301. * @param uniqueId defines the texture's unique id
  36302. * @return the texture or null if none found.
  36303. */
  36304. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36305. /**
  36306. * Gets a camera using its id
  36307. * @param id defines the id to look for
  36308. * @returns the camera or null if not found
  36309. */
  36310. getCameraByID(id: string): Nullable<Camera>;
  36311. /**
  36312. * Gets a camera using its unique id
  36313. * @param uniqueId defines the unique id to look for
  36314. * @returns the camera or null if not found
  36315. */
  36316. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36317. /**
  36318. * Gets a camera using its name
  36319. * @param name defines the camera's name
  36320. * @return the camera or null if none found.
  36321. */
  36322. getCameraByName(name: string): Nullable<Camera>;
  36323. /**
  36324. * Gets a bone using its id
  36325. * @param id defines the bone's id
  36326. * @return the bone or null if not found
  36327. */
  36328. getBoneByID(id: string): Nullable<Bone>;
  36329. /**
  36330. * Gets a bone using its id
  36331. * @param name defines the bone's name
  36332. * @return the bone or null if not found
  36333. */
  36334. getBoneByName(name: string): Nullable<Bone>;
  36335. /**
  36336. * Gets a light node using its name
  36337. * @param name defines the the light's name
  36338. * @return the light or null if none found.
  36339. */
  36340. getLightByName(name: string): Nullable<Light>;
  36341. /**
  36342. * Gets a light node using its id
  36343. * @param id defines the light's id
  36344. * @return the light or null if none found.
  36345. */
  36346. getLightByID(id: string): Nullable<Light>;
  36347. /**
  36348. * Gets a light node using its scene-generated unique ID
  36349. * @param uniqueId defines the light's unique id
  36350. * @return the light or null if none found.
  36351. */
  36352. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36353. /**
  36354. * Gets a particle system by id
  36355. * @param id defines the particle system id
  36356. * @return the corresponding system or null if none found
  36357. */
  36358. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36359. /**
  36360. * Gets a geometry using its ID
  36361. * @param id defines the geometry's id
  36362. * @return the geometry or null if none found.
  36363. */
  36364. getGeometryByID(id: string): Nullable<Geometry>;
  36365. private _getGeometryByUniqueID;
  36366. /**
  36367. * Add a new geometry to this scene
  36368. * @param geometry defines the geometry to be added to the scene.
  36369. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36370. * @return a boolean defining if the geometry was added or not
  36371. */
  36372. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36373. /**
  36374. * Removes an existing geometry
  36375. * @param geometry defines the geometry to be removed from the scene
  36376. * @return a boolean defining if the geometry was removed or not
  36377. */
  36378. removeGeometry(geometry: Geometry): boolean;
  36379. /**
  36380. * Gets the list of geometries attached to the scene
  36381. * @returns an array of Geometry
  36382. */
  36383. getGeometries(): Geometry[];
  36384. /**
  36385. * Gets the first added mesh found of a given ID
  36386. * @param id defines the id to search for
  36387. * @return the mesh found or null if not found at all
  36388. */
  36389. getMeshByID(id: string): Nullable<AbstractMesh>;
  36390. /**
  36391. * Gets a list of meshes using their id
  36392. * @param id defines the id to search for
  36393. * @returns a list of meshes
  36394. */
  36395. getMeshesByID(id: string): Array<AbstractMesh>;
  36396. /**
  36397. * Gets the first added transform node found of a given ID
  36398. * @param id defines the id to search for
  36399. * @return the found transform node or null if not found at all.
  36400. */
  36401. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36402. /**
  36403. * Gets a transform node with its auto-generated unique id
  36404. * @param uniqueId efines the unique id to search for
  36405. * @return the found transform node or null if not found at all.
  36406. */
  36407. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36408. /**
  36409. * Gets a list of transform nodes using their id
  36410. * @param id defines the id to search for
  36411. * @returns a list of transform nodes
  36412. */
  36413. getTransformNodesByID(id: string): Array<TransformNode>;
  36414. /**
  36415. * Gets a mesh with its auto-generated unique id
  36416. * @param uniqueId defines the unique id to search for
  36417. * @return the found mesh or null if not found at all.
  36418. */
  36419. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36420. /**
  36421. * Gets a the last added mesh using a given id
  36422. * @param id defines the id to search for
  36423. * @return the found mesh or null if not found at all.
  36424. */
  36425. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36426. /**
  36427. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36428. * @param id defines the id to search for
  36429. * @return the found node or null if not found at all
  36430. */
  36431. getLastEntryByID(id: string): Nullable<Node>;
  36432. /**
  36433. * Gets a node (Mesh, Camera, Light) using a given id
  36434. * @param id defines the id to search for
  36435. * @return the found node or null if not found at all
  36436. */
  36437. getNodeByID(id: string): Nullable<Node>;
  36438. /**
  36439. * Gets a node (Mesh, Camera, Light) using a given name
  36440. * @param name defines the name to search for
  36441. * @return the found node or null if not found at all.
  36442. */
  36443. getNodeByName(name: string): Nullable<Node>;
  36444. /**
  36445. * Gets a mesh using a given name
  36446. * @param name defines the name to search for
  36447. * @return the found mesh or null if not found at all.
  36448. */
  36449. getMeshByName(name: string): Nullable<AbstractMesh>;
  36450. /**
  36451. * Gets a transform node using a given name
  36452. * @param name defines the name to search for
  36453. * @return the found transform node or null if not found at all.
  36454. */
  36455. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36456. /**
  36457. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36458. * @param id defines the id to search for
  36459. * @return the found skeleton or null if not found at all.
  36460. */
  36461. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36462. /**
  36463. * Gets a skeleton using a given auto generated unique id
  36464. * @param uniqueId defines the unique id to search for
  36465. * @return the found skeleton or null if not found at all.
  36466. */
  36467. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36468. /**
  36469. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36470. * @param id defines the id to search for
  36471. * @return the found skeleton or null if not found at all.
  36472. */
  36473. getSkeletonById(id: string): Nullable<Skeleton>;
  36474. /**
  36475. * Gets a skeleton using a given name
  36476. * @param name defines the name to search for
  36477. * @return the found skeleton or null if not found at all.
  36478. */
  36479. getSkeletonByName(name: string): Nullable<Skeleton>;
  36480. /**
  36481. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36482. * @param id defines the id to search for
  36483. * @return the found morph target manager or null if not found at all.
  36484. */
  36485. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36486. /**
  36487. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36488. * @param id defines the id to search for
  36489. * @return the found morph target or null if not found at all.
  36490. */
  36491. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36492. /**
  36493. * Gets a boolean indicating if the given mesh is active
  36494. * @param mesh defines the mesh to look for
  36495. * @returns true if the mesh is in the active list
  36496. */
  36497. isActiveMesh(mesh: AbstractMesh): boolean;
  36498. /**
  36499. * Return a unique id as a string which can serve as an identifier for the scene
  36500. */
  36501. get uid(): string;
  36502. /**
  36503. * Add an externaly attached data from its key.
  36504. * This method call will fail and return false, if such key already exists.
  36505. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36506. * @param key the unique key that identifies the data
  36507. * @param data the data object to associate to the key for this Engine instance
  36508. * @return true if no such key were already present and the data was added successfully, false otherwise
  36509. */
  36510. addExternalData<T>(key: string, data: T): boolean;
  36511. /**
  36512. * Get an externaly attached data from its key
  36513. * @param key the unique key that identifies the data
  36514. * @return the associated data, if present (can be null), or undefined if not present
  36515. */
  36516. getExternalData<T>(key: string): Nullable<T>;
  36517. /**
  36518. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36519. * @param key the unique key that identifies the data
  36520. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36521. * @return the associated data, can be null if the factory returned null.
  36522. */
  36523. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36524. /**
  36525. * Remove an externaly attached data from the Engine instance
  36526. * @param key the unique key that identifies the data
  36527. * @return true if the data was successfully removed, false if it doesn't exist
  36528. */
  36529. removeExternalData(key: string): boolean;
  36530. private _evaluateSubMesh;
  36531. /**
  36532. * Clear the processed materials smart array preventing retention point in material dispose.
  36533. */
  36534. freeProcessedMaterials(): void;
  36535. private _preventFreeActiveMeshesAndRenderingGroups;
  36536. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36537. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36538. * when disposing several meshes in a row or a hierarchy of meshes.
  36539. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36540. */
  36541. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36542. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36543. /**
  36544. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36545. */
  36546. freeActiveMeshes(): void;
  36547. /**
  36548. * Clear the info related to rendering groups preventing retention points during dispose.
  36549. */
  36550. freeRenderingGroups(): void;
  36551. /** @hidden */
  36552. _isInIntermediateRendering(): boolean;
  36553. /**
  36554. * Lambda returning the list of potentially active meshes.
  36555. */
  36556. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36557. /**
  36558. * Lambda returning the list of potentially active sub meshes.
  36559. */
  36560. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36561. /**
  36562. * Lambda returning the list of potentially intersecting sub meshes.
  36563. */
  36564. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36565. /**
  36566. * Lambda returning the list of potentially colliding sub meshes.
  36567. */
  36568. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36569. private _activeMeshesFrozen;
  36570. private _skipEvaluateActiveMeshesCompletely;
  36571. /**
  36572. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36573. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36574. * @returns the current scene
  36575. */
  36576. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36577. /**
  36578. * Use this function to restart evaluating active meshes on every frame
  36579. * @returns the current scene
  36580. */
  36581. unfreezeActiveMeshes(): Scene;
  36582. private _evaluateActiveMeshes;
  36583. private _activeMesh;
  36584. /**
  36585. * Update the transform matrix to update from the current active camera
  36586. * @param force defines a boolean used to force the update even if cache is up to date
  36587. */
  36588. updateTransformMatrix(force?: boolean): void;
  36589. private _bindFrameBuffer;
  36590. /** @hidden */
  36591. _allowPostProcessClearColor: boolean;
  36592. /** @hidden */
  36593. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36594. private _processSubCameras;
  36595. private _checkIntersections;
  36596. /** @hidden */
  36597. _advancePhysicsEngineStep(step: number): void;
  36598. /**
  36599. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36600. */
  36601. getDeterministicFrameTime: () => number;
  36602. /** @hidden */
  36603. _animate(): void;
  36604. /** Execute all animations (for a frame) */
  36605. animate(): void;
  36606. /**
  36607. * Render the scene
  36608. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36609. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36610. */
  36611. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36612. /**
  36613. * Freeze all materials
  36614. * A frozen material will not be updatable but should be faster to render
  36615. */
  36616. freezeMaterials(): void;
  36617. /**
  36618. * Unfreeze all materials
  36619. * A frozen material will not be updatable but should be faster to render
  36620. */
  36621. unfreezeMaterials(): void;
  36622. /**
  36623. * Releases all held ressources
  36624. */
  36625. dispose(): void;
  36626. /**
  36627. * Gets if the scene is already disposed
  36628. */
  36629. get isDisposed(): boolean;
  36630. /**
  36631. * Call this function to reduce memory footprint of the scene.
  36632. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36633. */
  36634. clearCachedVertexData(): void;
  36635. /**
  36636. * This function will remove the local cached buffer data from texture.
  36637. * It will save memory but will prevent the texture from being rebuilt
  36638. */
  36639. cleanCachedTextureBuffer(): void;
  36640. /**
  36641. * Get the world extend vectors with an optional filter
  36642. *
  36643. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36644. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36645. */
  36646. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36647. min: Vector3;
  36648. max: Vector3;
  36649. };
  36650. /**
  36651. * Creates a ray that can be used to pick in the scene
  36652. * @param x defines the x coordinate of the origin (on-screen)
  36653. * @param y defines the y coordinate of the origin (on-screen)
  36654. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36655. * @param camera defines the camera to use for the picking
  36656. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36657. * @returns a Ray
  36658. */
  36659. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  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 result defines the ray where to store the picking ray
  36666. * @param camera defines the camera to use for the picking
  36667. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36668. * @returns the current scene
  36669. */
  36670. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36671. /**
  36672. * Creates a ray that can be used to pick in the scene
  36673. * @param x defines the x coordinate of the origin (on-screen)
  36674. * @param y defines the y coordinate of the origin (on-screen)
  36675. * @param camera defines the camera to use for the picking
  36676. * @returns a Ray
  36677. */
  36678. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36679. /**
  36680. * Creates a ray that can be used to pick in the scene
  36681. * @param x defines the x coordinate of the origin (on-screen)
  36682. * @param y defines the y coordinate of the origin (on-screen)
  36683. * @param result defines the ray where to store the picking ray
  36684. * @param camera defines the camera to use for the picking
  36685. * @returns the current scene
  36686. */
  36687. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36688. /** Launch a ray to try to pick a mesh in the scene
  36689. * @param x position on screen
  36690. * @param y position on screen
  36691. * @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
  36692. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36693. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36695. * @returns a PickingInfo
  36696. */
  36697. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36698. /** Use the given ray to pick a mesh in the scene
  36699. * @param ray The ray to use to pick meshes
  36700. * @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
  36701. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36702. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36703. * @returns a PickingInfo
  36704. */
  36705. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36706. /**
  36707. * Launch a ray to try to pick a mesh in the scene
  36708. * @param x X position on screen
  36709. * @param y Y position on screen
  36710. * @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
  36711. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36713. * @returns an array of PickingInfo
  36714. */
  36715. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36716. /**
  36717. * Launch a ray to try to pick a mesh in the scene
  36718. * @param ray Ray to use
  36719. * @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
  36720. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36721. * @returns an array of PickingInfo
  36722. */
  36723. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36724. /**
  36725. * Force the value of meshUnderPointer
  36726. * @param mesh defines the mesh to use
  36727. */
  36728. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36729. /**
  36730. * Gets the mesh under the pointer
  36731. * @returns a Mesh or null if no mesh is under the pointer
  36732. */
  36733. getPointerOverMesh(): Nullable<AbstractMesh>;
  36734. /** @hidden */
  36735. _rebuildGeometries(): void;
  36736. /** @hidden */
  36737. _rebuildTextures(): void;
  36738. private _getByTags;
  36739. /**
  36740. * Get a list of meshes by tags
  36741. * @param tagsQuery defines the tags query to use
  36742. * @param forEach defines a predicate used to filter results
  36743. * @returns an array of Mesh
  36744. */
  36745. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36746. /**
  36747. * Get a list of cameras by tags
  36748. * @param tagsQuery defines the tags query to use
  36749. * @param forEach defines a predicate used to filter results
  36750. * @returns an array of Camera
  36751. */
  36752. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36753. /**
  36754. * Get a list of lights by tags
  36755. * @param tagsQuery defines the tags query to use
  36756. * @param forEach defines a predicate used to filter results
  36757. * @returns an array of Light
  36758. */
  36759. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36760. /**
  36761. * Get a list of materials by tags
  36762. * @param tagsQuery defines the tags query to use
  36763. * @param forEach defines a predicate used to filter results
  36764. * @returns an array of Material
  36765. */
  36766. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36767. /**
  36768. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36769. * This allowed control for front to back rendering or reversly depending of the special needs.
  36770. *
  36771. * @param renderingGroupId The rendering group id corresponding to its index
  36772. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36773. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36774. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36775. */
  36776. 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;
  36777. /**
  36778. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36779. *
  36780. * @param renderingGroupId The rendering group id corresponding to its index
  36781. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36782. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36783. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36784. */
  36785. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36786. /**
  36787. * Gets the current auto clear configuration for one rendering group of the rendering
  36788. * manager.
  36789. * @param index the rendering group index to get the information for
  36790. * @returns The auto clear setup for the requested rendering group
  36791. */
  36792. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36793. private _blockMaterialDirtyMechanism;
  36794. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36795. get blockMaterialDirtyMechanism(): boolean;
  36796. set blockMaterialDirtyMechanism(value: boolean);
  36797. /**
  36798. * Will flag all materials as dirty to trigger new shader compilation
  36799. * @param flag defines the flag used to specify which material part must be marked as dirty
  36800. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36801. */
  36802. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36803. /** @hidden */
  36804. _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;
  36805. /** @hidden */
  36806. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36807. /** @hidden */
  36808. _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;
  36809. /** @hidden */
  36810. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36811. /** @hidden */
  36812. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36813. /** @hidden */
  36814. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36815. }
  36816. }
  36817. declare module BABYLON {
  36818. /**
  36819. * Set of assets to keep when moving a scene into an asset container.
  36820. */
  36821. export class KeepAssets extends AbstractScene {
  36822. }
  36823. /**
  36824. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36825. */
  36826. export class InstantiatedEntries {
  36827. /**
  36828. * List of new root nodes (eg. nodes with no parent)
  36829. */
  36830. rootNodes: TransformNode[];
  36831. /**
  36832. * List of new skeletons
  36833. */
  36834. skeletons: Skeleton[];
  36835. /**
  36836. * List of new animation groups
  36837. */
  36838. animationGroups: AnimationGroup[];
  36839. }
  36840. /**
  36841. * Container with a set of assets that can be added or removed from a scene.
  36842. */
  36843. export class AssetContainer extends AbstractScene {
  36844. /**
  36845. * The scene the AssetContainer belongs to.
  36846. */
  36847. scene: Scene;
  36848. /**
  36849. * Instantiates an AssetContainer.
  36850. * @param scene The scene the AssetContainer belongs to.
  36851. */
  36852. constructor(scene: Scene);
  36853. /**
  36854. * Instantiate or clone all meshes and add the new ones to the scene.
  36855. * Skeletons and animation groups will all be cloned
  36856. * @param nameFunction defines an optional function used to get new names for clones
  36857. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36858. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36859. */
  36860. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36861. /**
  36862. * Adds all the assets from the container to the scene.
  36863. */
  36864. addAllToScene(): void;
  36865. /**
  36866. * Removes all the assets in the container from the scene
  36867. */
  36868. removeAllFromScene(): void;
  36869. /**
  36870. * Disposes all the assets in the container
  36871. */
  36872. dispose(): void;
  36873. private _moveAssets;
  36874. /**
  36875. * Removes all the assets contained in the scene and adds them to the container.
  36876. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36877. */
  36878. moveAllFromScene(keepAssets?: KeepAssets): void;
  36879. /**
  36880. * 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.
  36881. * @returns the root mesh
  36882. */
  36883. createRootMesh(): Mesh;
  36884. /**
  36885. * Merge animations from this asset container into a scene
  36886. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36887. * @param animatables set of animatables to retarget to a node from the scene
  36888. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36889. */
  36890. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36891. }
  36892. }
  36893. declare module BABYLON {
  36894. /**
  36895. * Defines how the parser contract is defined.
  36896. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36897. */
  36898. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36899. /**
  36900. * Defines how the individual parser contract is defined.
  36901. * These parser can parse an individual asset
  36902. */
  36903. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36904. /**
  36905. * Base class of the scene acting as a container for the different elements composing a scene.
  36906. * This class is dynamically extended by the different components of the scene increasing
  36907. * flexibility and reducing coupling
  36908. */
  36909. export abstract class AbstractScene {
  36910. /**
  36911. * Stores the list of available parsers in the application.
  36912. */
  36913. private static _BabylonFileParsers;
  36914. /**
  36915. * Stores the list of available individual parsers in the application.
  36916. */
  36917. private static _IndividualBabylonFileParsers;
  36918. /**
  36919. * Adds a parser in the list of available ones
  36920. * @param name Defines the name of the parser
  36921. * @param parser Defines the parser to add
  36922. */
  36923. static AddParser(name: string, parser: BabylonFileParser): void;
  36924. /**
  36925. * Gets a general parser from the list of avaialble ones
  36926. * @param name Defines the name of the parser
  36927. * @returns the requested parser or null
  36928. */
  36929. static GetParser(name: string): Nullable<BabylonFileParser>;
  36930. /**
  36931. * Adds n individual parser in the list of available ones
  36932. * @param name Defines the name of the parser
  36933. * @param parser Defines the parser to add
  36934. */
  36935. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36936. /**
  36937. * Gets an individual parser from the list of avaialble ones
  36938. * @param name Defines the name of the parser
  36939. * @returns the requested parser or null
  36940. */
  36941. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36942. /**
  36943. * Parser json data and populate both a scene and its associated container object
  36944. * @param jsonData Defines the data to parse
  36945. * @param scene Defines the scene to parse the data for
  36946. * @param container Defines the container attached to the parsing sequence
  36947. * @param rootUrl Defines the root url of the data
  36948. */
  36949. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36950. /**
  36951. * Gets the list of root nodes (ie. nodes with no parent)
  36952. */
  36953. rootNodes: Node[];
  36954. /** All of the cameras added to this scene
  36955. * @see http://doc.babylonjs.com/babylon101/cameras
  36956. */
  36957. cameras: Camera[];
  36958. /**
  36959. * All of the lights added to this scene
  36960. * @see http://doc.babylonjs.com/babylon101/lights
  36961. */
  36962. lights: Light[];
  36963. /**
  36964. * All of the (abstract) meshes added to this scene
  36965. */
  36966. meshes: AbstractMesh[];
  36967. /**
  36968. * The list of skeletons added to the scene
  36969. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36970. */
  36971. skeletons: Skeleton[];
  36972. /**
  36973. * All of the particle systems added to this scene
  36974. * @see http://doc.babylonjs.com/babylon101/particles
  36975. */
  36976. particleSystems: IParticleSystem[];
  36977. /**
  36978. * Gets a list of Animations associated with the scene
  36979. */
  36980. animations: Animation[];
  36981. /**
  36982. * All of the animation groups added to this scene
  36983. * @see http://doc.babylonjs.com/how_to/group
  36984. */
  36985. animationGroups: AnimationGroup[];
  36986. /**
  36987. * All of the multi-materials added to this scene
  36988. * @see http://doc.babylonjs.com/how_to/multi_materials
  36989. */
  36990. multiMaterials: MultiMaterial[];
  36991. /**
  36992. * All of the materials added to this scene
  36993. * In the context of a Scene, it is not supposed to be modified manually.
  36994. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36995. * Note also that the order of the Material within the array is not significant and might change.
  36996. * @see http://doc.babylonjs.com/babylon101/materials
  36997. */
  36998. materials: Material[];
  36999. /**
  37000. * The list of morph target managers added to the scene
  37001. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37002. */
  37003. morphTargetManagers: MorphTargetManager[];
  37004. /**
  37005. * The list of geometries used in the scene.
  37006. */
  37007. geometries: Geometry[];
  37008. /**
  37009. * All of the tranform nodes added to this scene
  37010. * In the context of a Scene, it is not supposed to be modified manually.
  37011. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37012. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37013. * @see http://doc.babylonjs.com/how_to/transformnode
  37014. */
  37015. transformNodes: TransformNode[];
  37016. /**
  37017. * ActionManagers available on the scene.
  37018. */
  37019. actionManagers: AbstractActionManager[];
  37020. /**
  37021. * Textures to keep.
  37022. */
  37023. textures: BaseTexture[];
  37024. /**
  37025. * Environment texture for the scene
  37026. */
  37027. environmentTexture: Nullable<BaseTexture>;
  37028. /**
  37029. * @returns all meshes, lights, cameras, transformNodes and bones
  37030. */
  37031. getNodes(): Array<Node>;
  37032. }
  37033. }
  37034. declare module BABYLON {
  37035. /**
  37036. * Interface used to define options for Sound class
  37037. */
  37038. export interface ISoundOptions {
  37039. /**
  37040. * Does the sound autoplay once loaded.
  37041. */
  37042. autoplay?: boolean;
  37043. /**
  37044. * Does the sound loop after it finishes playing once.
  37045. */
  37046. loop?: boolean;
  37047. /**
  37048. * Sound's volume
  37049. */
  37050. volume?: number;
  37051. /**
  37052. * Is it a spatial sound?
  37053. */
  37054. spatialSound?: boolean;
  37055. /**
  37056. * Maximum distance to hear that sound
  37057. */
  37058. maxDistance?: number;
  37059. /**
  37060. * Uses user defined attenuation function
  37061. */
  37062. useCustomAttenuation?: boolean;
  37063. /**
  37064. * Define the roll off factor of spatial sounds.
  37065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37066. */
  37067. rolloffFactor?: number;
  37068. /**
  37069. * Define the reference distance the sound should be heard perfectly.
  37070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37071. */
  37072. refDistance?: number;
  37073. /**
  37074. * Define the distance attenuation model the sound will follow.
  37075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37076. */
  37077. distanceModel?: string;
  37078. /**
  37079. * Defines the playback speed (1 by default)
  37080. */
  37081. playbackRate?: number;
  37082. /**
  37083. * Defines if the sound is from a streaming source
  37084. */
  37085. streaming?: boolean;
  37086. /**
  37087. * Defines an optional length (in seconds) inside the sound file
  37088. */
  37089. length?: number;
  37090. /**
  37091. * Defines an optional offset (in seconds) inside the sound file
  37092. */
  37093. offset?: number;
  37094. /**
  37095. * If true, URLs will not be required to state the audio file codec to use.
  37096. */
  37097. skipCodecCheck?: boolean;
  37098. }
  37099. /**
  37100. * Defines a sound that can be played in the application.
  37101. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37103. */
  37104. export class Sound {
  37105. /**
  37106. * The name of the sound in the scene.
  37107. */
  37108. name: string;
  37109. /**
  37110. * Does the sound autoplay once loaded.
  37111. */
  37112. autoplay: boolean;
  37113. /**
  37114. * Does the sound loop after it finishes playing once.
  37115. */
  37116. loop: boolean;
  37117. /**
  37118. * Does the sound use a custom attenuation curve to simulate the falloff
  37119. * happening when the source gets further away from the camera.
  37120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37121. */
  37122. useCustomAttenuation: boolean;
  37123. /**
  37124. * The sound track id this sound belongs to.
  37125. */
  37126. soundTrackId: number;
  37127. /**
  37128. * Is this sound currently played.
  37129. */
  37130. isPlaying: boolean;
  37131. /**
  37132. * Is this sound currently paused.
  37133. */
  37134. isPaused: boolean;
  37135. /**
  37136. * Does this sound enables spatial sound.
  37137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37138. */
  37139. spatialSound: boolean;
  37140. /**
  37141. * Define the reference distance the sound should be heard perfectly.
  37142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37143. */
  37144. refDistance: number;
  37145. /**
  37146. * Define the roll off factor of spatial sounds.
  37147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37148. */
  37149. rolloffFactor: number;
  37150. /**
  37151. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37153. */
  37154. maxDistance: number;
  37155. /**
  37156. * Define the distance attenuation model the sound will follow.
  37157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37158. */
  37159. distanceModel: string;
  37160. /**
  37161. * @hidden
  37162. * Back Compat
  37163. **/
  37164. onended: () => any;
  37165. /**
  37166. * Observable event when the current playing sound finishes.
  37167. */
  37168. onEndedObservable: Observable<Sound>;
  37169. private _panningModel;
  37170. private _playbackRate;
  37171. private _streaming;
  37172. private _startTime;
  37173. private _startOffset;
  37174. private _position;
  37175. /** @hidden */
  37176. _positionInEmitterSpace: boolean;
  37177. private _localDirection;
  37178. private _volume;
  37179. private _isReadyToPlay;
  37180. private _isDirectional;
  37181. private _readyToPlayCallback;
  37182. private _audioBuffer;
  37183. private _soundSource;
  37184. private _streamingSource;
  37185. private _soundPanner;
  37186. private _soundGain;
  37187. private _inputAudioNode;
  37188. private _outputAudioNode;
  37189. private _coneInnerAngle;
  37190. private _coneOuterAngle;
  37191. private _coneOuterGain;
  37192. private _scene;
  37193. private _connectedTransformNode;
  37194. private _customAttenuationFunction;
  37195. private _registerFunc;
  37196. private _isOutputConnected;
  37197. private _htmlAudioElement;
  37198. private _urlType;
  37199. private _length?;
  37200. private _offset?;
  37201. /** @hidden */
  37202. static _SceneComponentInitialization: (scene: Scene) => void;
  37203. /**
  37204. * Create a sound and attach it to a scene
  37205. * @param name Name of your sound
  37206. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37207. * @param scene defines the scene the sound belongs to
  37208. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37209. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37210. */
  37211. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37212. /**
  37213. * Release the sound and its associated resources
  37214. */
  37215. dispose(): void;
  37216. /**
  37217. * Gets if the sounds is ready to be played or not.
  37218. * @returns true if ready, otherwise false
  37219. */
  37220. isReady(): boolean;
  37221. private _soundLoaded;
  37222. /**
  37223. * Sets the data of the sound from an audiobuffer
  37224. * @param audioBuffer The audioBuffer containing the data
  37225. */
  37226. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37227. /**
  37228. * Updates the current sounds options such as maxdistance, loop...
  37229. * @param options A JSON object containing values named as the object properties
  37230. */
  37231. updateOptions(options: ISoundOptions): void;
  37232. private _createSpatialParameters;
  37233. private _updateSpatialParameters;
  37234. /**
  37235. * Switch the panning model to HRTF:
  37236. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37238. */
  37239. switchPanningModelToHRTF(): void;
  37240. /**
  37241. * Switch the panning model to Equal Power:
  37242. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37244. */
  37245. switchPanningModelToEqualPower(): void;
  37246. private _switchPanningModel;
  37247. /**
  37248. * Connect this sound to a sound track audio node like gain...
  37249. * @param soundTrackAudioNode the sound track audio node to connect to
  37250. */
  37251. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37252. /**
  37253. * Transform this sound into a directional source
  37254. * @param coneInnerAngle Size of the inner cone in degree
  37255. * @param coneOuterAngle Size of the outer cone in degree
  37256. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37257. */
  37258. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37259. /**
  37260. * Gets or sets the inner angle for the directional cone.
  37261. */
  37262. get directionalConeInnerAngle(): number;
  37263. /**
  37264. * Gets or sets the inner angle for the directional cone.
  37265. */
  37266. set directionalConeInnerAngle(value: number);
  37267. /**
  37268. * Gets or sets the outer angle for the directional cone.
  37269. */
  37270. get directionalConeOuterAngle(): number;
  37271. /**
  37272. * Gets or sets the outer angle for the directional cone.
  37273. */
  37274. set directionalConeOuterAngle(value: number);
  37275. /**
  37276. * Sets the position of the emitter if spatial sound is enabled
  37277. * @param newPosition Defines the new posisiton
  37278. */
  37279. setPosition(newPosition: Vector3): void;
  37280. /**
  37281. * Sets the local direction of the emitter if spatial sound is enabled
  37282. * @param newLocalDirection Defines the new local direction
  37283. */
  37284. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37285. private _updateDirection;
  37286. /** @hidden */
  37287. updateDistanceFromListener(): void;
  37288. /**
  37289. * Sets a new custom attenuation function for the sound.
  37290. * @param callback Defines the function used for the attenuation
  37291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37292. */
  37293. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37294. /**
  37295. * Play the sound
  37296. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37297. * @param offset (optional) Start the sound at a specific time in seconds
  37298. * @param length (optional) Sound duration (in seconds)
  37299. */
  37300. play(time?: number, offset?: number, length?: number): void;
  37301. private _onended;
  37302. /**
  37303. * Stop the sound
  37304. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37305. */
  37306. stop(time?: number): void;
  37307. /**
  37308. * Put the sound in pause
  37309. */
  37310. pause(): void;
  37311. /**
  37312. * Sets a dedicated volume for this sounds
  37313. * @param newVolume Define the new volume of the sound
  37314. * @param time Define time for gradual change to new volume
  37315. */
  37316. setVolume(newVolume: number, time?: number): void;
  37317. /**
  37318. * Set the sound play back rate
  37319. * @param newPlaybackRate Define the playback rate the sound should be played at
  37320. */
  37321. setPlaybackRate(newPlaybackRate: number): void;
  37322. /**
  37323. * Gets the volume of the sound.
  37324. * @returns the volume of the sound
  37325. */
  37326. getVolume(): number;
  37327. /**
  37328. * Attach the sound to a dedicated mesh
  37329. * @param transformNode The transform node to connect the sound with
  37330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37331. */
  37332. attachToMesh(transformNode: TransformNode): void;
  37333. /**
  37334. * Detach the sound from the previously attached mesh
  37335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37336. */
  37337. detachFromMesh(): void;
  37338. private _onRegisterAfterWorldMatrixUpdate;
  37339. /**
  37340. * Clone the current sound in the scene.
  37341. * @returns the new sound clone
  37342. */
  37343. clone(): Nullable<Sound>;
  37344. /**
  37345. * Gets the current underlying audio buffer containing the data
  37346. * @returns the audio buffer
  37347. */
  37348. getAudioBuffer(): Nullable<AudioBuffer>;
  37349. /**
  37350. * Serializes the Sound in a JSON representation
  37351. * @returns the JSON representation of the sound
  37352. */
  37353. serialize(): any;
  37354. /**
  37355. * Parse a JSON representation of a sound to innstantiate in a given scene
  37356. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37357. * @param scene Define the scene the new parsed sound should be created in
  37358. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37359. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37360. * @returns the newly parsed sound
  37361. */
  37362. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37363. }
  37364. }
  37365. declare module BABYLON {
  37366. /**
  37367. * This defines an action helpful to play a defined sound on a triggered action.
  37368. */
  37369. export class PlaySoundAction extends Action {
  37370. private _sound;
  37371. /**
  37372. * Instantiate the action
  37373. * @param triggerOptions defines the trigger options
  37374. * @param sound defines the sound to play
  37375. * @param condition defines the trigger related conditions
  37376. */
  37377. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37378. /** @hidden */
  37379. _prepare(): void;
  37380. /**
  37381. * Execute the action and play the sound.
  37382. */
  37383. execute(): void;
  37384. /**
  37385. * Serializes the actions and its related information.
  37386. * @param parent defines the object to serialize in
  37387. * @returns the serialized object
  37388. */
  37389. serialize(parent: any): any;
  37390. }
  37391. /**
  37392. * This defines an action helpful to stop a defined sound on a triggered action.
  37393. */
  37394. export class StopSoundAction extends Action {
  37395. private _sound;
  37396. /**
  37397. * Instantiate the action
  37398. * @param triggerOptions defines the trigger options
  37399. * @param sound defines the sound to stop
  37400. * @param condition defines the trigger related conditions
  37401. */
  37402. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37403. /** @hidden */
  37404. _prepare(): void;
  37405. /**
  37406. * Execute the action and stop the sound.
  37407. */
  37408. execute(): void;
  37409. /**
  37410. * Serializes the actions and its related information.
  37411. * @param parent defines the object to serialize in
  37412. * @returns the serialized object
  37413. */
  37414. serialize(parent: any): any;
  37415. }
  37416. }
  37417. declare module BABYLON {
  37418. /**
  37419. * This defines an action responsible to change the value of a property
  37420. * by interpolating between its current value and the newly set one once triggered.
  37421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37422. */
  37423. export class InterpolateValueAction extends Action {
  37424. /**
  37425. * Defines the path of the property where the value should be interpolated
  37426. */
  37427. propertyPath: string;
  37428. /**
  37429. * Defines the target value at the end of the interpolation.
  37430. */
  37431. value: any;
  37432. /**
  37433. * Defines the time it will take for the property to interpolate to the value.
  37434. */
  37435. duration: number;
  37436. /**
  37437. * Defines if the other scene animations should be stopped when the action has been triggered
  37438. */
  37439. stopOtherAnimations?: boolean;
  37440. /**
  37441. * Defines a callback raised once the interpolation animation has been done.
  37442. */
  37443. onInterpolationDone?: () => void;
  37444. /**
  37445. * Observable triggered once the interpolation animation has been done.
  37446. */
  37447. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37448. private _target;
  37449. private _effectiveTarget;
  37450. private _property;
  37451. /**
  37452. * Instantiate the action
  37453. * @param triggerOptions defines the trigger options
  37454. * @param target defines the object containing the value to interpolate
  37455. * @param propertyPath defines the path to the property in the target object
  37456. * @param value defines the target value at the end of the interpolation
  37457. * @param duration deines the time it will take for the property to interpolate to the value.
  37458. * @param condition defines the trigger related conditions
  37459. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37460. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37461. */
  37462. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37463. /** @hidden */
  37464. _prepare(): void;
  37465. /**
  37466. * Execute the action starts the value interpolation.
  37467. */
  37468. execute(): void;
  37469. /**
  37470. * Serializes the actions and its related information.
  37471. * @param parent defines the object to serialize in
  37472. * @returns the serialized object
  37473. */
  37474. serialize(parent: any): any;
  37475. }
  37476. }
  37477. declare module BABYLON {
  37478. /**
  37479. * Options allowed during the creation of a sound track.
  37480. */
  37481. export interface ISoundTrackOptions {
  37482. /**
  37483. * The volume the sound track should take during creation
  37484. */
  37485. volume?: number;
  37486. /**
  37487. * Define if the sound track is the main sound track of the scene
  37488. */
  37489. mainTrack?: boolean;
  37490. }
  37491. /**
  37492. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37493. * It will be also used in a future release to apply effects on a specific track.
  37494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37495. */
  37496. export class SoundTrack {
  37497. /**
  37498. * The unique identifier of the sound track in the scene.
  37499. */
  37500. id: number;
  37501. /**
  37502. * The list of sounds included in the sound track.
  37503. */
  37504. soundCollection: Array<Sound>;
  37505. private _outputAudioNode;
  37506. private _scene;
  37507. private _connectedAnalyser;
  37508. private _options;
  37509. private _isInitialized;
  37510. /**
  37511. * Creates a new sound track.
  37512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37513. * @param scene Define the scene the sound track belongs to
  37514. * @param options
  37515. */
  37516. constructor(scene: Scene, options?: ISoundTrackOptions);
  37517. private _initializeSoundTrackAudioGraph;
  37518. /**
  37519. * Release the sound track and its associated resources
  37520. */
  37521. dispose(): void;
  37522. /**
  37523. * Adds a sound to this sound track
  37524. * @param sound define the cound to add
  37525. * @ignoreNaming
  37526. */
  37527. AddSound(sound: Sound): void;
  37528. /**
  37529. * Removes a sound to this sound track
  37530. * @param sound define the cound to remove
  37531. * @ignoreNaming
  37532. */
  37533. RemoveSound(sound: Sound): void;
  37534. /**
  37535. * Set a global volume for the full sound track.
  37536. * @param newVolume Define the new volume of the sound track
  37537. */
  37538. setVolume(newVolume: number): void;
  37539. /**
  37540. * Switch the panning model to HRTF:
  37541. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37543. */
  37544. switchPanningModelToHRTF(): void;
  37545. /**
  37546. * Switch the panning model to Equal Power:
  37547. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37549. */
  37550. switchPanningModelToEqualPower(): void;
  37551. /**
  37552. * Connect the sound track to an audio analyser allowing some amazing
  37553. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37555. * @param analyser The analyser to connect to the engine
  37556. */
  37557. connectToAnalyser(analyser: Analyser): void;
  37558. }
  37559. }
  37560. declare module BABYLON {
  37561. interface AbstractScene {
  37562. /**
  37563. * The list of sounds used in the scene.
  37564. */
  37565. sounds: Nullable<Array<Sound>>;
  37566. }
  37567. interface Scene {
  37568. /**
  37569. * @hidden
  37570. * Backing field
  37571. */
  37572. _mainSoundTrack: SoundTrack;
  37573. /**
  37574. * The main sound track played by the scene.
  37575. * It cotains your primary collection of sounds.
  37576. */
  37577. mainSoundTrack: SoundTrack;
  37578. /**
  37579. * The list of sound tracks added to the scene
  37580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37581. */
  37582. soundTracks: Nullable<Array<SoundTrack>>;
  37583. /**
  37584. * Gets a sound using a given name
  37585. * @param name defines the name to search for
  37586. * @return the found sound or null if not found at all.
  37587. */
  37588. getSoundByName(name: string): Nullable<Sound>;
  37589. /**
  37590. * Gets or sets if audio support is enabled
  37591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37592. */
  37593. audioEnabled: boolean;
  37594. /**
  37595. * Gets or sets if audio will be output to headphones
  37596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37597. */
  37598. headphone: boolean;
  37599. /**
  37600. * Gets or sets custom audio listener position provider
  37601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37602. */
  37603. audioListenerPositionProvider: Nullable<() => Vector3>;
  37604. /**
  37605. * Gets or sets a refresh rate when using 3D audio positioning
  37606. */
  37607. audioPositioningRefreshRate: number;
  37608. }
  37609. /**
  37610. * Defines the sound scene component responsible to manage any sounds
  37611. * in a given scene.
  37612. */
  37613. export class AudioSceneComponent implements ISceneSerializableComponent {
  37614. /**
  37615. * The component name helpfull to identify the component in the list of scene components.
  37616. */
  37617. readonly name: string;
  37618. /**
  37619. * The scene the component belongs to.
  37620. */
  37621. scene: Scene;
  37622. private _audioEnabled;
  37623. /**
  37624. * Gets whether audio is enabled or not.
  37625. * Please use related enable/disable method to switch state.
  37626. */
  37627. get audioEnabled(): boolean;
  37628. private _headphone;
  37629. /**
  37630. * Gets whether audio is outputing to headphone or not.
  37631. * Please use the according Switch methods to change output.
  37632. */
  37633. get headphone(): boolean;
  37634. /**
  37635. * Gets or sets a refresh rate when using 3D audio positioning
  37636. */
  37637. audioPositioningRefreshRate: number;
  37638. private _audioListenerPositionProvider;
  37639. /**
  37640. * Gets the current audio listener position provider
  37641. */
  37642. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37643. /**
  37644. * Sets a custom listener position for all sounds in the scene
  37645. * By default, this is the position of the first active camera
  37646. */
  37647. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37648. /**
  37649. * Creates a new instance of the component for the given scene
  37650. * @param scene Defines the scene to register the component in
  37651. */
  37652. constructor(scene: Scene);
  37653. /**
  37654. * Registers the component in a given scene
  37655. */
  37656. register(): void;
  37657. /**
  37658. * Rebuilds the elements related to this component in case of
  37659. * context lost for instance.
  37660. */
  37661. rebuild(): void;
  37662. /**
  37663. * Serializes the component data to the specified json object
  37664. * @param serializationObject The object to serialize to
  37665. */
  37666. serialize(serializationObject: any): void;
  37667. /**
  37668. * Adds all the elements from the container to the scene
  37669. * @param container the container holding the elements
  37670. */
  37671. addFromContainer(container: AbstractScene): void;
  37672. /**
  37673. * Removes all the elements in the container from the scene
  37674. * @param container contains the elements to remove
  37675. * @param dispose if the removed element should be disposed (default: false)
  37676. */
  37677. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37678. /**
  37679. * Disposes the component and the associated ressources.
  37680. */
  37681. dispose(): void;
  37682. /**
  37683. * Disables audio in the associated scene.
  37684. */
  37685. disableAudio(): void;
  37686. /**
  37687. * Enables audio in the associated scene.
  37688. */
  37689. enableAudio(): void;
  37690. /**
  37691. * Switch audio to headphone output.
  37692. */
  37693. switchAudioModeForHeadphones(): void;
  37694. /**
  37695. * Switch audio to normal speakers.
  37696. */
  37697. switchAudioModeForNormalSpeakers(): void;
  37698. private _cachedCameraDirection;
  37699. private _cachedCameraPosition;
  37700. private _lastCheck;
  37701. private _afterRender;
  37702. }
  37703. }
  37704. declare module BABYLON {
  37705. /**
  37706. * Wraps one or more Sound objects and selects one with random weight for playback.
  37707. */
  37708. export class WeightedSound {
  37709. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37710. loop: boolean;
  37711. private _coneInnerAngle;
  37712. private _coneOuterAngle;
  37713. private _volume;
  37714. /** A Sound is currently playing. */
  37715. isPlaying: boolean;
  37716. /** A Sound is currently paused. */
  37717. isPaused: boolean;
  37718. private _sounds;
  37719. private _weights;
  37720. private _currentIndex?;
  37721. /**
  37722. * Creates a new WeightedSound from the list of sounds given.
  37723. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37724. * @param sounds Array of Sounds that will be selected from.
  37725. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37726. */
  37727. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37728. /**
  37729. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37730. */
  37731. get directionalConeInnerAngle(): number;
  37732. /**
  37733. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37734. */
  37735. set directionalConeInnerAngle(value: number);
  37736. /**
  37737. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37738. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37739. */
  37740. get directionalConeOuterAngle(): number;
  37741. /**
  37742. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37743. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37744. */
  37745. set directionalConeOuterAngle(value: number);
  37746. /**
  37747. * Playback volume.
  37748. */
  37749. get volume(): number;
  37750. /**
  37751. * Playback volume.
  37752. */
  37753. set volume(value: number);
  37754. private _onended;
  37755. /**
  37756. * Suspend playback
  37757. */
  37758. pause(): void;
  37759. /**
  37760. * Stop playback
  37761. */
  37762. stop(): void;
  37763. /**
  37764. * Start playback.
  37765. * @param startOffset Position the clip head at a specific time in seconds.
  37766. */
  37767. play(startOffset?: number): void;
  37768. }
  37769. }
  37770. declare module BABYLON {
  37771. /**
  37772. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37773. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37774. */
  37775. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37776. /**
  37777. * Gets the name of the behavior.
  37778. */
  37779. get name(): string;
  37780. /**
  37781. * The easing function used by animations
  37782. */
  37783. static EasingFunction: BackEase;
  37784. /**
  37785. * The easing mode used by animations
  37786. */
  37787. static EasingMode: number;
  37788. /**
  37789. * The duration of the animation, in milliseconds
  37790. */
  37791. transitionDuration: number;
  37792. /**
  37793. * Length of the distance animated by the transition when lower radius is reached
  37794. */
  37795. lowerRadiusTransitionRange: number;
  37796. /**
  37797. * Length of the distance animated by the transition when upper radius is reached
  37798. */
  37799. upperRadiusTransitionRange: number;
  37800. private _autoTransitionRange;
  37801. /**
  37802. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37803. */
  37804. get autoTransitionRange(): boolean;
  37805. /**
  37806. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37807. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37808. */
  37809. set autoTransitionRange(value: boolean);
  37810. private _attachedCamera;
  37811. private _onAfterCheckInputsObserver;
  37812. private _onMeshTargetChangedObserver;
  37813. /**
  37814. * Initializes the behavior.
  37815. */
  37816. init(): void;
  37817. /**
  37818. * Attaches the behavior to its arc rotate camera.
  37819. * @param camera Defines the camera to attach the behavior to
  37820. */
  37821. attach(camera: ArcRotateCamera): void;
  37822. /**
  37823. * Detaches the behavior from its current arc rotate camera.
  37824. */
  37825. detach(): void;
  37826. private _radiusIsAnimating;
  37827. private _radiusBounceTransition;
  37828. private _animatables;
  37829. private _cachedWheelPrecision;
  37830. /**
  37831. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37832. * @param radiusLimit The limit to check against.
  37833. * @return Bool to indicate if at limit.
  37834. */
  37835. private _isRadiusAtLimit;
  37836. /**
  37837. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37838. * @param radiusDelta The delta by which to animate to. Can be negative.
  37839. */
  37840. private _applyBoundRadiusAnimation;
  37841. /**
  37842. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37843. */
  37844. protected _clearAnimationLocks(): void;
  37845. /**
  37846. * Stops and removes all animations that have been applied to the camera
  37847. */
  37848. stopAllAnimations(): void;
  37849. }
  37850. }
  37851. declare module BABYLON {
  37852. /**
  37853. * 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.
  37854. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37855. */
  37856. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37857. /**
  37858. * Gets the name of the behavior.
  37859. */
  37860. get name(): string;
  37861. private _mode;
  37862. private _radiusScale;
  37863. private _positionScale;
  37864. private _defaultElevation;
  37865. private _elevationReturnTime;
  37866. private _elevationReturnWaitTime;
  37867. private _zoomStopsAnimation;
  37868. private _framingTime;
  37869. /**
  37870. * The easing function used by animations
  37871. */
  37872. static EasingFunction: ExponentialEase;
  37873. /**
  37874. * The easing mode used by animations
  37875. */
  37876. static EasingMode: number;
  37877. /**
  37878. * Sets the current mode used by the behavior
  37879. */
  37880. set mode(mode: number);
  37881. /**
  37882. * Gets current mode used by the behavior.
  37883. */
  37884. get mode(): number;
  37885. /**
  37886. * Sets the scale applied to the radius (1 by default)
  37887. */
  37888. set radiusScale(radius: number);
  37889. /**
  37890. * Gets the scale applied to the radius
  37891. */
  37892. get radiusScale(): number;
  37893. /**
  37894. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37895. */
  37896. set positionScale(scale: number);
  37897. /**
  37898. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37899. */
  37900. get positionScale(): number;
  37901. /**
  37902. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37903. * behaviour is triggered, in radians.
  37904. */
  37905. set defaultElevation(elevation: number);
  37906. /**
  37907. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37908. * behaviour is triggered, in radians.
  37909. */
  37910. get defaultElevation(): number;
  37911. /**
  37912. * Sets the time (in milliseconds) taken to return to the default beta position.
  37913. * Negative value indicates camera should not return to default.
  37914. */
  37915. set elevationReturnTime(speed: number);
  37916. /**
  37917. * Gets the time (in milliseconds) taken to return to the default beta position.
  37918. * Negative value indicates camera should not return to default.
  37919. */
  37920. get elevationReturnTime(): number;
  37921. /**
  37922. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37923. */
  37924. set elevationReturnWaitTime(time: number);
  37925. /**
  37926. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37927. */
  37928. get elevationReturnWaitTime(): number;
  37929. /**
  37930. * Sets the flag that indicates if user zooming should stop animation.
  37931. */
  37932. set zoomStopsAnimation(flag: boolean);
  37933. /**
  37934. * Gets the flag that indicates if user zooming should stop animation.
  37935. */
  37936. get zoomStopsAnimation(): boolean;
  37937. /**
  37938. * Sets the transition time when framing the mesh, in milliseconds
  37939. */
  37940. set framingTime(time: number);
  37941. /**
  37942. * Gets the transition time when framing the mesh, in milliseconds
  37943. */
  37944. get framingTime(): number;
  37945. /**
  37946. * Define if the behavior should automatically change the configured
  37947. * camera limits and sensibilities.
  37948. */
  37949. autoCorrectCameraLimitsAndSensibility: boolean;
  37950. private _onPrePointerObservableObserver;
  37951. private _onAfterCheckInputsObserver;
  37952. private _onMeshTargetChangedObserver;
  37953. private _attachedCamera;
  37954. private _isPointerDown;
  37955. private _lastInteractionTime;
  37956. /**
  37957. * Initializes the behavior.
  37958. */
  37959. init(): void;
  37960. /**
  37961. * Attaches the behavior to its arc rotate camera.
  37962. * @param camera Defines the camera to attach the behavior to
  37963. */
  37964. attach(camera: ArcRotateCamera): void;
  37965. /**
  37966. * Detaches the behavior from its current arc rotate camera.
  37967. */
  37968. detach(): void;
  37969. private _animatables;
  37970. private _betaIsAnimating;
  37971. private _betaTransition;
  37972. private _radiusTransition;
  37973. private _vectorTransition;
  37974. /**
  37975. * Targets the given mesh and updates zoom level accordingly.
  37976. * @param mesh The mesh to target.
  37977. * @param radius Optional. If a cached radius position already exists, overrides default.
  37978. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37979. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37980. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37981. */
  37982. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37983. /**
  37984. * Targets the given mesh with its children and updates zoom level accordingly.
  37985. * @param mesh The mesh to target.
  37986. * @param radius Optional. If a cached radius position already exists, overrides default.
  37987. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37988. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37989. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37990. */
  37991. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37992. /**
  37993. * Targets the given meshes with their children and updates zoom level accordingly.
  37994. * @param meshes The mesh to target.
  37995. * @param radius Optional. If a cached radius position already exists, overrides default.
  37996. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37997. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37998. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37999. */
  38000. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38001. /**
  38002. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38003. * @param minimumWorld Determines the smaller position of the bounding box extend
  38004. * @param maximumWorld Determines the bigger position of the bounding box extend
  38005. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38006. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38007. */
  38008. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38009. /**
  38010. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38011. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38012. * frustum width.
  38013. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38014. * to fully enclose the mesh in the viewing frustum.
  38015. */
  38016. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38017. /**
  38018. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38019. * is automatically returned to its default position (expected to be above ground plane).
  38020. */
  38021. private _maintainCameraAboveGround;
  38022. /**
  38023. * Returns the frustum slope based on the canvas ratio and camera FOV
  38024. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38025. */
  38026. private _getFrustumSlope;
  38027. /**
  38028. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38029. */
  38030. private _clearAnimationLocks;
  38031. /**
  38032. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38033. */
  38034. private _applyUserInteraction;
  38035. /**
  38036. * Stops and removes all animations that have been applied to the camera
  38037. */
  38038. stopAllAnimations(): void;
  38039. /**
  38040. * Gets a value indicating if the user is moving the camera
  38041. */
  38042. get isUserIsMoving(): boolean;
  38043. /**
  38044. * The camera can move all the way towards the mesh.
  38045. */
  38046. static IgnoreBoundsSizeMode: number;
  38047. /**
  38048. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38049. */
  38050. static FitFrustumSidesMode: number;
  38051. }
  38052. }
  38053. declare module BABYLON {
  38054. /**
  38055. * Base class for Camera Pointer Inputs.
  38056. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38057. * for example usage.
  38058. */
  38059. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38060. /**
  38061. * Defines the camera the input is attached to.
  38062. */
  38063. abstract camera: Camera;
  38064. /**
  38065. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38066. */
  38067. protected _altKey: boolean;
  38068. protected _ctrlKey: boolean;
  38069. protected _metaKey: boolean;
  38070. protected _shiftKey: boolean;
  38071. /**
  38072. * Which mouse buttons were pressed at time of last mouse event.
  38073. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38074. */
  38075. protected _buttonsPressed: number;
  38076. /**
  38077. * Defines the buttons associated with the input to handle camera move.
  38078. */
  38079. buttons: number[];
  38080. /**
  38081. * Attach the input controls to a specific dom element to get the input from.
  38082. * @param element Defines the element the controls should be listened from
  38083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38084. */
  38085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38086. /**
  38087. * Detach the current controls from the specified dom element.
  38088. * @param element Defines the element to stop listening the inputs from
  38089. */
  38090. detachControl(element: Nullable<HTMLElement>): void;
  38091. /**
  38092. * Gets the class name of the current input.
  38093. * @returns the class name
  38094. */
  38095. getClassName(): string;
  38096. /**
  38097. * Get the friendly name associated with the input class.
  38098. * @returns the input friendly name
  38099. */
  38100. getSimpleName(): string;
  38101. /**
  38102. * Called on pointer POINTERDOUBLETAP event.
  38103. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38104. */
  38105. protected onDoubleTap(type: string): void;
  38106. /**
  38107. * Called on pointer POINTERMOVE event if only a single touch is active.
  38108. * Override this method to provide functionality.
  38109. */
  38110. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38111. /**
  38112. * Called on pointer POINTERMOVE event if multiple touches are active.
  38113. * Override this method to provide functionality.
  38114. */
  38115. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38116. /**
  38117. * Called on JS contextmenu event.
  38118. * Override this method to provide functionality.
  38119. */
  38120. protected onContextMenu(evt: PointerEvent): void;
  38121. /**
  38122. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38123. * press.
  38124. * Override this method to provide functionality.
  38125. */
  38126. protected onButtonDown(evt: PointerEvent): void;
  38127. /**
  38128. * Called each time a new POINTERUP event occurs. Ie, for each button
  38129. * release.
  38130. * Override this method to provide functionality.
  38131. */
  38132. protected onButtonUp(evt: PointerEvent): void;
  38133. /**
  38134. * Called when window becomes inactive.
  38135. * Override this method to provide functionality.
  38136. */
  38137. protected onLostFocus(): void;
  38138. private _pointerInput;
  38139. private _observer;
  38140. private _onLostFocus;
  38141. private pointA;
  38142. private pointB;
  38143. }
  38144. }
  38145. declare module BABYLON {
  38146. /**
  38147. * Manage the pointers inputs to control an arc rotate camera.
  38148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38149. */
  38150. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38151. /**
  38152. * Defines the camera the input is attached to.
  38153. */
  38154. camera: ArcRotateCamera;
  38155. /**
  38156. * Gets the class name of the current input.
  38157. * @returns the class name
  38158. */
  38159. getClassName(): string;
  38160. /**
  38161. * Defines the buttons associated with the input to handle camera move.
  38162. */
  38163. buttons: number[];
  38164. /**
  38165. * Defines the pointer angular sensibility along the X axis or how fast is
  38166. * the camera rotating.
  38167. */
  38168. angularSensibilityX: number;
  38169. /**
  38170. * Defines the pointer angular sensibility along the Y axis or how fast is
  38171. * the camera rotating.
  38172. */
  38173. angularSensibilityY: number;
  38174. /**
  38175. * Defines the pointer pinch precision or how fast is the camera zooming.
  38176. */
  38177. pinchPrecision: number;
  38178. /**
  38179. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38180. * from 0.
  38181. * It defines the percentage of current camera.radius to use as delta when
  38182. * pinch zoom is used.
  38183. */
  38184. pinchDeltaPercentage: number;
  38185. /**
  38186. * Defines the pointer panning sensibility or how fast is the camera moving.
  38187. */
  38188. panningSensibility: number;
  38189. /**
  38190. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38191. */
  38192. multiTouchPanning: boolean;
  38193. /**
  38194. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38195. * zoom (pinch) through multitouch.
  38196. */
  38197. multiTouchPanAndZoom: boolean;
  38198. /**
  38199. * Revers pinch action direction.
  38200. */
  38201. pinchInwards: boolean;
  38202. private _isPanClick;
  38203. private _twoFingerActivityCount;
  38204. private _isPinching;
  38205. /**
  38206. * Called on pointer POINTERMOVE event if only a single touch is active.
  38207. */
  38208. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38209. /**
  38210. * Called on pointer POINTERDOUBLETAP event.
  38211. */
  38212. protected onDoubleTap(type: string): void;
  38213. /**
  38214. * Called on pointer POINTERMOVE event if multiple touches are active.
  38215. */
  38216. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38217. /**
  38218. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38219. * press.
  38220. */
  38221. protected onButtonDown(evt: PointerEvent): void;
  38222. /**
  38223. * Called each time a new POINTERUP event occurs. Ie, for each button
  38224. * release.
  38225. */
  38226. protected onButtonUp(evt: PointerEvent): void;
  38227. /**
  38228. * Called when window becomes inactive.
  38229. */
  38230. protected onLostFocus(): void;
  38231. }
  38232. }
  38233. declare module BABYLON {
  38234. /**
  38235. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38237. */
  38238. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38239. /**
  38240. * Defines the camera the input is attached to.
  38241. */
  38242. camera: ArcRotateCamera;
  38243. /**
  38244. * Defines the list of key codes associated with the up action (increase alpha)
  38245. */
  38246. keysUp: number[];
  38247. /**
  38248. * Defines the list of key codes associated with the down action (decrease alpha)
  38249. */
  38250. keysDown: number[];
  38251. /**
  38252. * Defines the list of key codes associated with the left action (increase beta)
  38253. */
  38254. keysLeft: number[];
  38255. /**
  38256. * Defines the list of key codes associated with the right action (decrease beta)
  38257. */
  38258. keysRight: number[];
  38259. /**
  38260. * Defines the list of key codes associated with the reset action.
  38261. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38262. */
  38263. keysReset: number[];
  38264. /**
  38265. * Defines the panning sensibility of the inputs.
  38266. * (How fast is the camera paning)
  38267. */
  38268. panningSensibility: number;
  38269. /**
  38270. * Defines the zooming sensibility of the inputs.
  38271. * (How fast is the camera zooming)
  38272. */
  38273. zoomingSensibility: number;
  38274. /**
  38275. * Defines wether maintaining the alt key down switch the movement mode from
  38276. * orientation to zoom.
  38277. */
  38278. useAltToZoom: boolean;
  38279. /**
  38280. * Rotation speed of the camera
  38281. */
  38282. angularSpeed: number;
  38283. private _keys;
  38284. private _ctrlPressed;
  38285. private _altPressed;
  38286. private _onCanvasBlurObserver;
  38287. private _onKeyboardObserver;
  38288. private _engine;
  38289. private _scene;
  38290. /**
  38291. * Attach the input controls to a specific dom element to get the input from.
  38292. * @param element Defines the element the controls should be listened from
  38293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38294. */
  38295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38296. /**
  38297. * Detach the current controls from the specified dom element.
  38298. * @param element Defines the element to stop listening the inputs from
  38299. */
  38300. detachControl(element: Nullable<HTMLElement>): void;
  38301. /**
  38302. * Update the current camera state depending on the inputs that have been used this frame.
  38303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38304. */
  38305. checkInputs(): void;
  38306. /**
  38307. * Gets the class name of the current intput.
  38308. * @returns the class name
  38309. */
  38310. getClassName(): string;
  38311. /**
  38312. * Get the friendly name associated with the input class.
  38313. * @returns the input friendly name
  38314. */
  38315. getSimpleName(): string;
  38316. }
  38317. }
  38318. declare module BABYLON {
  38319. /**
  38320. * Manage the mouse wheel inputs to control an arc rotate camera.
  38321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38322. */
  38323. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38324. /**
  38325. * Defines the camera the input is attached to.
  38326. */
  38327. camera: ArcRotateCamera;
  38328. /**
  38329. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38330. */
  38331. wheelPrecision: number;
  38332. /**
  38333. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38334. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38335. */
  38336. wheelDeltaPercentage: number;
  38337. private _wheel;
  38338. private _observer;
  38339. private computeDeltaFromMouseWheelLegacyEvent;
  38340. /**
  38341. * Attach the input controls to a specific dom element to get the input from.
  38342. * @param element Defines the element the controls should be listened from
  38343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38344. */
  38345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38346. /**
  38347. * Detach the current controls from the specified dom element.
  38348. * @param element Defines the element to stop listening the inputs from
  38349. */
  38350. detachControl(element: Nullable<HTMLElement>): void;
  38351. /**
  38352. * Gets the class name of the current intput.
  38353. * @returns the class name
  38354. */
  38355. getClassName(): string;
  38356. /**
  38357. * Get the friendly name associated with the input class.
  38358. * @returns the input friendly name
  38359. */
  38360. getSimpleName(): string;
  38361. }
  38362. }
  38363. declare module BABYLON {
  38364. /**
  38365. * Default Inputs manager for the ArcRotateCamera.
  38366. * It groups all the default supported inputs for ease of use.
  38367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38368. */
  38369. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38370. /**
  38371. * Instantiates a new ArcRotateCameraInputsManager.
  38372. * @param camera Defines the camera the inputs belong to
  38373. */
  38374. constructor(camera: ArcRotateCamera);
  38375. /**
  38376. * Add mouse wheel input support to the input manager.
  38377. * @returns the current input manager
  38378. */
  38379. addMouseWheel(): ArcRotateCameraInputsManager;
  38380. /**
  38381. * Add pointers input support to the input manager.
  38382. * @returns the current input manager
  38383. */
  38384. addPointers(): ArcRotateCameraInputsManager;
  38385. /**
  38386. * Add keyboard input support to the input manager.
  38387. * @returns the current input manager
  38388. */
  38389. addKeyboard(): ArcRotateCameraInputsManager;
  38390. }
  38391. }
  38392. declare module BABYLON {
  38393. /**
  38394. * This represents an orbital type of camera.
  38395. *
  38396. * 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.
  38397. * 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.
  38398. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38399. */
  38400. export class ArcRotateCamera extends TargetCamera {
  38401. /**
  38402. * Defines the rotation angle of the camera along the longitudinal axis.
  38403. */
  38404. alpha: number;
  38405. /**
  38406. * Defines the rotation angle of the camera along the latitudinal axis.
  38407. */
  38408. beta: number;
  38409. /**
  38410. * Defines the radius of the camera from it s target point.
  38411. */
  38412. radius: number;
  38413. protected _target: Vector3;
  38414. protected _targetHost: Nullable<AbstractMesh>;
  38415. /**
  38416. * Defines the target point of the camera.
  38417. * The camera looks towards it form the radius distance.
  38418. */
  38419. get target(): Vector3;
  38420. set target(value: Vector3);
  38421. /**
  38422. * Define the current local position of the camera in the scene
  38423. */
  38424. get position(): Vector3;
  38425. set position(newPosition: Vector3);
  38426. protected _upVector: Vector3;
  38427. protected _upToYMatrix: Matrix;
  38428. protected _YToUpMatrix: Matrix;
  38429. /**
  38430. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38431. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38432. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38433. */
  38434. set upVector(vec: Vector3);
  38435. get upVector(): Vector3;
  38436. /**
  38437. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38438. */
  38439. setMatUp(): void;
  38440. /**
  38441. * Current inertia value on the longitudinal axis.
  38442. * The bigger this number the longer it will take for the camera to stop.
  38443. */
  38444. inertialAlphaOffset: number;
  38445. /**
  38446. * Current inertia value on the latitudinal axis.
  38447. * The bigger this number the longer it will take for the camera to stop.
  38448. */
  38449. inertialBetaOffset: number;
  38450. /**
  38451. * Current inertia value on the radius axis.
  38452. * The bigger this number the longer it will take for the camera to stop.
  38453. */
  38454. inertialRadiusOffset: number;
  38455. /**
  38456. * Minimum allowed angle on the longitudinal axis.
  38457. * This can help limiting how the Camera is able to move in the scene.
  38458. */
  38459. lowerAlphaLimit: Nullable<number>;
  38460. /**
  38461. * Maximum allowed angle on the longitudinal axis.
  38462. * This can help limiting how the Camera is able to move in the scene.
  38463. */
  38464. upperAlphaLimit: Nullable<number>;
  38465. /**
  38466. * Minimum allowed angle on the latitudinal axis.
  38467. * This can help limiting how the Camera is able to move in the scene.
  38468. */
  38469. lowerBetaLimit: number;
  38470. /**
  38471. * Maximum allowed angle on the latitudinal axis.
  38472. * This can help limiting how the Camera is able to move in the scene.
  38473. */
  38474. upperBetaLimit: number;
  38475. /**
  38476. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38477. * This can help limiting how the Camera is able to move in the scene.
  38478. */
  38479. lowerRadiusLimit: Nullable<number>;
  38480. /**
  38481. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38482. * This can help limiting how the Camera is able to move in the scene.
  38483. */
  38484. upperRadiusLimit: Nullable<number>;
  38485. /**
  38486. * Defines the current inertia value used during panning of the camera along the X axis.
  38487. */
  38488. inertialPanningX: number;
  38489. /**
  38490. * Defines the current inertia value used during panning of the camera along the Y axis.
  38491. */
  38492. inertialPanningY: number;
  38493. /**
  38494. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38495. * Basically if your fingers moves away from more than this distance you will be considered
  38496. * in pinch mode.
  38497. */
  38498. pinchToPanMaxDistance: number;
  38499. /**
  38500. * Defines the maximum distance the camera can pan.
  38501. * This could help keeping the cammera always in your scene.
  38502. */
  38503. panningDistanceLimit: Nullable<number>;
  38504. /**
  38505. * Defines the target of the camera before paning.
  38506. */
  38507. panningOriginTarget: Vector3;
  38508. /**
  38509. * Defines the value of the inertia used during panning.
  38510. * 0 would mean stop inertia and one would mean no decelleration at all.
  38511. */
  38512. panningInertia: number;
  38513. /**
  38514. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38515. */
  38516. get angularSensibilityX(): number;
  38517. set angularSensibilityX(value: number);
  38518. /**
  38519. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38520. */
  38521. get angularSensibilityY(): number;
  38522. set angularSensibilityY(value: number);
  38523. /**
  38524. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38525. */
  38526. get pinchPrecision(): number;
  38527. set pinchPrecision(value: number);
  38528. /**
  38529. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38530. * It will be used instead of pinchDeltaPrecision if different from 0.
  38531. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38532. */
  38533. get pinchDeltaPercentage(): number;
  38534. set pinchDeltaPercentage(value: number);
  38535. /**
  38536. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38537. */
  38538. get panningSensibility(): number;
  38539. set panningSensibility(value: number);
  38540. /**
  38541. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38542. */
  38543. get keysUp(): number[];
  38544. set keysUp(value: number[]);
  38545. /**
  38546. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38547. */
  38548. get keysDown(): number[];
  38549. set keysDown(value: number[]);
  38550. /**
  38551. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38552. */
  38553. get keysLeft(): number[];
  38554. set keysLeft(value: number[]);
  38555. /**
  38556. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38557. */
  38558. get keysRight(): number[];
  38559. set keysRight(value: number[]);
  38560. /**
  38561. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38562. */
  38563. get wheelPrecision(): number;
  38564. set wheelPrecision(value: number);
  38565. /**
  38566. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38567. * It will be used instead of pinchDeltaPrecision if different from 0.
  38568. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38569. */
  38570. get wheelDeltaPercentage(): number;
  38571. set wheelDeltaPercentage(value: number);
  38572. /**
  38573. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38574. */
  38575. zoomOnFactor: number;
  38576. /**
  38577. * Defines a screen offset for the camera position.
  38578. */
  38579. targetScreenOffset: Vector2;
  38580. /**
  38581. * Allows the camera to be completely reversed.
  38582. * If false the camera can not arrive upside down.
  38583. */
  38584. allowUpsideDown: boolean;
  38585. /**
  38586. * Define if double tap/click is used to restore the previously saved state of the camera.
  38587. */
  38588. useInputToRestoreState: boolean;
  38589. /** @hidden */
  38590. _viewMatrix: Matrix;
  38591. /** @hidden */
  38592. _useCtrlForPanning: boolean;
  38593. /** @hidden */
  38594. _panningMouseButton: number;
  38595. /**
  38596. * Defines the input associated to the camera.
  38597. */
  38598. inputs: ArcRotateCameraInputsManager;
  38599. /** @hidden */
  38600. _reset: () => void;
  38601. /**
  38602. * Defines the allowed panning axis.
  38603. */
  38604. panningAxis: Vector3;
  38605. protected _localDirection: Vector3;
  38606. protected _transformedDirection: Vector3;
  38607. private _bouncingBehavior;
  38608. /**
  38609. * Gets the bouncing behavior of the camera if it has been enabled.
  38610. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38611. */
  38612. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38613. /**
  38614. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38615. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38616. */
  38617. get useBouncingBehavior(): boolean;
  38618. set useBouncingBehavior(value: boolean);
  38619. private _framingBehavior;
  38620. /**
  38621. * Gets the framing behavior of the camera if it has been enabled.
  38622. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38623. */
  38624. get framingBehavior(): Nullable<FramingBehavior>;
  38625. /**
  38626. * Defines if the framing behavior of the camera is enabled on the camera.
  38627. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38628. */
  38629. get useFramingBehavior(): boolean;
  38630. set useFramingBehavior(value: boolean);
  38631. private _autoRotationBehavior;
  38632. /**
  38633. * Gets the auto rotation behavior of the camera if it has been enabled.
  38634. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38635. */
  38636. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38637. /**
  38638. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38639. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38640. */
  38641. get useAutoRotationBehavior(): boolean;
  38642. set useAutoRotationBehavior(value: boolean);
  38643. /**
  38644. * Observable triggered when the mesh target has been changed on the camera.
  38645. */
  38646. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38647. /**
  38648. * Event raised when the camera is colliding with a mesh.
  38649. */
  38650. onCollide: (collidedMesh: AbstractMesh) => void;
  38651. /**
  38652. * Defines whether the camera should check collision with the objects oh the scene.
  38653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38654. */
  38655. checkCollisions: boolean;
  38656. /**
  38657. * Defines the collision radius of the camera.
  38658. * This simulates a sphere around the camera.
  38659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38660. */
  38661. collisionRadius: Vector3;
  38662. protected _collider: Collider;
  38663. protected _previousPosition: Vector3;
  38664. protected _collisionVelocity: Vector3;
  38665. protected _newPosition: Vector3;
  38666. protected _previousAlpha: number;
  38667. protected _previousBeta: number;
  38668. protected _previousRadius: number;
  38669. protected _collisionTriggered: boolean;
  38670. protected _targetBoundingCenter: Nullable<Vector3>;
  38671. private _computationVector;
  38672. /**
  38673. * Instantiates a new ArcRotateCamera in a given scene
  38674. * @param name Defines the name of the camera
  38675. * @param alpha Defines the camera rotation along the logitudinal axis
  38676. * @param beta Defines the camera rotation along the latitudinal axis
  38677. * @param radius Defines the camera distance from its target
  38678. * @param target Defines the camera target
  38679. * @param scene Defines the scene the camera belongs to
  38680. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38681. */
  38682. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38683. /** @hidden */
  38684. _initCache(): void;
  38685. /** @hidden */
  38686. _updateCache(ignoreParentClass?: boolean): void;
  38687. protected _getTargetPosition(): Vector3;
  38688. private _storedAlpha;
  38689. private _storedBeta;
  38690. private _storedRadius;
  38691. private _storedTarget;
  38692. private _storedTargetScreenOffset;
  38693. /**
  38694. * Stores the current state of the camera (alpha, beta, radius and target)
  38695. * @returns the camera itself
  38696. */
  38697. storeState(): Camera;
  38698. /**
  38699. * @hidden
  38700. * Restored camera state. You must call storeState() first
  38701. */
  38702. _restoreStateValues(): boolean;
  38703. /** @hidden */
  38704. _isSynchronizedViewMatrix(): boolean;
  38705. /**
  38706. * Attached controls to the current camera.
  38707. * @param element Defines the element the controls should be listened from
  38708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38709. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38710. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38711. */
  38712. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38713. /**
  38714. * Detach the current controls from the camera.
  38715. * The camera will stop reacting to inputs.
  38716. * @param element Defines the element to stop listening the inputs from
  38717. */
  38718. detachControl(element: HTMLElement): void;
  38719. /** @hidden */
  38720. _checkInputs(): void;
  38721. protected _checkLimits(): void;
  38722. /**
  38723. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38724. */
  38725. rebuildAnglesAndRadius(): void;
  38726. /**
  38727. * Use a position to define the current camera related information like alpha, beta and radius
  38728. * @param position Defines the position to set the camera at
  38729. */
  38730. setPosition(position: Vector3): void;
  38731. /**
  38732. * Defines the target the camera should look at.
  38733. * This will automatically adapt alpha beta and radius to fit within the new target.
  38734. * @param target Defines the new target as a Vector or a mesh
  38735. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38736. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38737. */
  38738. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38739. /** @hidden */
  38740. _getViewMatrix(): Matrix;
  38741. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38742. /**
  38743. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38744. * @param meshes Defines the mesh to zoom on
  38745. * @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)
  38746. */
  38747. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38748. /**
  38749. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38750. * The target will be changed but the radius
  38751. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38752. * @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)
  38753. */
  38754. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38755. min: Vector3;
  38756. max: Vector3;
  38757. distance: number;
  38758. }, doNotUpdateMaxZ?: boolean): void;
  38759. /**
  38760. * @override
  38761. * Override Camera.createRigCamera
  38762. */
  38763. createRigCamera(name: string, cameraIndex: number): Camera;
  38764. /**
  38765. * @hidden
  38766. * @override
  38767. * Override Camera._updateRigCameras
  38768. */
  38769. _updateRigCameras(): void;
  38770. /**
  38771. * Destroy the camera and release the current resources hold by it.
  38772. */
  38773. dispose(): void;
  38774. /**
  38775. * Gets the current object class name.
  38776. * @return the class name
  38777. */
  38778. getClassName(): string;
  38779. }
  38780. }
  38781. declare module BABYLON {
  38782. /**
  38783. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38784. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38785. */
  38786. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38787. /**
  38788. * Gets the name of the behavior.
  38789. */
  38790. get name(): string;
  38791. private _zoomStopsAnimation;
  38792. private _idleRotationSpeed;
  38793. private _idleRotationWaitTime;
  38794. private _idleRotationSpinupTime;
  38795. /**
  38796. * Sets the flag that indicates if user zooming should stop animation.
  38797. */
  38798. set zoomStopsAnimation(flag: boolean);
  38799. /**
  38800. * Gets the flag that indicates if user zooming should stop animation.
  38801. */
  38802. get zoomStopsAnimation(): boolean;
  38803. /**
  38804. * Sets the default speed at which the camera rotates around the model.
  38805. */
  38806. set idleRotationSpeed(speed: number);
  38807. /**
  38808. * Gets the default speed at which the camera rotates around the model.
  38809. */
  38810. get idleRotationSpeed(): number;
  38811. /**
  38812. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38813. */
  38814. set idleRotationWaitTime(time: number);
  38815. /**
  38816. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38817. */
  38818. get idleRotationWaitTime(): number;
  38819. /**
  38820. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38821. */
  38822. set idleRotationSpinupTime(time: number);
  38823. /**
  38824. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38825. */
  38826. get idleRotationSpinupTime(): number;
  38827. /**
  38828. * Gets a value indicating if the camera is currently rotating because of this behavior
  38829. */
  38830. get rotationInProgress(): boolean;
  38831. private _onPrePointerObservableObserver;
  38832. private _onAfterCheckInputsObserver;
  38833. private _attachedCamera;
  38834. private _isPointerDown;
  38835. private _lastFrameTime;
  38836. private _lastInteractionTime;
  38837. private _cameraRotationSpeed;
  38838. /**
  38839. * Initializes the behavior.
  38840. */
  38841. init(): void;
  38842. /**
  38843. * Attaches the behavior to its arc rotate camera.
  38844. * @param camera Defines the camera to attach the behavior to
  38845. */
  38846. attach(camera: ArcRotateCamera): void;
  38847. /**
  38848. * Detaches the behavior from its current arc rotate camera.
  38849. */
  38850. detach(): void;
  38851. /**
  38852. * Returns true if user is scrolling.
  38853. * @return true if user is scrolling.
  38854. */
  38855. private _userIsZooming;
  38856. private _lastFrameRadius;
  38857. private _shouldAnimationStopForInteraction;
  38858. /**
  38859. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38860. */
  38861. private _applyUserInteraction;
  38862. private _userIsMoving;
  38863. }
  38864. }
  38865. declare module BABYLON {
  38866. /**
  38867. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38868. */
  38869. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38870. private ui;
  38871. /**
  38872. * The name of the behavior
  38873. */
  38874. name: string;
  38875. /**
  38876. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38877. */
  38878. distanceAwayFromFace: number;
  38879. /**
  38880. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38881. */
  38882. distanceAwayFromBottomOfFace: number;
  38883. private _faceVectors;
  38884. private _target;
  38885. private _scene;
  38886. private _onRenderObserver;
  38887. private _tmpMatrix;
  38888. private _tmpVector;
  38889. /**
  38890. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38891. * @param ui The transform node that should be attched to the mesh
  38892. */
  38893. constructor(ui: TransformNode);
  38894. /**
  38895. * Initializes the behavior
  38896. */
  38897. init(): void;
  38898. private _closestFace;
  38899. private _zeroVector;
  38900. private _lookAtTmpMatrix;
  38901. private _lookAtToRef;
  38902. /**
  38903. * Attaches the AttachToBoxBehavior to the passed in mesh
  38904. * @param target The mesh that the specified node will be attached to
  38905. */
  38906. attach(target: Mesh): void;
  38907. /**
  38908. * Detaches the behavior from the mesh
  38909. */
  38910. detach(): void;
  38911. }
  38912. }
  38913. declare module BABYLON {
  38914. /**
  38915. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38916. */
  38917. export class FadeInOutBehavior implements Behavior<Mesh> {
  38918. /**
  38919. * Time in milliseconds to delay before fading in (Default: 0)
  38920. */
  38921. delay: number;
  38922. /**
  38923. * Time in milliseconds for the mesh to fade in (Default: 300)
  38924. */
  38925. fadeInTime: number;
  38926. private _millisecondsPerFrame;
  38927. private _hovered;
  38928. private _hoverValue;
  38929. private _ownerNode;
  38930. /**
  38931. * Instatiates the FadeInOutBehavior
  38932. */
  38933. constructor();
  38934. /**
  38935. * The name of the behavior
  38936. */
  38937. get name(): string;
  38938. /**
  38939. * Initializes the behavior
  38940. */
  38941. init(): void;
  38942. /**
  38943. * Attaches the fade behavior on the passed in mesh
  38944. * @param ownerNode The mesh that will be faded in/out once attached
  38945. */
  38946. attach(ownerNode: Mesh): void;
  38947. /**
  38948. * Detaches the behavior from the mesh
  38949. */
  38950. detach(): void;
  38951. /**
  38952. * Triggers the mesh to begin fading in or out
  38953. * @param value if the object should fade in or out (true to fade in)
  38954. */
  38955. fadeIn(value: boolean): void;
  38956. private _update;
  38957. private _setAllVisibility;
  38958. }
  38959. }
  38960. declare module BABYLON {
  38961. /**
  38962. * Class containing a set of static utilities functions for managing Pivots
  38963. * @hidden
  38964. */
  38965. export class PivotTools {
  38966. private static _PivotCached;
  38967. private static _OldPivotPoint;
  38968. private static _PivotTranslation;
  38969. private static _PivotTmpVector;
  38970. /** @hidden */
  38971. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38972. /** @hidden */
  38973. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38974. }
  38975. }
  38976. declare module BABYLON {
  38977. /**
  38978. * Class containing static functions to help procedurally build meshes
  38979. */
  38980. export class PlaneBuilder {
  38981. /**
  38982. * Creates a plane mesh
  38983. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38984. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38985. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38987. * * 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
  38988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38989. * @param name defines the name of the mesh
  38990. * @param options defines the options used to create the mesh
  38991. * @param scene defines the hosting scene
  38992. * @returns the plane mesh
  38993. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38994. */
  38995. static CreatePlane(name: string, options: {
  38996. size?: number;
  38997. width?: number;
  38998. height?: number;
  38999. sideOrientation?: number;
  39000. frontUVs?: Vector4;
  39001. backUVs?: Vector4;
  39002. updatable?: boolean;
  39003. sourcePlane?: Plane;
  39004. }, scene?: Nullable<Scene>): Mesh;
  39005. }
  39006. }
  39007. declare module BABYLON {
  39008. /**
  39009. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39010. */
  39011. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39012. private static _AnyMouseID;
  39013. /**
  39014. * Abstract mesh the behavior is set on
  39015. */
  39016. attachedNode: AbstractMesh;
  39017. private _dragPlane;
  39018. private _scene;
  39019. private _pointerObserver;
  39020. private _beforeRenderObserver;
  39021. private static _planeScene;
  39022. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39023. /**
  39024. * 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)
  39025. */
  39026. maxDragAngle: number;
  39027. /**
  39028. * @hidden
  39029. */
  39030. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39031. /**
  39032. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39033. */
  39034. currentDraggingPointerID: number;
  39035. /**
  39036. * The last position where the pointer hit the drag plane in world space
  39037. */
  39038. lastDragPosition: Vector3;
  39039. /**
  39040. * If the behavior is currently in a dragging state
  39041. */
  39042. dragging: boolean;
  39043. /**
  39044. * 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)
  39045. */
  39046. dragDeltaRatio: number;
  39047. /**
  39048. * If the drag plane orientation should be updated during the dragging (Default: true)
  39049. */
  39050. updateDragPlane: boolean;
  39051. private _debugMode;
  39052. private _moving;
  39053. /**
  39054. * Fires each time the attached mesh is dragged with the pointer
  39055. * * delta between last drag position and current drag position in world space
  39056. * * dragDistance along the drag axis
  39057. * * dragPlaneNormal normal of the current drag plane used during the drag
  39058. * * dragPlanePoint in world space where the drag intersects the drag plane
  39059. */
  39060. onDragObservable: Observable<{
  39061. delta: Vector3;
  39062. dragPlanePoint: Vector3;
  39063. dragPlaneNormal: Vector3;
  39064. dragDistance: number;
  39065. pointerId: number;
  39066. }>;
  39067. /**
  39068. * Fires each time a drag begins (eg. mouse down on mesh)
  39069. */
  39070. onDragStartObservable: Observable<{
  39071. dragPlanePoint: Vector3;
  39072. pointerId: number;
  39073. }>;
  39074. /**
  39075. * Fires each time a drag ends (eg. mouse release after drag)
  39076. */
  39077. onDragEndObservable: Observable<{
  39078. dragPlanePoint: Vector3;
  39079. pointerId: number;
  39080. }>;
  39081. /**
  39082. * If the attached mesh should be moved when dragged
  39083. */
  39084. moveAttached: boolean;
  39085. /**
  39086. * If the drag behavior will react to drag events (Default: true)
  39087. */
  39088. enabled: boolean;
  39089. /**
  39090. * If pointer events should start and release the drag (Default: true)
  39091. */
  39092. startAndReleaseDragOnPointerEvents: boolean;
  39093. /**
  39094. * If camera controls should be detached during the drag
  39095. */
  39096. detachCameraControls: boolean;
  39097. /**
  39098. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39099. */
  39100. useObjectOrientationForDragging: boolean;
  39101. private _options;
  39102. /**
  39103. * Gets the options used by the behavior
  39104. */
  39105. get options(): {
  39106. dragAxis?: Vector3;
  39107. dragPlaneNormal?: Vector3;
  39108. };
  39109. /**
  39110. * Sets the options used by the behavior
  39111. */
  39112. set options(options: {
  39113. dragAxis?: Vector3;
  39114. dragPlaneNormal?: Vector3;
  39115. });
  39116. /**
  39117. * Creates a pointer drag behavior that can be attached to a mesh
  39118. * @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)
  39119. */
  39120. constructor(options?: {
  39121. dragAxis?: Vector3;
  39122. dragPlaneNormal?: Vector3;
  39123. });
  39124. /**
  39125. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39126. */
  39127. validateDrag: (targetPosition: Vector3) => boolean;
  39128. /**
  39129. * The name of the behavior
  39130. */
  39131. get name(): string;
  39132. /**
  39133. * Initializes the behavior
  39134. */
  39135. init(): void;
  39136. private _tmpVector;
  39137. private _alternatePickedPoint;
  39138. private _worldDragAxis;
  39139. private _targetPosition;
  39140. private _attachedElement;
  39141. /**
  39142. * Attaches the drag behavior the passed in mesh
  39143. * @param ownerNode The mesh that will be dragged around once attached
  39144. * @param predicate Predicate to use for pick filtering
  39145. */
  39146. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39147. /**
  39148. * Force relase the drag action by code.
  39149. */
  39150. releaseDrag(): void;
  39151. private _startDragRay;
  39152. private _lastPointerRay;
  39153. /**
  39154. * Simulates the start of a pointer drag event on the behavior
  39155. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39156. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39157. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39158. */
  39159. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39160. private _startDrag;
  39161. private _dragDelta;
  39162. private _moveDrag;
  39163. private _pickWithRayOnDragPlane;
  39164. private _pointA;
  39165. private _pointB;
  39166. private _pointC;
  39167. private _lineA;
  39168. private _lineB;
  39169. private _localAxis;
  39170. private _lookAt;
  39171. private _updateDragPlanePosition;
  39172. /**
  39173. * Detaches the behavior from the mesh
  39174. */
  39175. detach(): void;
  39176. }
  39177. }
  39178. declare module BABYLON {
  39179. /**
  39180. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39181. */
  39182. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39183. private _dragBehaviorA;
  39184. private _dragBehaviorB;
  39185. private _startDistance;
  39186. private _initialScale;
  39187. private _targetScale;
  39188. private _ownerNode;
  39189. private _sceneRenderObserver;
  39190. /**
  39191. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39192. */
  39193. constructor();
  39194. /**
  39195. * The name of the behavior
  39196. */
  39197. get name(): string;
  39198. /**
  39199. * Initializes the behavior
  39200. */
  39201. init(): void;
  39202. private _getCurrentDistance;
  39203. /**
  39204. * Attaches the scale behavior the passed in mesh
  39205. * @param ownerNode The mesh that will be scaled around once attached
  39206. */
  39207. attach(ownerNode: Mesh): void;
  39208. /**
  39209. * Detaches the behavior from the mesh
  39210. */
  39211. detach(): void;
  39212. }
  39213. }
  39214. declare module BABYLON {
  39215. /**
  39216. * 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
  39217. */
  39218. export class SixDofDragBehavior implements Behavior<Mesh> {
  39219. private static _virtualScene;
  39220. private _ownerNode;
  39221. private _sceneRenderObserver;
  39222. private _scene;
  39223. private _targetPosition;
  39224. private _virtualOriginMesh;
  39225. private _virtualDragMesh;
  39226. private _pointerObserver;
  39227. private _moving;
  39228. private _startingOrientation;
  39229. /**
  39230. * 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)
  39231. */
  39232. private zDragFactor;
  39233. /**
  39234. * If the object should rotate to face the drag origin
  39235. */
  39236. rotateDraggedObject: boolean;
  39237. /**
  39238. * If the behavior is currently in a dragging state
  39239. */
  39240. dragging: boolean;
  39241. /**
  39242. * 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)
  39243. */
  39244. dragDeltaRatio: number;
  39245. /**
  39246. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39247. */
  39248. currentDraggingPointerID: number;
  39249. /**
  39250. * If camera controls should be detached during the drag
  39251. */
  39252. detachCameraControls: boolean;
  39253. /**
  39254. * Fires each time a drag starts
  39255. */
  39256. onDragStartObservable: Observable<{}>;
  39257. /**
  39258. * Fires each time a drag ends (eg. mouse release after drag)
  39259. */
  39260. onDragEndObservable: Observable<{}>;
  39261. /**
  39262. * 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
  39263. */
  39264. constructor();
  39265. /**
  39266. * The name of the behavior
  39267. */
  39268. get name(): string;
  39269. /**
  39270. * Initializes the behavior
  39271. */
  39272. init(): void;
  39273. /**
  39274. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39275. */
  39276. private get _pointerCamera();
  39277. /**
  39278. * Attaches the scale behavior the passed in mesh
  39279. * @param ownerNode The mesh that will be scaled around once attached
  39280. */
  39281. attach(ownerNode: Mesh): void;
  39282. /**
  39283. * Detaches the behavior from the mesh
  39284. */
  39285. detach(): void;
  39286. }
  39287. }
  39288. declare module BABYLON {
  39289. /**
  39290. * Class used to apply inverse kinematics to bones
  39291. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39292. */
  39293. export class BoneIKController {
  39294. private static _tmpVecs;
  39295. private static _tmpQuat;
  39296. private static _tmpMats;
  39297. /**
  39298. * Gets or sets the target mesh
  39299. */
  39300. targetMesh: AbstractMesh;
  39301. /** Gets or sets the mesh used as pole */
  39302. poleTargetMesh: AbstractMesh;
  39303. /**
  39304. * Gets or sets the bone used as pole
  39305. */
  39306. poleTargetBone: Nullable<Bone>;
  39307. /**
  39308. * Gets or sets the target position
  39309. */
  39310. targetPosition: Vector3;
  39311. /**
  39312. * Gets or sets the pole target position
  39313. */
  39314. poleTargetPosition: Vector3;
  39315. /**
  39316. * Gets or sets the pole target local offset
  39317. */
  39318. poleTargetLocalOffset: Vector3;
  39319. /**
  39320. * Gets or sets the pole angle
  39321. */
  39322. poleAngle: number;
  39323. /**
  39324. * Gets or sets the mesh associated with the controller
  39325. */
  39326. mesh: AbstractMesh;
  39327. /**
  39328. * 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)
  39329. */
  39330. slerpAmount: number;
  39331. private _bone1Quat;
  39332. private _bone1Mat;
  39333. private _bone2Ang;
  39334. private _bone1;
  39335. private _bone2;
  39336. private _bone1Length;
  39337. private _bone2Length;
  39338. private _maxAngle;
  39339. private _maxReach;
  39340. private _rightHandedSystem;
  39341. private _bendAxis;
  39342. private _slerping;
  39343. private _adjustRoll;
  39344. /**
  39345. * Gets or sets maximum allowed angle
  39346. */
  39347. get maxAngle(): number;
  39348. set maxAngle(value: number);
  39349. /**
  39350. * Creates a new BoneIKController
  39351. * @param mesh defines the mesh to control
  39352. * @param bone defines the bone to control
  39353. * @param options defines options to set up the controller
  39354. */
  39355. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39356. targetMesh?: AbstractMesh;
  39357. poleTargetMesh?: AbstractMesh;
  39358. poleTargetBone?: Bone;
  39359. poleTargetLocalOffset?: Vector3;
  39360. poleAngle?: number;
  39361. bendAxis?: Vector3;
  39362. maxAngle?: number;
  39363. slerpAmount?: number;
  39364. });
  39365. private _setMaxAngle;
  39366. /**
  39367. * Force the controller to update the bones
  39368. */
  39369. update(): void;
  39370. }
  39371. }
  39372. declare module BABYLON {
  39373. /**
  39374. * Class used to make a bone look toward a point in space
  39375. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39376. */
  39377. export class BoneLookController {
  39378. private static _tmpVecs;
  39379. private static _tmpQuat;
  39380. private static _tmpMats;
  39381. /**
  39382. * The target Vector3 that the bone will look at
  39383. */
  39384. target: Vector3;
  39385. /**
  39386. * The mesh that the bone is attached to
  39387. */
  39388. mesh: AbstractMesh;
  39389. /**
  39390. * The bone that will be looking to the target
  39391. */
  39392. bone: Bone;
  39393. /**
  39394. * The up axis of the coordinate system that is used when the bone is rotated
  39395. */
  39396. upAxis: Vector3;
  39397. /**
  39398. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39399. */
  39400. upAxisSpace: Space;
  39401. /**
  39402. * Used to make an adjustment to the yaw of the bone
  39403. */
  39404. adjustYaw: number;
  39405. /**
  39406. * Used to make an adjustment to the pitch of the bone
  39407. */
  39408. adjustPitch: number;
  39409. /**
  39410. * Used to make an adjustment to the roll of the bone
  39411. */
  39412. adjustRoll: number;
  39413. /**
  39414. * 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)
  39415. */
  39416. slerpAmount: number;
  39417. private _minYaw;
  39418. private _maxYaw;
  39419. private _minPitch;
  39420. private _maxPitch;
  39421. private _minYawSin;
  39422. private _minYawCos;
  39423. private _maxYawSin;
  39424. private _maxYawCos;
  39425. private _midYawConstraint;
  39426. private _minPitchTan;
  39427. private _maxPitchTan;
  39428. private _boneQuat;
  39429. private _slerping;
  39430. private _transformYawPitch;
  39431. private _transformYawPitchInv;
  39432. private _firstFrameSkipped;
  39433. private _yawRange;
  39434. private _fowardAxis;
  39435. /**
  39436. * Gets or sets the minimum yaw angle that the bone can look to
  39437. */
  39438. get minYaw(): number;
  39439. set minYaw(value: number);
  39440. /**
  39441. * Gets or sets the maximum yaw angle that the bone can look to
  39442. */
  39443. get maxYaw(): number;
  39444. set maxYaw(value: number);
  39445. /**
  39446. * Gets or sets the minimum pitch angle that the bone can look to
  39447. */
  39448. get minPitch(): number;
  39449. set minPitch(value: number);
  39450. /**
  39451. * Gets or sets the maximum pitch angle that the bone can look to
  39452. */
  39453. get maxPitch(): number;
  39454. set maxPitch(value: number);
  39455. /**
  39456. * Create a BoneLookController
  39457. * @param mesh the mesh that the bone belongs to
  39458. * @param bone the bone that will be looking to the target
  39459. * @param target the target Vector3 to look at
  39460. * @param options optional settings:
  39461. * * maxYaw: the maximum angle the bone will yaw to
  39462. * * minYaw: the minimum angle the bone will yaw to
  39463. * * maxPitch: the maximum angle the bone will pitch to
  39464. * * minPitch: the minimum angle the bone will yaw to
  39465. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39466. * * upAxis: the up axis of the coordinate system
  39467. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39468. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39469. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39470. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39471. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39472. * * adjustRoll: used to make an adjustment to the roll of the bone
  39473. **/
  39474. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39475. maxYaw?: number;
  39476. minYaw?: number;
  39477. maxPitch?: number;
  39478. minPitch?: number;
  39479. slerpAmount?: number;
  39480. upAxis?: Vector3;
  39481. upAxisSpace?: Space;
  39482. yawAxis?: Vector3;
  39483. pitchAxis?: Vector3;
  39484. adjustYaw?: number;
  39485. adjustPitch?: number;
  39486. adjustRoll?: number;
  39487. });
  39488. /**
  39489. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39490. */
  39491. update(): void;
  39492. private _getAngleDiff;
  39493. private _getAngleBetween;
  39494. private _isAngleBetween;
  39495. }
  39496. }
  39497. declare module BABYLON {
  39498. /**
  39499. * Manage the gamepad inputs to control an arc rotate camera.
  39500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39501. */
  39502. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39503. /**
  39504. * Defines the camera the input is attached to.
  39505. */
  39506. camera: ArcRotateCamera;
  39507. /**
  39508. * Defines the gamepad the input is gathering event from.
  39509. */
  39510. gamepad: Nullable<Gamepad>;
  39511. /**
  39512. * Defines the gamepad rotation sensiblity.
  39513. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39514. */
  39515. gamepadRotationSensibility: number;
  39516. /**
  39517. * Defines the gamepad move sensiblity.
  39518. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39519. */
  39520. gamepadMoveSensibility: number;
  39521. private _yAxisScale;
  39522. /**
  39523. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39524. */
  39525. get invertYAxis(): boolean;
  39526. set invertYAxis(value: boolean);
  39527. private _onGamepadConnectedObserver;
  39528. private _onGamepadDisconnectedObserver;
  39529. /**
  39530. * Attach the input controls to a specific dom element to get the input from.
  39531. * @param element Defines the element the controls should be listened from
  39532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39533. */
  39534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39535. /**
  39536. * Detach the current controls from the specified dom element.
  39537. * @param element Defines the element to stop listening the inputs from
  39538. */
  39539. detachControl(element: Nullable<HTMLElement>): void;
  39540. /**
  39541. * Update the current camera state depending on the inputs that have been used this frame.
  39542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39543. */
  39544. checkInputs(): void;
  39545. /**
  39546. * Gets the class name of the current intput.
  39547. * @returns the class name
  39548. */
  39549. getClassName(): string;
  39550. /**
  39551. * Get the friendly name associated with the input class.
  39552. * @returns the input friendly name
  39553. */
  39554. getSimpleName(): string;
  39555. }
  39556. }
  39557. declare module BABYLON {
  39558. interface ArcRotateCameraInputsManager {
  39559. /**
  39560. * Add orientation input support to the input manager.
  39561. * @returns the current input manager
  39562. */
  39563. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39564. }
  39565. /**
  39566. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39568. */
  39569. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39570. /**
  39571. * Defines the camera the input is attached to.
  39572. */
  39573. camera: ArcRotateCamera;
  39574. /**
  39575. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39576. */
  39577. alphaCorrection: number;
  39578. /**
  39579. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39580. */
  39581. gammaCorrection: number;
  39582. private _alpha;
  39583. private _gamma;
  39584. private _dirty;
  39585. private _deviceOrientationHandler;
  39586. /**
  39587. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39588. */
  39589. constructor();
  39590. /**
  39591. * Attach the input controls to a specific dom element to get the input from.
  39592. * @param element Defines the element the controls should be listened from
  39593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39594. */
  39595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39596. /** @hidden */
  39597. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39598. /**
  39599. * Update the current camera state depending on the inputs that have been used this frame.
  39600. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39601. */
  39602. checkInputs(): void;
  39603. /**
  39604. * Detach the current controls from the specified dom element.
  39605. * @param element Defines the element to stop listening the inputs from
  39606. */
  39607. detachControl(element: Nullable<HTMLElement>): void;
  39608. /**
  39609. * Gets the class name of the current intput.
  39610. * @returns the class name
  39611. */
  39612. getClassName(): string;
  39613. /**
  39614. * Get the friendly name associated with the input class.
  39615. * @returns the input friendly name
  39616. */
  39617. getSimpleName(): string;
  39618. }
  39619. }
  39620. declare module BABYLON {
  39621. /**
  39622. * Listen to mouse events to control the camera.
  39623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39624. */
  39625. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39626. /**
  39627. * Defines the camera the input is attached to.
  39628. */
  39629. camera: FlyCamera;
  39630. /**
  39631. * Defines if touch is enabled. (Default is true.)
  39632. */
  39633. touchEnabled: boolean;
  39634. /**
  39635. * Defines the buttons associated with the input to handle camera rotation.
  39636. */
  39637. buttons: number[];
  39638. /**
  39639. * Assign buttons for Yaw control.
  39640. */
  39641. buttonsYaw: number[];
  39642. /**
  39643. * Assign buttons for Pitch control.
  39644. */
  39645. buttonsPitch: number[];
  39646. /**
  39647. * Assign buttons for Roll control.
  39648. */
  39649. buttonsRoll: number[];
  39650. /**
  39651. * Detect if any button is being pressed while mouse is moved.
  39652. * -1 = Mouse locked.
  39653. * 0 = Left button.
  39654. * 1 = Middle Button.
  39655. * 2 = Right Button.
  39656. */
  39657. activeButton: number;
  39658. /**
  39659. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39660. * Higher values reduce its sensitivity.
  39661. */
  39662. angularSensibility: number;
  39663. private _mousemoveCallback;
  39664. private _observer;
  39665. private _rollObserver;
  39666. private previousPosition;
  39667. private noPreventDefault;
  39668. private element;
  39669. /**
  39670. * Listen to mouse events to control the camera.
  39671. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39673. */
  39674. constructor(touchEnabled?: boolean);
  39675. /**
  39676. * Attach the mouse control to the HTML DOM element.
  39677. * @param element Defines the element that listens to the input events.
  39678. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39679. */
  39680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39681. /**
  39682. * Detach the current controls from the specified dom element.
  39683. * @param element Defines the element to stop listening the inputs from
  39684. */
  39685. detachControl(element: Nullable<HTMLElement>): void;
  39686. /**
  39687. * Gets the class name of the current input.
  39688. * @returns the class name.
  39689. */
  39690. getClassName(): string;
  39691. /**
  39692. * Get the friendly name associated with the input class.
  39693. * @returns the input's friendly name.
  39694. */
  39695. getSimpleName(): string;
  39696. private _pointerInput;
  39697. private _onMouseMove;
  39698. /**
  39699. * Rotate camera by mouse offset.
  39700. */
  39701. private rotateCamera;
  39702. }
  39703. }
  39704. declare module BABYLON {
  39705. /**
  39706. * Default Inputs manager for the FlyCamera.
  39707. * It groups all the default supported inputs for ease of use.
  39708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39709. */
  39710. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39711. /**
  39712. * Instantiates a new FlyCameraInputsManager.
  39713. * @param camera Defines the camera the inputs belong to.
  39714. */
  39715. constructor(camera: FlyCamera);
  39716. /**
  39717. * Add keyboard input support to the input manager.
  39718. * @returns the new FlyCameraKeyboardMoveInput().
  39719. */
  39720. addKeyboard(): FlyCameraInputsManager;
  39721. /**
  39722. * Add mouse input support to the input manager.
  39723. * @param touchEnabled Enable touch screen support.
  39724. * @returns the new FlyCameraMouseInput().
  39725. */
  39726. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39727. }
  39728. }
  39729. declare module BABYLON {
  39730. /**
  39731. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39732. * such as in a 3D Space Shooter or a Flight Simulator.
  39733. */
  39734. export class FlyCamera extends TargetCamera {
  39735. /**
  39736. * Define the collision ellipsoid of the camera.
  39737. * This is helpful for simulating a camera body, like a player's body.
  39738. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39739. */
  39740. ellipsoid: Vector3;
  39741. /**
  39742. * Define an offset for the position of the ellipsoid around the camera.
  39743. * This can be helpful if the camera is attached away from the player's body center,
  39744. * such as at its head.
  39745. */
  39746. ellipsoidOffset: Vector3;
  39747. /**
  39748. * Enable or disable collisions of the camera with the rest of the scene objects.
  39749. */
  39750. checkCollisions: boolean;
  39751. /**
  39752. * Enable or disable gravity on the camera.
  39753. */
  39754. applyGravity: boolean;
  39755. /**
  39756. * Define the current direction the camera is moving to.
  39757. */
  39758. cameraDirection: Vector3;
  39759. /**
  39760. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39761. * This overrides and empties cameraRotation.
  39762. */
  39763. rotationQuaternion: Quaternion;
  39764. /**
  39765. * Track Roll to maintain the wanted Rolling when looking around.
  39766. */
  39767. _trackRoll: number;
  39768. /**
  39769. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39770. */
  39771. rollCorrect: number;
  39772. /**
  39773. * Mimic a banked turn, Rolling the camera when Yawing.
  39774. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39775. */
  39776. bankedTurn: boolean;
  39777. /**
  39778. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39779. */
  39780. bankedTurnLimit: number;
  39781. /**
  39782. * Value of 0 disables the banked Roll.
  39783. * Value of 1 is equal to the Yaw angle in radians.
  39784. */
  39785. bankedTurnMultiplier: number;
  39786. /**
  39787. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39788. */
  39789. inputs: FlyCameraInputsManager;
  39790. /**
  39791. * Gets the input sensibility for mouse input.
  39792. * Higher values reduce sensitivity.
  39793. */
  39794. get angularSensibility(): number;
  39795. /**
  39796. * Sets the input sensibility for a mouse input.
  39797. * Higher values reduce sensitivity.
  39798. */
  39799. set angularSensibility(value: number);
  39800. /**
  39801. * Get the keys for camera movement forward.
  39802. */
  39803. get keysForward(): number[];
  39804. /**
  39805. * Set the keys for camera movement forward.
  39806. */
  39807. set keysForward(value: number[]);
  39808. /**
  39809. * Get the keys for camera movement backward.
  39810. */
  39811. get keysBackward(): number[];
  39812. set keysBackward(value: number[]);
  39813. /**
  39814. * Get the keys for camera movement up.
  39815. */
  39816. get keysUp(): number[];
  39817. /**
  39818. * Set the keys for camera movement up.
  39819. */
  39820. set keysUp(value: number[]);
  39821. /**
  39822. * Get the keys for camera movement down.
  39823. */
  39824. get keysDown(): number[];
  39825. /**
  39826. * Set the keys for camera movement down.
  39827. */
  39828. set keysDown(value: number[]);
  39829. /**
  39830. * Get the keys for camera movement left.
  39831. */
  39832. get keysLeft(): number[];
  39833. /**
  39834. * Set the keys for camera movement left.
  39835. */
  39836. set keysLeft(value: number[]);
  39837. /**
  39838. * Set the keys for camera movement right.
  39839. */
  39840. get keysRight(): number[];
  39841. /**
  39842. * Set the keys for camera movement right.
  39843. */
  39844. set keysRight(value: number[]);
  39845. /**
  39846. * Event raised when the camera collides with a mesh in the scene.
  39847. */
  39848. onCollide: (collidedMesh: AbstractMesh) => void;
  39849. private _collider;
  39850. private _needMoveForGravity;
  39851. private _oldPosition;
  39852. private _diffPosition;
  39853. private _newPosition;
  39854. /** @hidden */
  39855. _localDirection: Vector3;
  39856. /** @hidden */
  39857. _transformedDirection: Vector3;
  39858. /**
  39859. * Instantiates a FlyCamera.
  39860. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39861. * such as in a 3D Space Shooter or a Flight Simulator.
  39862. * @param name Define the name of the camera in the scene.
  39863. * @param position Define the starting position of the camera in the scene.
  39864. * @param scene Define the scene the camera belongs to.
  39865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39866. */
  39867. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39868. /**
  39869. * Attach a control to the HTML DOM element.
  39870. * @param element Defines the element that listens to the input events.
  39871. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39872. */
  39873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39874. /**
  39875. * Detach a control from the HTML DOM element.
  39876. * The camera will stop reacting to that input.
  39877. * @param element Defines the element that listens to the input events.
  39878. */
  39879. detachControl(element: HTMLElement): void;
  39880. private _collisionMask;
  39881. /**
  39882. * Get the mask that the camera ignores in collision events.
  39883. */
  39884. get collisionMask(): number;
  39885. /**
  39886. * Set the mask that the camera ignores in collision events.
  39887. */
  39888. set collisionMask(mask: number);
  39889. /** @hidden */
  39890. _collideWithWorld(displacement: Vector3): void;
  39891. /** @hidden */
  39892. private _onCollisionPositionChange;
  39893. /** @hidden */
  39894. _checkInputs(): void;
  39895. /** @hidden */
  39896. _decideIfNeedsToMove(): boolean;
  39897. /** @hidden */
  39898. _updatePosition(): void;
  39899. /**
  39900. * Restore the Roll to its target value at the rate specified.
  39901. * @param rate - Higher means slower restoring.
  39902. * @hidden
  39903. */
  39904. restoreRoll(rate: number): void;
  39905. /**
  39906. * Destroy the camera and release the current resources held by it.
  39907. */
  39908. dispose(): void;
  39909. /**
  39910. * Get the current object class name.
  39911. * @returns the class name.
  39912. */
  39913. getClassName(): string;
  39914. }
  39915. }
  39916. declare module BABYLON {
  39917. /**
  39918. * Listen to keyboard events to control the camera.
  39919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39920. */
  39921. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39922. /**
  39923. * Defines the camera the input is attached to.
  39924. */
  39925. camera: FlyCamera;
  39926. /**
  39927. * The list of keyboard keys used to control the forward move of the camera.
  39928. */
  39929. keysForward: number[];
  39930. /**
  39931. * The list of keyboard keys used to control the backward move of the camera.
  39932. */
  39933. keysBackward: number[];
  39934. /**
  39935. * The list of keyboard keys used to control the forward move of the camera.
  39936. */
  39937. keysUp: number[];
  39938. /**
  39939. * The list of keyboard keys used to control the backward move of the camera.
  39940. */
  39941. keysDown: number[];
  39942. /**
  39943. * The list of keyboard keys used to control the right strafe move of the camera.
  39944. */
  39945. keysRight: number[];
  39946. /**
  39947. * The list of keyboard keys used to control the left strafe move of the camera.
  39948. */
  39949. keysLeft: number[];
  39950. private _keys;
  39951. private _onCanvasBlurObserver;
  39952. private _onKeyboardObserver;
  39953. private _engine;
  39954. private _scene;
  39955. /**
  39956. * Attach the input controls to a specific dom element to get the input from.
  39957. * @param element Defines the element the controls should be listened from
  39958. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39959. */
  39960. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39961. /**
  39962. * Detach the current controls from the specified dom element.
  39963. * @param element Defines the element to stop listening the inputs from
  39964. */
  39965. detachControl(element: Nullable<HTMLElement>): void;
  39966. /**
  39967. * Gets the class name of the current intput.
  39968. * @returns the class name
  39969. */
  39970. getClassName(): string;
  39971. /** @hidden */
  39972. _onLostFocus(e: FocusEvent): void;
  39973. /**
  39974. * Get the friendly name associated with the input class.
  39975. * @returns the input friendly name
  39976. */
  39977. getSimpleName(): string;
  39978. /**
  39979. * Update the current camera state depending on the inputs that have been used this frame.
  39980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39981. */
  39982. checkInputs(): void;
  39983. }
  39984. }
  39985. declare module BABYLON {
  39986. /**
  39987. * Manage the mouse wheel inputs to control a follow camera.
  39988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39989. */
  39990. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39991. /**
  39992. * Defines the camera the input is attached to.
  39993. */
  39994. camera: FollowCamera;
  39995. /**
  39996. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39997. */
  39998. axisControlRadius: boolean;
  39999. /**
  40000. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40001. */
  40002. axisControlHeight: boolean;
  40003. /**
  40004. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40005. */
  40006. axisControlRotation: boolean;
  40007. /**
  40008. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40009. * relation to mouseWheel events.
  40010. */
  40011. wheelPrecision: number;
  40012. /**
  40013. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40014. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40015. */
  40016. wheelDeltaPercentage: number;
  40017. private _wheel;
  40018. private _observer;
  40019. /**
  40020. * Attach the input controls to a specific dom element to get the input from.
  40021. * @param element Defines the element the controls should be listened from
  40022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40023. */
  40024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40025. /**
  40026. * Detach the current controls from the specified dom element.
  40027. * @param element Defines the element to stop listening the inputs from
  40028. */
  40029. detachControl(element: Nullable<HTMLElement>): void;
  40030. /**
  40031. * Gets the class name of the current intput.
  40032. * @returns the class name
  40033. */
  40034. getClassName(): string;
  40035. /**
  40036. * Get the friendly name associated with the input class.
  40037. * @returns the input friendly name
  40038. */
  40039. getSimpleName(): string;
  40040. }
  40041. }
  40042. declare module BABYLON {
  40043. /**
  40044. * Manage the pointers inputs to control an follow camera.
  40045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40046. */
  40047. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40048. /**
  40049. * Defines the camera the input is attached to.
  40050. */
  40051. camera: FollowCamera;
  40052. /**
  40053. * Gets the class name of the current input.
  40054. * @returns the class name
  40055. */
  40056. getClassName(): string;
  40057. /**
  40058. * Defines the pointer angular sensibility along the X axis or how fast is
  40059. * the camera rotating.
  40060. * A negative number will reverse the axis direction.
  40061. */
  40062. angularSensibilityX: number;
  40063. /**
  40064. * Defines the pointer angular sensibility along the Y axis or how fast is
  40065. * the camera rotating.
  40066. * A negative number will reverse the axis direction.
  40067. */
  40068. angularSensibilityY: number;
  40069. /**
  40070. * Defines the pointer pinch precision or how fast is the camera zooming.
  40071. * A negative number will reverse the axis direction.
  40072. */
  40073. pinchPrecision: number;
  40074. /**
  40075. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40076. * from 0.
  40077. * It defines the percentage of current camera.radius to use as delta when
  40078. * pinch zoom is used.
  40079. */
  40080. pinchDeltaPercentage: number;
  40081. /**
  40082. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40083. */
  40084. axisXControlRadius: boolean;
  40085. /**
  40086. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40087. */
  40088. axisXControlHeight: boolean;
  40089. /**
  40090. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40091. */
  40092. axisXControlRotation: boolean;
  40093. /**
  40094. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40095. */
  40096. axisYControlRadius: boolean;
  40097. /**
  40098. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40099. */
  40100. axisYControlHeight: boolean;
  40101. /**
  40102. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40103. */
  40104. axisYControlRotation: boolean;
  40105. /**
  40106. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40107. */
  40108. axisPinchControlRadius: boolean;
  40109. /**
  40110. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40111. */
  40112. axisPinchControlHeight: boolean;
  40113. /**
  40114. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40115. */
  40116. axisPinchControlRotation: boolean;
  40117. /**
  40118. * Log error messages if basic misconfiguration has occurred.
  40119. */
  40120. warningEnable: boolean;
  40121. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40122. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40123. private _warningCounter;
  40124. private _warning;
  40125. }
  40126. }
  40127. declare module BABYLON {
  40128. /**
  40129. * Default Inputs manager for the FollowCamera.
  40130. * It groups all the default supported inputs for ease of use.
  40131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40132. */
  40133. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40134. /**
  40135. * Instantiates a new FollowCameraInputsManager.
  40136. * @param camera Defines the camera the inputs belong to
  40137. */
  40138. constructor(camera: FollowCamera);
  40139. /**
  40140. * Add keyboard input support to the input manager.
  40141. * @returns the current input manager
  40142. */
  40143. addKeyboard(): FollowCameraInputsManager;
  40144. /**
  40145. * Add mouse wheel input support to the input manager.
  40146. * @returns the current input manager
  40147. */
  40148. addMouseWheel(): FollowCameraInputsManager;
  40149. /**
  40150. * Add pointers input support to the input manager.
  40151. * @returns the current input manager
  40152. */
  40153. addPointers(): FollowCameraInputsManager;
  40154. /**
  40155. * Add orientation input support to the input manager.
  40156. * @returns the current input manager
  40157. */
  40158. addVRDeviceOrientation(): FollowCameraInputsManager;
  40159. }
  40160. }
  40161. declare module BABYLON {
  40162. /**
  40163. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40164. * an arc rotate version arcFollowCamera are available.
  40165. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40166. */
  40167. export class FollowCamera extends TargetCamera {
  40168. /**
  40169. * Distance the follow camera should follow an object at
  40170. */
  40171. radius: number;
  40172. /**
  40173. * Minimum allowed distance of the camera to the axis of rotation
  40174. * (The camera can not get closer).
  40175. * This can help limiting how the Camera is able to move in the scene.
  40176. */
  40177. lowerRadiusLimit: Nullable<number>;
  40178. /**
  40179. * Maximum allowed distance of the camera to the axis of rotation
  40180. * (The camera can not get further).
  40181. * This can help limiting how the Camera is able to move in the scene.
  40182. */
  40183. upperRadiusLimit: Nullable<number>;
  40184. /**
  40185. * Define a rotation offset between the camera and the object it follows
  40186. */
  40187. rotationOffset: number;
  40188. /**
  40189. * Minimum allowed angle to camera position relative to target object.
  40190. * This can help limiting how the Camera is able to move in the scene.
  40191. */
  40192. lowerRotationOffsetLimit: Nullable<number>;
  40193. /**
  40194. * Maximum allowed angle to camera position relative to target object.
  40195. * This can help limiting how the Camera is able to move in the scene.
  40196. */
  40197. upperRotationOffsetLimit: Nullable<number>;
  40198. /**
  40199. * Define a height offset between the camera and the object it follows.
  40200. * It can help following an object from the top (like a car chaing a plane)
  40201. */
  40202. heightOffset: number;
  40203. /**
  40204. * Minimum allowed height of camera position relative to target object.
  40205. * This can help limiting how the Camera is able to move in the scene.
  40206. */
  40207. lowerHeightOffsetLimit: Nullable<number>;
  40208. /**
  40209. * Maximum allowed height of camera position relative to target object.
  40210. * This can help limiting how the Camera is able to move in the scene.
  40211. */
  40212. upperHeightOffsetLimit: Nullable<number>;
  40213. /**
  40214. * Define how fast the camera can accelerate to follow it s target.
  40215. */
  40216. cameraAcceleration: number;
  40217. /**
  40218. * Define the speed limit of the camera following an object.
  40219. */
  40220. maxCameraSpeed: number;
  40221. /**
  40222. * Define the target of the camera.
  40223. */
  40224. lockedTarget: Nullable<AbstractMesh>;
  40225. /**
  40226. * Defines the input associated with the camera.
  40227. */
  40228. inputs: FollowCameraInputsManager;
  40229. /**
  40230. * Instantiates the follow camera.
  40231. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40232. * @param name Define the name of the camera in the scene
  40233. * @param position Define the position of the camera
  40234. * @param scene Define the scene the camera belong to
  40235. * @param lockedTarget Define the target of the camera
  40236. */
  40237. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40238. private _follow;
  40239. /**
  40240. * Attached controls to the current camera.
  40241. * @param element Defines the element the controls should be listened from
  40242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40243. */
  40244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40245. /**
  40246. * Detach the current controls from the camera.
  40247. * The camera will stop reacting to inputs.
  40248. * @param element Defines the element to stop listening the inputs from
  40249. */
  40250. detachControl(element: HTMLElement): void;
  40251. /** @hidden */
  40252. _checkInputs(): void;
  40253. private _checkLimits;
  40254. /**
  40255. * Gets the camera class name.
  40256. * @returns the class name
  40257. */
  40258. getClassName(): string;
  40259. }
  40260. /**
  40261. * Arc Rotate version of the follow camera.
  40262. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40263. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40264. */
  40265. export class ArcFollowCamera extends TargetCamera {
  40266. /** The longitudinal angle of the camera */
  40267. alpha: number;
  40268. /** The latitudinal angle of the camera */
  40269. beta: number;
  40270. /** The radius of the camera from its target */
  40271. radius: number;
  40272. /** Define the camera target (the messh it should follow) */
  40273. target: Nullable<AbstractMesh>;
  40274. private _cartesianCoordinates;
  40275. /**
  40276. * Instantiates a new ArcFollowCamera
  40277. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40278. * @param name Define the name of the camera
  40279. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40280. * @param beta Define the rotation angle of the camera around the elevation axis
  40281. * @param radius Define the radius of the camera from its target point
  40282. * @param target Define the target of the camera
  40283. * @param scene Define the scene the camera belongs to
  40284. */
  40285. constructor(name: string,
  40286. /** The longitudinal angle of the camera */
  40287. alpha: number,
  40288. /** The latitudinal angle of the camera */
  40289. beta: number,
  40290. /** The radius of the camera from its target */
  40291. radius: number,
  40292. /** Define the camera target (the messh it should follow) */
  40293. target: Nullable<AbstractMesh>, scene: Scene);
  40294. private _follow;
  40295. /** @hidden */
  40296. _checkInputs(): void;
  40297. /**
  40298. * Returns the class name of the object.
  40299. * It is mostly used internally for serialization purposes.
  40300. */
  40301. getClassName(): string;
  40302. }
  40303. }
  40304. declare module BABYLON {
  40305. /**
  40306. * Manage the keyboard inputs to control the movement of a follow camera.
  40307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40308. */
  40309. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40310. /**
  40311. * Defines the camera the input is attached to.
  40312. */
  40313. camera: FollowCamera;
  40314. /**
  40315. * Defines the list of key codes associated with the up action (increase heightOffset)
  40316. */
  40317. keysHeightOffsetIncr: number[];
  40318. /**
  40319. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40320. */
  40321. keysHeightOffsetDecr: number[];
  40322. /**
  40323. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40324. */
  40325. keysHeightOffsetModifierAlt: boolean;
  40326. /**
  40327. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40328. */
  40329. keysHeightOffsetModifierCtrl: boolean;
  40330. /**
  40331. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40332. */
  40333. keysHeightOffsetModifierShift: boolean;
  40334. /**
  40335. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40336. */
  40337. keysRotationOffsetIncr: number[];
  40338. /**
  40339. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40340. */
  40341. keysRotationOffsetDecr: number[];
  40342. /**
  40343. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40344. */
  40345. keysRotationOffsetModifierAlt: boolean;
  40346. /**
  40347. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40348. */
  40349. keysRotationOffsetModifierCtrl: boolean;
  40350. /**
  40351. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40352. */
  40353. keysRotationOffsetModifierShift: boolean;
  40354. /**
  40355. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40356. */
  40357. keysRadiusIncr: number[];
  40358. /**
  40359. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40360. */
  40361. keysRadiusDecr: number[];
  40362. /**
  40363. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40364. */
  40365. keysRadiusModifierAlt: boolean;
  40366. /**
  40367. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40368. */
  40369. keysRadiusModifierCtrl: boolean;
  40370. /**
  40371. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40372. */
  40373. keysRadiusModifierShift: boolean;
  40374. /**
  40375. * Defines the rate of change of heightOffset.
  40376. */
  40377. heightSensibility: number;
  40378. /**
  40379. * Defines the rate of change of rotationOffset.
  40380. */
  40381. rotationSensibility: number;
  40382. /**
  40383. * Defines the rate of change of radius.
  40384. */
  40385. radiusSensibility: number;
  40386. private _keys;
  40387. private _ctrlPressed;
  40388. private _altPressed;
  40389. private _shiftPressed;
  40390. private _onCanvasBlurObserver;
  40391. private _onKeyboardObserver;
  40392. private _engine;
  40393. private _scene;
  40394. /**
  40395. * Attach the input controls to a specific dom element to get the input from.
  40396. * @param element Defines the element the controls should be listened from
  40397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40398. */
  40399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40400. /**
  40401. * Detach the current controls from the specified dom element.
  40402. * @param element Defines the element to stop listening the inputs from
  40403. */
  40404. detachControl(element: Nullable<HTMLElement>): void;
  40405. /**
  40406. * Update the current camera state depending on the inputs that have been used this frame.
  40407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40408. */
  40409. checkInputs(): void;
  40410. /**
  40411. * Gets the class name of the current input.
  40412. * @returns the class name
  40413. */
  40414. getClassName(): string;
  40415. /**
  40416. * Get the friendly name associated with the input class.
  40417. * @returns the input friendly name
  40418. */
  40419. getSimpleName(): string;
  40420. /**
  40421. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40422. * allow modification of the heightOffset value.
  40423. */
  40424. private _modifierHeightOffset;
  40425. /**
  40426. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40427. * allow modification of the rotationOffset value.
  40428. */
  40429. private _modifierRotationOffset;
  40430. /**
  40431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40432. * allow modification of the radius value.
  40433. */
  40434. private _modifierRadius;
  40435. }
  40436. }
  40437. declare module BABYLON {
  40438. interface FreeCameraInputsManager {
  40439. /**
  40440. * @hidden
  40441. */
  40442. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40443. /**
  40444. * Add orientation input support to the input manager.
  40445. * @returns the current input manager
  40446. */
  40447. addDeviceOrientation(): FreeCameraInputsManager;
  40448. }
  40449. /**
  40450. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40451. * Screen rotation is taken into account.
  40452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40453. */
  40454. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40455. private _camera;
  40456. private _screenOrientationAngle;
  40457. private _constantTranform;
  40458. private _screenQuaternion;
  40459. private _alpha;
  40460. private _beta;
  40461. private _gamma;
  40462. /**
  40463. * Can be used to detect if a device orientation sensor is available on a device
  40464. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40465. * @returns a promise that will resolve on orientation change
  40466. */
  40467. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40468. /**
  40469. * @hidden
  40470. */
  40471. _onDeviceOrientationChangedObservable: Observable<void>;
  40472. /**
  40473. * Instantiates a new input
  40474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40475. */
  40476. constructor();
  40477. /**
  40478. * Define the camera controlled by the input.
  40479. */
  40480. get camera(): FreeCamera;
  40481. set camera(camera: FreeCamera);
  40482. /**
  40483. * Attach the input controls to a specific dom element to get the input from.
  40484. * @param element Defines the element the controls should be listened from
  40485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40486. */
  40487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40488. private _orientationChanged;
  40489. private _deviceOrientation;
  40490. /**
  40491. * Detach the current controls from the specified dom element.
  40492. * @param element Defines the element to stop listening the inputs from
  40493. */
  40494. detachControl(element: Nullable<HTMLElement>): void;
  40495. /**
  40496. * Update the current camera state depending on the inputs that have been used this frame.
  40497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40498. */
  40499. checkInputs(): void;
  40500. /**
  40501. * Gets the class name of the current intput.
  40502. * @returns the class name
  40503. */
  40504. getClassName(): string;
  40505. /**
  40506. * Get the friendly name associated with the input class.
  40507. * @returns the input friendly name
  40508. */
  40509. getSimpleName(): string;
  40510. }
  40511. }
  40512. declare module BABYLON {
  40513. /**
  40514. * Manage the gamepad inputs to control a free camera.
  40515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40516. */
  40517. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40518. /**
  40519. * Define the camera the input is attached to.
  40520. */
  40521. camera: FreeCamera;
  40522. /**
  40523. * Define the Gamepad controlling the input
  40524. */
  40525. gamepad: Nullable<Gamepad>;
  40526. /**
  40527. * Defines the gamepad rotation sensiblity.
  40528. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40529. */
  40530. gamepadAngularSensibility: number;
  40531. /**
  40532. * Defines the gamepad move sensiblity.
  40533. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40534. */
  40535. gamepadMoveSensibility: number;
  40536. private _yAxisScale;
  40537. /**
  40538. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40539. */
  40540. get invertYAxis(): boolean;
  40541. set invertYAxis(value: boolean);
  40542. private _onGamepadConnectedObserver;
  40543. private _onGamepadDisconnectedObserver;
  40544. private _cameraTransform;
  40545. private _deltaTransform;
  40546. private _vector3;
  40547. private _vector2;
  40548. /**
  40549. * Attach the input controls to a specific dom element to get the input from.
  40550. * @param element Defines the element the controls should be listened from
  40551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40552. */
  40553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40554. /**
  40555. * Detach the current controls from the specified dom element.
  40556. * @param element Defines the element to stop listening the inputs from
  40557. */
  40558. detachControl(element: Nullable<HTMLElement>): void;
  40559. /**
  40560. * Update the current camera state depending on the inputs that have been used this frame.
  40561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40562. */
  40563. checkInputs(): void;
  40564. /**
  40565. * Gets the class name of the current intput.
  40566. * @returns the class name
  40567. */
  40568. getClassName(): string;
  40569. /**
  40570. * Get the friendly name associated with the input class.
  40571. * @returns the input friendly name
  40572. */
  40573. getSimpleName(): string;
  40574. }
  40575. }
  40576. declare module BABYLON {
  40577. /**
  40578. * Defines the potential axis of a Joystick
  40579. */
  40580. export enum JoystickAxis {
  40581. /** X axis */
  40582. X = 0,
  40583. /** Y axis */
  40584. Y = 1,
  40585. /** Z axis */
  40586. Z = 2
  40587. }
  40588. /**
  40589. * Class used to define virtual joystick (used in touch mode)
  40590. */
  40591. export class VirtualJoystick {
  40592. /**
  40593. * Gets or sets a boolean indicating that left and right values must be inverted
  40594. */
  40595. reverseLeftRight: boolean;
  40596. /**
  40597. * Gets or sets a boolean indicating that up and down values must be inverted
  40598. */
  40599. reverseUpDown: boolean;
  40600. /**
  40601. * Gets the offset value for the position (ie. the change of the position value)
  40602. */
  40603. deltaPosition: Vector3;
  40604. /**
  40605. * Gets a boolean indicating if the virtual joystick was pressed
  40606. */
  40607. pressed: boolean;
  40608. /**
  40609. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40610. */
  40611. static Canvas: Nullable<HTMLCanvasElement>;
  40612. private static _globalJoystickIndex;
  40613. private static vjCanvasContext;
  40614. private static vjCanvasWidth;
  40615. private static vjCanvasHeight;
  40616. private static halfWidth;
  40617. private _action;
  40618. private _axisTargetedByLeftAndRight;
  40619. private _axisTargetedByUpAndDown;
  40620. private _joystickSensibility;
  40621. private _inversedSensibility;
  40622. private _joystickPointerID;
  40623. private _joystickColor;
  40624. private _joystickPointerPos;
  40625. private _joystickPreviousPointerPos;
  40626. private _joystickPointerStartPos;
  40627. private _deltaJoystickVector;
  40628. private _leftJoystick;
  40629. private _touches;
  40630. private _onPointerDownHandlerRef;
  40631. private _onPointerMoveHandlerRef;
  40632. private _onPointerUpHandlerRef;
  40633. private _onResize;
  40634. /**
  40635. * Creates a new virtual joystick
  40636. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40637. */
  40638. constructor(leftJoystick?: boolean);
  40639. /**
  40640. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40641. * @param newJoystickSensibility defines the new sensibility
  40642. */
  40643. setJoystickSensibility(newJoystickSensibility: number): void;
  40644. private _onPointerDown;
  40645. private _onPointerMove;
  40646. private _onPointerUp;
  40647. /**
  40648. * Change the color of the virtual joystick
  40649. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40650. */
  40651. setJoystickColor(newColor: string): void;
  40652. /**
  40653. * Defines a callback to call when the joystick is touched
  40654. * @param action defines the callback
  40655. */
  40656. setActionOnTouch(action: () => any): void;
  40657. /**
  40658. * Defines which axis you'd like to control for left & right
  40659. * @param axis defines the axis to use
  40660. */
  40661. setAxisForLeftRight(axis: JoystickAxis): void;
  40662. /**
  40663. * Defines which axis you'd like to control for up & down
  40664. * @param axis defines the axis to use
  40665. */
  40666. setAxisForUpDown(axis: JoystickAxis): void;
  40667. private _drawVirtualJoystick;
  40668. /**
  40669. * Release internal HTML canvas
  40670. */
  40671. releaseCanvas(): void;
  40672. }
  40673. }
  40674. declare module BABYLON {
  40675. interface FreeCameraInputsManager {
  40676. /**
  40677. * Add virtual joystick input support to the input manager.
  40678. * @returns the current input manager
  40679. */
  40680. addVirtualJoystick(): FreeCameraInputsManager;
  40681. }
  40682. /**
  40683. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40685. */
  40686. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40687. /**
  40688. * Defines the camera the input is attached to.
  40689. */
  40690. camera: FreeCamera;
  40691. private _leftjoystick;
  40692. private _rightjoystick;
  40693. /**
  40694. * Gets the left stick of the virtual joystick.
  40695. * @returns The virtual Joystick
  40696. */
  40697. getLeftJoystick(): VirtualJoystick;
  40698. /**
  40699. * Gets the right stick of the virtual joystick.
  40700. * @returns The virtual Joystick
  40701. */
  40702. getRightJoystick(): VirtualJoystick;
  40703. /**
  40704. * Update the current camera state depending on the inputs that have been used this frame.
  40705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40706. */
  40707. checkInputs(): void;
  40708. /**
  40709. * Attach the input controls to a specific dom element to get the input from.
  40710. * @param element Defines the element the controls should be listened from
  40711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40712. */
  40713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40714. /**
  40715. * Detach the current controls from the specified dom element.
  40716. * @param element Defines the element to stop listening the inputs from
  40717. */
  40718. detachControl(element: Nullable<HTMLElement>): void;
  40719. /**
  40720. * Gets the class name of the current intput.
  40721. * @returns the class name
  40722. */
  40723. getClassName(): string;
  40724. /**
  40725. * Get the friendly name associated with the input class.
  40726. * @returns the input friendly name
  40727. */
  40728. getSimpleName(): string;
  40729. }
  40730. }
  40731. declare module BABYLON {
  40732. /**
  40733. * This represents a FPS type of camera controlled by touch.
  40734. * This is like a universal camera minus the Gamepad controls.
  40735. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40736. */
  40737. export class TouchCamera extends FreeCamera {
  40738. /**
  40739. * Defines the touch sensibility for rotation.
  40740. * The higher the faster.
  40741. */
  40742. get touchAngularSensibility(): number;
  40743. set touchAngularSensibility(value: number);
  40744. /**
  40745. * Defines the touch sensibility for move.
  40746. * The higher the faster.
  40747. */
  40748. get touchMoveSensibility(): number;
  40749. set touchMoveSensibility(value: number);
  40750. /**
  40751. * Instantiates a new touch camera.
  40752. * This represents a FPS type of camera controlled by touch.
  40753. * This is like a universal camera minus the Gamepad controls.
  40754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40755. * @param name Define the name of the camera in the scene
  40756. * @param position Define the start position of the camera in the scene
  40757. * @param scene Define the scene the camera belongs to
  40758. */
  40759. constructor(name: string, position: Vector3, scene: Scene);
  40760. /**
  40761. * Gets the current object class name.
  40762. * @return the class name
  40763. */
  40764. getClassName(): string;
  40765. /** @hidden */
  40766. _setupInputs(): void;
  40767. }
  40768. }
  40769. declare module BABYLON {
  40770. /**
  40771. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40772. * being tilted forward or back and left or right.
  40773. */
  40774. export class DeviceOrientationCamera extends FreeCamera {
  40775. private _initialQuaternion;
  40776. private _quaternionCache;
  40777. private _tmpDragQuaternion;
  40778. private _disablePointerInputWhenUsingDeviceOrientation;
  40779. /**
  40780. * Creates a new device orientation camera
  40781. * @param name The name of the camera
  40782. * @param position The start position camera
  40783. * @param scene The scene the camera belongs to
  40784. */
  40785. constructor(name: string, position: Vector3, scene: Scene);
  40786. /**
  40787. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40788. */
  40789. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40790. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40791. private _dragFactor;
  40792. /**
  40793. * Enabled turning on the y axis when the orientation sensor is active
  40794. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40795. */
  40796. enableHorizontalDragging(dragFactor?: number): void;
  40797. /**
  40798. * Gets the current instance class name ("DeviceOrientationCamera").
  40799. * This helps avoiding instanceof at run time.
  40800. * @returns the class name
  40801. */
  40802. getClassName(): string;
  40803. /**
  40804. * @hidden
  40805. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40806. */
  40807. _checkInputs(): void;
  40808. /**
  40809. * Reset the camera to its default orientation on the specified axis only.
  40810. * @param axis The axis to reset
  40811. */
  40812. resetToCurrentRotation(axis?: Axis): void;
  40813. }
  40814. }
  40815. declare module BABYLON {
  40816. /**
  40817. * Defines supported buttons for XBox360 compatible gamepads
  40818. */
  40819. export enum Xbox360Button {
  40820. /** A */
  40821. A = 0,
  40822. /** B */
  40823. B = 1,
  40824. /** X */
  40825. X = 2,
  40826. /** Y */
  40827. Y = 3,
  40828. /** Start */
  40829. Start = 4,
  40830. /** Back */
  40831. Back = 5,
  40832. /** Left button */
  40833. LB = 6,
  40834. /** Right button */
  40835. RB = 7,
  40836. /** Left stick */
  40837. LeftStick = 8,
  40838. /** Right stick */
  40839. RightStick = 9
  40840. }
  40841. /** Defines values for XBox360 DPad */
  40842. export enum Xbox360Dpad {
  40843. /** Up */
  40844. Up = 0,
  40845. /** Down */
  40846. Down = 1,
  40847. /** Left */
  40848. Left = 2,
  40849. /** Right */
  40850. Right = 3
  40851. }
  40852. /**
  40853. * Defines a XBox360 gamepad
  40854. */
  40855. export class Xbox360Pad extends Gamepad {
  40856. private _leftTrigger;
  40857. private _rightTrigger;
  40858. private _onlefttriggerchanged;
  40859. private _onrighttriggerchanged;
  40860. private _onbuttondown;
  40861. private _onbuttonup;
  40862. private _ondpaddown;
  40863. private _ondpadup;
  40864. /** Observable raised when a button is pressed */
  40865. onButtonDownObservable: Observable<Xbox360Button>;
  40866. /** Observable raised when a button is released */
  40867. onButtonUpObservable: Observable<Xbox360Button>;
  40868. /** Observable raised when a pad is pressed */
  40869. onPadDownObservable: Observable<Xbox360Dpad>;
  40870. /** Observable raised when a pad is released */
  40871. onPadUpObservable: Observable<Xbox360Dpad>;
  40872. private _buttonA;
  40873. private _buttonB;
  40874. private _buttonX;
  40875. private _buttonY;
  40876. private _buttonBack;
  40877. private _buttonStart;
  40878. private _buttonLB;
  40879. private _buttonRB;
  40880. private _buttonLeftStick;
  40881. private _buttonRightStick;
  40882. private _dPadUp;
  40883. private _dPadDown;
  40884. private _dPadLeft;
  40885. private _dPadRight;
  40886. private _isXboxOnePad;
  40887. /**
  40888. * Creates a new XBox360 gamepad object
  40889. * @param id defines the id of this gamepad
  40890. * @param index defines its index
  40891. * @param gamepad defines the internal HTML gamepad object
  40892. * @param xboxOne defines if it is a XBox One gamepad
  40893. */
  40894. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40895. /**
  40896. * Defines the callback to call when left trigger is pressed
  40897. * @param callback defines the callback to use
  40898. */
  40899. onlefttriggerchanged(callback: (value: number) => void): void;
  40900. /**
  40901. * Defines the callback to call when right trigger is pressed
  40902. * @param callback defines the callback to use
  40903. */
  40904. onrighttriggerchanged(callback: (value: number) => void): void;
  40905. /**
  40906. * Gets the left trigger value
  40907. */
  40908. get leftTrigger(): number;
  40909. /**
  40910. * Sets the left trigger value
  40911. */
  40912. set leftTrigger(newValue: number);
  40913. /**
  40914. * Gets the right trigger value
  40915. */
  40916. get rightTrigger(): number;
  40917. /**
  40918. * Sets the right trigger value
  40919. */
  40920. set rightTrigger(newValue: number);
  40921. /**
  40922. * Defines the callback to call when a button is pressed
  40923. * @param callback defines the callback to use
  40924. */
  40925. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40926. /**
  40927. * Defines the callback to call when a button is released
  40928. * @param callback defines the callback to use
  40929. */
  40930. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40931. /**
  40932. * Defines the callback to call when a pad is pressed
  40933. * @param callback defines the callback to use
  40934. */
  40935. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40936. /**
  40937. * Defines the callback to call when a pad is released
  40938. * @param callback defines the callback to use
  40939. */
  40940. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40941. private _setButtonValue;
  40942. private _setDPadValue;
  40943. /**
  40944. * Gets the value of the `A` button
  40945. */
  40946. get buttonA(): number;
  40947. /**
  40948. * Sets the value of the `A` button
  40949. */
  40950. set buttonA(value: number);
  40951. /**
  40952. * Gets the value of the `B` button
  40953. */
  40954. get buttonB(): number;
  40955. /**
  40956. * Sets the value of the `B` button
  40957. */
  40958. set buttonB(value: number);
  40959. /**
  40960. * Gets the value of the `X` button
  40961. */
  40962. get buttonX(): number;
  40963. /**
  40964. * Sets the value of the `X` button
  40965. */
  40966. set buttonX(value: number);
  40967. /**
  40968. * Gets the value of the `Y` button
  40969. */
  40970. get buttonY(): number;
  40971. /**
  40972. * Sets the value of the `Y` button
  40973. */
  40974. set buttonY(value: number);
  40975. /**
  40976. * Gets the value of the `Start` button
  40977. */
  40978. get buttonStart(): number;
  40979. /**
  40980. * Sets the value of the `Start` button
  40981. */
  40982. set buttonStart(value: number);
  40983. /**
  40984. * Gets the value of the `Back` button
  40985. */
  40986. get buttonBack(): number;
  40987. /**
  40988. * Sets the value of the `Back` button
  40989. */
  40990. set buttonBack(value: number);
  40991. /**
  40992. * Gets the value of the `Left` button
  40993. */
  40994. get buttonLB(): number;
  40995. /**
  40996. * Sets the value of the `Left` button
  40997. */
  40998. set buttonLB(value: number);
  40999. /**
  41000. * Gets the value of the `Right` button
  41001. */
  41002. get buttonRB(): number;
  41003. /**
  41004. * Sets the value of the `Right` button
  41005. */
  41006. set buttonRB(value: number);
  41007. /**
  41008. * Gets the value of the Left joystick
  41009. */
  41010. get buttonLeftStick(): number;
  41011. /**
  41012. * Sets the value of the Left joystick
  41013. */
  41014. set buttonLeftStick(value: number);
  41015. /**
  41016. * Gets the value of the Right joystick
  41017. */
  41018. get buttonRightStick(): number;
  41019. /**
  41020. * Sets the value of the Right joystick
  41021. */
  41022. set buttonRightStick(value: number);
  41023. /**
  41024. * Gets the value of D-pad up
  41025. */
  41026. get dPadUp(): number;
  41027. /**
  41028. * Sets the value of D-pad up
  41029. */
  41030. set dPadUp(value: number);
  41031. /**
  41032. * Gets the value of D-pad down
  41033. */
  41034. get dPadDown(): number;
  41035. /**
  41036. * Sets the value of D-pad down
  41037. */
  41038. set dPadDown(value: number);
  41039. /**
  41040. * Gets the value of D-pad left
  41041. */
  41042. get dPadLeft(): number;
  41043. /**
  41044. * Sets the value of D-pad left
  41045. */
  41046. set dPadLeft(value: number);
  41047. /**
  41048. * Gets the value of D-pad right
  41049. */
  41050. get dPadRight(): number;
  41051. /**
  41052. * Sets the value of D-pad right
  41053. */
  41054. set dPadRight(value: number);
  41055. /**
  41056. * Force the gamepad to synchronize with device values
  41057. */
  41058. update(): void;
  41059. /**
  41060. * Disposes the gamepad
  41061. */
  41062. dispose(): void;
  41063. }
  41064. }
  41065. declare module BABYLON {
  41066. /**
  41067. * Defines supported buttons for DualShock compatible gamepads
  41068. */
  41069. export enum DualShockButton {
  41070. /** Cross */
  41071. Cross = 0,
  41072. /** Circle */
  41073. Circle = 1,
  41074. /** Square */
  41075. Square = 2,
  41076. /** Triangle */
  41077. Triangle = 3,
  41078. /** Options */
  41079. Options = 4,
  41080. /** Share */
  41081. Share = 5,
  41082. /** L1 */
  41083. L1 = 6,
  41084. /** R1 */
  41085. R1 = 7,
  41086. /** Left stick */
  41087. LeftStick = 8,
  41088. /** Right stick */
  41089. RightStick = 9
  41090. }
  41091. /** Defines values for DualShock DPad */
  41092. export enum DualShockDpad {
  41093. /** Up */
  41094. Up = 0,
  41095. /** Down */
  41096. Down = 1,
  41097. /** Left */
  41098. Left = 2,
  41099. /** Right */
  41100. Right = 3
  41101. }
  41102. /**
  41103. * Defines a DualShock gamepad
  41104. */
  41105. export class DualShockPad extends Gamepad {
  41106. private _leftTrigger;
  41107. private _rightTrigger;
  41108. private _onlefttriggerchanged;
  41109. private _onrighttriggerchanged;
  41110. private _onbuttondown;
  41111. private _onbuttonup;
  41112. private _ondpaddown;
  41113. private _ondpadup;
  41114. /** Observable raised when a button is pressed */
  41115. onButtonDownObservable: Observable<DualShockButton>;
  41116. /** Observable raised when a button is released */
  41117. onButtonUpObservable: Observable<DualShockButton>;
  41118. /** Observable raised when a pad is pressed */
  41119. onPadDownObservable: Observable<DualShockDpad>;
  41120. /** Observable raised when a pad is released */
  41121. onPadUpObservable: Observable<DualShockDpad>;
  41122. private _buttonCross;
  41123. private _buttonCircle;
  41124. private _buttonSquare;
  41125. private _buttonTriangle;
  41126. private _buttonShare;
  41127. private _buttonOptions;
  41128. private _buttonL1;
  41129. private _buttonR1;
  41130. private _buttonLeftStick;
  41131. private _buttonRightStick;
  41132. private _dPadUp;
  41133. private _dPadDown;
  41134. private _dPadLeft;
  41135. private _dPadRight;
  41136. /**
  41137. * Creates a new DualShock gamepad object
  41138. * @param id defines the id of this gamepad
  41139. * @param index defines its index
  41140. * @param gamepad defines the internal HTML gamepad object
  41141. */
  41142. constructor(id: string, index: number, gamepad: any);
  41143. /**
  41144. * Defines the callback to call when left trigger is pressed
  41145. * @param callback defines the callback to use
  41146. */
  41147. onlefttriggerchanged(callback: (value: number) => void): void;
  41148. /**
  41149. * Defines the callback to call when right trigger is pressed
  41150. * @param callback defines the callback to use
  41151. */
  41152. onrighttriggerchanged(callback: (value: number) => void): void;
  41153. /**
  41154. * Gets the left trigger value
  41155. */
  41156. get leftTrigger(): number;
  41157. /**
  41158. * Sets the left trigger value
  41159. */
  41160. set leftTrigger(newValue: number);
  41161. /**
  41162. * Gets the right trigger value
  41163. */
  41164. get rightTrigger(): number;
  41165. /**
  41166. * Sets the right trigger value
  41167. */
  41168. set rightTrigger(newValue: number);
  41169. /**
  41170. * Defines the callback to call when a button is pressed
  41171. * @param callback defines the callback to use
  41172. */
  41173. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41174. /**
  41175. * Defines the callback to call when a button is released
  41176. * @param callback defines the callback to use
  41177. */
  41178. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41179. /**
  41180. * Defines the callback to call when a pad is pressed
  41181. * @param callback defines the callback to use
  41182. */
  41183. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41184. /**
  41185. * Defines the callback to call when a pad is released
  41186. * @param callback defines the callback to use
  41187. */
  41188. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41189. private _setButtonValue;
  41190. private _setDPadValue;
  41191. /**
  41192. * Gets the value of the `Cross` button
  41193. */
  41194. get buttonCross(): number;
  41195. /**
  41196. * Sets the value of the `Cross` button
  41197. */
  41198. set buttonCross(value: number);
  41199. /**
  41200. * Gets the value of the `Circle` button
  41201. */
  41202. get buttonCircle(): number;
  41203. /**
  41204. * Sets the value of the `Circle` button
  41205. */
  41206. set buttonCircle(value: number);
  41207. /**
  41208. * Gets the value of the `Square` button
  41209. */
  41210. get buttonSquare(): number;
  41211. /**
  41212. * Sets the value of the `Square` button
  41213. */
  41214. set buttonSquare(value: number);
  41215. /**
  41216. * Gets the value of the `Triangle` button
  41217. */
  41218. get buttonTriangle(): number;
  41219. /**
  41220. * Sets the value of the `Triangle` button
  41221. */
  41222. set buttonTriangle(value: number);
  41223. /**
  41224. * Gets the value of the `Options` button
  41225. */
  41226. get buttonOptions(): number;
  41227. /**
  41228. * Sets the value of the `Options` button
  41229. */
  41230. set buttonOptions(value: number);
  41231. /**
  41232. * Gets the value of the `Share` button
  41233. */
  41234. get buttonShare(): number;
  41235. /**
  41236. * Sets the value of the `Share` button
  41237. */
  41238. set buttonShare(value: number);
  41239. /**
  41240. * Gets the value of the `L1` button
  41241. */
  41242. get buttonL1(): number;
  41243. /**
  41244. * Sets the value of the `L1` button
  41245. */
  41246. set buttonL1(value: number);
  41247. /**
  41248. * Gets the value of the `R1` button
  41249. */
  41250. get buttonR1(): number;
  41251. /**
  41252. * Sets the value of the `R1` button
  41253. */
  41254. set buttonR1(value: number);
  41255. /**
  41256. * Gets the value of the Left joystick
  41257. */
  41258. get buttonLeftStick(): number;
  41259. /**
  41260. * Sets the value of the Left joystick
  41261. */
  41262. set buttonLeftStick(value: number);
  41263. /**
  41264. * Gets the value of the Right joystick
  41265. */
  41266. get buttonRightStick(): number;
  41267. /**
  41268. * Sets the value of the Right joystick
  41269. */
  41270. set buttonRightStick(value: number);
  41271. /**
  41272. * Gets the value of D-pad up
  41273. */
  41274. get dPadUp(): number;
  41275. /**
  41276. * Sets the value of D-pad up
  41277. */
  41278. set dPadUp(value: number);
  41279. /**
  41280. * Gets the value of D-pad down
  41281. */
  41282. get dPadDown(): number;
  41283. /**
  41284. * Sets the value of D-pad down
  41285. */
  41286. set dPadDown(value: number);
  41287. /**
  41288. * Gets the value of D-pad left
  41289. */
  41290. get dPadLeft(): number;
  41291. /**
  41292. * Sets the value of D-pad left
  41293. */
  41294. set dPadLeft(value: number);
  41295. /**
  41296. * Gets the value of D-pad right
  41297. */
  41298. get dPadRight(): number;
  41299. /**
  41300. * Sets the value of D-pad right
  41301. */
  41302. set dPadRight(value: number);
  41303. /**
  41304. * Force the gamepad to synchronize with device values
  41305. */
  41306. update(): void;
  41307. /**
  41308. * Disposes the gamepad
  41309. */
  41310. dispose(): void;
  41311. }
  41312. }
  41313. declare module BABYLON {
  41314. /**
  41315. * Manager for handling gamepads
  41316. */
  41317. export class GamepadManager {
  41318. private _scene?;
  41319. private _babylonGamepads;
  41320. private _oneGamepadConnected;
  41321. /** @hidden */
  41322. _isMonitoring: boolean;
  41323. private _gamepadEventSupported;
  41324. private _gamepadSupport?;
  41325. /**
  41326. * observable to be triggered when the gamepad controller has been connected
  41327. */
  41328. onGamepadConnectedObservable: Observable<Gamepad>;
  41329. /**
  41330. * observable to be triggered when the gamepad controller has been disconnected
  41331. */
  41332. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41333. private _onGamepadConnectedEvent;
  41334. private _onGamepadDisconnectedEvent;
  41335. /**
  41336. * Initializes the gamepad manager
  41337. * @param _scene BabylonJS scene
  41338. */
  41339. constructor(_scene?: Scene | undefined);
  41340. /**
  41341. * The gamepads in the game pad manager
  41342. */
  41343. get gamepads(): Gamepad[];
  41344. /**
  41345. * Get the gamepad controllers based on type
  41346. * @param type The type of gamepad controller
  41347. * @returns Nullable gamepad
  41348. */
  41349. getGamepadByType(type?: number): Nullable<Gamepad>;
  41350. /**
  41351. * Disposes the gamepad manager
  41352. */
  41353. dispose(): void;
  41354. private _addNewGamepad;
  41355. private _startMonitoringGamepads;
  41356. private _stopMonitoringGamepads;
  41357. /** @hidden */
  41358. _checkGamepadsStatus(): void;
  41359. private _updateGamepadObjects;
  41360. }
  41361. }
  41362. declare module BABYLON {
  41363. interface Scene {
  41364. /** @hidden */
  41365. _gamepadManager: Nullable<GamepadManager>;
  41366. /**
  41367. * Gets the gamepad manager associated with the scene
  41368. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41369. */
  41370. gamepadManager: GamepadManager;
  41371. }
  41372. /**
  41373. * Interface representing a free camera inputs manager
  41374. */
  41375. interface FreeCameraInputsManager {
  41376. /**
  41377. * Adds gamepad input support to the FreeCameraInputsManager.
  41378. * @returns the FreeCameraInputsManager
  41379. */
  41380. addGamepad(): FreeCameraInputsManager;
  41381. }
  41382. /**
  41383. * Interface representing an arc rotate camera inputs manager
  41384. */
  41385. interface ArcRotateCameraInputsManager {
  41386. /**
  41387. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41388. * @returns the camera inputs manager
  41389. */
  41390. addGamepad(): ArcRotateCameraInputsManager;
  41391. }
  41392. /**
  41393. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41394. */
  41395. export class GamepadSystemSceneComponent implements ISceneComponent {
  41396. /**
  41397. * The component name helpfull to identify the component in the list of scene components.
  41398. */
  41399. readonly name: string;
  41400. /**
  41401. * The scene the component belongs to.
  41402. */
  41403. scene: Scene;
  41404. /**
  41405. * Creates a new instance of the component for the given scene
  41406. * @param scene Defines the scene to register the component in
  41407. */
  41408. constructor(scene: Scene);
  41409. /**
  41410. * Registers the component in a given scene
  41411. */
  41412. register(): void;
  41413. /**
  41414. * Rebuilds the elements related to this component in case of
  41415. * context lost for instance.
  41416. */
  41417. rebuild(): void;
  41418. /**
  41419. * Disposes the component and the associated ressources
  41420. */
  41421. dispose(): void;
  41422. private _beforeCameraUpdate;
  41423. }
  41424. }
  41425. declare module BABYLON {
  41426. /**
  41427. * 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,
  41428. * which still works and will still be found in many Playgrounds.
  41429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41430. */
  41431. export class UniversalCamera extends TouchCamera {
  41432. /**
  41433. * Defines the gamepad rotation sensiblity.
  41434. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41435. */
  41436. get gamepadAngularSensibility(): number;
  41437. set gamepadAngularSensibility(value: number);
  41438. /**
  41439. * Defines the gamepad move sensiblity.
  41440. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41441. */
  41442. get gamepadMoveSensibility(): number;
  41443. set gamepadMoveSensibility(value: number);
  41444. /**
  41445. * 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,
  41446. * which still works and will still be found in many Playgrounds.
  41447. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41448. * @param name Define the name of the camera in the scene
  41449. * @param position Define the start position of the camera in the scene
  41450. * @param scene Define the scene the camera belongs to
  41451. */
  41452. constructor(name: string, position: Vector3, scene: Scene);
  41453. /**
  41454. * Gets the current object class name.
  41455. * @return the class name
  41456. */
  41457. getClassName(): string;
  41458. }
  41459. }
  41460. declare module BABYLON {
  41461. /**
  41462. * This represents a FPS type of camera. This is only here for back compat purpose.
  41463. * Please use the UniversalCamera instead as both are identical.
  41464. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41465. */
  41466. export class GamepadCamera extends UniversalCamera {
  41467. /**
  41468. * Instantiates a new Gamepad Camera
  41469. * This represents a FPS type of camera. This is only here for back compat purpose.
  41470. * Please use the UniversalCamera instead as both are identical.
  41471. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41472. * @param name Define the name of the camera in the scene
  41473. * @param position Define the start position of the camera in the scene
  41474. * @param scene Define the scene the camera belongs to
  41475. */
  41476. constructor(name: string, position: Vector3, scene: Scene);
  41477. /**
  41478. * Gets the current object class name.
  41479. * @return the class name
  41480. */
  41481. getClassName(): string;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /** @hidden */
  41486. export var passPixelShader: {
  41487. name: string;
  41488. shader: string;
  41489. };
  41490. }
  41491. declare module BABYLON {
  41492. /** @hidden */
  41493. export var passCubePixelShader: {
  41494. name: string;
  41495. shader: string;
  41496. };
  41497. }
  41498. declare module BABYLON {
  41499. /**
  41500. * PassPostProcess which produces an output the same as it's input
  41501. */
  41502. export class PassPostProcess extends PostProcess {
  41503. /**
  41504. * Creates the PassPostProcess
  41505. * @param name The name of the effect.
  41506. * @param options The required width/height ratio to downsize to before computing the render pass.
  41507. * @param camera The camera to apply the render pass to.
  41508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41509. * @param engine The engine which the post process will be applied. (default: current engine)
  41510. * @param reusable If the post process can be reused on the same frame. (default: false)
  41511. * @param textureType The type of texture to be used when performing the post processing.
  41512. * @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)
  41513. */
  41514. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41515. }
  41516. /**
  41517. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41518. */
  41519. export class PassCubePostProcess extends PostProcess {
  41520. private _face;
  41521. /**
  41522. * Gets or sets the cube face to display.
  41523. * * 0 is +X
  41524. * * 1 is -X
  41525. * * 2 is +Y
  41526. * * 3 is -Y
  41527. * * 4 is +Z
  41528. * * 5 is -Z
  41529. */
  41530. get face(): number;
  41531. set face(value: number);
  41532. /**
  41533. * Creates the PassCubePostProcess
  41534. * @param name The name of the effect.
  41535. * @param options The required width/height ratio to downsize to before computing the render pass.
  41536. * @param camera The camera to apply the render pass to.
  41537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41538. * @param engine The engine which the post process will be applied. (default: current engine)
  41539. * @param reusable If the post process can be reused on the same frame. (default: false)
  41540. * @param textureType The type of texture to be used when performing the post processing.
  41541. * @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)
  41542. */
  41543. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41544. }
  41545. }
  41546. declare module BABYLON {
  41547. /** @hidden */
  41548. export var anaglyphPixelShader: {
  41549. name: string;
  41550. shader: string;
  41551. };
  41552. }
  41553. declare module BABYLON {
  41554. /**
  41555. * Postprocess used to generate anaglyphic rendering
  41556. */
  41557. export class AnaglyphPostProcess extends PostProcess {
  41558. private _passedProcess;
  41559. /**
  41560. * Creates a new AnaglyphPostProcess
  41561. * @param name defines postprocess name
  41562. * @param options defines creation options or target ratio scale
  41563. * @param rigCameras defines cameras using this postprocess
  41564. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41565. * @param engine defines hosting engine
  41566. * @param reusable defines if the postprocess will be reused multiple times per frame
  41567. */
  41568. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41569. }
  41570. }
  41571. declare module BABYLON {
  41572. /**
  41573. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41574. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41575. */
  41576. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41577. /**
  41578. * Creates a new AnaglyphArcRotateCamera
  41579. * @param name defines camera name
  41580. * @param alpha defines alpha angle (in radians)
  41581. * @param beta defines beta angle (in radians)
  41582. * @param radius defines radius
  41583. * @param target defines camera target
  41584. * @param interaxialDistance defines distance between each color axis
  41585. * @param scene defines the hosting scene
  41586. */
  41587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41588. /**
  41589. * Gets camera class name
  41590. * @returns AnaglyphArcRotateCamera
  41591. */
  41592. getClassName(): string;
  41593. }
  41594. }
  41595. declare module BABYLON {
  41596. /**
  41597. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41598. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41599. */
  41600. export class AnaglyphFreeCamera extends FreeCamera {
  41601. /**
  41602. * Creates a new AnaglyphFreeCamera
  41603. * @param name defines camera name
  41604. * @param position defines initial position
  41605. * @param interaxialDistance defines distance between each color axis
  41606. * @param scene defines the hosting scene
  41607. */
  41608. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41609. /**
  41610. * Gets camera class name
  41611. * @returns AnaglyphFreeCamera
  41612. */
  41613. getClassName(): string;
  41614. }
  41615. }
  41616. declare module BABYLON {
  41617. /**
  41618. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41619. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41620. */
  41621. export class AnaglyphGamepadCamera extends GamepadCamera {
  41622. /**
  41623. * Creates a new AnaglyphGamepadCamera
  41624. * @param name defines camera name
  41625. * @param position defines initial position
  41626. * @param interaxialDistance defines distance between each color axis
  41627. * @param scene defines the hosting scene
  41628. */
  41629. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41630. /**
  41631. * Gets camera class name
  41632. * @returns AnaglyphGamepadCamera
  41633. */
  41634. getClassName(): string;
  41635. }
  41636. }
  41637. declare module BABYLON {
  41638. /**
  41639. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41640. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41641. */
  41642. export class AnaglyphUniversalCamera extends UniversalCamera {
  41643. /**
  41644. * Creates a new AnaglyphUniversalCamera
  41645. * @param name defines camera name
  41646. * @param position defines initial position
  41647. * @param interaxialDistance defines distance between each color axis
  41648. * @param scene defines the hosting scene
  41649. */
  41650. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41651. /**
  41652. * Gets camera class name
  41653. * @returns AnaglyphUniversalCamera
  41654. */
  41655. getClassName(): string;
  41656. }
  41657. }
  41658. declare module BABYLON {
  41659. /** @hidden */
  41660. export var stereoscopicInterlacePixelShader: {
  41661. name: string;
  41662. shader: string;
  41663. };
  41664. }
  41665. declare module BABYLON {
  41666. /**
  41667. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41668. */
  41669. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41670. private _stepSize;
  41671. private _passedProcess;
  41672. /**
  41673. * Initializes a StereoscopicInterlacePostProcessI
  41674. * @param name The name of the effect.
  41675. * @param rigCameras The rig cameras to be appled to the post process
  41676. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41677. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41679. * @param engine The engine which the post process will be applied. (default: current engine)
  41680. * @param reusable If the post process can be reused on the same frame. (default: false)
  41681. */
  41682. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41683. }
  41684. /**
  41685. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41686. */
  41687. export class StereoscopicInterlacePostProcess extends PostProcess {
  41688. private _stepSize;
  41689. private _passedProcess;
  41690. /**
  41691. * Initializes a StereoscopicInterlacePostProcess
  41692. * @param name The name of the effect.
  41693. * @param rigCameras The rig cameras to be appled to the post process
  41694. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41696. * @param engine The engine which the post process will be applied. (default: current engine)
  41697. * @param reusable If the post process can be reused on the same frame. (default: false)
  41698. */
  41699. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41700. }
  41701. }
  41702. declare module BABYLON {
  41703. /**
  41704. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41705. * @see http://doc.babylonjs.com/features/cameras
  41706. */
  41707. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41708. /**
  41709. * Creates a new StereoscopicArcRotateCamera
  41710. * @param name defines camera name
  41711. * @param alpha defines alpha angle (in radians)
  41712. * @param beta defines beta angle (in radians)
  41713. * @param radius defines radius
  41714. * @param target defines camera target
  41715. * @param interaxialDistance defines distance between each color axis
  41716. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41717. * @param scene defines the hosting scene
  41718. */
  41719. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41720. /**
  41721. * Gets camera class name
  41722. * @returns StereoscopicArcRotateCamera
  41723. */
  41724. getClassName(): string;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41730. * @see http://doc.babylonjs.com/features/cameras
  41731. */
  41732. export class StereoscopicFreeCamera extends FreeCamera {
  41733. /**
  41734. * Creates a new StereoscopicFreeCamera
  41735. * @param name defines camera name
  41736. * @param position defines initial position
  41737. * @param interaxialDistance defines distance between each color axis
  41738. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41739. * @param scene defines the hosting scene
  41740. */
  41741. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41742. /**
  41743. * Gets camera class name
  41744. * @returns StereoscopicFreeCamera
  41745. */
  41746. getClassName(): string;
  41747. }
  41748. }
  41749. declare module BABYLON {
  41750. /**
  41751. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41752. * @see http://doc.babylonjs.com/features/cameras
  41753. */
  41754. export class StereoscopicGamepadCamera extends GamepadCamera {
  41755. /**
  41756. * Creates a new StereoscopicGamepadCamera
  41757. * @param name defines camera name
  41758. * @param position defines initial position
  41759. * @param interaxialDistance defines distance between each color axis
  41760. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41761. * @param scene defines the hosting scene
  41762. */
  41763. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41764. /**
  41765. * Gets camera class name
  41766. * @returns StereoscopicGamepadCamera
  41767. */
  41768. getClassName(): string;
  41769. }
  41770. }
  41771. declare module BABYLON {
  41772. /**
  41773. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41774. * @see http://doc.babylonjs.com/features/cameras
  41775. */
  41776. export class StereoscopicUniversalCamera extends UniversalCamera {
  41777. /**
  41778. * Creates a new StereoscopicUniversalCamera
  41779. * @param name defines camera name
  41780. * @param position defines initial position
  41781. * @param interaxialDistance defines distance between each color axis
  41782. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41783. * @param scene defines the hosting scene
  41784. */
  41785. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41786. /**
  41787. * Gets camera class name
  41788. * @returns StereoscopicUniversalCamera
  41789. */
  41790. getClassName(): string;
  41791. }
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41796. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41797. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41798. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41799. */
  41800. export class VirtualJoysticksCamera extends FreeCamera {
  41801. /**
  41802. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41803. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41804. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41805. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41806. * @param name Define the name of the camera in the scene
  41807. * @param position Define the start position of the camera in the scene
  41808. * @param scene Define the scene the camera belongs to
  41809. */
  41810. constructor(name: string, position: Vector3, scene: Scene);
  41811. /**
  41812. * Gets the current object class name.
  41813. * @return the class name
  41814. */
  41815. getClassName(): string;
  41816. }
  41817. }
  41818. declare module BABYLON {
  41819. /**
  41820. * This represents all the required metrics to create a VR camera.
  41821. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41822. */
  41823. export class VRCameraMetrics {
  41824. /**
  41825. * Define the horizontal resolution off the screen.
  41826. */
  41827. hResolution: number;
  41828. /**
  41829. * Define the vertical resolution off the screen.
  41830. */
  41831. vResolution: number;
  41832. /**
  41833. * Define the horizontal screen size.
  41834. */
  41835. hScreenSize: number;
  41836. /**
  41837. * Define the vertical screen size.
  41838. */
  41839. vScreenSize: number;
  41840. /**
  41841. * Define the vertical screen center position.
  41842. */
  41843. vScreenCenter: number;
  41844. /**
  41845. * Define the distance of the eyes to the screen.
  41846. */
  41847. eyeToScreenDistance: number;
  41848. /**
  41849. * Define the distance between both lenses
  41850. */
  41851. lensSeparationDistance: number;
  41852. /**
  41853. * Define the distance between both viewer's eyes.
  41854. */
  41855. interpupillaryDistance: number;
  41856. /**
  41857. * Define the distortion factor of the VR postprocess.
  41858. * Please, touch with care.
  41859. */
  41860. distortionK: number[];
  41861. /**
  41862. * Define the chromatic aberration correction factors for the VR post process.
  41863. */
  41864. chromaAbCorrection: number[];
  41865. /**
  41866. * Define the scale factor of the post process.
  41867. * The smaller the better but the slower.
  41868. */
  41869. postProcessScaleFactor: number;
  41870. /**
  41871. * Define an offset for the lens center.
  41872. */
  41873. lensCenterOffset: number;
  41874. /**
  41875. * Define if the current vr camera should compensate the distortion of the lense or not.
  41876. */
  41877. compensateDistortion: boolean;
  41878. /**
  41879. * Defines if multiview should be enabled when rendering (Default: false)
  41880. */
  41881. multiviewEnabled: boolean;
  41882. /**
  41883. * Gets the rendering aspect ratio based on the provided resolutions.
  41884. */
  41885. get aspectRatio(): number;
  41886. /**
  41887. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41888. */
  41889. get aspectRatioFov(): number;
  41890. /**
  41891. * @hidden
  41892. */
  41893. get leftHMatrix(): Matrix;
  41894. /**
  41895. * @hidden
  41896. */
  41897. get rightHMatrix(): Matrix;
  41898. /**
  41899. * @hidden
  41900. */
  41901. get leftPreViewMatrix(): Matrix;
  41902. /**
  41903. * @hidden
  41904. */
  41905. get rightPreViewMatrix(): Matrix;
  41906. /**
  41907. * Get the default VRMetrics based on the most generic setup.
  41908. * @returns the default vr metrics
  41909. */
  41910. static GetDefault(): VRCameraMetrics;
  41911. }
  41912. }
  41913. declare module BABYLON {
  41914. /** @hidden */
  41915. export var vrDistortionCorrectionPixelShader: {
  41916. name: string;
  41917. shader: string;
  41918. };
  41919. }
  41920. declare module BABYLON {
  41921. /**
  41922. * VRDistortionCorrectionPostProcess used for mobile VR
  41923. */
  41924. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41925. private _isRightEye;
  41926. private _distortionFactors;
  41927. private _postProcessScaleFactor;
  41928. private _lensCenterOffset;
  41929. private _scaleIn;
  41930. private _scaleFactor;
  41931. private _lensCenter;
  41932. /**
  41933. * Initializes the VRDistortionCorrectionPostProcess
  41934. * @param name The name of the effect.
  41935. * @param camera The camera to apply the render pass to.
  41936. * @param isRightEye If this is for the right eye distortion
  41937. * @param vrMetrics All the required metrics for the VR camera
  41938. */
  41939. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41940. }
  41941. }
  41942. declare module BABYLON {
  41943. /**
  41944. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41945. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41946. */
  41947. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41948. /**
  41949. * Creates a new VRDeviceOrientationArcRotateCamera
  41950. * @param name defines camera name
  41951. * @param alpha defines the camera rotation along the logitudinal axis
  41952. * @param beta defines the camera rotation along the latitudinal axis
  41953. * @param radius defines the camera distance from its target
  41954. * @param target defines the camera target
  41955. * @param scene defines the scene the camera belongs to
  41956. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41957. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41958. */
  41959. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41960. /**
  41961. * Gets camera class name
  41962. * @returns VRDeviceOrientationArcRotateCamera
  41963. */
  41964. getClassName(): string;
  41965. }
  41966. }
  41967. declare module BABYLON {
  41968. /**
  41969. * Camera used to simulate VR rendering (based on FreeCamera)
  41970. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41971. */
  41972. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41973. /**
  41974. * Creates a new VRDeviceOrientationFreeCamera
  41975. * @param name defines camera name
  41976. * @param position defines the start position of the camera
  41977. * @param scene defines the scene the camera belongs to
  41978. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41979. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41980. */
  41981. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41982. /**
  41983. * Gets camera class name
  41984. * @returns VRDeviceOrientationFreeCamera
  41985. */
  41986. getClassName(): string;
  41987. }
  41988. }
  41989. declare module BABYLON {
  41990. /**
  41991. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41992. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41993. */
  41994. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41995. /**
  41996. * Creates a new VRDeviceOrientationGamepadCamera
  41997. * @param name defines camera name
  41998. * @param position defines the start position of the camera
  41999. * @param scene defines the scene the camera belongs to
  42000. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42001. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42002. */
  42003. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42004. /**
  42005. * Gets camera class name
  42006. * @returns VRDeviceOrientationGamepadCamera
  42007. */
  42008. getClassName(): string;
  42009. }
  42010. }
  42011. declare module BABYLON {
  42012. /** @hidden */
  42013. export var imageProcessingPixelShader: {
  42014. name: string;
  42015. shader: string;
  42016. };
  42017. }
  42018. declare module BABYLON {
  42019. /**
  42020. * ImageProcessingPostProcess
  42021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42022. */
  42023. export class ImageProcessingPostProcess extends PostProcess {
  42024. /**
  42025. * Default configuration related to image processing available in the PBR Material.
  42026. */
  42027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42028. /**
  42029. * Gets the image processing configuration used either in this material.
  42030. */
  42031. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42032. /**
  42033. * Sets the Default image processing configuration used either in the this material.
  42034. *
  42035. * If sets to null, the scene one is in use.
  42036. */
  42037. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42038. /**
  42039. * Keep track of the image processing observer to allow dispose and replace.
  42040. */
  42041. private _imageProcessingObserver;
  42042. /**
  42043. * Attaches a new image processing configuration to the PBR Material.
  42044. * @param configuration
  42045. */
  42046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42047. /**
  42048. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42049. */
  42050. get colorCurves(): Nullable<ColorCurves>;
  42051. /**
  42052. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42053. */
  42054. set colorCurves(value: Nullable<ColorCurves>);
  42055. /**
  42056. * Gets wether the color curves effect is enabled.
  42057. */
  42058. get colorCurvesEnabled(): boolean;
  42059. /**
  42060. * Sets wether the color curves effect is enabled.
  42061. */
  42062. set colorCurvesEnabled(value: boolean);
  42063. /**
  42064. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42065. */
  42066. get colorGradingTexture(): Nullable<BaseTexture>;
  42067. /**
  42068. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42069. */
  42070. set colorGradingTexture(value: Nullable<BaseTexture>);
  42071. /**
  42072. * Gets wether the color grading effect is enabled.
  42073. */
  42074. get colorGradingEnabled(): boolean;
  42075. /**
  42076. * Gets wether the color grading effect is enabled.
  42077. */
  42078. set colorGradingEnabled(value: boolean);
  42079. /**
  42080. * Gets exposure used in the effect.
  42081. */
  42082. get exposure(): number;
  42083. /**
  42084. * Sets exposure used in the effect.
  42085. */
  42086. set exposure(value: number);
  42087. /**
  42088. * Gets wether tonemapping is enabled or not.
  42089. */
  42090. get toneMappingEnabled(): boolean;
  42091. /**
  42092. * Sets wether tonemapping is enabled or not
  42093. */
  42094. set toneMappingEnabled(value: boolean);
  42095. /**
  42096. * Gets the type of tone mapping effect.
  42097. */
  42098. get toneMappingType(): number;
  42099. /**
  42100. * Sets the type of tone mapping effect.
  42101. */
  42102. set toneMappingType(value: number);
  42103. /**
  42104. * Gets contrast used in the effect.
  42105. */
  42106. get contrast(): number;
  42107. /**
  42108. * Sets contrast used in the effect.
  42109. */
  42110. set contrast(value: number);
  42111. /**
  42112. * Gets Vignette stretch size.
  42113. */
  42114. get vignetteStretch(): number;
  42115. /**
  42116. * Sets Vignette stretch size.
  42117. */
  42118. set vignetteStretch(value: number);
  42119. /**
  42120. * Gets Vignette centre X Offset.
  42121. */
  42122. get vignetteCentreX(): number;
  42123. /**
  42124. * Sets Vignette centre X Offset.
  42125. */
  42126. set vignetteCentreX(value: number);
  42127. /**
  42128. * Gets Vignette centre Y Offset.
  42129. */
  42130. get vignetteCentreY(): number;
  42131. /**
  42132. * Sets Vignette centre Y Offset.
  42133. */
  42134. set vignetteCentreY(value: number);
  42135. /**
  42136. * Gets Vignette weight or intensity of the vignette effect.
  42137. */
  42138. get vignetteWeight(): number;
  42139. /**
  42140. * Sets Vignette weight or intensity of the vignette effect.
  42141. */
  42142. set vignetteWeight(value: number);
  42143. /**
  42144. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42145. * if vignetteEnabled is set to true.
  42146. */
  42147. get vignetteColor(): Color4;
  42148. /**
  42149. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42150. * if vignetteEnabled is set to true.
  42151. */
  42152. set vignetteColor(value: Color4);
  42153. /**
  42154. * Gets Camera field of view used by the Vignette effect.
  42155. */
  42156. get vignetteCameraFov(): number;
  42157. /**
  42158. * Sets Camera field of view used by the Vignette effect.
  42159. */
  42160. set vignetteCameraFov(value: number);
  42161. /**
  42162. * Gets the vignette blend mode allowing different kind of effect.
  42163. */
  42164. get vignetteBlendMode(): number;
  42165. /**
  42166. * Sets the vignette blend mode allowing different kind of effect.
  42167. */
  42168. set vignetteBlendMode(value: number);
  42169. /**
  42170. * Gets wether the vignette effect is enabled.
  42171. */
  42172. get vignetteEnabled(): boolean;
  42173. /**
  42174. * Sets wether the vignette effect is enabled.
  42175. */
  42176. set vignetteEnabled(value: boolean);
  42177. private _fromLinearSpace;
  42178. /**
  42179. * Gets wether the input of the processing is in Gamma or Linear Space.
  42180. */
  42181. get fromLinearSpace(): boolean;
  42182. /**
  42183. * Sets wether the input of the processing is in Gamma or Linear Space.
  42184. */
  42185. set fromLinearSpace(value: boolean);
  42186. /**
  42187. * Defines cache preventing GC.
  42188. */
  42189. private _defines;
  42190. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42191. /**
  42192. * "ImageProcessingPostProcess"
  42193. * @returns "ImageProcessingPostProcess"
  42194. */
  42195. getClassName(): string;
  42196. protected _updateParameters(): void;
  42197. dispose(camera?: Camera): void;
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * Class containing static functions to help procedurally build meshes
  42203. */
  42204. export class GroundBuilder {
  42205. /**
  42206. * Creates a ground mesh
  42207. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42208. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42210. * @param name defines the name of the mesh
  42211. * @param options defines the options used to create the mesh
  42212. * @param scene defines the hosting scene
  42213. * @returns the ground mesh
  42214. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42215. */
  42216. static CreateGround(name: string, options: {
  42217. width?: number;
  42218. height?: number;
  42219. subdivisions?: number;
  42220. subdivisionsX?: number;
  42221. subdivisionsY?: number;
  42222. updatable?: boolean;
  42223. }, scene: any): Mesh;
  42224. /**
  42225. * Creates a tiled ground mesh
  42226. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42227. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42228. * * 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
  42229. * * 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
  42230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42231. * @param name defines the name of the mesh
  42232. * @param options defines the options used to create the mesh
  42233. * @param scene defines the hosting scene
  42234. * @returns the tiled ground mesh
  42235. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42236. */
  42237. static CreateTiledGround(name: string, options: {
  42238. xmin: number;
  42239. zmin: number;
  42240. xmax: number;
  42241. zmax: number;
  42242. subdivisions?: {
  42243. w: number;
  42244. h: number;
  42245. };
  42246. precision?: {
  42247. w: number;
  42248. h: number;
  42249. };
  42250. updatable?: boolean;
  42251. }, scene?: Nullable<Scene>): Mesh;
  42252. /**
  42253. * Creates a ground mesh from a height map
  42254. * * The parameter `url` sets the URL of the height map image resource.
  42255. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42256. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42257. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42258. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42259. * * 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.
  42260. * * 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).
  42261. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42263. * @param name defines the name of the mesh
  42264. * @param url defines the url to the height map
  42265. * @param options defines the options used to create the mesh
  42266. * @param scene defines the hosting scene
  42267. * @returns the ground mesh
  42268. * @see https://doc.babylonjs.com/babylon101/height_map
  42269. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42270. */
  42271. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42272. width?: number;
  42273. height?: number;
  42274. subdivisions?: number;
  42275. minHeight?: number;
  42276. maxHeight?: number;
  42277. colorFilter?: Color3;
  42278. alphaFilter?: number;
  42279. updatable?: boolean;
  42280. onReady?: (mesh: GroundMesh) => void;
  42281. }, scene?: Nullable<Scene>): GroundMesh;
  42282. }
  42283. }
  42284. declare module BABYLON {
  42285. /**
  42286. * Class containing static functions to help procedurally build meshes
  42287. */
  42288. export class TorusBuilder {
  42289. /**
  42290. * Creates a torus mesh
  42291. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42292. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42293. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42295. * * 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
  42296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42297. * @param name defines the name of the mesh
  42298. * @param options defines the options used to create the mesh
  42299. * @param scene defines the hosting scene
  42300. * @returns the torus mesh
  42301. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42302. */
  42303. static CreateTorus(name: string, options: {
  42304. diameter?: number;
  42305. thickness?: number;
  42306. tessellation?: number;
  42307. updatable?: boolean;
  42308. sideOrientation?: number;
  42309. frontUVs?: Vector4;
  42310. backUVs?: Vector4;
  42311. }, scene: any): Mesh;
  42312. }
  42313. }
  42314. declare module BABYLON {
  42315. /**
  42316. * Class containing static functions to help procedurally build meshes
  42317. */
  42318. export class CylinderBuilder {
  42319. /**
  42320. * Creates a cylinder or a cone mesh
  42321. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42322. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42323. * * 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.
  42324. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42325. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42326. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42327. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42328. * * 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).
  42329. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42330. * * 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).
  42331. * * 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
  42332. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42333. * * 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
  42334. * * 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.
  42335. * * If `enclose` is false, a ring surface is one element.
  42336. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42337. * * 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
  42338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42339. * * 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
  42340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42341. * @param name defines the name of the mesh
  42342. * @param options defines the options used to create the mesh
  42343. * @param scene defines the hosting scene
  42344. * @returns the cylinder mesh
  42345. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42346. */
  42347. static CreateCylinder(name: string, options: {
  42348. height?: number;
  42349. diameterTop?: number;
  42350. diameterBottom?: number;
  42351. diameter?: number;
  42352. tessellation?: number;
  42353. subdivisions?: number;
  42354. arc?: number;
  42355. faceColors?: Color4[];
  42356. faceUV?: Vector4[];
  42357. updatable?: boolean;
  42358. hasRings?: boolean;
  42359. enclose?: boolean;
  42360. cap?: number;
  42361. sideOrientation?: number;
  42362. frontUVs?: Vector4;
  42363. backUVs?: Vector4;
  42364. }, scene: any): Mesh;
  42365. }
  42366. }
  42367. declare module BABYLON {
  42368. /**
  42369. * States of the webXR experience
  42370. */
  42371. export enum WebXRState {
  42372. /**
  42373. * Transitioning to being in XR mode
  42374. */
  42375. ENTERING_XR = 0,
  42376. /**
  42377. * Transitioning to non XR mode
  42378. */
  42379. EXITING_XR = 1,
  42380. /**
  42381. * In XR mode and presenting
  42382. */
  42383. IN_XR = 2,
  42384. /**
  42385. * Not entered XR mode
  42386. */
  42387. NOT_IN_XR = 3
  42388. }
  42389. /**
  42390. * Abstraction of the XR render target
  42391. */
  42392. export interface WebXRRenderTarget extends IDisposable {
  42393. /**
  42394. * xrpresent context of the canvas which can be used to display/mirror xr content
  42395. */
  42396. canvasContext: WebGLRenderingContext;
  42397. /**
  42398. * xr layer for the canvas
  42399. */
  42400. xrLayer: Nullable<XRWebGLLayer>;
  42401. /**
  42402. * Initializes the xr layer for the session
  42403. * @param xrSession xr session
  42404. * @returns a promise that will resolve once the XR Layer has been created
  42405. */
  42406. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * COnfiguration object for WebXR output canvas
  42412. */
  42413. export class WebXRManagedOutputCanvasOptions {
  42414. /**
  42415. * Options for this XR Layer output
  42416. */
  42417. canvasOptions?: XRWebGLLayerOptions;
  42418. /**
  42419. * CSS styling for a newly created canvas (if not provided)
  42420. */
  42421. newCanvasCssStyle?: string;
  42422. /**
  42423. * An optional canvas in case you wish to create it yourself and provide it here.
  42424. * If not provided, a new canvas will be created
  42425. */
  42426. canvasElement?: HTMLCanvasElement;
  42427. /**
  42428. * Get the default values of the configuration object
  42429. * @returns default values of this configuration object
  42430. */
  42431. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42432. }
  42433. /**
  42434. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42435. */
  42436. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42437. private _options;
  42438. private _engine;
  42439. private _canvas;
  42440. /**
  42441. * Rendering context of the canvas which can be used to display/mirror xr content
  42442. */
  42443. canvasContext: WebGLRenderingContext;
  42444. /**
  42445. * xr layer for the canvas
  42446. */
  42447. xrLayer: Nullable<XRWebGLLayer>;
  42448. /**
  42449. * Initializes the xr layer for the session
  42450. * @param xrSession xr session
  42451. * @returns a promise that will resolve once the XR Layer has been created
  42452. */
  42453. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42454. /**
  42455. * Initializes the canvas to be added/removed upon entering/exiting xr
  42456. * @param _xrSessionManager The XR Session manager
  42457. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42458. */
  42459. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42460. /**
  42461. * Disposes of the object
  42462. */
  42463. dispose(): void;
  42464. private _setManagedOutputCanvas;
  42465. private _addCanvas;
  42466. private _removeCanvas;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /**
  42471. * Manages an XRSession to work with Babylon's engine
  42472. * @see https://doc.babylonjs.com/how_to/webxr
  42473. */
  42474. export class WebXRSessionManager implements IDisposable {
  42475. /** The scene which the session should be created for */
  42476. scene: Scene;
  42477. /**
  42478. * Fires every time a new xrFrame arrives which can be used to update the camera
  42479. */
  42480. onXRFrameObservable: Observable<XRFrame>;
  42481. /**
  42482. * Fires when the xr session is ended either by the device or manually done
  42483. */
  42484. onXRSessionEnded: Observable<any>;
  42485. /**
  42486. * Fires when the xr session is ended either by the device or manually done
  42487. */
  42488. onXRSessionInit: Observable<XRSession>;
  42489. /**
  42490. * Fires when the reference space changed
  42491. */
  42492. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42493. /**
  42494. * Underlying xr session
  42495. */
  42496. session: XRSession;
  42497. /**
  42498. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42499. * or get the offset the player is currently at.
  42500. */
  42501. viewerReferenceSpace: XRReferenceSpace;
  42502. private _referenceSpace;
  42503. /**
  42504. * The current reference space used in this session. This reference space can constantly change!
  42505. * It is mainly used to offset the camera's position.
  42506. */
  42507. get referenceSpace(): XRReferenceSpace;
  42508. /**
  42509. * Set a new reference space and triggers the observable
  42510. */
  42511. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42512. /**
  42513. * The base reference space from which the session started. good if you want to reset your
  42514. * reference space
  42515. */
  42516. baseReferenceSpace: XRReferenceSpace;
  42517. /**
  42518. * Used just in case of a failure to initialize an immersive session.
  42519. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42520. */
  42521. defaultHeightCompensation: number;
  42522. /**
  42523. * Current XR frame
  42524. */
  42525. currentFrame: Nullable<XRFrame>;
  42526. /** WebXR timestamp updated every frame */
  42527. currentTimestamp: number;
  42528. private _xrNavigator;
  42529. private baseLayer;
  42530. private _rttProvider;
  42531. private _sessionEnded;
  42532. /**
  42533. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42534. * @param scene The scene which the session should be created for
  42535. */
  42536. constructor(
  42537. /** The scene which the session should be created for */
  42538. scene: Scene);
  42539. /**
  42540. * Initializes the manager
  42541. * After initialization enterXR can be called to start an XR session
  42542. * @returns Promise which resolves after it is initialized
  42543. */
  42544. initializeAsync(): Promise<void>;
  42545. /**
  42546. * Initializes an xr session
  42547. * @param xrSessionMode mode to initialize
  42548. * @param xrSessionInit defines optional and required values to pass to the session builder
  42549. * @returns a promise which will resolve once the session has been initialized
  42550. */
  42551. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42552. /**
  42553. * Sets the reference space on the xr session
  42554. * @param referenceSpaceType space to set
  42555. * @returns a promise that will resolve once the reference space has been set
  42556. */
  42557. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42558. /**
  42559. * Resets the reference space to the one started the session
  42560. */
  42561. resetReferenceSpace(): void;
  42562. /**
  42563. * Updates the render state of the session
  42564. * @param state state to set
  42565. * @returns a promise that resolves once the render state has been updated
  42566. */
  42567. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42568. /**
  42569. * Starts rendering to the xr layer
  42570. */
  42571. runXRRenderLoop(): void;
  42572. /**
  42573. * Gets the correct render target texture to be rendered this frame for this eye
  42574. * @param eye the eye for which to get the render target
  42575. * @returns the render target for the specified eye
  42576. */
  42577. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42578. /**
  42579. * Stops the xrSession and restores the renderloop
  42580. * @returns Promise which resolves after it exits XR
  42581. */
  42582. exitXRAsync(): Promise<void>;
  42583. /**
  42584. * Checks if a session would be supported for the creation options specified
  42585. * @param sessionMode session mode to check if supported eg. immersive-vr
  42586. * @returns A Promise that resolves to true if supported and false if not
  42587. */
  42588. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42589. /**
  42590. * Creates a WebXRRenderTarget object for the XR session
  42591. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42592. * @param options optional options to provide when creating a new render target
  42593. * @returns a WebXR render target to which the session can render
  42594. */
  42595. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42596. /**
  42597. * @hidden
  42598. * Converts the render layer of xrSession to a render target
  42599. * @param session session to create render target for
  42600. * @param scene scene the new render target should be created for
  42601. * @param baseLayer the webgl layer to create the render target for
  42602. */
  42603. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42604. /**
  42605. * Disposes of the session manager
  42606. */
  42607. dispose(): void;
  42608. /**
  42609. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42610. * @param sessionMode defines the session to test
  42611. * @returns a promise with boolean as final value
  42612. */
  42613. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42614. }
  42615. }
  42616. declare module BABYLON {
  42617. /**
  42618. * WebXR Camera which holds the views for the xrSession
  42619. * @see https://doc.babylonjs.com/how_to/webxr
  42620. */
  42621. export class WebXRCamera extends FreeCamera {
  42622. private _xrSessionManager;
  42623. /**
  42624. * Should position compensation execute on first frame.
  42625. * This is used when copying the position from a native (non XR) camera
  42626. */
  42627. compensateOnFirstFrame: boolean;
  42628. private _firstFrame;
  42629. private _referencedPosition;
  42630. private _referenceQuaternion;
  42631. private _xrInvPositionCache;
  42632. private _xrInvQuaternionCache;
  42633. /**
  42634. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42635. * @param name the name of the camera
  42636. * @param scene the scene to add the camera to
  42637. */
  42638. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42639. private _updateNumberOfRigCameras;
  42640. /**
  42641. * Sets this camera's transformation based on a non-vr camera
  42642. * @param otherCamera the non-vr camera to copy the transformation from
  42643. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42644. */
  42645. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42646. /** @hidden */
  42647. _updateForDualEyeDebugging(): void;
  42648. private _updateReferenceSpace;
  42649. private _updateReferenceSpaceOffset;
  42650. private _updateFromXRSession;
  42651. }
  42652. }
  42653. declare module BABYLON {
  42654. /**
  42655. * Defining the interface required for a (webxr) feature
  42656. */
  42657. export interface IWebXRFeature extends IDisposable {
  42658. /**
  42659. * Is this feature attached
  42660. */
  42661. attached: boolean;
  42662. /**
  42663. * Should auto-attach be disabled?
  42664. */
  42665. disableAutoAttach: boolean;
  42666. /**
  42667. * Attach the feature to the session
  42668. * Will usually be called by the features manager
  42669. *
  42670. * @param force should attachment be forced (even when already attached)
  42671. * @returns true if successful.
  42672. */
  42673. attach(force?: boolean): boolean;
  42674. /**
  42675. * Detach the feature from the session
  42676. * Will usually be called by the features manager
  42677. *
  42678. * @returns true if successful.
  42679. */
  42680. detach(): boolean;
  42681. }
  42682. /**
  42683. * A list of the currently available features without referencing them
  42684. */
  42685. export class WebXRFeatureName {
  42686. /**
  42687. * The name of the hit test feature
  42688. */
  42689. static HIT_TEST: string;
  42690. /**
  42691. * The name of the anchor system feature
  42692. */
  42693. static ANCHOR_SYSTEM: string;
  42694. /**
  42695. * The name of the background remover feature
  42696. */
  42697. static BACKGROUND_REMOVER: string;
  42698. /**
  42699. * The name of the pointer selection feature
  42700. */
  42701. static POINTER_SELECTION: string;
  42702. /**
  42703. * The name of the teleportation feature
  42704. */
  42705. static TELEPORTATION: string;
  42706. /**
  42707. * The name of the plane detection feature
  42708. */
  42709. static PLANE_DETECTION: string;
  42710. }
  42711. /**
  42712. * Defining the constructor of a feature. Used to register the modules.
  42713. */
  42714. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42715. /**
  42716. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42717. * It is mainly used in AR sessions.
  42718. *
  42719. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42720. */
  42721. export class WebXRFeaturesManager implements IDisposable {
  42722. private _xrSessionManager;
  42723. private static readonly _AvailableFeatures;
  42724. /**
  42725. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42726. * Mainly used internally.
  42727. *
  42728. * @param featureName the name of the feature to register
  42729. * @param constructorFunction the function used to construct the module
  42730. * @param version the (babylon) version of the module
  42731. * @param stable is that a stable version of this module
  42732. */
  42733. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42734. /**
  42735. * Returns a constructor of a specific feature.
  42736. *
  42737. * @param featureName the name of the feature to construct
  42738. * @param version the version of the feature to load
  42739. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42740. * @param options optional options provided to the module.
  42741. * @returns a function that, when called, will return a new instance of this feature
  42742. */
  42743. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42744. /**
  42745. * Return the latest unstable version of this feature
  42746. * @param featureName the name of the feature to search
  42747. * @returns the version number. if not found will return -1
  42748. */
  42749. static GetLatestVersionOfFeature(featureName: string): number;
  42750. /**
  42751. * Return the latest stable version of this feature
  42752. * @param featureName the name of the feature to search
  42753. * @returns the version number. if not found will return -1
  42754. */
  42755. static GetStableVersionOfFeature(featureName: string): number;
  42756. /**
  42757. * Can be used to return the list of features currently registered
  42758. *
  42759. * @returns an Array of available features
  42760. */
  42761. static GetAvailableFeatures(): string[];
  42762. /**
  42763. * Gets the versions available for a specific feature
  42764. * @param featureName the name of the feature
  42765. * @returns an array with the available versions
  42766. */
  42767. static GetAvailableVersions(featureName: string): string[];
  42768. private _features;
  42769. /**
  42770. * constructs a new features manages.
  42771. *
  42772. * @param _xrSessionManager an instance of WebXRSessionManager
  42773. */
  42774. constructor(_xrSessionManager: WebXRSessionManager);
  42775. /**
  42776. * 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.
  42777. * 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.
  42778. *
  42779. * @param featureName the name of the feature to load or the class of the feature
  42780. * @param version optional version to load. if not provided the latest version will be enabled
  42781. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42782. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42783. * @returns a new constructed feature or throws an error if feature not found.
  42784. */
  42785. enableFeature(featureName: string | {
  42786. Name: string;
  42787. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42788. /**
  42789. * Used to disable an already-enabled feature
  42790. * The feature will be disposed and will be recreated once enabled.
  42791. * @param featureName the feature to disable
  42792. * @returns true if disable was successful
  42793. */
  42794. disableFeature(featureName: string | {
  42795. Name: string;
  42796. }): boolean;
  42797. /**
  42798. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42799. * Can be used during a session to start a feature
  42800. * @param featureName the name of feature to attach
  42801. */
  42802. attachFeature(featureName: string): void;
  42803. /**
  42804. * Can be used inside a session or when the session ends to detach a specific feature
  42805. * @param featureName the name of the feature to detach
  42806. */
  42807. detachFeature(featureName: string): void;
  42808. /**
  42809. * Get the list of enabled features
  42810. * @returns an array of enabled features
  42811. */
  42812. getEnabledFeatures(): string[];
  42813. /**
  42814. * get the implementation of an enabled feature.
  42815. * @param featureName the name of the feature to load
  42816. * @returns the feature class, if found
  42817. */
  42818. getEnabledFeature(featureName: string): IWebXRFeature;
  42819. /**
  42820. * dispose this features manager
  42821. */
  42822. dispose(): void;
  42823. }
  42824. }
  42825. declare module BABYLON {
  42826. /**
  42827. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42828. * @see https://doc.babylonjs.com/how_to/webxr
  42829. */
  42830. export class WebXRExperienceHelper implements IDisposable {
  42831. private scene;
  42832. /**
  42833. * Camera used to render xr content
  42834. */
  42835. camera: WebXRCamera;
  42836. /**
  42837. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42838. */
  42839. state: WebXRState;
  42840. private _setState;
  42841. /**
  42842. * Fires when the state of the experience helper has changed
  42843. */
  42844. onStateChangedObservable: Observable<WebXRState>;
  42845. /**
  42846. * Observers registered here will be triggered after the camera's initial transformation is set
  42847. * This can be used to set a different ground level or an extra rotation.
  42848. *
  42849. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42850. * to the position set after this observable is done executing.
  42851. */
  42852. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42853. /** Session manager used to keep track of xr session */
  42854. sessionManager: WebXRSessionManager;
  42855. /** A features manager for this xr session */
  42856. featuresManager: WebXRFeaturesManager;
  42857. private _nonVRCamera;
  42858. private _originalSceneAutoClear;
  42859. private _supported;
  42860. /**
  42861. * Creates the experience helper
  42862. * @param scene the scene to attach the experience helper to
  42863. * @returns a promise for the experience helper
  42864. */
  42865. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42866. /**
  42867. * Creates a WebXRExperienceHelper
  42868. * @param scene The scene the helper should be created in
  42869. */
  42870. private constructor();
  42871. /**
  42872. * Exits XR mode and returns the scene to its original state
  42873. * @returns promise that resolves after xr mode has exited
  42874. */
  42875. exitXRAsync(): Promise<void>;
  42876. /**
  42877. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42878. * @param sessionMode options for the XR session
  42879. * @param referenceSpaceType frame of reference of the XR session
  42880. * @param renderTarget the output canvas that will be used to enter XR mode
  42881. * @returns promise that resolves after xr mode has entered
  42882. */
  42883. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42884. /**
  42885. * Disposes of the experience helper
  42886. */
  42887. dispose(): void;
  42888. private _nonXRToXRCamera;
  42889. }
  42890. }
  42891. declare module BABYLON {
  42892. /**
  42893. * X-Y values for axes in WebXR
  42894. */
  42895. export interface IWebXRMotionControllerAxesValue {
  42896. /**
  42897. * The value of the x axis
  42898. */
  42899. x: number;
  42900. /**
  42901. * The value of the y-axis
  42902. */
  42903. y: number;
  42904. }
  42905. /**
  42906. * changed / previous values for the values of this component
  42907. */
  42908. export interface IWebXRMotionControllerComponentChangesValues<T> {
  42909. /**
  42910. * current (this frame) value
  42911. */
  42912. current: T;
  42913. /**
  42914. * previous (last change) value
  42915. */
  42916. previous: T;
  42917. }
  42918. /**
  42919. * Represents changes in the component between current frame and last values recorded
  42920. */
  42921. export interface IWebXRMotionControllerComponentChanges {
  42922. /**
  42923. * will be populated with previous and current values if touched changed
  42924. */
  42925. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42926. /**
  42927. * will be populated with previous and current values if pressed changed
  42928. */
  42929. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42930. /**
  42931. * will be populated with previous and current values if value changed
  42932. */
  42933. value?: IWebXRMotionControllerComponentChangesValues<number>;
  42934. /**
  42935. * will be populated with previous and current values if axes changed
  42936. */
  42937. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  42938. }
  42939. /**
  42940. * This class represents a single component (for example button or thumbstick) of a motion controller
  42941. */
  42942. export class WebXRControllerComponent implements IDisposable {
  42943. /**
  42944. * the id of this component
  42945. */
  42946. id: string;
  42947. /**
  42948. * the type of the component
  42949. */
  42950. type: MotionControllerComponentType;
  42951. private _buttonIndex;
  42952. private _axesIndices;
  42953. /**
  42954. * Thumbstick component type
  42955. */
  42956. static THUMBSTICK: string;
  42957. /**
  42958. * Touchpad component type
  42959. */
  42960. static TOUCHPAD: string;
  42961. /**
  42962. * trigger component type
  42963. */
  42964. static TRIGGER: string;
  42965. /**
  42966. * squeeze component type
  42967. */
  42968. static SQUEEZE: string;
  42969. /**
  42970. * Observers registered here will be triggered when the state of a button changes
  42971. * State change is either pressed / touched / value
  42972. */
  42973. onButtonStateChanged: Observable<WebXRControllerComponent>;
  42974. /**
  42975. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  42976. * the axes data changes
  42977. */
  42978. onAxisValueChanged: Observable<{
  42979. x: number;
  42980. y: number;
  42981. }>;
  42982. private _currentValue;
  42983. private _touched;
  42984. private _pressed;
  42985. private _axes;
  42986. private _changes;
  42987. /**
  42988. * Creates a new component for a motion controller.
  42989. * It is created by the motion controller itself
  42990. *
  42991. * @param id the id of this component
  42992. * @param type the type of the component
  42993. * @param _buttonIndex index in the buttons array of the gamepad
  42994. * @param _axesIndices indices of the values in the axes array of the gamepad
  42995. */
  42996. constructor(
  42997. /**
  42998. * the id of this component
  42999. */
  43000. id: string,
  43001. /**
  43002. * the type of the component
  43003. */
  43004. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43005. /**
  43006. * Get the current value of this component
  43007. */
  43008. get value(): number;
  43009. /**
  43010. * is the button currently pressed
  43011. */
  43012. get pressed(): boolean;
  43013. /**
  43014. * is the button currently touched
  43015. */
  43016. get touched(): boolean;
  43017. /**
  43018. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43019. */
  43020. get axes(): IWebXRMotionControllerAxesValue;
  43021. /**
  43022. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43023. */
  43024. get changes(): IWebXRMotionControllerComponentChanges;
  43025. /**
  43026. * Is this component a button (hence - pressable)
  43027. * @returns true if can be pressed
  43028. */
  43029. isButton(): boolean;
  43030. /**
  43031. * Are there axes correlating to this component
  43032. * @return true is axes data is available
  43033. */
  43034. isAxes(): boolean;
  43035. /**
  43036. * update this component using the gamepad object it is in. Called on every frame
  43037. * @param nativeController the native gamepad controller object
  43038. */
  43039. update(nativeController: IMinimalMotionControllerObject): void;
  43040. /**
  43041. * Dispose this component
  43042. */
  43043. dispose(): void;
  43044. }
  43045. }
  43046. declare module BABYLON {
  43047. /**
  43048. * Class used to represent data loading progression
  43049. */
  43050. export class SceneLoaderProgressEvent {
  43051. /** defines if data length to load can be evaluated */
  43052. readonly lengthComputable: boolean;
  43053. /** defines the loaded data length */
  43054. readonly loaded: number;
  43055. /** defines the data length to load */
  43056. readonly total: number;
  43057. /**
  43058. * Create a new progress event
  43059. * @param lengthComputable defines if data length to load can be evaluated
  43060. * @param loaded defines the loaded data length
  43061. * @param total defines the data length to load
  43062. */
  43063. constructor(
  43064. /** defines if data length to load can be evaluated */
  43065. lengthComputable: boolean,
  43066. /** defines the loaded data length */
  43067. loaded: number,
  43068. /** defines the data length to load */
  43069. total: number);
  43070. /**
  43071. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43072. * @param event defines the source event
  43073. * @returns a new SceneLoaderProgressEvent
  43074. */
  43075. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43076. }
  43077. /**
  43078. * Interface used by SceneLoader plugins to define supported file extensions
  43079. */
  43080. export interface ISceneLoaderPluginExtensions {
  43081. /**
  43082. * Defines the list of supported extensions
  43083. */
  43084. [extension: string]: {
  43085. isBinary: boolean;
  43086. };
  43087. }
  43088. /**
  43089. * Interface used by SceneLoader plugin factory
  43090. */
  43091. export interface ISceneLoaderPluginFactory {
  43092. /**
  43093. * Defines the name of the factory
  43094. */
  43095. name: string;
  43096. /**
  43097. * Function called to create a new plugin
  43098. * @return the new plugin
  43099. */
  43100. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43101. /**
  43102. * The callback that returns true if the data can be directly loaded.
  43103. * @param data string containing the file data
  43104. * @returns if the data can be loaded directly
  43105. */
  43106. canDirectLoad?(data: string): boolean;
  43107. }
  43108. /**
  43109. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43110. */
  43111. export interface ISceneLoaderPluginBase {
  43112. /**
  43113. * The friendly name of this plugin.
  43114. */
  43115. name: string;
  43116. /**
  43117. * The file extensions supported by this plugin.
  43118. */
  43119. extensions: string | ISceneLoaderPluginExtensions;
  43120. /**
  43121. * The callback called when loading from a url.
  43122. * @param scene scene loading this url
  43123. * @param url url to load
  43124. * @param onSuccess callback called when the file successfully loads
  43125. * @param onProgress callback called while file is loading (if the server supports this mode)
  43126. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43127. * @param onError callback called when the file fails to load
  43128. * @returns a file request object
  43129. */
  43130. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43131. /**
  43132. * The callback called when loading from a file object.
  43133. * @param scene scene loading this file
  43134. * @param file defines the file to load
  43135. * @param onSuccess defines the callback to call when data is loaded
  43136. * @param onProgress defines the callback to call during loading process
  43137. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43138. * @param onError defines the callback to call when an error occurs
  43139. * @returns a file request object
  43140. */
  43141. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43142. /**
  43143. * The callback that returns true if the data can be directly loaded.
  43144. * @param data string containing the file data
  43145. * @returns if the data can be loaded directly
  43146. */
  43147. canDirectLoad?(data: string): boolean;
  43148. /**
  43149. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43150. * @param scene scene loading this data
  43151. * @param data string containing the data
  43152. * @returns data to pass to the plugin
  43153. */
  43154. directLoad?(scene: Scene, data: string): any;
  43155. /**
  43156. * The callback that allows custom handling of the root url based on the response url.
  43157. * @param rootUrl the original root url
  43158. * @param responseURL the response url if available
  43159. * @returns the new root url
  43160. */
  43161. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43162. }
  43163. /**
  43164. * Interface used to define a SceneLoader plugin
  43165. */
  43166. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43167. /**
  43168. * Import meshes into a scene.
  43169. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43170. * @param scene The scene to import into
  43171. * @param data The data to import
  43172. * @param rootUrl The root url for scene and resources
  43173. * @param meshes The meshes array to import into
  43174. * @param particleSystems The particle systems array to import into
  43175. * @param skeletons The skeletons array to import into
  43176. * @param onError The callback when import fails
  43177. * @returns True if successful or false otherwise
  43178. */
  43179. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43180. /**
  43181. * Load into a scene.
  43182. * @param scene The scene to load into
  43183. * @param data The data to import
  43184. * @param rootUrl The root url for scene and resources
  43185. * @param onError The callback when import fails
  43186. * @returns True if successful or false otherwise
  43187. */
  43188. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43189. /**
  43190. * Load into an asset container.
  43191. * @param scene The scene to load into
  43192. * @param data The data to import
  43193. * @param rootUrl The root url for scene and resources
  43194. * @param onError The callback when import fails
  43195. * @returns The loaded asset container
  43196. */
  43197. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43198. }
  43199. /**
  43200. * Interface used to define an async SceneLoader plugin
  43201. */
  43202. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43203. /**
  43204. * Import meshes into a scene.
  43205. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43206. * @param scene The scene to import into
  43207. * @param data The data to import
  43208. * @param rootUrl The root url for scene and resources
  43209. * @param onProgress The callback when the load progresses
  43210. * @param fileName Defines the name of the file to load
  43211. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43212. */
  43213. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43214. meshes: AbstractMesh[];
  43215. particleSystems: IParticleSystem[];
  43216. skeletons: Skeleton[];
  43217. animationGroups: AnimationGroup[];
  43218. }>;
  43219. /**
  43220. * Load into a scene.
  43221. * @param scene The scene to load into
  43222. * @param data The data to import
  43223. * @param rootUrl The root url for scene and resources
  43224. * @param onProgress The callback when the load progresses
  43225. * @param fileName Defines the name of the file to load
  43226. * @returns Nothing
  43227. */
  43228. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43229. /**
  43230. * Load into an asset container.
  43231. * @param scene The scene to load into
  43232. * @param data The data to import
  43233. * @param rootUrl The root url for scene and resources
  43234. * @param onProgress The callback when the load progresses
  43235. * @param fileName Defines the name of the file to load
  43236. * @returns The loaded asset container
  43237. */
  43238. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43239. }
  43240. /**
  43241. * Mode that determines how to handle old animation groups before loading new ones.
  43242. */
  43243. export enum SceneLoaderAnimationGroupLoadingMode {
  43244. /**
  43245. * Reset all old animations to initial state then dispose them.
  43246. */
  43247. Clean = 0,
  43248. /**
  43249. * Stop all old animations.
  43250. */
  43251. Stop = 1,
  43252. /**
  43253. * Restart old animations from first frame.
  43254. */
  43255. Sync = 2,
  43256. /**
  43257. * Old animations remains untouched.
  43258. */
  43259. NoSync = 3
  43260. }
  43261. /**
  43262. * Class used to load scene from various file formats using registered plugins
  43263. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43264. */
  43265. export class SceneLoader {
  43266. /**
  43267. * No logging while loading
  43268. */
  43269. static readonly NO_LOGGING: number;
  43270. /**
  43271. * Minimal logging while loading
  43272. */
  43273. static readonly MINIMAL_LOGGING: number;
  43274. /**
  43275. * Summary logging while loading
  43276. */
  43277. static readonly SUMMARY_LOGGING: number;
  43278. /**
  43279. * Detailled logging while loading
  43280. */
  43281. static readonly DETAILED_LOGGING: number;
  43282. /**
  43283. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43284. */
  43285. static get ForceFullSceneLoadingForIncremental(): boolean;
  43286. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43287. /**
  43288. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43289. */
  43290. static get ShowLoadingScreen(): boolean;
  43291. static set ShowLoadingScreen(value: boolean);
  43292. /**
  43293. * Defines the current logging level (while loading the scene)
  43294. * @ignorenaming
  43295. */
  43296. static get loggingLevel(): number;
  43297. static set loggingLevel(value: number);
  43298. /**
  43299. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43300. */
  43301. static get CleanBoneMatrixWeights(): boolean;
  43302. static set CleanBoneMatrixWeights(value: boolean);
  43303. /**
  43304. * Event raised when a plugin is used to load a scene
  43305. */
  43306. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43307. private static _registeredPlugins;
  43308. private static _getDefaultPlugin;
  43309. private static _getPluginForExtension;
  43310. private static _getPluginForDirectLoad;
  43311. private static _getPluginForFilename;
  43312. private static _getDirectLoad;
  43313. private static _loadData;
  43314. private static _getFileInfo;
  43315. /**
  43316. * Gets a plugin that can load the given extension
  43317. * @param extension defines the extension to load
  43318. * @returns a plugin or null if none works
  43319. */
  43320. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43321. /**
  43322. * Gets a boolean indicating that the given extension can be loaded
  43323. * @param extension defines the extension to load
  43324. * @returns true if the extension is supported
  43325. */
  43326. static IsPluginForExtensionAvailable(extension: string): boolean;
  43327. /**
  43328. * Adds a new plugin to the list of registered plugins
  43329. * @param plugin defines the plugin to add
  43330. */
  43331. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43332. /**
  43333. * Import meshes into a scene
  43334. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43335. * @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)
  43336. * @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)
  43337. * @param scene the instance of BABYLON.Scene to append to
  43338. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43339. * @param onProgress a callback with a progress event for each file being loaded
  43340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43341. * @param pluginExtension the extension used to determine the plugin
  43342. * @returns The loaded plugin
  43343. */
  43344. 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>;
  43345. /**
  43346. * Import meshes into a scene
  43347. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43348. * @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)
  43349. * @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)
  43350. * @param scene the instance of BABYLON.Scene to append to
  43351. * @param onProgress a callback with a progress event for each file being loaded
  43352. * @param pluginExtension the extension used to determine the plugin
  43353. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43354. */
  43355. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43356. meshes: AbstractMesh[];
  43357. particleSystems: IParticleSystem[];
  43358. skeletons: Skeleton[];
  43359. animationGroups: AnimationGroup[];
  43360. }>;
  43361. /**
  43362. * Load a scene
  43363. * @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)
  43364. * @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)
  43365. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43366. * @param onSuccess a callback with the scene when import succeeds
  43367. * @param onProgress a callback with a progress event for each file being loaded
  43368. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43369. * @param pluginExtension the extension used to determine the plugin
  43370. * @returns The loaded plugin
  43371. */
  43372. 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>;
  43373. /**
  43374. * Load a scene
  43375. * @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)
  43376. * @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)
  43377. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43378. * @param onProgress a callback with a progress event for each file being loaded
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded scene
  43381. */
  43382. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43383. /**
  43384. * Append a scene
  43385. * @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)
  43386. * @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)
  43387. * @param scene is the instance of BABYLON.Scene to append to
  43388. * @param onSuccess a callback with the scene when import succeeds
  43389. * @param onProgress a callback with a progress event for each file being loaded
  43390. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43391. * @param pluginExtension the extension used to determine the plugin
  43392. * @returns The loaded plugin
  43393. */
  43394. 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>;
  43395. /**
  43396. * Append a scene
  43397. * @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)
  43398. * @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)
  43399. * @param scene is the instance of BABYLON.Scene to append to
  43400. * @param onProgress a callback with a progress event for each file being loaded
  43401. * @param pluginExtension the extension used to determine the plugin
  43402. * @returns The given scene
  43403. */
  43404. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43405. /**
  43406. * Load a scene into an asset container
  43407. * @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)
  43408. * @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)
  43409. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43410. * @param onSuccess a callback with the scene when import succeeds
  43411. * @param onProgress a callback with a progress event for each file being loaded
  43412. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43413. * @param pluginExtension the extension used to determine the plugin
  43414. * @returns The loaded plugin
  43415. */
  43416. 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>;
  43417. /**
  43418. * Load a scene into an asset container
  43419. * @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)
  43420. * @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)
  43421. * @param scene is the instance of Scene to append to
  43422. * @param onProgress a callback with a progress event for each file being loaded
  43423. * @param pluginExtension the extension used to determine the plugin
  43424. * @returns The loaded asset container
  43425. */
  43426. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43427. /**
  43428. * Import animations from a file into a scene
  43429. * @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)
  43430. * @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)
  43431. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43432. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43433. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43434. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43435. * @param onSuccess a callback with the scene when import succeeds
  43436. * @param onProgress a callback with a progress event for each file being loaded
  43437. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43438. */
  43439. 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;
  43440. /**
  43441. * Import animations from a file into a scene
  43442. * @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)
  43443. * @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)
  43444. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43445. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43446. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43447. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43448. * @param onSuccess a callback with the scene when import succeeds
  43449. * @param onProgress a callback with a progress event for each file being loaded
  43450. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43451. * @returns the updated scene with imported animations
  43452. */
  43453. 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>;
  43454. }
  43455. }
  43456. declare module BABYLON {
  43457. /**
  43458. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43459. */
  43460. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  43461. /**
  43462. * The type of components available in motion controllers.
  43463. * This is not the name of the component.
  43464. */
  43465. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43466. /**
  43467. * The schema of motion controller layout.
  43468. * No object will be initialized using this interface
  43469. * This is used just to define the profile.
  43470. */
  43471. export interface IMotionControllerLayout {
  43472. /**
  43473. * Defines the main button component id
  43474. */
  43475. selectComponentId: string;
  43476. /**
  43477. * Available components (unsorted)
  43478. */
  43479. components: {
  43480. /**
  43481. * A map of component Ids
  43482. */
  43483. [componentId: string]: {
  43484. /**
  43485. * The type of input the component outputs
  43486. */
  43487. type: MotionControllerComponentType;
  43488. };
  43489. };
  43490. /**
  43491. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  43492. */
  43493. gamepad?: {
  43494. /**
  43495. * Is the mapping based on the xr-standard defined here:
  43496. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  43497. */
  43498. mapping: "" | "xr-standard";
  43499. /**
  43500. * The buttons available in this input in the right order
  43501. * index of this button will be the index in the gamepadObject.buttons array
  43502. * correlates to the componentId in components
  43503. */
  43504. buttons: Array<string | null>;
  43505. /**
  43506. * Definition of the axes of the gamepad input, sorted
  43507. * Correlates to componentIds in the components map
  43508. */
  43509. axes: Array<{
  43510. /**
  43511. * The component id that the axis correlates to
  43512. */
  43513. componentId: string;
  43514. /**
  43515. * X or Y Axis
  43516. */
  43517. axis: "x-axis" | "y-axis";
  43518. } | null>;
  43519. };
  43520. }
  43521. /**
  43522. * A definition for the layout map in the input profile
  43523. */
  43524. export interface IMotionControllerLayoutMap {
  43525. /**
  43526. * Layouts with handness type as a key
  43527. */
  43528. [handness: string]: IMotionControllerLayout;
  43529. }
  43530. /**
  43531. * The XR Input profile schema
  43532. * Profiles can be found here:
  43533. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43534. */
  43535. export interface IMotionControllerProfile {
  43536. /**
  43537. * The id of this profile
  43538. * correlates to the profile(s) in the xrInput.profiles array
  43539. */
  43540. profileId: string;
  43541. /**
  43542. * fallback profiles for this profileId
  43543. */
  43544. fallbackProfileIds: string[];
  43545. /**
  43546. * The layout map, with handness as key
  43547. */
  43548. layouts: IMotionControllerLayoutMap;
  43549. }
  43550. /**
  43551. * A helper-interface for the 3 meshes needed for controller button animation
  43552. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43553. */
  43554. export interface IMotionControllerButtonMeshMap {
  43555. /**
  43556. * The mesh that will be changed when value changes
  43557. */
  43558. valueMesh: AbstractMesh;
  43559. /**
  43560. * the mesh that defines the pressed value mesh position.
  43561. * This is used to find the max-position of this button
  43562. */
  43563. pressedMesh: AbstractMesh;
  43564. /**
  43565. * the mesh that defines the unpressed value mesh position.
  43566. * This is used to find the min (or initial) position of this button
  43567. */
  43568. unpressedMesh: AbstractMesh;
  43569. }
  43570. /**
  43571. * A helper-interface for the 3 meshes needed for controller axis animation.
  43572. * This will be expanded when touchpad animations are fully supported
  43573. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43574. */
  43575. export interface IMotionControllerAxisMeshMap {
  43576. /**
  43577. * The mesh that will be changed when axis value changes
  43578. */
  43579. valueMesh: AbstractMesh;
  43580. /**
  43581. * the mesh that defines the minimum value mesh position.
  43582. */
  43583. minMesh: AbstractMesh;
  43584. /**
  43585. * the mesh that defines the maximum value mesh position.
  43586. */
  43587. maxMesh: AbstractMesh;
  43588. }
  43589. /**
  43590. * The elements needed for change-detection of the gamepad objects in motion controllers
  43591. */
  43592. export interface IMinimalMotionControllerObject {
  43593. /**
  43594. * An array of available buttons
  43595. */
  43596. buttons: Array<{
  43597. /**
  43598. * Value of the button/trigger
  43599. */
  43600. value: number;
  43601. /**
  43602. * If the button/trigger is currently touched
  43603. */
  43604. touched: boolean;
  43605. /**
  43606. * If the button/trigger is currently pressed
  43607. */
  43608. pressed: boolean;
  43609. }>;
  43610. /**
  43611. * Available axes of this controller
  43612. */
  43613. axes: number[];
  43614. }
  43615. /**
  43616. * An Abstract Motion controller
  43617. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43618. * Each component has an observable to check for changes in value and state
  43619. */
  43620. export abstract class WebXRAbstractMotionController implements IDisposable {
  43621. protected scene: Scene;
  43622. protected layout: IMotionControllerLayout;
  43623. /**
  43624. * The gamepad object correlating to this controller
  43625. */
  43626. gamepadObject: IMinimalMotionControllerObject;
  43627. /**
  43628. * handness (left/right/none) of this controller
  43629. */
  43630. handness: MotionControllerHandness;
  43631. /**
  43632. * Component type map
  43633. */
  43634. static ComponentType: {
  43635. TRIGGER: string;
  43636. SQUEEZE: string;
  43637. TOUCHPAD: string;
  43638. THUMBSTICK: string;
  43639. BUTTON: string;
  43640. };
  43641. /**
  43642. * The profile id of this motion controller
  43643. */
  43644. abstract profileId: string;
  43645. /**
  43646. * A map of components (WebXRControllerComponent) in this motion controller
  43647. * Components have a ComponentType and can also have both button and axis definitions
  43648. */
  43649. readonly components: {
  43650. [id: string]: WebXRControllerComponent;
  43651. };
  43652. /**
  43653. * Observers registered here will be triggered when the model of this controller is done loading
  43654. */
  43655. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43656. /**
  43657. * The root mesh of the model. It is null if the model was not yet initialized
  43658. */
  43659. rootMesh: Nullable<AbstractMesh>;
  43660. private _modelReady;
  43661. /**
  43662. * constructs a new abstract motion controller
  43663. * @param scene the scene to which the model of the controller will be added
  43664. * @param layout The profile layout to load
  43665. * @param gamepadObject The gamepad object correlating to this controller
  43666. * @param handness handness (left/right/none) of this controller
  43667. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43668. */
  43669. constructor(scene: Scene, layout: IMotionControllerLayout,
  43670. /**
  43671. * The gamepad object correlating to this controller
  43672. */
  43673. gamepadObject: IMinimalMotionControllerObject,
  43674. /**
  43675. * handness (left/right/none) of this controller
  43676. */
  43677. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43678. private _initComponent;
  43679. /**
  43680. * Update this model using the current XRFrame
  43681. * @param xrFrame the current xr frame to use and update the model
  43682. */
  43683. updateFromXRFrame(xrFrame: XRFrame): void;
  43684. /**
  43685. * Get the list of components available in this motion controller
  43686. * @returns an array of strings correlating to available components
  43687. */
  43688. getComponentTypes(): string[];
  43689. /**
  43690. * Get the main (Select) component of this controller as defined in the layout
  43691. * @returns the main component of this controller
  43692. */
  43693. getMainComponent(): WebXRControllerComponent;
  43694. /**
  43695. * get a component based an its component id as defined in layout.components
  43696. * @param id the id of the component
  43697. * @returns the component correlates to the id or undefined if not found
  43698. */
  43699. getComponent(id: string): WebXRControllerComponent;
  43700. /**
  43701. * Loads the model correlating to this controller
  43702. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43703. * @returns A promise fulfilled with the result of the model loading
  43704. */
  43705. loadModel(): Promise<boolean>;
  43706. /**
  43707. * Update the model itself with the current frame data
  43708. * @param xrFrame the frame to use for updating the model mesh
  43709. */
  43710. protected updateModel(xrFrame: XRFrame): void;
  43711. /**
  43712. * Moves the axis on the controller mesh based on its current state
  43713. * @param axis the index of the axis
  43714. * @param axisValue the value of the axis which determines the meshes new position
  43715. * @hidden
  43716. */
  43717. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  43718. /**
  43719. * Moves the buttons on the controller mesh based on their current state
  43720. * @param buttonName the name of the button to move
  43721. * @param buttonValue the value of the button which determines the buttons new position
  43722. */
  43723. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  43724. private _getGenericFilenameAndPath;
  43725. private _getGenericParentMesh;
  43726. /**
  43727. * Get the filename and path for this controller's model
  43728. * @returns a map of filename and path
  43729. */
  43730. protected abstract _getFilenameAndPath(): {
  43731. filename: string;
  43732. path: string;
  43733. };
  43734. /**
  43735. * This function will be called after the model was successfully loaded and can be used
  43736. * for mesh transformations before it is available for the user
  43737. * @param meshes the loaded meshes
  43738. */
  43739. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43740. /**
  43741. * Set the root mesh for this controller. Important for the WebXR controller class
  43742. * @param meshes the loaded meshes
  43743. */
  43744. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43745. /**
  43746. * A function executed each frame that updates the mesh (if needed)
  43747. * @param xrFrame the current xrFrame
  43748. */
  43749. protected abstract _updateModel(xrFrame: XRFrame): void;
  43750. /**
  43751. * This function is called before the mesh is loaded. It checks for loading constraints.
  43752. * For example, this function can check if the GLB loader is available
  43753. * If this function returns false, the generic controller will be loaded instead
  43754. * @returns Is the client ready to load the mesh
  43755. */
  43756. protected abstract _getModelLoadingConstraints(): boolean;
  43757. /**
  43758. * Dispose this controller, the model mesh and all its components
  43759. */
  43760. dispose(): void;
  43761. }
  43762. }
  43763. declare module BABYLON {
  43764. /**
  43765. * A generic trigger-only motion controller for WebXR
  43766. */
  43767. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43768. /**
  43769. * Static version of the profile id of this controller
  43770. */
  43771. static ProfileId: string;
  43772. profileId: string;
  43773. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43774. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43775. protected _updateModel(): void;
  43776. protected _getFilenameAndPath(): {
  43777. filename: string;
  43778. path: string;
  43779. };
  43780. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43781. protected _getModelLoadingConstraints(): boolean;
  43782. }
  43783. }
  43784. declare module BABYLON {
  43785. /**
  43786. * A construction function type to create a new controller based on an xrInput object
  43787. */
  43788. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  43789. /**
  43790. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  43791. *
  43792. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  43793. * it should be replaced with auto-loaded controllers.
  43794. *
  43795. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  43796. */
  43797. export class WebXRMotionControllerManager {
  43798. private static _AvailableControllers;
  43799. private static _Fallbacks;
  43800. /**
  43801. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  43802. *
  43803. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  43804. *
  43805. * @param type the profile type to register
  43806. * @param constructFunction the function to be called when loading this profile
  43807. */
  43808. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  43809. /**
  43810. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  43811. * The order of search:
  43812. *
  43813. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  43814. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  43815. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  43816. * 4) return the generic trigger controller if none were found
  43817. *
  43818. * @param xrInput the xrInput to which a new controller is initialized
  43819. * @param scene the scene to which the model will be added
  43820. * @param forceProfile force a certain profile for this controller
  43821. * @return the motion controller class for this profile id or the generic standard class if none was found
  43822. */
  43823. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  43824. /**
  43825. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  43826. * @param profileId the profile to which a fallback needs to be found
  43827. * @return an array with corresponding fallback profiles
  43828. */
  43829. static FindFallbackWithProfileId(profileId: string): string[];
  43830. /**
  43831. * Register a fallback to a specific profile.
  43832. * @param profileId the profileId that will receive the fallbacks
  43833. * @param fallbacks A list of fallback profiles
  43834. */
  43835. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  43836. /**
  43837. * Register the default fallbacks.
  43838. * This function is called automatically when this file is imported.
  43839. */
  43840. static DefaultFallbacks(): void;
  43841. }
  43842. }
  43843. declare module BABYLON {
  43844. /**
  43845. * Configuration options for the WebXR controller creation
  43846. */
  43847. export interface IWebXRControllerOptions {
  43848. /**
  43849. * Force a specific controller type for this controller.
  43850. * This can be used when creating your own profile or when testing different controllers
  43851. */
  43852. forceControllerProfile?: string;
  43853. }
  43854. /**
  43855. * Represents an XR controller
  43856. */
  43857. export class WebXRController {
  43858. private _scene;
  43859. /** The underlying input source for the controller */
  43860. inputSource: XRInputSource;
  43861. private _options;
  43862. /**
  43863. * 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
  43864. */
  43865. grip?: AbstractMesh;
  43866. /**
  43867. * Pointer which can be used to select objects or attach a visible laser to
  43868. */
  43869. pointer: AbstractMesh;
  43870. /**
  43871. * If available, this is the gamepad object related to this controller.
  43872. * Using this object it is possible to get click events and trackpad changes of the
  43873. * webxr controller that is currently being used.
  43874. */
  43875. motionController?: WebXRAbstractMotionController;
  43876. /**
  43877. * Event that fires when the controller is removed/disposed
  43878. */
  43879. onDisposeObservable: Observable<{}>;
  43880. private _tmpQuaternion;
  43881. private _tmpVector;
  43882. private _uniqueId;
  43883. /**
  43884. * Creates the controller
  43885. * @see https://doc.babylonjs.com/how_to/webxr
  43886. * @param _scene the scene which the controller should be associated to
  43887. * @param inputSource the underlying input source for the controller
  43888. * @param _options options for this controller creation
  43889. */
  43890. constructor(_scene: Scene,
  43891. /** The underlying input source for the controller */
  43892. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  43893. /**
  43894. * Get this controllers unique id
  43895. */
  43896. get uniqueId(): string;
  43897. /**
  43898. * Updates the controller pose based on the given XRFrame
  43899. * @param xrFrame xr frame to update the pose with
  43900. * @param referenceSpace reference space to use
  43901. */
  43902. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43903. /**
  43904. * Gets a world space ray coming from the controller
  43905. * @param result the resulting ray
  43906. */
  43907. getWorldPointerRayToRef(result: Ray): void;
  43908. /**
  43909. * Disposes of the object
  43910. */
  43911. dispose(): void;
  43912. }
  43913. }
  43914. declare module BABYLON {
  43915. /**
  43916. * The schema for initialization options of the XR Input class
  43917. */
  43918. export interface IWebXRInputOptions {
  43919. /**
  43920. * If set to true no model will be automatically loaded
  43921. */
  43922. doNotLoadControllerMeshes?: boolean;
  43923. /**
  43924. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  43925. * If not found, the xr input profile data will be used.
  43926. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  43927. */
  43928. forceInputProfile?: string;
  43929. }
  43930. /**
  43931. * XR input used to track XR inputs such as controllers/rays
  43932. */
  43933. export class WebXRInput implements IDisposable {
  43934. /**
  43935. * the xr session manager for this session
  43936. */
  43937. xrSessionManager: WebXRSessionManager;
  43938. /**
  43939. * the WebXR camera for this session. Mainly used for teleportation
  43940. */
  43941. xrCamera: WebXRCamera;
  43942. private readonly options;
  43943. /**
  43944. * XR controllers being tracked
  43945. */
  43946. controllers: Array<WebXRController>;
  43947. private _frameObserver;
  43948. private _sessionEndedObserver;
  43949. private _sessionInitObserver;
  43950. /**
  43951. * Event when a controller has been connected/added
  43952. */
  43953. onControllerAddedObservable: Observable<WebXRController>;
  43954. /**
  43955. * Event when a controller has been removed/disconnected
  43956. */
  43957. onControllerRemovedObservable: Observable<WebXRController>;
  43958. /**
  43959. * Initializes the WebXRInput
  43960. * @param xrSessionManager the xr session manager for this session
  43961. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  43962. * @param options = initialization options for this xr input
  43963. */
  43964. constructor(
  43965. /**
  43966. * the xr session manager for this session
  43967. */
  43968. xrSessionManager: WebXRSessionManager,
  43969. /**
  43970. * the WebXR camera for this session. Mainly used for teleportation
  43971. */
  43972. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  43973. private _onInputSourcesChange;
  43974. private _addAndRemoveControllers;
  43975. /**
  43976. * Disposes of the object
  43977. */
  43978. dispose(): void;
  43979. }
  43980. }
  43981. declare module BABYLON {
  43982. /**
  43983. * This is the base class for all WebXR features.
  43984. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  43985. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  43986. */
  43987. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  43988. protected _xrSessionManager: WebXRSessionManager;
  43989. /**
  43990. * Construct a new (abstract) webxr feature
  43991. * @param _xrSessionManager the xr session manager for this feature
  43992. */
  43993. constructor(_xrSessionManager: WebXRSessionManager);
  43994. private _attached;
  43995. private _removeOnDetach;
  43996. /**
  43997. * Is this feature attached
  43998. */
  43999. get attached(): boolean;
  44000. /**
  44001. * Should auto-attach be disabled?
  44002. */
  44003. disableAutoAttach: boolean;
  44004. /**
  44005. * attach this feature
  44006. *
  44007. * @param force should attachment be forced (even when already attached)
  44008. * @returns true if successful, false is failed or already attached
  44009. */
  44010. attach(force?: boolean): boolean;
  44011. /**
  44012. * detach this feature.
  44013. *
  44014. * @returns true if successful, false if failed or already detached
  44015. */
  44016. detach(): boolean;
  44017. /**
  44018. * Dispose this feature and all of the resources attached
  44019. */
  44020. dispose(): void;
  44021. /**
  44022. * Code in this function will be executed on each xrFrame received from the browser.
  44023. * This function will not execute after the feature is detached.
  44024. * @param _xrFrame the current frame
  44025. */
  44026. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44027. /**
  44028. * This is used to register callbacks that will automatically be removed when detach is called.
  44029. * @param observable the observable to which the observer will be attached
  44030. * @param callback the callback to register
  44031. */
  44032. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44033. }
  44034. }
  44035. declare module BABYLON {
  44036. /**
  44037. * Options interface for the pointer selection module
  44038. */
  44039. export interface IWebXRControllerPointerSelectionOptions {
  44040. /**
  44041. * the xr input to use with this pointer selection
  44042. */
  44043. xrInput: WebXRInput;
  44044. /**
  44045. * Different button type to use instead of the main component
  44046. */
  44047. overrideButtonId?: string;
  44048. /**
  44049. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44050. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44051. * 3000 means 3 seconds between pointing at something and selecting it
  44052. */
  44053. timeToSelect?: number;
  44054. /**
  44055. * 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)
  44056. * If not disabled, the last picked point will be used to execute a pointer up event
  44057. * If disabled, pointer up event will be triggered right after the pointer down event.
  44058. * Used in screen and gaze target ray mode only
  44059. */
  44060. disablePointerUpOnTouchOut: boolean;
  44061. /**
  44062. * For gaze mode (time to select instead of press)
  44063. */
  44064. forceGazeMode: boolean;
  44065. /**
  44066. * 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
  44067. * to start a new countdown to the pointer down event.
  44068. * Defaults to 1.
  44069. */
  44070. gazeModePointerMovedFactor?: number;
  44071. }
  44072. /**
  44073. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44074. */
  44075. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44076. private readonly _options;
  44077. /**
  44078. * The module's name
  44079. */
  44080. static readonly Name: string;
  44081. /**
  44082. * The (Babylon) version of this module.
  44083. * This is an integer representing the implementation version.
  44084. * This number does not correspond to the webxr specs version
  44085. */
  44086. static readonly Version: number;
  44087. /**
  44088. * This color will be set to the laser pointer when selection is triggered
  44089. */
  44090. laserPointerPickedColor: Color3;
  44091. /**
  44092. * This color will be applied to the selection ring when selection is triggered
  44093. */
  44094. selectionMeshPickedColor: Color3;
  44095. /**
  44096. * default color of the selection ring
  44097. */
  44098. selectionMeshDefaultColor: Color3;
  44099. /**
  44100. * Default color of the laser pointer
  44101. */
  44102. lasterPointerDefaultColor: Color3;
  44103. /**
  44104. * Should the laser pointer be displayed
  44105. */
  44106. displayLaserPointer: boolean;
  44107. /**
  44108. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44109. */
  44110. displaySelectionMesh: boolean;
  44111. /**
  44112. * Disable lighting on the laser pointer (so it will always be visible)
  44113. */
  44114. disablePointerLighting: boolean;
  44115. /**
  44116. * Disable lighting on the selection mesh (so it will always be visible)
  44117. */
  44118. disableSelectionMeshLighting: boolean;
  44119. private static _idCounter;
  44120. private _tmpRay;
  44121. private _controllers;
  44122. private _scene;
  44123. /**
  44124. * constructs a new background remover module
  44125. * @param _xrSessionManager the session manager for this module
  44126. * @param _options read-only options to be used in this module
  44127. */
  44128. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44129. /**
  44130. * attach this feature
  44131. * Will usually be called by the features manager
  44132. *
  44133. * @returns true if successful.
  44134. */
  44135. attach(): boolean;
  44136. /**
  44137. * detach this feature.
  44138. * Will usually be called by the features manager
  44139. *
  44140. * @returns true if successful.
  44141. */
  44142. detach(): boolean;
  44143. /**
  44144. * Get the xr controller that correlates to the pointer id in the pointer event
  44145. *
  44146. * @param id the pointer id to search for
  44147. * @returns the controller that correlates to this id or null if not found
  44148. */
  44149. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  44150. protected _onXRFrame(_xrFrame: XRFrame): void;
  44151. private _attachController;
  44152. private _attachScreenRayMode;
  44153. private _attachGazeMode;
  44154. private _tmpVectorForPickCompare;
  44155. private _pickingMoved;
  44156. private _attachTrackedPointerRayMode;
  44157. private _detachController;
  44158. private _generateNewMeshPair;
  44159. private _convertNormalToDirectionOfRay;
  44160. private _updatePointerDistance;
  44161. }
  44162. }
  44163. declare module BABYLON {
  44164. /**
  44165. * Button which can be used to enter a different mode of XR
  44166. */
  44167. export class WebXREnterExitUIButton {
  44168. /** button element */
  44169. element: HTMLElement;
  44170. /** XR initialization options for the button */
  44171. sessionMode: XRSessionMode;
  44172. /** Reference space type */
  44173. referenceSpaceType: XRReferenceSpaceType;
  44174. /**
  44175. * Creates a WebXREnterExitUIButton
  44176. * @param element button element
  44177. * @param sessionMode XR initialization session mode
  44178. * @param referenceSpaceType the type of reference space to be used
  44179. */
  44180. constructor(
  44181. /** button element */
  44182. element: HTMLElement,
  44183. /** XR initialization options for the button */
  44184. sessionMode: XRSessionMode,
  44185. /** Reference space type */
  44186. referenceSpaceType: XRReferenceSpaceType);
  44187. /**
  44188. * Overwritable function which can be used to update the button's visuals when the state changes
  44189. * @param activeButton the current active button in the UI
  44190. */
  44191. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44192. }
  44193. /**
  44194. * Options to create the webXR UI
  44195. */
  44196. export class WebXREnterExitUIOptions {
  44197. /**
  44198. * Context to enter xr with
  44199. */
  44200. renderTarget?: Nullable<WebXRRenderTarget>;
  44201. /**
  44202. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44203. */
  44204. customButtons?: Array<WebXREnterExitUIButton>;
  44205. /**
  44206. * A session mode to use when creating the default button.
  44207. * Default is immersive-vr
  44208. */
  44209. sessionMode?: XRSessionMode;
  44210. /**
  44211. * A reference space type to use when creating the default button.
  44212. * Default is local-floor
  44213. */
  44214. referenceSpaceType?: XRReferenceSpaceType;
  44215. }
  44216. /**
  44217. * UI to allow the user to enter/exit XR mode
  44218. */
  44219. export class WebXREnterExitUI implements IDisposable {
  44220. private scene;
  44221. /** version of the options passed to this UI */
  44222. options: WebXREnterExitUIOptions;
  44223. private _overlay;
  44224. private _buttons;
  44225. private _activeButton;
  44226. /**
  44227. * Fired every time the active button is changed.
  44228. *
  44229. * When xr is entered via a button that launches xr that button will be the callback parameter
  44230. *
  44231. * When exiting xr the callback parameter will be null)
  44232. */
  44233. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44234. /**
  44235. * Creates UI to allow the user to enter/exit XR mode
  44236. * @param scene the scene to add the ui to
  44237. * @param helper the xr experience helper to enter/exit xr with
  44238. * @param options options to configure the UI
  44239. * @returns the created ui
  44240. */
  44241. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44242. /**
  44243. *
  44244. * @param scene babylon scene object to use
  44245. * @param options (read-only) version of the options passed to this UI
  44246. */
  44247. private constructor();
  44248. private _updateButtons;
  44249. /**
  44250. * Disposes of the object
  44251. */
  44252. dispose(): void;
  44253. }
  44254. }
  44255. declare module BABYLON {
  44256. /**
  44257. * Class containing static functions to help procedurally build meshes
  44258. */
  44259. export class LinesBuilder {
  44260. /**
  44261. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44262. * * 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
  44263. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44264. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44265. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44266. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44267. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44268. * * 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
  44269. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44272. * @param name defines the name of the new line system
  44273. * @param options defines the options used to create the line system
  44274. * @param scene defines the hosting scene
  44275. * @returns a new line system mesh
  44276. */
  44277. static CreateLineSystem(name: string, options: {
  44278. lines: Vector3[][];
  44279. updatable?: boolean;
  44280. instance?: Nullable<LinesMesh>;
  44281. colors?: Nullable<Color4[][]>;
  44282. useVertexAlpha?: boolean;
  44283. }, scene: Nullable<Scene>): LinesMesh;
  44284. /**
  44285. * Creates a line mesh
  44286. * 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
  44287. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44288. * * The parameter `points` is an array successive Vector3
  44289. * * 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
  44290. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44291. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44292. * * When updating an instance, remember that only point positions can change, not the number of points
  44293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44295. * @param name defines the name of the new line system
  44296. * @param options defines the options used to create the line system
  44297. * @param scene defines the hosting scene
  44298. * @returns a new line mesh
  44299. */
  44300. static CreateLines(name: string, options: {
  44301. points: Vector3[];
  44302. updatable?: boolean;
  44303. instance?: Nullable<LinesMesh>;
  44304. colors?: Color4[];
  44305. useVertexAlpha?: boolean;
  44306. }, scene?: Nullable<Scene>): LinesMesh;
  44307. /**
  44308. * Creates a dashed line mesh
  44309. * * 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
  44310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44311. * * The parameter `points` is an array successive Vector3
  44312. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44313. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44314. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44315. * * 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
  44316. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44317. * * When updating an instance, remember that only point positions can change, not the number of points
  44318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44319. * @param name defines the name of the mesh
  44320. * @param options defines the options used to create the mesh
  44321. * @param scene defines the hosting scene
  44322. * @returns the dashed line mesh
  44323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44324. */
  44325. static CreateDashedLines(name: string, options: {
  44326. points: Vector3[];
  44327. dashSize?: number;
  44328. gapSize?: number;
  44329. dashNb?: number;
  44330. updatable?: boolean;
  44331. instance?: LinesMesh;
  44332. useVertexAlpha?: boolean;
  44333. }, scene?: Nullable<Scene>): LinesMesh;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /**
  44338. * The options container for the teleportation module
  44339. */
  44340. export interface IWebXRTeleportationOptions {
  44341. /**
  44342. * Babylon XR Input class for controller
  44343. */
  44344. xrInput: WebXRInput;
  44345. /**
  44346. * A list of meshes to use as floor meshes.
  44347. * Meshes can be added and removed after initializing the feature using the
  44348. * addFloorMesh and removeFloorMesh functions
  44349. * If empty, rotation will still work
  44350. */
  44351. floorMeshes?: AbstractMesh[];
  44352. /**
  44353. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44354. * If you want to support rotation, make sure your mesh has a direction indicator.
  44355. *
  44356. * When left untouched, the default mesh will be initialized.
  44357. */
  44358. teleportationTargetMesh?: AbstractMesh;
  44359. /**
  44360. * Values to configure the default target mesh
  44361. */
  44362. defaultTargetMeshOptions?: {
  44363. /**
  44364. * Fill color of the teleportation area
  44365. */
  44366. teleportationFillColor?: string;
  44367. /**
  44368. * Border color for the teleportation area
  44369. */
  44370. teleportationBorderColor?: string;
  44371. /**
  44372. * Override the default material of the torus and arrow
  44373. */
  44374. torusArrowMaterial?: Material;
  44375. /**
  44376. * Disable the mesh's animation sequence
  44377. */
  44378. disableAnimation?: boolean;
  44379. };
  44380. /**
  44381. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44382. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44383. */
  44384. useMainComponentOnly?: boolean;
  44385. /**
  44386. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44387. */
  44388. timeToTeleport?: number;
  44389. }
  44390. /**
  44391. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44392. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44393. * the input of the attached controllers.
  44394. */
  44395. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44396. private _options;
  44397. /**
  44398. * The module's name
  44399. */
  44400. static readonly Name: string;
  44401. /**
  44402. * The (Babylon) version of this module.
  44403. * This is an integer representing the implementation version.
  44404. * This number does not correspond to the webxr specs version
  44405. */
  44406. static readonly Version: number;
  44407. /**
  44408. * Is rotation enabled when moving forward?
  44409. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44410. */
  44411. rotationEnabled: boolean;
  44412. /**
  44413. * Should the module support parabolic ray on top of direct ray
  44414. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44415. * Very helpful when moving between floors / different heights
  44416. */
  44417. parabolicRayEnabled: boolean;
  44418. /**
  44419. * The distance from the user to the inspection point in the direction of the controller
  44420. * A higher number will allow the user to move further
  44421. * defaults to 5 (meters, in xr units)
  44422. */
  44423. parabolicCheckRadius: number;
  44424. /**
  44425. * How much rotation should be applied when rotating right and left
  44426. */
  44427. rotationAngle: number;
  44428. /**
  44429. * Distance to travel when moving backwards
  44430. */
  44431. backwardsTeleportationDistance: number;
  44432. /**
  44433. * Add a new mesh to the floor meshes array
  44434. * @param mesh the mesh to use as floor mesh
  44435. */
  44436. addFloorMesh(mesh: AbstractMesh): void;
  44437. /**
  44438. * Remove a mesh from the floor meshes array
  44439. * @param mesh the mesh to remove
  44440. */
  44441. removeFloorMesh(mesh: AbstractMesh): void;
  44442. /**
  44443. * Remove a mesh from the floor meshes array using its name
  44444. * @param name the mesh name to remove
  44445. */
  44446. removeFloorMeshByName(name: string): void;
  44447. private _tmpRay;
  44448. private _tmpVector;
  44449. private _floorMeshes;
  44450. private _controllers;
  44451. /**
  44452. * constructs a new anchor system
  44453. * @param _xrSessionManager an instance of WebXRSessionManager
  44454. * @param _options configuration object for this feature
  44455. */
  44456. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44457. private _selectionFeature;
  44458. /**
  44459. * This function sets a selection feature that will be disabled when
  44460. * the forward ray is shown and will be reattached when hidden.
  44461. * This is used to remove the selection rays when moving.
  44462. * @param selectionFeature the feature to disable when forward movement is enabled
  44463. */
  44464. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44465. attach(): boolean;
  44466. detach(): boolean;
  44467. dispose(): void;
  44468. protected _onXRFrame(_xrFrame: XRFrame): void;
  44469. private _currentTeleportationControllerId;
  44470. private _attachController;
  44471. private _teleportForward;
  44472. private _detachController;
  44473. private createDefaultTargetMesh;
  44474. private setTargetMeshVisibility;
  44475. private setTargetMeshPosition;
  44476. private _quadraticBezierCurve;
  44477. private showParabolicPath;
  44478. }
  44479. }
  44480. declare module BABYLON {
  44481. /**
  44482. * Options for the default xr helper
  44483. */
  44484. export class WebXRDefaultExperienceOptions {
  44485. /**
  44486. * Floor meshes that will be used for teleporting
  44487. */
  44488. floorMeshes?: Array<AbstractMesh>;
  44489. /**
  44490. * Enable or disable default UI to enter XR
  44491. */
  44492. disableDefaultUI?: boolean;
  44493. /**
  44494. * optional configuration for the output canvas
  44495. */
  44496. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44497. /**
  44498. * optional UI options. This can be used among other to change session mode and reference space type
  44499. */
  44500. uiOptions?: WebXREnterExitUIOptions;
  44501. /**
  44502. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44503. */
  44504. inputOptions?: IWebXRInputOptions;
  44505. /**
  44506. * Should teleportation not initialize. defaults to false.
  44507. */
  44508. disableTeleportation?: boolean;
  44509. /**
  44510. * If set to true, the first frame will not be used to reset position
  44511. * The first frame is mainly used when copying transformation from the old camera
  44512. * Mainly used in AR
  44513. */
  44514. ignoreNativeCameraTransformation?: boolean;
  44515. }
  44516. /**
  44517. * Default experience which provides a similar setup to the previous webVRExperience
  44518. */
  44519. export class WebXRDefaultExperience {
  44520. /**
  44521. * Base experience
  44522. */
  44523. baseExperience: WebXRExperienceHelper;
  44524. /**
  44525. * Input experience extension
  44526. */
  44527. input: WebXRInput;
  44528. /**
  44529. * Enables laser pointer and selection
  44530. */
  44531. pointerSelection: WebXRControllerPointerSelection;
  44532. /**
  44533. * Enables teleportation
  44534. */
  44535. teleportation: WebXRMotionControllerTeleportation;
  44536. /**
  44537. * Enables ui for entering/exiting xr
  44538. */
  44539. enterExitUI: WebXREnterExitUI;
  44540. /**
  44541. * Default target xr should render to
  44542. */
  44543. renderTarget: WebXRRenderTarget;
  44544. /**
  44545. * Creates the default xr experience
  44546. * @param scene scene
  44547. * @param options options for basic configuration
  44548. * @returns resulting WebXRDefaultExperience
  44549. */
  44550. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44551. private constructor();
  44552. /**
  44553. * DIsposes of the experience helper
  44554. */
  44555. dispose(): void;
  44556. }
  44557. }
  44558. declare module BABYLON {
  44559. /**
  44560. * Options to modify the vr teleportation behavior.
  44561. */
  44562. export interface VRTeleportationOptions {
  44563. /**
  44564. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44565. */
  44566. floorMeshName?: string;
  44567. /**
  44568. * A list of meshes to be used as the teleportation floor. (default: empty)
  44569. */
  44570. floorMeshes?: Mesh[];
  44571. /**
  44572. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44573. */
  44574. teleportationMode?: number;
  44575. /**
  44576. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44577. */
  44578. teleportationTime?: number;
  44579. /**
  44580. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44581. */
  44582. teleportationSpeed?: number;
  44583. /**
  44584. * The easing function used in the animation or null for Linear. (default CircleEase)
  44585. */
  44586. easingFunction?: EasingFunction;
  44587. }
  44588. /**
  44589. * Options to modify the vr experience helper's behavior.
  44590. */
  44591. export interface VRExperienceHelperOptions extends WebVROptions {
  44592. /**
  44593. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44594. */
  44595. createDeviceOrientationCamera?: boolean;
  44596. /**
  44597. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44598. */
  44599. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44600. /**
  44601. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44602. */
  44603. laserToggle?: boolean;
  44604. /**
  44605. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44606. */
  44607. floorMeshes?: Mesh[];
  44608. /**
  44609. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44610. */
  44611. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44612. /**
  44613. * Defines if WebXR should be used instead of WebVR (if available)
  44614. */
  44615. useXR?: boolean;
  44616. }
  44617. /**
  44618. * Event containing information after VR has been entered
  44619. */
  44620. export class OnAfterEnteringVRObservableEvent {
  44621. /**
  44622. * If entering vr was successful
  44623. */
  44624. success: boolean;
  44625. }
  44626. /**
  44627. * Helps to quickly add VR support to an existing scene.
  44628. * See http://doc.babylonjs.com/how_to/webvr_helper
  44629. */
  44630. export class VRExperienceHelper {
  44631. /** Options to modify the vr experience helper's behavior. */
  44632. webVROptions: VRExperienceHelperOptions;
  44633. private _scene;
  44634. private _position;
  44635. private _btnVR;
  44636. private _btnVRDisplayed;
  44637. private _webVRsupported;
  44638. private _webVRready;
  44639. private _webVRrequesting;
  44640. private _webVRpresenting;
  44641. private _hasEnteredVR;
  44642. private _fullscreenVRpresenting;
  44643. private _inputElement;
  44644. private _webVRCamera;
  44645. private _vrDeviceOrientationCamera;
  44646. private _deviceOrientationCamera;
  44647. private _existingCamera;
  44648. private _onKeyDown;
  44649. private _onVrDisplayPresentChange;
  44650. private _onVRDisplayChanged;
  44651. private _onVRRequestPresentStart;
  44652. private _onVRRequestPresentComplete;
  44653. /**
  44654. * 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)
  44655. */
  44656. enableGazeEvenWhenNoPointerLock: boolean;
  44657. /**
  44658. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44659. */
  44660. exitVROnDoubleTap: boolean;
  44661. /**
  44662. * Observable raised right before entering VR.
  44663. */
  44664. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44665. /**
  44666. * Observable raised when entering VR has completed.
  44667. */
  44668. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44669. /**
  44670. * Observable raised when exiting VR.
  44671. */
  44672. onExitingVRObservable: Observable<VRExperienceHelper>;
  44673. /**
  44674. * Observable raised when controller mesh is loaded.
  44675. */
  44676. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44677. /** Return this.onEnteringVRObservable
  44678. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44679. */
  44680. get onEnteringVR(): Observable<VRExperienceHelper>;
  44681. /** Return this.onExitingVRObservable
  44682. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44683. */
  44684. get onExitingVR(): Observable<VRExperienceHelper>;
  44685. /** Return this.onControllerMeshLoadedObservable
  44686. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44687. */
  44688. get onControllerMeshLoaded(): Observable<WebVRController>;
  44689. private _rayLength;
  44690. private _useCustomVRButton;
  44691. private _teleportationRequested;
  44692. private _teleportActive;
  44693. private _floorMeshName;
  44694. private _floorMeshesCollection;
  44695. private _teleportationMode;
  44696. private _teleportationTime;
  44697. private _teleportationSpeed;
  44698. private _teleportationEasing;
  44699. private _rotationAllowed;
  44700. private _teleportBackwardsVector;
  44701. private _teleportationTarget;
  44702. private _isDefaultTeleportationTarget;
  44703. private _postProcessMove;
  44704. private _teleportationFillColor;
  44705. private _teleportationBorderColor;
  44706. private _rotationAngle;
  44707. private _haloCenter;
  44708. private _cameraGazer;
  44709. private _padSensibilityUp;
  44710. private _padSensibilityDown;
  44711. private _leftController;
  44712. private _rightController;
  44713. private _gazeColor;
  44714. private _laserColor;
  44715. private _pickedLaserColor;
  44716. private _pickedGazeColor;
  44717. /**
  44718. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44719. */
  44720. onNewMeshSelected: Observable<AbstractMesh>;
  44721. /**
  44722. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44723. * This observable will provide the mesh and the controller used to select the mesh
  44724. */
  44725. onMeshSelectedWithController: Observable<{
  44726. mesh: AbstractMesh;
  44727. controller: WebVRController;
  44728. }>;
  44729. /**
  44730. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44731. */
  44732. onNewMeshPicked: Observable<PickingInfo>;
  44733. private _circleEase;
  44734. /**
  44735. * Observable raised before camera teleportation
  44736. */
  44737. onBeforeCameraTeleport: Observable<Vector3>;
  44738. /**
  44739. * Observable raised after camera teleportation
  44740. */
  44741. onAfterCameraTeleport: Observable<Vector3>;
  44742. /**
  44743. * Observable raised when current selected mesh gets unselected
  44744. */
  44745. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44746. private _raySelectionPredicate;
  44747. /**
  44748. * To be optionaly changed by user to define custom ray selection
  44749. */
  44750. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44751. /**
  44752. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44753. */
  44754. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44755. /**
  44756. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44757. */
  44758. teleportationEnabled: boolean;
  44759. private _defaultHeight;
  44760. private _teleportationInitialized;
  44761. private _interactionsEnabled;
  44762. private _interactionsRequested;
  44763. private _displayGaze;
  44764. private _displayLaserPointer;
  44765. /**
  44766. * The mesh used to display where the user is going to teleport.
  44767. */
  44768. get teleportationTarget(): Mesh;
  44769. /**
  44770. * Sets the mesh to be used to display where the user is going to teleport.
  44771. */
  44772. set teleportationTarget(value: Mesh);
  44773. /**
  44774. * 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
  44775. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44776. * See http://doc.babylonjs.com/resources/baking_transformations
  44777. */
  44778. get gazeTrackerMesh(): Mesh;
  44779. set gazeTrackerMesh(value: Mesh);
  44780. /**
  44781. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44782. */
  44783. updateGazeTrackerScale: boolean;
  44784. /**
  44785. * If the gaze trackers color should be updated when selecting meshes
  44786. */
  44787. updateGazeTrackerColor: boolean;
  44788. /**
  44789. * If the controller laser color should be updated when selecting meshes
  44790. */
  44791. updateControllerLaserColor: boolean;
  44792. /**
  44793. * The gaze tracking mesh corresponding to the left controller
  44794. */
  44795. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44796. /**
  44797. * The gaze tracking mesh corresponding to the right controller
  44798. */
  44799. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44800. /**
  44801. * If the ray of the gaze should be displayed.
  44802. */
  44803. get displayGaze(): boolean;
  44804. /**
  44805. * Sets if the ray of the gaze should be displayed.
  44806. */
  44807. set displayGaze(value: boolean);
  44808. /**
  44809. * If the ray of the LaserPointer should be displayed.
  44810. */
  44811. get displayLaserPointer(): boolean;
  44812. /**
  44813. * Sets if the ray of the LaserPointer should be displayed.
  44814. */
  44815. set displayLaserPointer(value: boolean);
  44816. /**
  44817. * The deviceOrientationCamera used as the camera when not in VR.
  44818. */
  44819. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44820. /**
  44821. * Based on the current WebVR support, returns the current VR camera used.
  44822. */
  44823. get currentVRCamera(): Nullable<Camera>;
  44824. /**
  44825. * The webVRCamera which is used when in VR.
  44826. */
  44827. get webVRCamera(): WebVRFreeCamera;
  44828. /**
  44829. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44830. */
  44831. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44832. /**
  44833. * The html button that is used to trigger entering into VR.
  44834. */
  44835. get vrButton(): Nullable<HTMLButtonElement>;
  44836. private get _teleportationRequestInitiated();
  44837. /**
  44838. * Defines wether or not Pointer lock should be requested when switching to
  44839. * full screen.
  44840. */
  44841. requestPointerLockOnFullScreen: boolean;
  44842. /**
  44843. * If asking to force XR, this will be populated with the default xr experience
  44844. */
  44845. xr: WebXRDefaultExperience;
  44846. /**
  44847. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44848. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44849. */
  44850. xrTestDone: boolean;
  44851. /**
  44852. * Instantiates a VRExperienceHelper.
  44853. * Helps to quickly add VR support to an existing scene.
  44854. * @param scene The scene the VRExperienceHelper belongs to.
  44855. * @param webVROptions Options to modify the vr experience helper's behavior.
  44856. */
  44857. constructor(scene: Scene,
  44858. /** Options to modify the vr experience helper's behavior. */
  44859. webVROptions?: VRExperienceHelperOptions);
  44860. private completeVRInit;
  44861. private _onDefaultMeshLoaded;
  44862. private _onResize;
  44863. private _onFullscreenChange;
  44864. /**
  44865. * Gets a value indicating if we are currently in VR mode.
  44866. */
  44867. get isInVRMode(): boolean;
  44868. private onVrDisplayPresentChange;
  44869. private onVRDisplayChanged;
  44870. private moveButtonToBottomRight;
  44871. private displayVRButton;
  44872. private updateButtonVisibility;
  44873. private _cachedAngularSensibility;
  44874. /**
  44875. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44876. * Otherwise, will use the fullscreen API.
  44877. */
  44878. enterVR(): void;
  44879. /**
  44880. * Attempt to exit VR, or fullscreen.
  44881. */
  44882. exitVR(): void;
  44883. /**
  44884. * The position of the vr experience helper.
  44885. */
  44886. get position(): Vector3;
  44887. /**
  44888. * Sets the position of the vr experience helper.
  44889. */
  44890. set position(value: Vector3);
  44891. /**
  44892. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44893. */
  44894. enableInteractions(): void;
  44895. private get _noControllerIsActive();
  44896. private beforeRender;
  44897. private _isTeleportationFloor;
  44898. /**
  44899. * Adds a floor mesh to be used for teleportation.
  44900. * @param floorMesh the mesh to be used for teleportation.
  44901. */
  44902. addFloorMesh(floorMesh: Mesh): void;
  44903. /**
  44904. * Removes a floor mesh from being used for teleportation.
  44905. * @param floorMesh the mesh to be removed.
  44906. */
  44907. removeFloorMesh(floorMesh: Mesh): void;
  44908. /**
  44909. * Enables interactions and teleportation using the VR controllers and gaze.
  44910. * @param vrTeleportationOptions options to modify teleportation behavior.
  44911. */
  44912. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44913. private _onNewGamepadConnected;
  44914. private _tryEnableInteractionOnController;
  44915. private _onNewGamepadDisconnected;
  44916. private _enableInteractionOnController;
  44917. private _checkTeleportWithRay;
  44918. private _checkRotate;
  44919. private _checkTeleportBackwards;
  44920. private _enableTeleportationOnController;
  44921. private _createTeleportationCircles;
  44922. private _displayTeleportationTarget;
  44923. private _hideTeleportationTarget;
  44924. private _rotateCamera;
  44925. private _moveTeleportationSelectorTo;
  44926. private _workingVector;
  44927. private _workingQuaternion;
  44928. private _workingMatrix;
  44929. /**
  44930. * Time Constant Teleportation Mode
  44931. */
  44932. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44933. /**
  44934. * Speed Constant Teleportation Mode
  44935. */
  44936. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44937. /**
  44938. * Teleports the users feet to the desired location
  44939. * @param location The location where the user's feet should be placed
  44940. */
  44941. teleportCamera(location: Vector3): void;
  44942. private _convertNormalToDirectionOfRay;
  44943. private _castRayAndSelectObject;
  44944. private _notifySelectedMeshUnselected;
  44945. /**
  44946. * Permanently set new colors for the laser pointer
  44947. * @param color the new laser color
  44948. * @param pickedColor the new laser color when picked mesh detected
  44949. */
  44950. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44951. /**
  44952. * Set lighting enabled / disabled on the laser pointer of both controllers
  44953. * @param enabled should the lighting be enabled on the laser pointer
  44954. */
  44955. setLaserLightingState(enabled?: boolean): void;
  44956. /**
  44957. * Permanently set new colors for the gaze pointer
  44958. * @param color the new gaze color
  44959. * @param pickedColor the new gaze color when picked mesh detected
  44960. */
  44961. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44962. /**
  44963. * Sets the color of the laser ray from the vr controllers.
  44964. * @param color new color for the ray.
  44965. */
  44966. changeLaserColor(color: Color3): void;
  44967. /**
  44968. * Sets the color of the ray from the vr headsets gaze.
  44969. * @param color new color for the ray.
  44970. */
  44971. changeGazeColor(color: Color3): void;
  44972. /**
  44973. * Exits VR and disposes of the vr experience helper
  44974. */
  44975. dispose(): void;
  44976. /**
  44977. * Gets the name of the VRExperienceHelper class
  44978. * @returns "VRExperienceHelper"
  44979. */
  44980. getClassName(): string;
  44981. }
  44982. }
  44983. declare module BABYLON {
  44984. /**
  44985. * Options used for hit testing
  44986. */
  44987. export interface IWebXRHitTestOptions {
  44988. /**
  44989. * Only test when user interacted with the scene. Default - hit test every frame
  44990. */
  44991. testOnPointerDownOnly?: boolean;
  44992. /**
  44993. * The node to use to transform the local results to world coordinates
  44994. */
  44995. worldParentNode?: TransformNode;
  44996. }
  44997. /**
  44998. * Interface defining the babylon result of raycasting/hit-test
  44999. */
  45000. export interface IWebXRHitResult {
  45001. /**
  45002. * The native hit test result
  45003. */
  45004. xrHitResult: XRHitResult;
  45005. /**
  45006. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45007. */
  45008. transformationMatrix: Matrix;
  45009. }
  45010. /**
  45011. * The currently-working hit-test module.
  45012. * Hit test (or raycasting) is used to interact with the real world.
  45013. * For further information read here - https://github.com/immersive-web/hit-test
  45014. */
  45015. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  45016. /**
  45017. * options to use when constructing this feature
  45018. */
  45019. readonly options: IWebXRHitTestOptions;
  45020. /**
  45021. * The module's name
  45022. */
  45023. static readonly Name: string;
  45024. /**
  45025. * The (Babylon) version of this module.
  45026. * This is an integer representing the implementation version.
  45027. * This number does not correspond to the webxr specs version
  45028. */
  45029. static readonly Version: number;
  45030. /**
  45031. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45032. * @param event the (select) event to use to select with
  45033. * @param referenceSpace the reference space to use for this hit test
  45034. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45035. */
  45036. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45037. /**
  45038. * execute a hit test with an XR Ray
  45039. *
  45040. * @param xrSession a native xrSession that will execute this hit test
  45041. * @param xrRay the ray (position and direction) to use for raycasting
  45042. * @param referenceSpace native XR reference space to use for the hit-test
  45043. * @param filter filter function that will filter the results
  45044. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45045. */
  45046. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45047. /**
  45048. * Triggered when new babylon (transformed) hit test results are available
  45049. */
  45050. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45051. private _onSelectEnabled;
  45052. /**
  45053. * Creates a new instance of the (legacy version) hit test feature
  45054. * @param _xrSessionManager an instance of WebXRSessionManager
  45055. * @param options options to use when constructing this feature
  45056. */
  45057. constructor(_xrSessionManager: WebXRSessionManager,
  45058. /**
  45059. * options to use when constructing this feature
  45060. */
  45061. options?: IWebXRHitTestOptions);
  45062. /**
  45063. * Populated with the last native XR Hit Results
  45064. */
  45065. lastNativeXRHitResults: XRHitResult[];
  45066. /**
  45067. * attach this feature
  45068. * Will usually be called by the features manager
  45069. *
  45070. * @returns true if successful.
  45071. */
  45072. attach(): boolean;
  45073. /**
  45074. * detach this feature.
  45075. * Will usually be called by the features manager
  45076. *
  45077. * @returns true if successful.
  45078. */
  45079. detach(): boolean;
  45080. private _onHitTestResults;
  45081. private _origin;
  45082. private _direction;
  45083. private _mat;
  45084. protected _onXRFrame(frame: XRFrame): void;
  45085. private _onSelect;
  45086. /**
  45087. * Dispose this feature and all of the resources attached
  45088. */
  45089. dispose(): void;
  45090. }
  45091. }
  45092. declare module BABYLON {
  45093. /**
  45094. * Options used in the plane detector module
  45095. */
  45096. export interface IWebXRPlaneDetectorOptions {
  45097. /**
  45098. * The node to use to transform the local results to world coordinates
  45099. */
  45100. worldParentNode?: TransformNode;
  45101. }
  45102. /**
  45103. * A babylon interface for a webxr plane.
  45104. * A Plane is actually a polygon, built from N points in space
  45105. *
  45106. * Supported in chrome 79, not supported in canary 81 ATM
  45107. */
  45108. export interface IWebXRPlane {
  45109. /**
  45110. * a babylon-assigned ID for this polygon
  45111. */
  45112. id: number;
  45113. /**
  45114. * the native xr-plane object
  45115. */
  45116. xrPlane: XRPlane;
  45117. /**
  45118. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45119. */
  45120. polygonDefinition: Array<Vector3>;
  45121. /**
  45122. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45123. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45124. */
  45125. transformationMatrix: Matrix;
  45126. }
  45127. /**
  45128. * The plane detector is used to detect planes in the real world when in AR
  45129. * For more information see https://github.com/immersive-web/real-world-geometry/
  45130. */
  45131. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  45132. private _options;
  45133. /**
  45134. * The module's name
  45135. */
  45136. static readonly Name: string;
  45137. /**
  45138. * The (Babylon) version of this module.
  45139. * This is an integer representing the implementation version.
  45140. * This number does not correspond to the webxr specs version
  45141. */
  45142. static readonly Version: number;
  45143. /**
  45144. * Observers registered here will be executed when a new plane was added to the session
  45145. */
  45146. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45147. /**
  45148. * Observers registered here will be executed when a plane is no longer detected in the session
  45149. */
  45150. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45151. /**
  45152. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45153. * This can execute N times every frame
  45154. */
  45155. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45156. private _enabled;
  45157. private _detectedPlanes;
  45158. private _lastFrameDetected;
  45159. /**
  45160. * construct a new Plane Detector
  45161. * @param _xrSessionManager an instance of xr Session manager
  45162. * @param _options configuration to use when constructing this feature
  45163. */
  45164. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45165. private _init;
  45166. protected _onXRFrame(frame: XRFrame): void;
  45167. /**
  45168. * Dispose this feature and all of the resources attached
  45169. */
  45170. dispose(): void;
  45171. private _updatePlaneWithXRPlane;
  45172. /**
  45173. * avoiding using Array.find for global support.
  45174. * @param xrPlane the plane to find in the array
  45175. */
  45176. private findIndexInPlaneArray;
  45177. }
  45178. }
  45179. declare module BABYLON {
  45180. /**
  45181. * Configuration options of the anchor system
  45182. */
  45183. export interface IWebXRAnchorSystemOptions {
  45184. /**
  45185. * a node that will be used to convert local to world coordinates
  45186. */
  45187. worldParentNode?: TransformNode;
  45188. /**
  45189. * should the anchor system use plane detection.
  45190. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45191. */
  45192. usePlaneDetection?: boolean;
  45193. /**
  45194. * Should a new anchor be added every time a select event is triggered
  45195. */
  45196. addAnchorOnSelect?: boolean;
  45197. }
  45198. /**
  45199. * A babylon container for an XR Anchor
  45200. */
  45201. export interface IWebXRAnchor {
  45202. /**
  45203. * A babylon-assigned ID for this anchor
  45204. */
  45205. id: number;
  45206. /**
  45207. * The native anchor object
  45208. */
  45209. xrAnchor: XRAnchor;
  45210. /**
  45211. * Transformation matrix to apply to an object attached to this anchor
  45212. */
  45213. transformationMatrix: Matrix;
  45214. }
  45215. /**
  45216. * An implementation of the anchor system of WebXR.
  45217. * Note that the current documented implementation is not available in any browser. Future implementations
  45218. * will use the frame to create an anchor and not the session or a detected plane
  45219. * For further information see https://github.com/immersive-web/anchors/
  45220. */
  45221. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  45222. private _options;
  45223. /**
  45224. * The module's name
  45225. */
  45226. static readonly Name: string;
  45227. /**
  45228. * The (Babylon) version of this module.
  45229. * This is an integer representing the implementation version.
  45230. * This number does not correspond to the webxr specs version
  45231. */
  45232. static readonly Version: number;
  45233. /**
  45234. * Observers registered here will be executed when a new anchor was added to the session
  45235. */
  45236. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45237. /**
  45238. * Observers registered here will be executed when an existing anchor updates
  45239. * This can execute N times every frame
  45240. */
  45241. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45242. /**
  45243. * Observers registered here will be executed when an anchor was removed from the session
  45244. */
  45245. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45246. private _planeDetector;
  45247. private _hitTestModule;
  45248. private _enabled;
  45249. private _trackedAnchors;
  45250. private _lastFrameDetected;
  45251. /**
  45252. * constructs a new anchor system
  45253. * @param _xrSessionManager an instance of WebXRSessionManager
  45254. * @param _options configuration object for this feature
  45255. */
  45256. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45257. /**
  45258. * set the plane detector to use in order to create anchors from frames
  45259. * @param planeDetector the plane-detector module to use
  45260. * @param enable enable plane-anchors. default is true
  45261. */
  45262. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45263. /**
  45264. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  45265. * @param hitTestModule the hit-test module to use.
  45266. */
  45267. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  45268. /**
  45269. * attach this feature
  45270. * Will usually be called by the features manager
  45271. *
  45272. * @returns true if successful.
  45273. */
  45274. attach(): boolean;
  45275. /**
  45276. * detach this feature.
  45277. * Will usually be called by the features manager
  45278. *
  45279. * @returns true if successful.
  45280. */
  45281. detach(): boolean;
  45282. /**
  45283. * Dispose this feature and all of the resources attached
  45284. */
  45285. dispose(): void;
  45286. protected _onXRFrame(frame: XRFrame): void;
  45287. private _onSelect;
  45288. /**
  45289. * Add anchor at a specific XR point.
  45290. *
  45291. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  45292. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  45293. * @returns a promise the fulfills when the anchor was created
  45294. */
  45295. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  45296. private _updateAnchorWithXRFrame;
  45297. /**
  45298. * avoiding using Array.find for global support.
  45299. * @param xrAnchor the plane to find in the array
  45300. */
  45301. private _findIndexInAnchorArray;
  45302. }
  45303. }
  45304. declare module BABYLON {
  45305. /**
  45306. * Options interface for the background remover plugin
  45307. */
  45308. export interface IWebXRBackgroundRemoverOptions {
  45309. /**
  45310. * don't disable the environment helper
  45311. */
  45312. ignoreEnvironmentHelper?: boolean;
  45313. /**
  45314. * flags to configure the removal of the environment helper.
  45315. * If not set, the entire background will be removed. If set, flags should be set as well.
  45316. */
  45317. environmentHelperRemovalFlags?: {
  45318. /**
  45319. * Should the skybox be removed (default false)
  45320. */
  45321. skyBox?: boolean;
  45322. /**
  45323. * Should the ground be removed (default false)
  45324. */
  45325. ground?: boolean;
  45326. };
  45327. /**
  45328. * Further background meshes to disable when entering AR
  45329. */
  45330. backgroundMeshes?: AbstractMesh[];
  45331. }
  45332. /**
  45333. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  45334. */
  45335. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  45336. /**
  45337. * read-only options to be used in this module
  45338. */
  45339. readonly options: IWebXRBackgroundRemoverOptions;
  45340. /**
  45341. * The module's name
  45342. */
  45343. static readonly Name: string;
  45344. /**
  45345. * The (Babylon) version of this module.
  45346. * This is an integer representing the implementation version.
  45347. * This number does not correspond to the webxr specs version
  45348. */
  45349. static readonly Version: number;
  45350. /**
  45351. * registered observers will be triggered when the background state changes
  45352. */
  45353. onBackgroundStateChangedObservable: Observable<boolean>;
  45354. /**
  45355. * constructs a new background remover module
  45356. * @param _xrSessionManager the session manager for this module
  45357. * @param options read-only options to be used in this module
  45358. */
  45359. constructor(_xrSessionManager: WebXRSessionManager,
  45360. /**
  45361. * read-only options to be used in this module
  45362. */
  45363. options?: IWebXRBackgroundRemoverOptions);
  45364. /**
  45365. * attach this feature
  45366. * Will usually be called by the features manager
  45367. *
  45368. * @returns true if successful.
  45369. */
  45370. attach(): boolean;
  45371. /**
  45372. * detach this feature.
  45373. * Will usually be called by the features manager
  45374. *
  45375. * @returns true if successful.
  45376. */
  45377. detach(): boolean;
  45378. private _setBackgroundState;
  45379. /**
  45380. * Dispose this feature and all of the resources attached
  45381. */
  45382. dispose(): void;
  45383. protected _onXRFrame(_xrFrame: XRFrame): void;
  45384. }
  45385. }
  45386. declare module BABYLON {
  45387. /**
  45388. * The motion controller class for all microsoft mixed reality controllers
  45389. */
  45390. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  45391. /**
  45392. * The base url used to load the left and right controller models
  45393. */
  45394. static MODEL_BASE_URL: string;
  45395. /**
  45396. * The name of the left controller model file
  45397. */
  45398. static MODEL_LEFT_FILENAME: string;
  45399. /**
  45400. * The name of the right controller model file
  45401. */
  45402. static MODEL_RIGHT_FILENAME: string;
  45403. profileId: string;
  45404. protected readonly _mapping: {
  45405. defaultButton: {
  45406. "valueNodeName": string;
  45407. "unpressedNodeName": string;
  45408. "pressedNodeName": string;
  45409. };
  45410. defaultAxis: {
  45411. "valueNodeName": string;
  45412. "minNodeName": string;
  45413. "maxNodeName": string;
  45414. };
  45415. buttons: {
  45416. "xr-standard-trigger": {
  45417. "rootNodeName": string;
  45418. "componentProperty": string;
  45419. "states": string[];
  45420. };
  45421. "xr-standard-squeeze": {
  45422. "rootNodeName": string;
  45423. "componentProperty": string;
  45424. "states": string[];
  45425. };
  45426. "xr-standard-touchpad": {
  45427. "rootNodeName": string;
  45428. "labelAnchorNodeName": string;
  45429. "touchPointNodeName": string;
  45430. };
  45431. "xr-standard-thumbstick": {
  45432. "rootNodeName": string;
  45433. "componentProperty": string;
  45434. "states": string[];
  45435. };
  45436. };
  45437. axes: {
  45438. "xr-standard-touchpad": {
  45439. "x-axis": {
  45440. "rootNodeName": string;
  45441. };
  45442. "y-axis": {
  45443. "rootNodeName": string;
  45444. };
  45445. };
  45446. "xr-standard-thumbstick": {
  45447. "x-axis": {
  45448. "rootNodeName": string;
  45449. };
  45450. "y-axis": {
  45451. "rootNodeName": string;
  45452. };
  45453. };
  45454. };
  45455. };
  45456. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45457. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45458. private _getChildByName;
  45459. private _getImmediateChildByName;
  45460. protected _getFilenameAndPath(): {
  45461. filename: string;
  45462. path: string;
  45463. };
  45464. protected _updateModel(): void;
  45465. protected _getModelLoadingConstraints(): boolean;
  45466. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45467. }
  45468. }
  45469. declare module BABYLON {
  45470. /**
  45471. * The motion controller class for oculus touch (quest, rift).
  45472. * This class supports legacy mapping as well the standard xr mapping
  45473. */
  45474. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  45475. private _forceLegacyControllers;
  45476. /**
  45477. * The base url used to load the left and right controller models
  45478. */
  45479. static MODEL_BASE_URL: string;
  45480. /**
  45481. * The name of the left controller model file
  45482. */
  45483. static MODEL_LEFT_FILENAME: string;
  45484. /**
  45485. * The name of the right controller model file
  45486. */
  45487. static MODEL_RIGHT_FILENAME: string;
  45488. /**
  45489. * Base Url for the Quest controller model.
  45490. */
  45491. static QUEST_MODEL_BASE_URL: string;
  45492. profileId: string;
  45493. private _modelRootNode;
  45494. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  45495. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45496. protected _getFilenameAndPath(): {
  45497. filename: string;
  45498. path: string;
  45499. };
  45500. /**
  45501. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  45502. * between the touch and touch 2.
  45503. */
  45504. private _isQuest;
  45505. protected _updateModel(): void;
  45506. protected _getModelLoadingConstraints(): boolean;
  45507. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45508. }
  45509. }
  45510. declare module BABYLON {
  45511. /**
  45512. * The motion controller class for the standard HTC-Vive controllers
  45513. */
  45514. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  45515. /**
  45516. * The base url used to load the left and right controller models
  45517. */
  45518. static MODEL_BASE_URL: string;
  45519. /**
  45520. * File name for the controller model.
  45521. */
  45522. static MODEL_FILENAME: string;
  45523. profileId: string;
  45524. private _modelRootNode;
  45525. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  45526. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45527. protected _getFilenameAndPath(): {
  45528. filename: string;
  45529. path: string;
  45530. };
  45531. protected _updateModel(): void;
  45532. protected _getModelLoadingConstraints(): boolean;
  45533. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45534. }
  45535. }
  45536. declare module BABYLON {
  45537. /**
  45538. * Contains an array of blocks representing the octree
  45539. */
  45540. export interface IOctreeContainer<T> {
  45541. /**
  45542. * Blocks within the octree
  45543. */
  45544. blocks: Array<OctreeBlock<T>>;
  45545. }
  45546. /**
  45547. * Class used to store a cell in an octree
  45548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45549. */
  45550. export class OctreeBlock<T> {
  45551. /**
  45552. * Gets the content of the current block
  45553. */
  45554. entries: T[];
  45555. /**
  45556. * Gets the list of block children
  45557. */
  45558. blocks: Array<OctreeBlock<T>>;
  45559. private _depth;
  45560. private _maxDepth;
  45561. private _capacity;
  45562. private _minPoint;
  45563. private _maxPoint;
  45564. private _boundingVectors;
  45565. private _creationFunc;
  45566. /**
  45567. * Creates a new block
  45568. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45569. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45570. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45571. * @param depth defines the current depth of this block in the octree
  45572. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45573. * @param creationFunc defines a callback to call when an element is added to the block
  45574. */
  45575. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45576. /**
  45577. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45578. */
  45579. get capacity(): number;
  45580. /**
  45581. * Gets the minimum vector (in world space) of the block's bounding box
  45582. */
  45583. get minPoint(): Vector3;
  45584. /**
  45585. * Gets the maximum vector (in world space) of the block's bounding box
  45586. */
  45587. get maxPoint(): Vector3;
  45588. /**
  45589. * Add a new element to this block
  45590. * @param entry defines the element to add
  45591. */
  45592. addEntry(entry: T): void;
  45593. /**
  45594. * Remove an element from this block
  45595. * @param entry defines the element to remove
  45596. */
  45597. removeEntry(entry: T): void;
  45598. /**
  45599. * Add an array of elements to this block
  45600. * @param entries defines the array of elements to add
  45601. */
  45602. addEntries(entries: T[]): void;
  45603. /**
  45604. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45605. * @param frustumPlanes defines the frustum planes to test
  45606. * @param selection defines the array to store current content if selection is positive
  45607. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45608. */
  45609. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45610. /**
  45611. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45612. * @param sphereCenter defines the bounding sphere center
  45613. * @param sphereRadius defines the bounding sphere radius
  45614. * @param selection defines the array to store current content if selection is positive
  45615. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45616. */
  45617. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45618. /**
  45619. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45620. * @param ray defines the ray to test with
  45621. * @param selection defines the array to store current content if selection is positive
  45622. */
  45623. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45624. /**
  45625. * Subdivide the content into child blocks (this block will then be empty)
  45626. */
  45627. createInnerBlocks(): void;
  45628. /**
  45629. * @hidden
  45630. */
  45631. 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;
  45632. }
  45633. }
  45634. declare module BABYLON {
  45635. /**
  45636. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45637. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45638. */
  45639. export class Octree<T> {
  45640. /** 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.) */
  45641. maxDepth: number;
  45642. /**
  45643. * Blocks within the octree containing objects
  45644. */
  45645. blocks: Array<OctreeBlock<T>>;
  45646. /**
  45647. * Content stored in the octree
  45648. */
  45649. dynamicContent: T[];
  45650. private _maxBlockCapacity;
  45651. private _selectionContent;
  45652. private _creationFunc;
  45653. /**
  45654. * Creates a octree
  45655. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45656. * @param creationFunc function to be used to instatiate the octree
  45657. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45658. * @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.)
  45659. */
  45660. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45661. /** 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.) */
  45662. maxDepth?: number);
  45663. /**
  45664. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45665. * @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);
  45666. * @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);
  45667. * @param entries meshes to be added to the octree blocks
  45668. */
  45669. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45670. /**
  45671. * Adds a mesh to the octree
  45672. * @param entry Mesh to add to the octree
  45673. */
  45674. addMesh(entry: T): void;
  45675. /**
  45676. * Remove an element from the octree
  45677. * @param entry defines the element to remove
  45678. */
  45679. removeMesh(entry: T): void;
  45680. /**
  45681. * Selects an array of meshes within the frustum
  45682. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45683. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45684. * @returns array of meshes within the frustum
  45685. */
  45686. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45687. /**
  45688. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45689. * @param sphereCenter defines the bounding sphere center
  45690. * @param sphereRadius defines the bounding sphere radius
  45691. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45692. * @returns an array of objects that intersect the sphere
  45693. */
  45694. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45695. /**
  45696. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45697. * @param ray defines the ray to test with
  45698. * @returns array of intersected objects
  45699. */
  45700. intersectsRay(ray: Ray): SmartArray<T>;
  45701. /**
  45702. * Adds a mesh into the octree block if it intersects the block
  45703. */
  45704. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45705. /**
  45706. * Adds a submesh into the octree block if it intersects the block
  45707. */
  45708. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45709. }
  45710. }
  45711. declare module BABYLON {
  45712. interface Scene {
  45713. /**
  45714. * @hidden
  45715. * Backing Filed
  45716. */
  45717. _selectionOctree: Octree<AbstractMesh>;
  45718. /**
  45719. * Gets the octree used to boost mesh selection (picking)
  45720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45721. */
  45722. selectionOctree: Octree<AbstractMesh>;
  45723. /**
  45724. * Creates or updates the octree used to boost selection (picking)
  45725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45726. * @param maxCapacity defines the maximum capacity per leaf
  45727. * @param maxDepth defines the maximum depth of the octree
  45728. * @returns an octree of AbstractMesh
  45729. */
  45730. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45731. }
  45732. interface AbstractMesh {
  45733. /**
  45734. * @hidden
  45735. * Backing Field
  45736. */
  45737. _submeshesOctree: Octree<SubMesh>;
  45738. /**
  45739. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45740. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45741. * @param maxCapacity defines the maximum size of each block (64 by default)
  45742. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45743. * @returns the new octree
  45744. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45746. */
  45747. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45748. }
  45749. /**
  45750. * Defines the octree scene component responsible to manage any octrees
  45751. * in a given scene.
  45752. */
  45753. export class OctreeSceneComponent {
  45754. /**
  45755. * The component name help to identify the component in the list of scene components.
  45756. */
  45757. readonly name: string;
  45758. /**
  45759. * The scene the component belongs to.
  45760. */
  45761. scene: Scene;
  45762. /**
  45763. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45764. */
  45765. readonly checksIsEnabled: boolean;
  45766. /**
  45767. * Creates a new instance of the component for the given scene
  45768. * @param scene Defines the scene to register the component in
  45769. */
  45770. constructor(scene: Scene);
  45771. /**
  45772. * Registers the component in a given scene
  45773. */
  45774. register(): void;
  45775. /**
  45776. * Return the list of active meshes
  45777. * @returns the list of active meshes
  45778. */
  45779. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45780. /**
  45781. * Return the list of active sub meshes
  45782. * @param mesh The mesh to get the candidates sub meshes from
  45783. * @returns the list of active sub meshes
  45784. */
  45785. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45786. private _tempRay;
  45787. /**
  45788. * Return the list of sub meshes intersecting with a given local ray
  45789. * @param mesh defines the mesh to find the submesh for
  45790. * @param localRay defines the ray in local space
  45791. * @returns the list of intersecting sub meshes
  45792. */
  45793. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45794. /**
  45795. * Return the list of sub meshes colliding with a collider
  45796. * @param mesh defines the mesh to find the submesh for
  45797. * @param collider defines the collider to evaluate the collision against
  45798. * @returns the list of colliding sub meshes
  45799. */
  45800. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45801. /**
  45802. * Rebuilds the elements related to this component in case of
  45803. * context lost for instance.
  45804. */
  45805. rebuild(): void;
  45806. /**
  45807. * Disposes the component and the associated ressources.
  45808. */
  45809. dispose(): void;
  45810. }
  45811. }
  45812. declare module BABYLON {
  45813. /**
  45814. * Renders a layer on top of an existing scene
  45815. */
  45816. export class UtilityLayerRenderer implements IDisposable {
  45817. /** the original scene that will be rendered on top of */
  45818. originalScene: Scene;
  45819. private _pointerCaptures;
  45820. private _lastPointerEvents;
  45821. private static _DefaultUtilityLayer;
  45822. private static _DefaultKeepDepthUtilityLayer;
  45823. private _sharedGizmoLight;
  45824. private _renderCamera;
  45825. /**
  45826. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45827. * @returns the camera that is used when rendering the utility layer
  45828. */
  45829. getRenderCamera(): Nullable<Camera>;
  45830. /**
  45831. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45832. * @param cam the camera that should be used when rendering the utility layer
  45833. */
  45834. setRenderCamera(cam: Nullable<Camera>): void;
  45835. /**
  45836. * @hidden
  45837. * Light which used by gizmos to get light shading
  45838. */
  45839. _getSharedGizmoLight(): HemisphericLight;
  45840. /**
  45841. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45842. */
  45843. pickUtilitySceneFirst: boolean;
  45844. /**
  45845. * 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)
  45846. */
  45847. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45848. /**
  45849. * 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)
  45850. */
  45851. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45852. /**
  45853. * The scene that is rendered on top of the original scene
  45854. */
  45855. utilityLayerScene: Scene;
  45856. /**
  45857. * If the utility layer should automatically be rendered on top of existing scene
  45858. */
  45859. shouldRender: boolean;
  45860. /**
  45861. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45862. */
  45863. onlyCheckPointerDownEvents: boolean;
  45864. /**
  45865. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45866. */
  45867. processAllEvents: boolean;
  45868. /**
  45869. * Observable raised when the pointer move from the utility layer scene to the main scene
  45870. */
  45871. onPointerOutObservable: Observable<number>;
  45872. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45873. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45874. private _afterRenderObserver;
  45875. private _sceneDisposeObserver;
  45876. private _originalPointerObserver;
  45877. /**
  45878. * Instantiates a UtilityLayerRenderer
  45879. * @param originalScene the original scene that will be rendered on top of
  45880. * @param handleEvents boolean indicating if the utility layer should handle events
  45881. */
  45882. constructor(
  45883. /** the original scene that will be rendered on top of */
  45884. originalScene: Scene, handleEvents?: boolean);
  45885. private _notifyObservers;
  45886. /**
  45887. * Renders the utility layers scene on top of the original scene
  45888. */
  45889. render(): void;
  45890. /**
  45891. * Disposes of the renderer
  45892. */
  45893. dispose(): void;
  45894. private _updateCamera;
  45895. }
  45896. }
  45897. declare module BABYLON {
  45898. /**
  45899. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45900. */
  45901. export class Gizmo implements IDisposable {
  45902. /** The utility layer the gizmo will be added to */
  45903. gizmoLayer: UtilityLayerRenderer;
  45904. /**
  45905. * The root mesh of the gizmo
  45906. */
  45907. _rootMesh: Mesh;
  45908. private _attachedMesh;
  45909. /**
  45910. * Ratio for the scale of the gizmo (Default: 1)
  45911. */
  45912. scaleRatio: number;
  45913. /**
  45914. * If a custom mesh has been set (Default: false)
  45915. */
  45916. protected _customMeshSet: boolean;
  45917. /**
  45918. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45919. * * When set, interactions will be enabled
  45920. */
  45921. get attachedMesh(): Nullable<AbstractMesh>;
  45922. set attachedMesh(value: Nullable<AbstractMesh>);
  45923. /**
  45924. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45925. * @param mesh The mesh to replace the default mesh of the gizmo
  45926. */
  45927. setCustomMesh(mesh: Mesh): void;
  45928. /**
  45929. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45930. */
  45931. updateGizmoRotationToMatchAttachedMesh: boolean;
  45932. /**
  45933. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45934. */
  45935. updateGizmoPositionToMatchAttachedMesh: boolean;
  45936. /**
  45937. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45938. */
  45939. updateScale: boolean;
  45940. protected _interactionsEnabled: boolean;
  45941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45942. private _beforeRenderObserver;
  45943. private _tempVector;
  45944. /**
  45945. * Creates a gizmo
  45946. * @param gizmoLayer The utility layer the gizmo will be added to
  45947. */
  45948. constructor(
  45949. /** The utility layer the gizmo will be added to */
  45950. gizmoLayer?: UtilityLayerRenderer);
  45951. /**
  45952. * Updates the gizmo to match the attached mesh's position/rotation
  45953. */
  45954. protected _update(): void;
  45955. /**
  45956. * Disposes of the gizmo
  45957. */
  45958. dispose(): void;
  45959. }
  45960. }
  45961. declare module BABYLON {
  45962. /**
  45963. * Single plane drag gizmo
  45964. */
  45965. export class PlaneDragGizmo extends Gizmo {
  45966. /**
  45967. * Drag behavior responsible for the gizmos dragging interactions
  45968. */
  45969. dragBehavior: PointerDragBehavior;
  45970. private _pointerObserver;
  45971. /**
  45972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45973. */
  45974. snapDistance: number;
  45975. /**
  45976. * Event that fires each time the gizmo snaps to a new location.
  45977. * * snapDistance is the the change in distance
  45978. */
  45979. onSnapObservable: Observable<{
  45980. snapDistance: number;
  45981. }>;
  45982. private _plane;
  45983. private _coloredMaterial;
  45984. private _hoverMaterial;
  45985. private _isEnabled;
  45986. private _parent;
  45987. /** @hidden */
  45988. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45989. /** @hidden */
  45990. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45991. /**
  45992. * Creates a PlaneDragGizmo
  45993. * @param gizmoLayer The utility layer the gizmo will be added to
  45994. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45995. * @param color The color of the gizmo
  45996. */
  45997. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45998. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45999. /**
  46000. * If the gizmo is enabled
  46001. */
  46002. set isEnabled(value: boolean);
  46003. get isEnabled(): boolean;
  46004. /**
  46005. * Disposes of the gizmo
  46006. */
  46007. dispose(): void;
  46008. }
  46009. }
  46010. declare module BABYLON {
  46011. /**
  46012. * Gizmo that enables dragging a mesh along 3 axis
  46013. */
  46014. export class PositionGizmo extends Gizmo {
  46015. /**
  46016. * Internal gizmo used for interactions on the x axis
  46017. */
  46018. xGizmo: AxisDragGizmo;
  46019. /**
  46020. * Internal gizmo used for interactions on the y axis
  46021. */
  46022. yGizmo: AxisDragGizmo;
  46023. /**
  46024. * Internal gizmo used for interactions on the z axis
  46025. */
  46026. zGizmo: AxisDragGizmo;
  46027. /**
  46028. * Internal gizmo used for interactions on the yz plane
  46029. */
  46030. xPlaneGizmo: PlaneDragGizmo;
  46031. /**
  46032. * Internal gizmo used for interactions on the xz plane
  46033. */
  46034. yPlaneGizmo: PlaneDragGizmo;
  46035. /**
  46036. * Internal gizmo used for interactions on the xy plane
  46037. */
  46038. zPlaneGizmo: PlaneDragGizmo;
  46039. /**
  46040. * private variables
  46041. */
  46042. private _meshAttached;
  46043. private _updateGizmoRotationToMatchAttachedMesh;
  46044. private _snapDistance;
  46045. private _scaleRatio;
  46046. /** Fires an event when any of it's sub gizmos are dragged */
  46047. onDragStartObservable: Observable<unknown>;
  46048. /** Fires an event when any of it's sub gizmos are released from dragging */
  46049. onDragEndObservable: Observable<unknown>;
  46050. /**
  46051. * If set to true, planar drag is enabled
  46052. */
  46053. private _planarGizmoEnabled;
  46054. get attachedMesh(): Nullable<AbstractMesh>;
  46055. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46056. /**
  46057. * Creates a PositionGizmo
  46058. * @param gizmoLayer The utility layer the gizmo will be added to
  46059. */
  46060. constructor(gizmoLayer?: UtilityLayerRenderer);
  46061. /**
  46062. * If the planar drag gizmo is enabled
  46063. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46064. */
  46065. set planarGizmoEnabled(value: boolean);
  46066. get planarGizmoEnabled(): boolean;
  46067. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46068. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46069. /**
  46070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46071. */
  46072. set snapDistance(value: number);
  46073. get snapDistance(): number;
  46074. /**
  46075. * Ratio for the scale of the gizmo (Default: 1)
  46076. */
  46077. set scaleRatio(value: number);
  46078. get scaleRatio(): number;
  46079. /**
  46080. * Disposes of the gizmo
  46081. */
  46082. dispose(): void;
  46083. /**
  46084. * CustomMeshes are not supported by this gizmo
  46085. * @param mesh The mesh to replace the default mesh of the gizmo
  46086. */
  46087. setCustomMesh(mesh: Mesh): void;
  46088. }
  46089. }
  46090. declare module BABYLON {
  46091. /**
  46092. * Single axis drag gizmo
  46093. */
  46094. export class AxisDragGizmo extends Gizmo {
  46095. /**
  46096. * Drag behavior responsible for the gizmos dragging interactions
  46097. */
  46098. dragBehavior: PointerDragBehavior;
  46099. private _pointerObserver;
  46100. /**
  46101. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46102. */
  46103. snapDistance: number;
  46104. /**
  46105. * Event that fires each time the gizmo snaps to a new location.
  46106. * * snapDistance is the the change in distance
  46107. */
  46108. onSnapObservable: Observable<{
  46109. snapDistance: number;
  46110. }>;
  46111. private _isEnabled;
  46112. private _parent;
  46113. private _arrow;
  46114. private _coloredMaterial;
  46115. private _hoverMaterial;
  46116. /** @hidden */
  46117. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46118. /** @hidden */
  46119. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46120. /**
  46121. * Creates an AxisDragGizmo
  46122. * @param gizmoLayer The utility layer the gizmo will be added to
  46123. * @param dragAxis The axis which the gizmo will be able to drag on
  46124. * @param color The color of the gizmo
  46125. */
  46126. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46128. /**
  46129. * If the gizmo is enabled
  46130. */
  46131. set isEnabled(value: boolean);
  46132. get isEnabled(): boolean;
  46133. /**
  46134. * Disposes of the gizmo
  46135. */
  46136. dispose(): void;
  46137. }
  46138. }
  46139. declare module BABYLON.Debug {
  46140. /**
  46141. * The Axes viewer will show 3 axes in a specific point in space
  46142. */
  46143. export class AxesViewer {
  46144. private _xAxis;
  46145. private _yAxis;
  46146. private _zAxis;
  46147. private _scaleLinesFactor;
  46148. private _instanced;
  46149. /**
  46150. * Gets the hosting scene
  46151. */
  46152. scene: Scene;
  46153. /**
  46154. * Gets or sets a number used to scale line length
  46155. */
  46156. scaleLines: number;
  46157. /** Gets the node hierarchy used to render x-axis */
  46158. get xAxis(): TransformNode;
  46159. /** Gets the node hierarchy used to render y-axis */
  46160. get yAxis(): TransformNode;
  46161. /** Gets the node hierarchy used to render z-axis */
  46162. get zAxis(): TransformNode;
  46163. /**
  46164. * Creates a new AxesViewer
  46165. * @param scene defines the hosting scene
  46166. * @param scaleLines defines a number used to scale line length (1 by default)
  46167. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46168. * @param xAxis defines the node hierarchy used to render the x-axis
  46169. * @param yAxis defines the node hierarchy used to render the y-axis
  46170. * @param zAxis defines the node hierarchy used to render the z-axis
  46171. */
  46172. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46173. /**
  46174. * Force the viewer to update
  46175. * @param position defines the position of the viewer
  46176. * @param xaxis defines the x axis of the viewer
  46177. * @param yaxis defines the y axis of the viewer
  46178. * @param zaxis defines the z axis of the viewer
  46179. */
  46180. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46181. /**
  46182. * Creates an instance of this axes viewer.
  46183. * @returns a new axes viewer with instanced meshes
  46184. */
  46185. createInstance(): AxesViewer;
  46186. /** Releases resources */
  46187. dispose(): void;
  46188. private static _SetRenderingGroupId;
  46189. }
  46190. }
  46191. declare module BABYLON.Debug {
  46192. /**
  46193. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46194. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46195. */
  46196. export class BoneAxesViewer extends AxesViewer {
  46197. /**
  46198. * Gets or sets the target mesh where to display the axes viewer
  46199. */
  46200. mesh: Nullable<Mesh>;
  46201. /**
  46202. * Gets or sets the target bone where to display the axes viewer
  46203. */
  46204. bone: Nullable<Bone>;
  46205. /** Gets current position */
  46206. pos: Vector3;
  46207. /** Gets direction of X axis */
  46208. xaxis: Vector3;
  46209. /** Gets direction of Y axis */
  46210. yaxis: Vector3;
  46211. /** Gets direction of Z axis */
  46212. zaxis: Vector3;
  46213. /**
  46214. * Creates a new BoneAxesViewer
  46215. * @param scene defines the hosting scene
  46216. * @param bone defines the target bone
  46217. * @param mesh defines the target mesh
  46218. * @param scaleLines defines a scaling factor for line length (1 by default)
  46219. */
  46220. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46221. /**
  46222. * Force the viewer to update
  46223. */
  46224. update(): void;
  46225. /** Releases resources */
  46226. dispose(): void;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Interface used to define scene explorer extensibility option
  46232. */
  46233. export interface IExplorerExtensibilityOption {
  46234. /**
  46235. * Define the option label
  46236. */
  46237. label: string;
  46238. /**
  46239. * Defines the action to execute on click
  46240. */
  46241. action: (entity: any) => void;
  46242. }
  46243. /**
  46244. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46245. */
  46246. export interface IExplorerExtensibilityGroup {
  46247. /**
  46248. * Defines a predicate to test if a given type mut be extended
  46249. */
  46250. predicate: (entity: any) => boolean;
  46251. /**
  46252. * Gets the list of options added to a type
  46253. */
  46254. entries: IExplorerExtensibilityOption[];
  46255. }
  46256. /**
  46257. * Interface used to define the options to use to create the Inspector
  46258. */
  46259. export interface IInspectorOptions {
  46260. /**
  46261. * Display in overlay mode (default: false)
  46262. */
  46263. overlay?: boolean;
  46264. /**
  46265. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46266. */
  46267. globalRoot?: HTMLElement;
  46268. /**
  46269. * Display the Scene explorer
  46270. */
  46271. showExplorer?: boolean;
  46272. /**
  46273. * Display the property inspector
  46274. */
  46275. showInspector?: boolean;
  46276. /**
  46277. * Display in embed mode (both panes on the right)
  46278. */
  46279. embedMode?: boolean;
  46280. /**
  46281. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46282. */
  46283. handleResize?: boolean;
  46284. /**
  46285. * Allow the panes to popup (default: true)
  46286. */
  46287. enablePopup?: boolean;
  46288. /**
  46289. * Allow the panes to be closed by users (default: true)
  46290. */
  46291. enableClose?: boolean;
  46292. /**
  46293. * Optional list of extensibility entries
  46294. */
  46295. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46296. /**
  46297. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46298. */
  46299. inspectorURL?: string;
  46300. /**
  46301. * Optional initial tab (default to DebugLayerTab.Properties)
  46302. */
  46303. initialTab?: DebugLayerTab;
  46304. }
  46305. interface Scene {
  46306. /**
  46307. * @hidden
  46308. * Backing field
  46309. */
  46310. _debugLayer: DebugLayer;
  46311. /**
  46312. * Gets the debug layer (aka Inspector) associated with the scene
  46313. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46314. */
  46315. debugLayer: DebugLayer;
  46316. }
  46317. /**
  46318. * Enum of inspector action tab
  46319. */
  46320. export enum DebugLayerTab {
  46321. /**
  46322. * Properties tag (default)
  46323. */
  46324. Properties = 0,
  46325. /**
  46326. * Debug tab
  46327. */
  46328. Debug = 1,
  46329. /**
  46330. * Statistics tab
  46331. */
  46332. Statistics = 2,
  46333. /**
  46334. * Tools tab
  46335. */
  46336. Tools = 3,
  46337. /**
  46338. * Settings tab
  46339. */
  46340. Settings = 4
  46341. }
  46342. /**
  46343. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46344. * what is happening in your scene
  46345. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46346. */
  46347. export class DebugLayer {
  46348. /**
  46349. * Define the url to get the inspector script from.
  46350. * By default it uses the babylonjs CDN.
  46351. * @ignoreNaming
  46352. */
  46353. static InspectorURL: string;
  46354. private _scene;
  46355. private BJSINSPECTOR;
  46356. private _onPropertyChangedObservable?;
  46357. /**
  46358. * Observable triggered when a property is changed through the inspector.
  46359. */
  46360. get onPropertyChangedObservable(): any;
  46361. /**
  46362. * Instantiates a new debug layer.
  46363. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46364. * what is happening in your scene
  46365. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46366. * @param scene Defines the scene to inspect
  46367. */
  46368. constructor(scene: Scene);
  46369. /** Creates the inspector window. */
  46370. private _createInspector;
  46371. /**
  46372. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46373. * @param entity defines the entity to select
  46374. * @param lineContainerTitle defines the specific block to highlight
  46375. */
  46376. select(entity: any, lineContainerTitle?: string): void;
  46377. /** Get the inspector from bundle or global */
  46378. private _getGlobalInspector;
  46379. /**
  46380. * Get if the inspector is visible or not.
  46381. * @returns true if visible otherwise, false
  46382. */
  46383. isVisible(): boolean;
  46384. /**
  46385. * Hide the inspector and close its window.
  46386. */
  46387. hide(): void;
  46388. /**
  46389. * Launch the debugLayer.
  46390. * @param config Define the configuration of the inspector
  46391. * @return a promise fulfilled when the debug layer is visible
  46392. */
  46393. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46394. }
  46395. }
  46396. declare module BABYLON {
  46397. /**
  46398. * Class containing static functions to help procedurally build meshes
  46399. */
  46400. export class BoxBuilder {
  46401. /**
  46402. * Creates a box mesh
  46403. * * The parameter `size` sets the size (float) of each box side (default 1)
  46404. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46405. * * 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)
  46406. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46408. * * 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
  46409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46410. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46411. * @param name defines the name of the mesh
  46412. * @param options defines the options used to create the mesh
  46413. * @param scene defines the hosting scene
  46414. * @returns the box mesh
  46415. */
  46416. static CreateBox(name: string, options: {
  46417. size?: number;
  46418. width?: number;
  46419. height?: number;
  46420. depth?: number;
  46421. faceUV?: Vector4[];
  46422. faceColors?: Color4[];
  46423. sideOrientation?: number;
  46424. frontUVs?: Vector4;
  46425. backUVs?: Vector4;
  46426. wrap?: boolean;
  46427. topBaseAt?: number;
  46428. bottomBaseAt?: number;
  46429. updatable?: boolean;
  46430. }, scene?: Nullable<Scene>): Mesh;
  46431. }
  46432. }
  46433. declare module BABYLON {
  46434. /**
  46435. * Class containing static functions to help procedurally build meshes
  46436. */
  46437. export class SphereBuilder {
  46438. /**
  46439. * Creates a sphere mesh
  46440. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46441. * * 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`)
  46442. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46443. * * 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
  46444. * * 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)
  46445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46446. * * 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
  46447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46448. * @param name defines the name of the mesh
  46449. * @param options defines the options used to create the mesh
  46450. * @param scene defines the hosting scene
  46451. * @returns the sphere mesh
  46452. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46453. */
  46454. static CreateSphere(name: string, options: {
  46455. segments?: number;
  46456. diameter?: number;
  46457. diameterX?: number;
  46458. diameterY?: number;
  46459. diameterZ?: number;
  46460. arc?: number;
  46461. slice?: number;
  46462. sideOrientation?: number;
  46463. frontUVs?: Vector4;
  46464. backUVs?: Vector4;
  46465. updatable?: boolean;
  46466. }, scene?: Nullable<Scene>): Mesh;
  46467. }
  46468. }
  46469. declare module BABYLON.Debug {
  46470. /**
  46471. * Used to show the physics impostor around the specific mesh
  46472. */
  46473. export class PhysicsViewer {
  46474. /** @hidden */
  46475. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46476. /** @hidden */
  46477. protected _meshes: Array<Nullable<AbstractMesh>>;
  46478. /** @hidden */
  46479. protected _scene: Nullable<Scene>;
  46480. /** @hidden */
  46481. protected _numMeshes: number;
  46482. /** @hidden */
  46483. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46484. private _renderFunction;
  46485. private _utilityLayer;
  46486. private _debugBoxMesh;
  46487. private _debugSphereMesh;
  46488. private _debugCylinderMesh;
  46489. private _debugMaterial;
  46490. private _debugMeshMeshes;
  46491. /**
  46492. * Creates a new PhysicsViewer
  46493. * @param scene defines the hosting scene
  46494. */
  46495. constructor(scene: Scene);
  46496. /** @hidden */
  46497. protected _updateDebugMeshes(): void;
  46498. /**
  46499. * Renders a specified physic impostor
  46500. * @param impostor defines the impostor to render
  46501. * @param targetMesh defines the mesh represented by the impostor
  46502. * @returns the new debug mesh used to render the impostor
  46503. */
  46504. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46505. /**
  46506. * Hides a specified physic impostor
  46507. * @param impostor defines the impostor to hide
  46508. */
  46509. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46510. private _getDebugMaterial;
  46511. private _getDebugBoxMesh;
  46512. private _getDebugSphereMesh;
  46513. private _getDebugCylinderMesh;
  46514. private _getDebugMeshMesh;
  46515. private _getDebugMesh;
  46516. /** Releases all resources */
  46517. dispose(): void;
  46518. }
  46519. }
  46520. declare module BABYLON {
  46521. /**
  46522. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46523. * in order to better appreciate the issue one might have.
  46524. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46525. */
  46526. export class RayHelper {
  46527. /**
  46528. * Defines the ray we are currently tryin to visualize.
  46529. */
  46530. ray: Nullable<Ray>;
  46531. private _renderPoints;
  46532. private _renderLine;
  46533. private _renderFunction;
  46534. private _scene;
  46535. private _updateToMeshFunction;
  46536. private _attachedToMesh;
  46537. private _meshSpaceDirection;
  46538. private _meshSpaceOrigin;
  46539. /**
  46540. * Helper function to create a colored helper in a scene in one line.
  46541. * @param ray Defines the ray we are currently tryin to visualize
  46542. * @param scene Defines the scene the ray is used in
  46543. * @param color Defines the color we want to see the ray in
  46544. * @returns The newly created ray helper.
  46545. */
  46546. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46547. /**
  46548. * Instantiate a new ray helper.
  46549. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46550. * in order to better appreciate the issue one might have.
  46551. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46552. * @param ray Defines the ray we are currently tryin to visualize
  46553. */
  46554. constructor(ray: Ray);
  46555. /**
  46556. * Shows the ray we are willing to debug.
  46557. * @param scene Defines the scene the ray needs to be rendered in
  46558. * @param color Defines the color the ray needs to be rendered in
  46559. */
  46560. show(scene: Scene, color?: Color3): void;
  46561. /**
  46562. * Hides the ray we are debugging.
  46563. */
  46564. hide(): void;
  46565. private _render;
  46566. /**
  46567. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46568. * @param mesh Defines the mesh we want the helper attached to
  46569. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46570. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46571. * @param length Defines the length of the ray
  46572. */
  46573. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46574. /**
  46575. * Detach the ray helper from the mesh it has previously been attached to.
  46576. */
  46577. detachFromMesh(): void;
  46578. private _updateToMesh;
  46579. /**
  46580. * Dispose the helper and release its associated resources.
  46581. */
  46582. dispose(): void;
  46583. }
  46584. }
  46585. declare module BABYLON.Debug {
  46586. /**
  46587. * Class used to render a debug view of a given skeleton
  46588. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46589. */
  46590. export class SkeletonViewer {
  46591. /** defines the skeleton to render */
  46592. skeleton: Skeleton;
  46593. /** defines the mesh attached to the skeleton */
  46594. mesh: AbstractMesh;
  46595. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46596. autoUpdateBonesMatrices: boolean;
  46597. /** defines the rendering group id to use with the viewer */
  46598. renderingGroupId: number;
  46599. /** Gets or sets the color used to render the skeleton */
  46600. color: Color3;
  46601. private _scene;
  46602. private _debugLines;
  46603. private _debugMesh;
  46604. private _isEnabled;
  46605. private _renderFunction;
  46606. private _utilityLayer;
  46607. /**
  46608. * Returns the mesh used to render the bones
  46609. */
  46610. get debugMesh(): Nullable<LinesMesh>;
  46611. /**
  46612. * Creates a new SkeletonViewer
  46613. * @param skeleton defines the skeleton to render
  46614. * @param mesh defines the mesh attached to the skeleton
  46615. * @param scene defines the hosting scene
  46616. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46617. * @param renderingGroupId defines the rendering group id to use with the viewer
  46618. */
  46619. constructor(
  46620. /** defines the skeleton to render */
  46621. skeleton: Skeleton,
  46622. /** defines the mesh attached to the skeleton */
  46623. mesh: AbstractMesh, scene: Scene,
  46624. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46625. autoUpdateBonesMatrices?: boolean,
  46626. /** defines the rendering group id to use with the viewer */
  46627. renderingGroupId?: number);
  46628. /** Gets or sets a boolean indicating if the viewer is enabled */
  46629. set isEnabled(value: boolean);
  46630. get isEnabled(): boolean;
  46631. private _getBonePosition;
  46632. private _getLinesForBonesWithLength;
  46633. private _getLinesForBonesNoLength;
  46634. /** Update the viewer to sync with current skeleton state */
  46635. update(): void;
  46636. /** Release associated resources */
  46637. dispose(): void;
  46638. }
  46639. }
  46640. declare module BABYLON {
  46641. /**
  46642. * Options to create the null engine
  46643. */
  46644. export class NullEngineOptions {
  46645. /**
  46646. * Render width (Default: 512)
  46647. */
  46648. renderWidth: number;
  46649. /**
  46650. * Render height (Default: 256)
  46651. */
  46652. renderHeight: number;
  46653. /**
  46654. * Texture size (Default: 512)
  46655. */
  46656. textureSize: number;
  46657. /**
  46658. * If delta time between frames should be constant
  46659. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46660. */
  46661. deterministicLockstep: boolean;
  46662. /**
  46663. * Maximum about of steps between frames (Default: 4)
  46664. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46665. */
  46666. lockstepMaxSteps: number;
  46667. }
  46668. /**
  46669. * The null engine class provides support for headless version of babylon.js.
  46670. * This can be used in server side scenario or for testing purposes
  46671. */
  46672. export class NullEngine extends Engine {
  46673. private _options;
  46674. /**
  46675. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46677. * @returns true if engine is in deterministic lock step mode
  46678. */
  46679. isDeterministicLockStep(): boolean;
  46680. /**
  46681. * Gets the max steps when engine is running in deterministic lock step
  46682. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46683. * @returns the max steps
  46684. */
  46685. getLockstepMaxSteps(): number;
  46686. /**
  46687. * Gets the current hardware scaling level.
  46688. * By default the hardware scaling level is computed from the window device ratio.
  46689. * 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.
  46690. * @returns a number indicating the current hardware scaling level
  46691. */
  46692. getHardwareScalingLevel(): number;
  46693. constructor(options?: NullEngineOptions);
  46694. /**
  46695. * Creates a vertex buffer
  46696. * @param vertices the data for the vertex buffer
  46697. * @returns the new WebGL static buffer
  46698. */
  46699. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46700. /**
  46701. * Creates a new index buffer
  46702. * @param indices defines the content of the index buffer
  46703. * @param updatable defines if the index buffer must be updatable
  46704. * @returns a new webGL buffer
  46705. */
  46706. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46707. /**
  46708. * Clear the current render buffer or the current render target (if any is set up)
  46709. * @param color defines the color to use
  46710. * @param backBuffer defines if the back buffer must be cleared
  46711. * @param depth defines if the depth buffer must be cleared
  46712. * @param stencil defines if the stencil buffer must be cleared
  46713. */
  46714. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46715. /**
  46716. * Gets the current render width
  46717. * @param useScreen defines if screen size must be used (or the current render target if any)
  46718. * @returns a number defining the current render width
  46719. */
  46720. getRenderWidth(useScreen?: boolean): number;
  46721. /**
  46722. * Gets the current render height
  46723. * @param useScreen defines if screen size must be used (or the current render target if any)
  46724. * @returns a number defining the current render height
  46725. */
  46726. getRenderHeight(useScreen?: boolean): number;
  46727. /**
  46728. * Set the WebGL's viewport
  46729. * @param viewport defines the viewport element to be used
  46730. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46731. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46732. */
  46733. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46734. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46735. /**
  46736. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46737. * @param pipelineContext defines the pipeline context to use
  46738. * @param uniformsNames defines the list of uniform names
  46739. * @returns an array of webGL uniform locations
  46740. */
  46741. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46742. /**
  46743. * Gets the lsit of active attributes for a given webGL program
  46744. * @param pipelineContext defines the pipeline context to use
  46745. * @param attributesNames defines the list of attribute names to get
  46746. * @returns an array of indices indicating the offset of each attribute
  46747. */
  46748. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46749. /**
  46750. * Binds an effect to the webGL context
  46751. * @param effect defines the effect to bind
  46752. */
  46753. bindSamplers(effect: Effect): void;
  46754. /**
  46755. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46756. * @param effect defines the effect to activate
  46757. */
  46758. enableEffect(effect: Effect): void;
  46759. /**
  46760. * Set various states to the webGL context
  46761. * @param culling defines backface culling state
  46762. * @param zOffset defines the value to apply to zOffset (0 by default)
  46763. * @param force defines if states must be applied even if cache is up to date
  46764. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46765. */
  46766. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46767. /**
  46768. * Set the value of an uniform to an array of int32
  46769. * @param uniform defines the webGL uniform location where to store the value
  46770. * @param array defines the array of int32 to store
  46771. */
  46772. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46773. /**
  46774. * Set the value of an uniform to an array of int32 (stored as vec2)
  46775. * @param uniform defines the webGL uniform location where to store the value
  46776. * @param array defines the array of int32 to store
  46777. */
  46778. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46779. /**
  46780. * Set the value of an uniform to an array of int32 (stored as vec3)
  46781. * @param uniform defines the webGL uniform location where to store the value
  46782. * @param array defines the array of int32 to store
  46783. */
  46784. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46785. /**
  46786. * Set the value of an uniform to an array of int32 (stored as vec4)
  46787. * @param uniform defines the webGL uniform location where to store the value
  46788. * @param array defines the array of int32 to store
  46789. */
  46790. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46791. /**
  46792. * Set the value of an uniform to an array of float32
  46793. * @param uniform defines the webGL uniform location where to store the value
  46794. * @param array defines the array of float32 to store
  46795. */
  46796. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46797. /**
  46798. * Set the value of an uniform to an array of float32 (stored as vec2)
  46799. * @param uniform defines the webGL uniform location where to store the value
  46800. * @param array defines the array of float32 to store
  46801. */
  46802. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46803. /**
  46804. * Set the value of an uniform to an array of float32 (stored as vec3)
  46805. * @param uniform defines the webGL uniform location where to store the value
  46806. * @param array defines the array of float32 to store
  46807. */
  46808. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46809. /**
  46810. * Set the value of an uniform to an array of float32 (stored as vec4)
  46811. * @param uniform defines the webGL uniform location where to store the value
  46812. * @param array defines the array of float32 to store
  46813. */
  46814. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46815. /**
  46816. * Set the value of an uniform to an array of number
  46817. * @param uniform defines the webGL uniform location where to store the value
  46818. * @param array defines the array of number to store
  46819. */
  46820. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46821. /**
  46822. * Set the value of an uniform to an array of number (stored as vec2)
  46823. * @param uniform defines the webGL uniform location where to store the value
  46824. * @param array defines the array of number to store
  46825. */
  46826. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46827. /**
  46828. * Set the value of an uniform to an array of number (stored as vec3)
  46829. * @param uniform defines the webGL uniform location where to store the value
  46830. * @param array defines the array of number to store
  46831. */
  46832. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46833. /**
  46834. * Set the value of an uniform to an array of number (stored as vec4)
  46835. * @param uniform defines the webGL uniform location where to store the value
  46836. * @param array defines the array of number to store
  46837. */
  46838. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46839. /**
  46840. * Set the value of an uniform to an array of float32 (stored as matrices)
  46841. * @param uniform defines the webGL uniform location where to store the value
  46842. * @param matrices defines the array of float32 to store
  46843. */
  46844. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46845. /**
  46846. * Set the value of an uniform to a matrix (3x3)
  46847. * @param uniform defines the webGL uniform location where to store the value
  46848. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46849. */
  46850. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46851. /**
  46852. * Set the value of an uniform to a matrix (2x2)
  46853. * @param uniform defines the webGL uniform location where to store the value
  46854. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46855. */
  46856. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46857. /**
  46858. * Set the value of an uniform to a number (float)
  46859. * @param uniform defines the webGL uniform location where to store the value
  46860. * @param value defines the float number to store
  46861. */
  46862. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46863. /**
  46864. * Set the value of an uniform to a vec2
  46865. * @param uniform defines the webGL uniform location where to store the value
  46866. * @param x defines the 1st component of the value
  46867. * @param y defines the 2nd component of the value
  46868. */
  46869. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46870. /**
  46871. * Set the value of an uniform to a vec3
  46872. * @param uniform defines the webGL uniform location where to store the value
  46873. * @param x defines the 1st component of the value
  46874. * @param y defines the 2nd component of the value
  46875. * @param z defines the 3rd component of the value
  46876. */
  46877. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46878. /**
  46879. * Set the value of an uniform to a boolean
  46880. * @param uniform defines the webGL uniform location where to store the value
  46881. * @param bool defines the boolean to store
  46882. */
  46883. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46884. /**
  46885. * Set the value of an uniform to a vec4
  46886. * @param uniform defines the webGL uniform location where to store the value
  46887. * @param x defines the 1st component of the value
  46888. * @param y defines the 2nd component of the value
  46889. * @param z defines the 3rd component of the value
  46890. * @param w defines the 4th component of the value
  46891. */
  46892. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46893. /**
  46894. * Sets the current alpha mode
  46895. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46896. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46897. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46898. */
  46899. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46900. /**
  46901. * Bind webGl buffers directly to the webGL context
  46902. * @param vertexBuffers defines the vertex buffer to bind
  46903. * @param indexBuffer defines the index buffer to bind
  46904. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46905. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46906. * @param effect defines the effect associated with the vertex buffer
  46907. */
  46908. bindBuffers(vertexBuffers: {
  46909. [key: string]: VertexBuffer;
  46910. }, indexBuffer: DataBuffer, effect: Effect): void;
  46911. /**
  46912. * Force the entire cache to be cleared
  46913. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46914. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46915. */
  46916. wipeCaches(bruteForce?: boolean): void;
  46917. /**
  46918. * Send a draw order
  46919. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46920. * @param indexStart defines the starting index
  46921. * @param indexCount defines the number of index to draw
  46922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46923. */
  46924. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46925. /**
  46926. * Draw a list of indexed primitives
  46927. * @param fillMode defines the primitive to use
  46928. * @param indexStart defines the starting index
  46929. * @param indexCount defines the number of index to draw
  46930. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46931. */
  46932. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46933. /**
  46934. * Draw a list of unindexed primitives
  46935. * @param fillMode defines the primitive to use
  46936. * @param verticesStart defines the index of first vertex to draw
  46937. * @param verticesCount defines the count of vertices to draw
  46938. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46939. */
  46940. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46941. /** @hidden */
  46942. _createTexture(): WebGLTexture;
  46943. /** @hidden */
  46944. _releaseTexture(texture: InternalTexture): void;
  46945. /**
  46946. * Usually called from Texture.ts.
  46947. * Passed information to create a WebGLTexture
  46948. * @param urlArg defines a value which contains one of the following:
  46949. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46950. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46951. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46952. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46953. * @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)
  46954. * @param scene needed for loading to the correct scene
  46955. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46956. * @param onLoad optional callback to be called upon successful completion
  46957. * @param onError optional callback to be called upon failure
  46958. * @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
  46959. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46960. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46961. * @param forcedExtension defines the extension to use to pick the right loader
  46962. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46963. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46964. */
  46965. 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;
  46966. /**
  46967. * Creates a new render target texture
  46968. * @param size defines the size of the texture
  46969. * @param options defines the options used to create the texture
  46970. * @returns a new render target texture stored in an InternalTexture
  46971. */
  46972. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46973. /**
  46974. * Update the sampling mode of a given texture
  46975. * @param samplingMode defines the required sampling mode
  46976. * @param texture defines the texture to update
  46977. */
  46978. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46979. /**
  46980. * Binds the frame buffer to the specified texture.
  46981. * @param texture The texture to render to or null for the default canvas
  46982. * @param faceIndex The face of the texture to render to in case of cube texture
  46983. * @param requiredWidth The width of the target to render to
  46984. * @param requiredHeight The height of the target to render to
  46985. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46986. * @param lodLevel defines le lod level to bind to the frame buffer
  46987. */
  46988. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46989. /**
  46990. * Unbind the current render target texture from the webGL context
  46991. * @param texture defines the render target texture to unbind
  46992. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46993. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46994. */
  46995. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46996. /**
  46997. * Creates a dynamic vertex buffer
  46998. * @param vertices the data for the dynamic vertex buffer
  46999. * @returns the new WebGL dynamic buffer
  47000. */
  47001. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47002. /**
  47003. * Update the content of a dynamic texture
  47004. * @param texture defines the texture to update
  47005. * @param canvas defines the canvas containing the source
  47006. * @param invertY defines if data must be stored with Y axis inverted
  47007. * @param premulAlpha defines if alpha is stored as premultiplied
  47008. * @param format defines the format of the data
  47009. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47010. */
  47011. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47012. /**
  47013. * Gets a boolean indicating if all created effects are ready
  47014. * @returns true if all effects are ready
  47015. */
  47016. areAllEffectsReady(): boolean;
  47017. /**
  47018. * @hidden
  47019. * Get the current error code of the webGL context
  47020. * @returns the error code
  47021. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47022. */
  47023. getError(): number;
  47024. /** @hidden */
  47025. _getUnpackAlignement(): number;
  47026. /** @hidden */
  47027. _unpackFlipY(value: boolean): void;
  47028. /**
  47029. * Update a dynamic index buffer
  47030. * @param indexBuffer defines the target index buffer
  47031. * @param indices defines the data to update
  47032. * @param offset defines the offset in the target index buffer where update should start
  47033. */
  47034. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47035. /**
  47036. * Updates a dynamic vertex buffer.
  47037. * @param vertexBuffer the vertex buffer to update
  47038. * @param vertices the data used to update the vertex buffer
  47039. * @param byteOffset the byte offset of the data (optional)
  47040. * @param byteLength the byte length of the data (optional)
  47041. */
  47042. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47043. /** @hidden */
  47044. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47045. /** @hidden */
  47046. _bindTexture(channel: number, texture: InternalTexture): void;
  47047. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47048. /**
  47049. * 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
  47050. */
  47051. releaseEffects(): void;
  47052. displayLoadingUI(): void;
  47053. hideLoadingUI(): void;
  47054. /** @hidden */
  47055. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47056. /** @hidden */
  47057. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47058. /** @hidden */
  47059. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47060. /** @hidden */
  47061. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47062. }
  47063. }
  47064. declare module BABYLON {
  47065. /** @hidden */
  47066. export class _OcclusionDataStorage {
  47067. /** @hidden */
  47068. occlusionInternalRetryCounter: number;
  47069. /** @hidden */
  47070. isOcclusionQueryInProgress: boolean;
  47071. /** @hidden */
  47072. isOccluded: boolean;
  47073. /** @hidden */
  47074. occlusionRetryCount: number;
  47075. /** @hidden */
  47076. occlusionType: number;
  47077. /** @hidden */
  47078. occlusionQueryAlgorithmType: number;
  47079. }
  47080. interface Engine {
  47081. /**
  47082. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47083. * @return the new query
  47084. */
  47085. createQuery(): WebGLQuery;
  47086. /**
  47087. * Delete and release a webGL query
  47088. * @param query defines the query to delete
  47089. * @return the current engine
  47090. */
  47091. deleteQuery(query: WebGLQuery): Engine;
  47092. /**
  47093. * Check if a given query has resolved and got its value
  47094. * @param query defines the query to check
  47095. * @returns true if the query got its value
  47096. */
  47097. isQueryResultAvailable(query: WebGLQuery): boolean;
  47098. /**
  47099. * Gets the value of a given query
  47100. * @param query defines the query to check
  47101. * @returns the value of the query
  47102. */
  47103. getQueryResult(query: WebGLQuery): number;
  47104. /**
  47105. * Initiates an occlusion query
  47106. * @param algorithmType defines the algorithm to use
  47107. * @param query defines the query to use
  47108. * @returns the current engine
  47109. * @see http://doc.babylonjs.com/features/occlusionquery
  47110. */
  47111. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47112. /**
  47113. * Ends an occlusion query
  47114. * @see http://doc.babylonjs.com/features/occlusionquery
  47115. * @param algorithmType defines the algorithm to use
  47116. * @returns the current engine
  47117. */
  47118. endOcclusionQuery(algorithmType: number): Engine;
  47119. /**
  47120. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47121. * Please note that only one query can be issued at a time
  47122. * @returns a time token used to track the time span
  47123. */
  47124. startTimeQuery(): Nullable<_TimeToken>;
  47125. /**
  47126. * Ends a time query
  47127. * @param token defines the token used to measure the time span
  47128. * @returns the time spent (in ns)
  47129. */
  47130. endTimeQuery(token: _TimeToken): int;
  47131. /** @hidden */
  47132. _currentNonTimestampToken: Nullable<_TimeToken>;
  47133. /** @hidden */
  47134. _createTimeQuery(): WebGLQuery;
  47135. /** @hidden */
  47136. _deleteTimeQuery(query: WebGLQuery): void;
  47137. /** @hidden */
  47138. _getGlAlgorithmType(algorithmType: number): number;
  47139. /** @hidden */
  47140. _getTimeQueryResult(query: WebGLQuery): any;
  47141. /** @hidden */
  47142. _getTimeQueryAvailability(query: WebGLQuery): any;
  47143. }
  47144. interface AbstractMesh {
  47145. /**
  47146. * Backing filed
  47147. * @hidden
  47148. */
  47149. __occlusionDataStorage: _OcclusionDataStorage;
  47150. /**
  47151. * Access property
  47152. * @hidden
  47153. */
  47154. _occlusionDataStorage: _OcclusionDataStorage;
  47155. /**
  47156. * 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.
  47157. * The default value is -1 which means don't break the query and wait till the result
  47158. * @see http://doc.babylonjs.com/features/occlusionquery
  47159. */
  47160. occlusionRetryCount: number;
  47161. /**
  47162. * 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:
  47163. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47164. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47165. * * 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.
  47166. * @see http://doc.babylonjs.com/features/occlusionquery
  47167. */
  47168. occlusionType: number;
  47169. /**
  47170. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47171. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47172. * * 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.
  47173. * @see http://doc.babylonjs.com/features/occlusionquery
  47174. */
  47175. occlusionQueryAlgorithmType: number;
  47176. /**
  47177. * 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
  47178. * @see http://doc.babylonjs.com/features/occlusionquery
  47179. */
  47180. isOccluded: boolean;
  47181. /**
  47182. * Flag to check the progress status of the query
  47183. * @see http://doc.babylonjs.com/features/occlusionquery
  47184. */
  47185. isOcclusionQueryInProgress: boolean;
  47186. }
  47187. }
  47188. declare module BABYLON {
  47189. /** @hidden */
  47190. export var _forceTransformFeedbackToBundle: boolean;
  47191. interface Engine {
  47192. /**
  47193. * Creates a webGL transform feedback object
  47194. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47195. * @returns the webGL transform feedback object
  47196. */
  47197. createTransformFeedback(): WebGLTransformFeedback;
  47198. /**
  47199. * Delete a webGL transform feedback object
  47200. * @param value defines the webGL transform feedback object to delete
  47201. */
  47202. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47203. /**
  47204. * Bind a webGL transform feedback object to the webgl context
  47205. * @param value defines the webGL transform feedback object to bind
  47206. */
  47207. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47208. /**
  47209. * Begins a transform feedback operation
  47210. * @param usePoints defines if points or triangles must be used
  47211. */
  47212. beginTransformFeedback(usePoints: boolean): void;
  47213. /**
  47214. * Ends a transform feedback operation
  47215. */
  47216. endTransformFeedback(): void;
  47217. /**
  47218. * Specify the varyings to use with transform feedback
  47219. * @param program defines the associated webGL program
  47220. * @param value defines the list of strings representing the varying names
  47221. */
  47222. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47223. /**
  47224. * Bind a webGL buffer for a transform feedback operation
  47225. * @param value defines the webGL buffer to bind
  47226. */
  47227. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47228. }
  47229. }
  47230. declare module BABYLON {
  47231. /**
  47232. * Creation options of the multi render target texture.
  47233. */
  47234. export interface IMultiRenderTargetOptions {
  47235. /**
  47236. * Define if the texture needs to create mip maps after render.
  47237. */
  47238. generateMipMaps?: boolean;
  47239. /**
  47240. * Define the types of all the draw buffers we want to create
  47241. */
  47242. types?: number[];
  47243. /**
  47244. * Define the sampling modes of all the draw buffers we want to create
  47245. */
  47246. samplingModes?: number[];
  47247. /**
  47248. * Define if a depth buffer is required
  47249. */
  47250. generateDepthBuffer?: boolean;
  47251. /**
  47252. * Define if a stencil buffer is required
  47253. */
  47254. generateStencilBuffer?: boolean;
  47255. /**
  47256. * Define if a depth texture is required instead of a depth buffer
  47257. */
  47258. generateDepthTexture?: boolean;
  47259. /**
  47260. * Define the number of desired draw buffers
  47261. */
  47262. textureCount?: number;
  47263. /**
  47264. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47265. */
  47266. doNotChangeAspectRatio?: boolean;
  47267. /**
  47268. * Define the default type of the buffers we are creating
  47269. */
  47270. defaultType?: number;
  47271. }
  47272. /**
  47273. * A multi render target, like a render target provides the ability to render to a texture.
  47274. * Unlike the render target, it can render to several draw buffers in one draw.
  47275. * This is specially interesting in deferred rendering or for any effects requiring more than
  47276. * just one color from a single pass.
  47277. */
  47278. export class MultiRenderTarget extends RenderTargetTexture {
  47279. private _internalTextures;
  47280. private _textures;
  47281. private _multiRenderTargetOptions;
  47282. /**
  47283. * Get if draw buffers are currently supported by the used hardware and browser.
  47284. */
  47285. get isSupported(): boolean;
  47286. /**
  47287. * Get the list of textures generated by the multi render target.
  47288. */
  47289. get textures(): Texture[];
  47290. /**
  47291. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47292. */
  47293. get depthTexture(): Texture;
  47294. /**
  47295. * Set the wrapping mode on U of all the textures we are rendering to.
  47296. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47297. */
  47298. set wrapU(wrap: number);
  47299. /**
  47300. * Set the wrapping mode on V of all the textures we are rendering to.
  47301. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47302. */
  47303. set wrapV(wrap: number);
  47304. /**
  47305. * Instantiate a new multi render target texture.
  47306. * A multi render target, like a render target provides the ability to render to a texture.
  47307. * Unlike the render target, it can render to several draw buffers in one draw.
  47308. * This is specially interesting in deferred rendering or for any effects requiring more than
  47309. * just one color from a single pass.
  47310. * @param name Define the name of the texture
  47311. * @param size Define the size of the buffers to render to
  47312. * @param count Define the number of target we are rendering into
  47313. * @param scene Define the scene the texture belongs to
  47314. * @param options Define the options used to create the multi render target
  47315. */
  47316. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47317. /** @hidden */
  47318. _rebuild(): void;
  47319. private _createInternalTextures;
  47320. private _createTextures;
  47321. /**
  47322. * Define the number of samples used if MSAA is enabled.
  47323. */
  47324. get samples(): number;
  47325. set samples(value: number);
  47326. /**
  47327. * Resize all the textures in the multi render target.
  47328. * Be carrefull as it will recreate all the data in the new texture.
  47329. * @param size Define the new size
  47330. */
  47331. resize(size: any): void;
  47332. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47333. /**
  47334. * Dispose the render targets and their associated resources
  47335. */
  47336. dispose(): void;
  47337. /**
  47338. * Release all the underlying texture used as draw buffers.
  47339. */
  47340. releaseInternalTextures(): void;
  47341. }
  47342. }
  47343. declare module BABYLON {
  47344. interface ThinEngine {
  47345. /**
  47346. * Unbind a list of render target textures from the webGL context
  47347. * This is used only when drawBuffer extension or webGL2 are active
  47348. * @param textures defines the render target textures to unbind
  47349. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47350. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47351. */
  47352. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47353. /**
  47354. * Create a multi render target texture
  47355. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47356. * @param size defines the size of the texture
  47357. * @param options defines the creation options
  47358. * @returns the cube texture as an InternalTexture
  47359. */
  47360. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47361. /**
  47362. * Update the sample count for a given multiple render target texture
  47363. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47364. * @param textures defines the textures to update
  47365. * @param samples defines the sample count to set
  47366. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47367. */
  47368. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47369. }
  47370. }
  47371. declare module BABYLON {
  47372. /**
  47373. * Class used to define an additional view for the engine
  47374. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47375. */
  47376. export class EngineView {
  47377. /** Defines the canvas where to render the view */
  47378. target: HTMLCanvasElement;
  47379. /** Defines an optional camera used to render the view (will use active camera else) */
  47380. camera?: Camera;
  47381. }
  47382. interface Engine {
  47383. /**
  47384. * Gets or sets the HTML element to use for attaching events
  47385. */
  47386. inputElement: Nullable<HTMLElement>;
  47387. /**
  47388. * Gets the current engine view
  47389. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47390. */
  47391. activeView: Nullable<EngineView>;
  47392. /** Gets or sets the list of views */
  47393. views: EngineView[];
  47394. /**
  47395. * Register a new child canvas
  47396. * @param canvas defines the canvas to register
  47397. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47398. * @returns the associated view
  47399. */
  47400. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47401. /**
  47402. * Remove a registered child canvas
  47403. * @param canvas defines the canvas to remove
  47404. * @returns the current engine
  47405. */
  47406. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47407. }
  47408. }
  47409. declare module BABYLON {
  47410. /**
  47411. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47412. */
  47413. export interface CubeMapInfo {
  47414. /**
  47415. * The pixel array for the front face.
  47416. * This is stored in format, left to right, up to down format.
  47417. */
  47418. front: Nullable<ArrayBufferView>;
  47419. /**
  47420. * The pixel array for the back face.
  47421. * This is stored in format, left to right, up to down format.
  47422. */
  47423. back: Nullable<ArrayBufferView>;
  47424. /**
  47425. * The pixel array for the left face.
  47426. * This is stored in format, left to right, up to down format.
  47427. */
  47428. left: Nullable<ArrayBufferView>;
  47429. /**
  47430. * The pixel array for the right face.
  47431. * This is stored in format, left to right, up to down format.
  47432. */
  47433. right: Nullable<ArrayBufferView>;
  47434. /**
  47435. * The pixel array for the up face.
  47436. * This is stored in format, left to right, up to down format.
  47437. */
  47438. up: Nullable<ArrayBufferView>;
  47439. /**
  47440. * The pixel array for the down face.
  47441. * This is stored in format, left to right, up to down format.
  47442. */
  47443. down: Nullable<ArrayBufferView>;
  47444. /**
  47445. * The size of the cubemap stored.
  47446. *
  47447. * Each faces will be size * size pixels.
  47448. */
  47449. size: number;
  47450. /**
  47451. * The format of the texture.
  47452. *
  47453. * RGBA, RGB.
  47454. */
  47455. format: number;
  47456. /**
  47457. * The type of the texture data.
  47458. *
  47459. * UNSIGNED_INT, FLOAT.
  47460. */
  47461. type: number;
  47462. /**
  47463. * Specifies whether the texture is in gamma space.
  47464. */
  47465. gammaSpace: boolean;
  47466. }
  47467. /**
  47468. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47469. */
  47470. export class PanoramaToCubeMapTools {
  47471. private static FACE_FRONT;
  47472. private static FACE_BACK;
  47473. private static FACE_RIGHT;
  47474. private static FACE_LEFT;
  47475. private static FACE_DOWN;
  47476. private static FACE_UP;
  47477. /**
  47478. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47479. *
  47480. * @param float32Array The source data.
  47481. * @param inputWidth The width of the input panorama.
  47482. * @param inputHeight The height of the input panorama.
  47483. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47484. * @return The cubemap data
  47485. */
  47486. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47487. private static CreateCubemapTexture;
  47488. private static CalcProjectionSpherical;
  47489. }
  47490. }
  47491. declare module BABYLON {
  47492. /**
  47493. * Helper class dealing with the extraction of spherical polynomial dataArray
  47494. * from a cube map.
  47495. */
  47496. export class CubeMapToSphericalPolynomialTools {
  47497. private static FileFaces;
  47498. /**
  47499. * Converts a texture to the according Spherical Polynomial data.
  47500. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47501. *
  47502. * @param texture The texture to extract the information from.
  47503. * @return The Spherical Polynomial data.
  47504. */
  47505. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47506. /**
  47507. * Converts a cubemap to the according Spherical Polynomial data.
  47508. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47509. *
  47510. * @param cubeInfo The Cube map to extract the information from.
  47511. * @return The Spherical Polynomial data.
  47512. */
  47513. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47514. }
  47515. }
  47516. declare module BABYLON {
  47517. interface BaseTexture {
  47518. /**
  47519. * Get the polynomial representation of the texture data.
  47520. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47521. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47522. */
  47523. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47524. }
  47525. }
  47526. declare module BABYLON {
  47527. /** @hidden */
  47528. export var rgbdEncodePixelShader: {
  47529. name: string;
  47530. shader: string;
  47531. };
  47532. }
  47533. declare module BABYLON {
  47534. /** @hidden */
  47535. export var rgbdDecodePixelShader: {
  47536. name: string;
  47537. shader: string;
  47538. };
  47539. }
  47540. declare module BABYLON {
  47541. /**
  47542. * Raw texture data and descriptor sufficient for WebGL texture upload
  47543. */
  47544. export interface EnvironmentTextureInfo {
  47545. /**
  47546. * Version of the environment map
  47547. */
  47548. version: number;
  47549. /**
  47550. * Width of image
  47551. */
  47552. width: number;
  47553. /**
  47554. * Irradiance information stored in the file.
  47555. */
  47556. irradiance: any;
  47557. /**
  47558. * Specular information stored in the file.
  47559. */
  47560. specular: any;
  47561. }
  47562. /**
  47563. * Defines One Image in the file. It requires only the position in the file
  47564. * as well as the length.
  47565. */
  47566. interface BufferImageData {
  47567. /**
  47568. * Length of the image data.
  47569. */
  47570. length: number;
  47571. /**
  47572. * Position of the data from the null terminator delimiting the end of the JSON.
  47573. */
  47574. position: number;
  47575. }
  47576. /**
  47577. * Defines the specular data enclosed in the file.
  47578. * This corresponds to the version 1 of the data.
  47579. */
  47580. export interface EnvironmentTextureSpecularInfoV1 {
  47581. /**
  47582. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47583. */
  47584. specularDataPosition?: number;
  47585. /**
  47586. * This contains all the images data needed to reconstruct the cubemap.
  47587. */
  47588. mipmaps: Array<BufferImageData>;
  47589. /**
  47590. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47591. */
  47592. lodGenerationScale: number;
  47593. }
  47594. /**
  47595. * Sets of helpers addressing the serialization and deserialization of environment texture
  47596. * stored in a BabylonJS env file.
  47597. * Those files are usually stored as .env files.
  47598. */
  47599. export class EnvironmentTextureTools {
  47600. /**
  47601. * Magic number identifying the env file.
  47602. */
  47603. private static _MagicBytes;
  47604. /**
  47605. * Gets the environment info from an env file.
  47606. * @param data The array buffer containing the .env bytes.
  47607. * @returns the environment file info (the json header) if successfully parsed.
  47608. */
  47609. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47610. /**
  47611. * Creates an environment texture from a loaded cube texture.
  47612. * @param texture defines the cube texture to convert in env file
  47613. * @return a promise containing the environment data if succesfull.
  47614. */
  47615. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47616. /**
  47617. * Creates a JSON representation of the spherical data.
  47618. * @param texture defines the texture containing the polynomials
  47619. * @return the JSON representation of the spherical info
  47620. */
  47621. private static _CreateEnvTextureIrradiance;
  47622. /**
  47623. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47624. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47625. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47626. * @return the views described by info providing access to the underlying buffer
  47627. */
  47628. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47629. /**
  47630. * Uploads the texture info contained in the env file to the GPU.
  47631. * @param texture defines the internal texture to upload to
  47632. * @param arrayBuffer defines the buffer cotaining the data to load
  47633. * @param info defines the texture info retrieved through the GetEnvInfo method
  47634. * @returns a promise
  47635. */
  47636. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47637. private static _OnImageReadyAsync;
  47638. /**
  47639. * Uploads the levels of image data to the GPU.
  47640. * @param texture defines the internal texture to upload to
  47641. * @param imageData defines the array buffer views of image data [mipmap][face]
  47642. * @returns a promise
  47643. */
  47644. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47645. /**
  47646. * Uploads spherical polynomials information to the texture.
  47647. * @param texture defines the texture we are trying to upload the information to
  47648. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47649. */
  47650. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47651. /** @hidden */
  47652. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47653. }
  47654. }
  47655. declare module BABYLON {
  47656. /**
  47657. * Contains position and normal vectors for a vertex
  47658. */
  47659. export class PositionNormalVertex {
  47660. /** the position of the vertex (defaut: 0,0,0) */
  47661. position: Vector3;
  47662. /** the normal of the vertex (defaut: 0,1,0) */
  47663. normal: Vector3;
  47664. /**
  47665. * Creates a PositionNormalVertex
  47666. * @param position the position of the vertex (defaut: 0,0,0)
  47667. * @param normal the normal of the vertex (defaut: 0,1,0)
  47668. */
  47669. constructor(
  47670. /** the position of the vertex (defaut: 0,0,0) */
  47671. position?: Vector3,
  47672. /** the normal of the vertex (defaut: 0,1,0) */
  47673. normal?: Vector3);
  47674. /**
  47675. * Clones the PositionNormalVertex
  47676. * @returns the cloned PositionNormalVertex
  47677. */
  47678. clone(): PositionNormalVertex;
  47679. }
  47680. /**
  47681. * Contains position, normal and uv vectors for a vertex
  47682. */
  47683. export class PositionNormalTextureVertex {
  47684. /** the position of the vertex (defaut: 0,0,0) */
  47685. position: Vector3;
  47686. /** the normal of the vertex (defaut: 0,1,0) */
  47687. normal: Vector3;
  47688. /** the uv of the vertex (default: 0,0) */
  47689. uv: Vector2;
  47690. /**
  47691. * Creates a PositionNormalTextureVertex
  47692. * @param position the position of the vertex (defaut: 0,0,0)
  47693. * @param normal the normal of the vertex (defaut: 0,1,0)
  47694. * @param uv the uv of the vertex (default: 0,0)
  47695. */
  47696. constructor(
  47697. /** the position of the vertex (defaut: 0,0,0) */
  47698. position?: Vector3,
  47699. /** the normal of the vertex (defaut: 0,1,0) */
  47700. normal?: Vector3,
  47701. /** the uv of the vertex (default: 0,0) */
  47702. uv?: Vector2);
  47703. /**
  47704. * Clones the PositionNormalTextureVertex
  47705. * @returns the cloned PositionNormalTextureVertex
  47706. */
  47707. clone(): PositionNormalTextureVertex;
  47708. }
  47709. }
  47710. declare module BABYLON {
  47711. /** @hidden */
  47712. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47713. private _genericAttributeLocation;
  47714. private _varyingLocationCount;
  47715. private _varyingLocationMap;
  47716. private _replacements;
  47717. private _textureCount;
  47718. private _uniforms;
  47719. lineProcessor(line: string): string;
  47720. attributeProcessor(attribute: string): string;
  47721. varyingProcessor(varying: string, isFragment: boolean): string;
  47722. uniformProcessor(uniform: string): string;
  47723. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47724. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47725. }
  47726. }
  47727. declare module BABYLON {
  47728. /**
  47729. * Container for accessors for natively-stored mesh data buffers.
  47730. */
  47731. class NativeDataBuffer extends DataBuffer {
  47732. /**
  47733. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47734. */
  47735. nativeIndexBuffer?: any;
  47736. /**
  47737. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47738. */
  47739. nativeVertexBuffer?: any;
  47740. }
  47741. /** @hidden */
  47742. class NativeTexture extends InternalTexture {
  47743. getInternalTexture(): InternalTexture;
  47744. getViewCount(): number;
  47745. }
  47746. /** @hidden */
  47747. export class NativeEngine extends Engine {
  47748. private readonly _native;
  47749. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47750. private readonly INVALID_HANDLE;
  47751. getHardwareScalingLevel(): number;
  47752. constructor();
  47753. /**
  47754. * Can be used to override the current requestAnimationFrame requester.
  47755. * @hidden
  47756. */
  47757. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47758. /**
  47759. * Override default engine behavior.
  47760. * @param color
  47761. * @param backBuffer
  47762. * @param depth
  47763. * @param stencil
  47764. */
  47765. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47766. /**
  47767. * Gets host document
  47768. * @returns the host document object
  47769. */
  47770. getHostDocument(): Nullable<Document>;
  47771. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47772. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47773. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47774. recordVertexArrayObject(vertexBuffers: {
  47775. [key: string]: VertexBuffer;
  47776. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47777. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47778. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47779. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47780. /**
  47781. * Draw a list of indexed primitives
  47782. * @param fillMode defines the primitive to use
  47783. * @param indexStart defines the starting index
  47784. * @param indexCount defines the number of index to draw
  47785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47786. */
  47787. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47788. /**
  47789. * Draw a list of unindexed primitives
  47790. * @param fillMode defines the primitive to use
  47791. * @param verticesStart defines the index of first vertex to draw
  47792. * @param verticesCount defines the count of vertices to draw
  47793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47794. */
  47795. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47796. createPipelineContext(): IPipelineContext;
  47797. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47798. /** @hidden */
  47799. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47800. /** @hidden */
  47801. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47802. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47803. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47804. protected _setProgram(program: WebGLProgram): void;
  47805. _releaseEffect(effect: Effect): void;
  47806. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47807. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47808. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47809. bindSamplers(effect: Effect): void;
  47810. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47811. getRenderWidth(useScreen?: boolean): number;
  47812. getRenderHeight(useScreen?: boolean): number;
  47813. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47814. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47815. /**
  47816. * Set the z offset to apply to current rendering
  47817. * @param value defines the offset to apply
  47818. */
  47819. setZOffset(value: number): void;
  47820. /**
  47821. * Gets the current value of the zOffset
  47822. * @returns the current zOffset state
  47823. */
  47824. getZOffset(): number;
  47825. /**
  47826. * Enable or disable depth buffering
  47827. * @param enable defines the state to set
  47828. */
  47829. setDepthBuffer(enable: boolean): void;
  47830. /**
  47831. * Gets a boolean indicating if depth writing is enabled
  47832. * @returns the current depth writing state
  47833. */
  47834. getDepthWrite(): boolean;
  47835. /**
  47836. * Enable or disable depth writing
  47837. * @param enable defines the state to set
  47838. */
  47839. setDepthWrite(enable: boolean): void;
  47840. /**
  47841. * Enable or disable color writing
  47842. * @param enable defines the state to set
  47843. */
  47844. setColorWrite(enable: boolean): void;
  47845. /**
  47846. * Gets a boolean indicating if color writing is enabled
  47847. * @returns the current color writing state
  47848. */
  47849. getColorWrite(): boolean;
  47850. /**
  47851. * Sets alpha constants used by some alpha blending modes
  47852. * @param r defines the red component
  47853. * @param g defines the green component
  47854. * @param b defines the blue component
  47855. * @param a defines the alpha component
  47856. */
  47857. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47858. /**
  47859. * Sets the current alpha mode
  47860. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47861. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47862. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47863. */
  47864. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47865. /**
  47866. * Gets the current alpha mode
  47867. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47868. * @returns the current alpha mode
  47869. */
  47870. getAlphaMode(): number;
  47871. setInt(uniform: WebGLUniformLocation, int: number): void;
  47872. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47873. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47874. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47875. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47876. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47877. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47878. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47879. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47880. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47881. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47882. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47883. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47884. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47885. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47886. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47887. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47888. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47889. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47890. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47891. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47892. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47893. wipeCaches(bruteForce?: boolean): void;
  47894. _createTexture(): WebGLTexture;
  47895. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47896. /**
  47897. * Usually called from BABYLON.Texture.ts.
  47898. * Passed information to create a WebGLTexture
  47899. * @param urlArg defines a value which contains one of the following:
  47900. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47901. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47902. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47903. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47904. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47905. * @param scene needed for loading to the correct scene
  47906. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47907. * @param onLoad optional callback to be called upon successful completion
  47908. * @param onError optional callback to be called upon failure
  47909. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47910. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47911. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47912. * @param forcedExtension defines the extension to use to pick the right loader
  47913. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47914. */
  47915. 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;
  47916. /**
  47917. * Creates a cube texture
  47918. * @param rootUrl defines the url where the files to load is located
  47919. * @param scene defines the current scene
  47920. * @param files defines the list of files to load (1 per face)
  47921. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47922. * @param onLoad defines an optional callback raised when the texture is loaded
  47923. * @param onError defines an optional callback raised if there is an issue to load the texture
  47924. * @param format defines the format of the data
  47925. * @param forcedExtension defines the extension to use to pick the right loader
  47926. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47927. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47928. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47929. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47930. * @returns the cube texture as an InternalTexture
  47931. */
  47932. 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;
  47933. private _getSamplingFilter;
  47934. private static _GetNativeTextureFormat;
  47935. createRenderTargetTexture(size: number | {
  47936. width: number;
  47937. height: number;
  47938. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47939. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47940. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47941. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47942. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47943. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47944. /**
  47945. * Updates a dynamic vertex buffer.
  47946. * @param vertexBuffer the vertex buffer to update
  47947. * @param data the data used to update the vertex buffer
  47948. * @param byteOffset the byte offset of the data (optional)
  47949. * @param byteLength the byte length of the data (optional)
  47950. */
  47951. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47952. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47953. private _updateAnisotropicLevel;
  47954. private _getAddressMode;
  47955. /** @hidden */
  47956. _bindTexture(channel: number, texture: InternalTexture): void;
  47957. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47958. releaseEffects(): void;
  47959. /** @hidden */
  47960. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47961. /** @hidden */
  47962. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47963. /** @hidden */
  47964. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47965. /** @hidden */
  47966. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47967. }
  47968. }
  47969. declare module BABYLON {
  47970. /**
  47971. * Gather the list of clipboard event types as constants.
  47972. */
  47973. export class ClipboardEventTypes {
  47974. /**
  47975. * The clipboard event is fired when a copy command is active (pressed).
  47976. */
  47977. static readonly COPY: number;
  47978. /**
  47979. * The clipboard event is fired when a cut command is active (pressed).
  47980. */
  47981. static readonly CUT: number;
  47982. /**
  47983. * The clipboard event is fired when a paste command is active (pressed).
  47984. */
  47985. static readonly PASTE: number;
  47986. }
  47987. /**
  47988. * This class is used to store clipboard related info for the onClipboardObservable event.
  47989. */
  47990. export class ClipboardInfo {
  47991. /**
  47992. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47993. */
  47994. type: number;
  47995. /**
  47996. * Defines the related dom event
  47997. */
  47998. event: ClipboardEvent;
  47999. /**
  48000. *Creates an instance of ClipboardInfo.
  48001. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48002. * @param event Defines the related dom event
  48003. */
  48004. constructor(
  48005. /**
  48006. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48007. */
  48008. type: number,
  48009. /**
  48010. * Defines the related dom event
  48011. */
  48012. event: ClipboardEvent);
  48013. /**
  48014. * Get the clipboard event's type from the keycode.
  48015. * @param keyCode Defines the keyCode for the current keyboard event.
  48016. * @return {number}
  48017. */
  48018. static GetTypeFromCharacter(keyCode: number): number;
  48019. }
  48020. }
  48021. declare module BABYLON {
  48022. /**
  48023. * Google Daydream controller
  48024. */
  48025. export class DaydreamController extends WebVRController {
  48026. /**
  48027. * Base Url for the controller model.
  48028. */
  48029. static MODEL_BASE_URL: string;
  48030. /**
  48031. * File name for the controller model.
  48032. */
  48033. static MODEL_FILENAME: string;
  48034. /**
  48035. * Gamepad Id prefix used to identify Daydream Controller.
  48036. */
  48037. static readonly GAMEPAD_ID_PREFIX: string;
  48038. /**
  48039. * Creates a new DaydreamController from a gamepad
  48040. * @param vrGamepad the gamepad that the controller should be created from
  48041. */
  48042. constructor(vrGamepad: any);
  48043. /**
  48044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48045. * @param scene scene in which to add meshes
  48046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48047. */
  48048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48049. /**
  48050. * Called once for each button that changed state since the last frame
  48051. * @param buttonIdx Which button index changed
  48052. * @param state New state of the button
  48053. * @param changes Which properties on the state changed since last frame
  48054. */
  48055. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48056. }
  48057. }
  48058. declare module BABYLON {
  48059. /**
  48060. * Gear VR Controller
  48061. */
  48062. export class GearVRController extends WebVRController {
  48063. /**
  48064. * Base Url for the controller model.
  48065. */
  48066. static MODEL_BASE_URL: string;
  48067. /**
  48068. * File name for the controller model.
  48069. */
  48070. static MODEL_FILENAME: string;
  48071. /**
  48072. * Gamepad Id prefix used to identify this controller.
  48073. */
  48074. static readonly GAMEPAD_ID_PREFIX: string;
  48075. private readonly _buttonIndexToObservableNameMap;
  48076. /**
  48077. * Creates a new GearVRController from a gamepad
  48078. * @param vrGamepad the gamepad that the controller should be created from
  48079. */
  48080. constructor(vrGamepad: any);
  48081. /**
  48082. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48083. * @param scene scene in which to add meshes
  48084. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48085. */
  48086. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48087. /**
  48088. * Called once for each button that changed state since the last frame
  48089. * @param buttonIdx Which button index changed
  48090. * @param state New state of the button
  48091. * @param changes Which properties on the state changed since last frame
  48092. */
  48093. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48094. }
  48095. }
  48096. declare module BABYLON {
  48097. /**
  48098. * Generic Controller
  48099. */
  48100. export class GenericController extends WebVRController {
  48101. /**
  48102. * Base Url for the controller model.
  48103. */
  48104. static readonly MODEL_BASE_URL: string;
  48105. /**
  48106. * File name for the controller model.
  48107. */
  48108. static readonly MODEL_FILENAME: string;
  48109. /**
  48110. * Creates a new GenericController from a gamepad
  48111. * @param vrGamepad the gamepad that the controller should be created from
  48112. */
  48113. constructor(vrGamepad: any);
  48114. /**
  48115. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48116. * @param scene scene in which to add meshes
  48117. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48118. */
  48119. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48120. /**
  48121. * Called once for each button that changed state since the last frame
  48122. * @param buttonIdx Which button index changed
  48123. * @param state New state of the button
  48124. * @param changes Which properties on the state changed since last frame
  48125. */
  48126. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48127. }
  48128. }
  48129. declare module BABYLON {
  48130. /**
  48131. * Oculus Touch Controller
  48132. */
  48133. export class OculusTouchController extends WebVRController {
  48134. /**
  48135. * Base Url for the controller model.
  48136. */
  48137. static MODEL_BASE_URL: string;
  48138. /**
  48139. * File name for the left controller model.
  48140. */
  48141. static MODEL_LEFT_FILENAME: string;
  48142. /**
  48143. * File name for the right controller model.
  48144. */
  48145. static MODEL_RIGHT_FILENAME: string;
  48146. /**
  48147. * Base Url for the Quest controller model.
  48148. */
  48149. static QUEST_MODEL_BASE_URL: string;
  48150. /**
  48151. * @hidden
  48152. * If the controllers are running on a device that needs the updated Quest controller models
  48153. */
  48154. static _IsQuest: boolean;
  48155. /**
  48156. * Fired when the secondary trigger on this controller is modified
  48157. */
  48158. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48159. /**
  48160. * Fired when the thumb rest on this controller is modified
  48161. */
  48162. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48163. /**
  48164. * Creates a new OculusTouchController from a gamepad
  48165. * @param vrGamepad the gamepad that the controller should be created from
  48166. */
  48167. constructor(vrGamepad: any);
  48168. /**
  48169. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48170. * @param scene scene in which to add meshes
  48171. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48172. */
  48173. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48174. /**
  48175. * Fired when the A button on this controller is modified
  48176. */
  48177. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48178. /**
  48179. * Fired when the B button on this controller is modified
  48180. */
  48181. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48182. /**
  48183. * Fired when the X button on this controller is modified
  48184. */
  48185. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48186. /**
  48187. * Fired when the Y button on this controller is modified
  48188. */
  48189. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48190. /**
  48191. * Called once for each button that changed state since the last frame
  48192. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48193. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48194. * 2) secondary trigger (same)
  48195. * 3) A (right) X (left), touch, pressed = value
  48196. * 4) B / Y
  48197. * 5) thumb rest
  48198. * @param buttonIdx Which button index changed
  48199. * @param state New state of the button
  48200. * @param changes Which properties on the state changed since last frame
  48201. */
  48202. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48203. }
  48204. }
  48205. declare module BABYLON {
  48206. /**
  48207. * Vive Controller
  48208. */
  48209. export class ViveController extends WebVRController {
  48210. /**
  48211. * Base Url for the controller model.
  48212. */
  48213. static MODEL_BASE_URL: string;
  48214. /**
  48215. * File name for the controller model.
  48216. */
  48217. static MODEL_FILENAME: string;
  48218. /**
  48219. * Creates a new ViveController from a gamepad
  48220. * @param vrGamepad the gamepad that the controller should be created from
  48221. */
  48222. constructor(vrGamepad: any);
  48223. /**
  48224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48225. * @param scene scene in which to add meshes
  48226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48227. */
  48228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48229. /**
  48230. * Fired when the left button on this controller is modified
  48231. */
  48232. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48233. /**
  48234. * Fired when the right button on this controller is modified
  48235. */
  48236. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48237. /**
  48238. * Fired when the menu button on this controller is modified
  48239. */
  48240. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48241. /**
  48242. * Called once for each button that changed state since the last frame
  48243. * Vive mapping:
  48244. * 0: touchpad
  48245. * 1: trigger
  48246. * 2: left AND right buttons
  48247. * 3: menu button
  48248. * @param buttonIdx Which button index changed
  48249. * @param state New state of the button
  48250. * @param changes Which properties on the state changed since last frame
  48251. */
  48252. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48253. }
  48254. }
  48255. declare module BABYLON {
  48256. /**
  48257. * Defines the WindowsMotionController object that the state of the windows motion controller
  48258. */
  48259. export class WindowsMotionController extends WebVRController {
  48260. /**
  48261. * The base url used to load the left and right controller models
  48262. */
  48263. static MODEL_BASE_URL: string;
  48264. /**
  48265. * The name of the left controller model file
  48266. */
  48267. static MODEL_LEFT_FILENAME: string;
  48268. /**
  48269. * The name of the right controller model file
  48270. */
  48271. static MODEL_RIGHT_FILENAME: string;
  48272. /**
  48273. * The controller name prefix for this controller type
  48274. */
  48275. static readonly GAMEPAD_ID_PREFIX: string;
  48276. /**
  48277. * The controller id pattern for this controller type
  48278. */
  48279. private static readonly GAMEPAD_ID_PATTERN;
  48280. private _loadedMeshInfo;
  48281. protected readonly _mapping: {
  48282. buttons: string[];
  48283. buttonMeshNames: {
  48284. 'trigger': string;
  48285. 'menu': string;
  48286. 'grip': string;
  48287. 'thumbstick': string;
  48288. 'trackpad': string;
  48289. };
  48290. buttonObservableNames: {
  48291. 'trigger': string;
  48292. 'menu': string;
  48293. 'grip': string;
  48294. 'thumbstick': string;
  48295. 'trackpad': string;
  48296. };
  48297. axisMeshNames: string[];
  48298. pointingPoseMeshName: string;
  48299. };
  48300. /**
  48301. * Fired when the trackpad on this controller is clicked
  48302. */
  48303. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48304. /**
  48305. * Fired when the trackpad on this controller is modified
  48306. */
  48307. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48308. /**
  48309. * The current x and y values of this controller's trackpad
  48310. */
  48311. trackpad: StickValues;
  48312. /**
  48313. * Creates a new WindowsMotionController from a gamepad
  48314. * @param vrGamepad the gamepad that the controller should be created from
  48315. */
  48316. constructor(vrGamepad: any);
  48317. /**
  48318. * Fired when the trigger on this controller is modified
  48319. */
  48320. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48321. /**
  48322. * Fired when the menu button on this controller is modified
  48323. */
  48324. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48325. /**
  48326. * Fired when the grip button on this controller is modified
  48327. */
  48328. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48329. /**
  48330. * Fired when the thumbstick button on this controller is modified
  48331. */
  48332. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48333. /**
  48334. * Fired when the touchpad button on this controller is modified
  48335. */
  48336. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48337. /**
  48338. * Fired when the touchpad values on this controller are modified
  48339. */
  48340. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48341. protected _updateTrackpad(): void;
  48342. /**
  48343. * Called once per frame by the engine.
  48344. */
  48345. update(): void;
  48346. /**
  48347. * Called once for each button that changed state since the last frame
  48348. * @param buttonIdx Which button index changed
  48349. * @param state New state of the button
  48350. * @param changes Which properties on the state changed since last frame
  48351. */
  48352. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48353. /**
  48354. * Moves the buttons on the controller mesh based on their current state
  48355. * @param buttonName the name of the button to move
  48356. * @param buttonValue the value of the button which determines the buttons new position
  48357. */
  48358. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48359. /**
  48360. * Moves the axis on the controller mesh based on its current state
  48361. * @param axis the index of the axis
  48362. * @param axisValue the value of the axis which determines the meshes new position
  48363. * @hidden
  48364. */
  48365. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48366. /**
  48367. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48368. * @param scene scene in which to add meshes
  48369. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48370. */
  48371. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48372. /**
  48373. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48374. * can be transformed by button presses and axes values, based on this._mapping.
  48375. *
  48376. * @param scene scene in which the meshes exist
  48377. * @param meshes list of meshes that make up the controller model to process
  48378. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48379. */
  48380. private processModel;
  48381. private createMeshInfo;
  48382. /**
  48383. * Gets the ray of the controller in the direction the controller is pointing
  48384. * @param length the length the resulting ray should be
  48385. * @returns a ray in the direction the controller is pointing
  48386. */
  48387. getForwardRay(length?: number): Ray;
  48388. /**
  48389. * Disposes of the controller
  48390. */
  48391. dispose(): void;
  48392. }
  48393. /**
  48394. * This class represents a new windows motion controller in XR.
  48395. */
  48396. export class XRWindowsMotionController extends WindowsMotionController {
  48397. /**
  48398. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48399. */
  48400. protected readonly _mapping: {
  48401. buttons: string[];
  48402. buttonMeshNames: {
  48403. 'trigger': string;
  48404. 'menu': string;
  48405. 'grip': string;
  48406. 'thumbstick': string;
  48407. 'trackpad': string;
  48408. };
  48409. buttonObservableNames: {
  48410. 'trigger': string;
  48411. 'menu': string;
  48412. 'grip': string;
  48413. 'thumbstick': string;
  48414. 'trackpad': string;
  48415. };
  48416. axisMeshNames: string[];
  48417. pointingPoseMeshName: string;
  48418. };
  48419. /**
  48420. * Construct a new XR-Based windows motion controller
  48421. *
  48422. * @param gamepadInfo the gamepad object from the browser
  48423. */
  48424. constructor(gamepadInfo: any);
  48425. /**
  48426. * holds the thumbstick values (X,Y)
  48427. */
  48428. thumbstickValues: StickValues;
  48429. /**
  48430. * Fired when the thumbstick on this controller is clicked
  48431. */
  48432. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48433. /**
  48434. * Fired when the thumbstick on this controller is modified
  48435. */
  48436. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48437. /**
  48438. * Fired when the touchpad button on this controller is modified
  48439. */
  48440. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48441. /**
  48442. * Fired when the touchpad values on this controller are modified
  48443. */
  48444. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48445. /**
  48446. * Fired when the thumbstick button on this controller is modified
  48447. * here to prevent breaking changes
  48448. */
  48449. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48450. /**
  48451. * updating the thumbstick(!) and not the trackpad.
  48452. * This is named this way due to the difference between WebVR and XR and to avoid
  48453. * changing the parent class.
  48454. */
  48455. protected _updateTrackpad(): void;
  48456. /**
  48457. * Disposes the class with joy
  48458. */
  48459. dispose(): void;
  48460. }
  48461. }
  48462. declare module BABYLON {
  48463. /**
  48464. * Class containing static functions to help procedurally build meshes
  48465. */
  48466. export class PolyhedronBuilder {
  48467. /**
  48468. * Creates a polyhedron mesh
  48469. * * 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
  48470. * * The parameter `size` (positive float, default 1) sets the polygon size
  48471. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48472. * * 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`
  48473. * * 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
  48474. * * 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)`)
  48475. * * 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
  48476. * * 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
  48477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48478. * * 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
  48479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48480. * @param name defines the name of the mesh
  48481. * @param options defines the options used to create the mesh
  48482. * @param scene defines the hosting scene
  48483. * @returns the polyhedron mesh
  48484. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48485. */
  48486. static CreatePolyhedron(name: string, options: {
  48487. type?: number;
  48488. size?: number;
  48489. sizeX?: number;
  48490. sizeY?: number;
  48491. sizeZ?: number;
  48492. custom?: any;
  48493. faceUV?: Vector4[];
  48494. faceColors?: Color4[];
  48495. flat?: boolean;
  48496. updatable?: boolean;
  48497. sideOrientation?: number;
  48498. frontUVs?: Vector4;
  48499. backUVs?: Vector4;
  48500. }, scene?: Nullable<Scene>): Mesh;
  48501. }
  48502. }
  48503. declare module BABYLON {
  48504. /**
  48505. * Gizmo that enables scaling a mesh along 3 axis
  48506. */
  48507. export class ScaleGizmo extends Gizmo {
  48508. /**
  48509. * Internal gizmo used for interactions on the x axis
  48510. */
  48511. xGizmo: AxisScaleGizmo;
  48512. /**
  48513. * Internal gizmo used for interactions on the y axis
  48514. */
  48515. yGizmo: AxisScaleGizmo;
  48516. /**
  48517. * Internal gizmo used for interactions on the z axis
  48518. */
  48519. zGizmo: AxisScaleGizmo;
  48520. /**
  48521. * Internal gizmo used to scale all axis equally
  48522. */
  48523. uniformScaleGizmo: AxisScaleGizmo;
  48524. private _meshAttached;
  48525. private _updateGizmoRotationToMatchAttachedMesh;
  48526. private _snapDistance;
  48527. private _scaleRatio;
  48528. private _uniformScalingMesh;
  48529. private _octahedron;
  48530. private _sensitivity;
  48531. /** Fires an event when any of it's sub gizmos are dragged */
  48532. onDragStartObservable: Observable<unknown>;
  48533. /** Fires an event when any of it's sub gizmos are released from dragging */
  48534. onDragEndObservable: Observable<unknown>;
  48535. get attachedMesh(): Nullable<AbstractMesh>;
  48536. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48537. /**
  48538. * Creates a ScaleGizmo
  48539. * @param gizmoLayer The utility layer the gizmo will be added to
  48540. */
  48541. constructor(gizmoLayer?: UtilityLayerRenderer);
  48542. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48543. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48544. /**
  48545. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48546. */
  48547. set snapDistance(value: number);
  48548. get snapDistance(): number;
  48549. /**
  48550. * Ratio for the scale of the gizmo (Default: 1)
  48551. */
  48552. set scaleRatio(value: number);
  48553. get scaleRatio(): number;
  48554. /**
  48555. * Sensitivity factor for dragging (Default: 1)
  48556. */
  48557. set sensitivity(value: number);
  48558. get sensitivity(): number;
  48559. /**
  48560. * Disposes of the gizmo
  48561. */
  48562. dispose(): void;
  48563. }
  48564. }
  48565. declare module BABYLON {
  48566. /**
  48567. * Single axis scale gizmo
  48568. */
  48569. export class AxisScaleGizmo extends Gizmo {
  48570. /**
  48571. * Drag behavior responsible for the gizmos dragging interactions
  48572. */
  48573. dragBehavior: PointerDragBehavior;
  48574. private _pointerObserver;
  48575. /**
  48576. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48577. */
  48578. snapDistance: number;
  48579. /**
  48580. * Event that fires each time the gizmo snaps to a new location.
  48581. * * snapDistance is the the change in distance
  48582. */
  48583. onSnapObservable: Observable<{
  48584. snapDistance: number;
  48585. }>;
  48586. /**
  48587. * If the scaling operation should be done on all axis (default: false)
  48588. */
  48589. uniformScaling: boolean;
  48590. /**
  48591. * Custom sensitivity value for the drag strength
  48592. */
  48593. sensitivity: number;
  48594. private _isEnabled;
  48595. private _parent;
  48596. private _arrow;
  48597. private _coloredMaterial;
  48598. private _hoverMaterial;
  48599. /**
  48600. * Creates an AxisScaleGizmo
  48601. * @param gizmoLayer The utility layer the gizmo will be added to
  48602. * @param dragAxis The axis which the gizmo will be able to scale on
  48603. * @param color The color of the gizmo
  48604. */
  48605. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48606. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48607. /**
  48608. * If the gizmo is enabled
  48609. */
  48610. set isEnabled(value: boolean);
  48611. get isEnabled(): boolean;
  48612. /**
  48613. * Disposes of the gizmo
  48614. */
  48615. dispose(): void;
  48616. /**
  48617. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48618. * @param mesh The mesh to replace the default mesh of the gizmo
  48619. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48620. */
  48621. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48622. }
  48623. }
  48624. declare module BABYLON {
  48625. /**
  48626. * Bounding box gizmo
  48627. */
  48628. export class BoundingBoxGizmo extends Gizmo {
  48629. private _lineBoundingBox;
  48630. private _rotateSpheresParent;
  48631. private _scaleBoxesParent;
  48632. private _boundingDimensions;
  48633. private _renderObserver;
  48634. private _pointerObserver;
  48635. private _scaleDragSpeed;
  48636. private _tmpQuaternion;
  48637. private _tmpVector;
  48638. private _tmpRotationMatrix;
  48639. /**
  48640. * 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)
  48641. */
  48642. ignoreChildren: boolean;
  48643. /**
  48644. * 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)
  48645. */
  48646. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48647. /**
  48648. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48649. */
  48650. rotationSphereSize: number;
  48651. /**
  48652. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48653. */
  48654. scaleBoxSize: number;
  48655. /**
  48656. * 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)
  48657. */
  48658. fixedDragMeshScreenSize: boolean;
  48659. /**
  48660. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48661. */
  48662. fixedDragMeshScreenSizeDistanceFactor: number;
  48663. /**
  48664. * Fired when a rotation sphere or scale box is dragged
  48665. */
  48666. onDragStartObservable: Observable<{}>;
  48667. /**
  48668. * Fired when a scale box is dragged
  48669. */
  48670. onScaleBoxDragObservable: Observable<{}>;
  48671. /**
  48672. * Fired when a scale box drag is ended
  48673. */
  48674. onScaleBoxDragEndObservable: Observable<{}>;
  48675. /**
  48676. * Fired when a rotation sphere is dragged
  48677. */
  48678. onRotationSphereDragObservable: Observable<{}>;
  48679. /**
  48680. * Fired when a rotation sphere drag is ended
  48681. */
  48682. onRotationSphereDragEndObservable: Observable<{}>;
  48683. /**
  48684. * 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)
  48685. */
  48686. scalePivot: Nullable<Vector3>;
  48687. /**
  48688. * Mesh used as a pivot to rotate the attached mesh
  48689. */
  48690. private _anchorMesh;
  48691. private _existingMeshScale;
  48692. private _dragMesh;
  48693. private pointerDragBehavior;
  48694. private coloredMaterial;
  48695. private hoverColoredMaterial;
  48696. /**
  48697. * Sets the color of the bounding box gizmo
  48698. * @param color the color to set
  48699. */
  48700. setColor(color: Color3): void;
  48701. /**
  48702. * Creates an BoundingBoxGizmo
  48703. * @param gizmoLayer The utility layer the gizmo will be added to
  48704. * @param color The color of the gizmo
  48705. */
  48706. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48707. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48708. private _selectNode;
  48709. /**
  48710. * Updates the bounding box information for the Gizmo
  48711. */
  48712. updateBoundingBox(): void;
  48713. private _updateRotationSpheres;
  48714. private _updateScaleBoxes;
  48715. /**
  48716. * Enables rotation on the specified axis and disables rotation on the others
  48717. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48718. */
  48719. setEnabledRotationAxis(axis: string): void;
  48720. /**
  48721. * Enables/disables scaling
  48722. * @param enable if scaling should be enabled
  48723. */
  48724. setEnabledScaling(enable: boolean): void;
  48725. private _updateDummy;
  48726. /**
  48727. * Enables a pointer drag behavior on the bounding box of the gizmo
  48728. */
  48729. enableDragBehavior(): void;
  48730. /**
  48731. * Disposes of the gizmo
  48732. */
  48733. dispose(): void;
  48734. /**
  48735. * 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)
  48736. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48737. * @returns the bounding box mesh with the passed in mesh as a child
  48738. */
  48739. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48740. /**
  48741. * CustomMeshes are not supported by this gizmo
  48742. * @param mesh The mesh to replace the default mesh of the gizmo
  48743. */
  48744. setCustomMesh(mesh: Mesh): void;
  48745. }
  48746. }
  48747. declare module BABYLON {
  48748. /**
  48749. * Single plane rotation gizmo
  48750. */
  48751. export class PlaneRotationGizmo extends Gizmo {
  48752. /**
  48753. * Drag behavior responsible for the gizmos dragging interactions
  48754. */
  48755. dragBehavior: PointerDragBehavior;
  48756. private _pointerObserver;
  48757. /**
  48758. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48759. */
  48760. snapDistance: number;
  48761. /**
  48762. * Event that fires each time the gizmo snaps to a new location.
  48763. * * snapDistance is the the change in distance
  48764. */
  48765. onSnapObservable: Observable<{
  48766. snapDistance: number;
  48767. }>;
  48768. private _isEnabled;
  48769. private _parent;
  48770. /**
  48771. * Creates a PlaneRotationGizmo
  48772. * @param gizmoLayer The utility layer the gizmo will be added to
  48773. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48774. * @param color The color of the gizmo
  48775. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48776. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48777. */
  48778. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48779. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48780. /**
  48781. * If the gizmo is enabled
  48782. */
  48783. set isEnabled(value: boolean);
  48784. get isEnabled(): boolean;
  48785. /**
  48786. * Disposes of the gizmo
  48787. */
  48788. dispose(): void;
  48789. }
  48790. }
  48791. declare module BABYLON {
  48792. /**
  48793. * Gizmo that enables rotating a mesh along 3 axis
  48794. */
  48795. export class RotationGizmo extends Gizmo {
  48796. /**
  48797. * Internal gizmo used for interactions on the x axis
  48798. */
  48799. xGizmo: PlaneRotationGizmo;
  48800. /**
  48801. * Internal gizmo used for interactions on the y axis
  48802. */
  48803. yGizmo: PlaneRotationGizmo;
  48804. /**
  48805. * Internal gizmo used for interactions on the z axis
  48806. */
  48807. zGizmo: PlaneRotationGizmo;
  48808. /** Fires an event when any of it's sub gizmos are dragged */
  48809. onDragStartObservable: Observable<unknown>;
  48810. /** Fires an event when any of it's sub gizmos are released from dragging */
  48811. onDragEndObservable: Observable<unknown>;
  48812. private _meshAttached;
  48813. get attachedMesh(): Nullable<AbstractMesh>;
  48814. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48815. /**
  48816. * Creates a RotationGizmo
  48817. * @param gizmoLayer The utility layer the gizmo will be added to
  48818. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48819. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48820. */
  48821. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48822. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48823. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48824. /**
  48825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48826. */
  48827. set snapDistance(value: number);
  48828. get snapDistance(): number;
  48829. /**
  48830. * Ratio for the scale of the gizmo (Default: 1)
  48831. */
  48832. set scaleRatio(value: number);
  48833. get scaleRatio(): number;
  48834. /**
  48835. * Disposes of the gizmo
  48836. */
  48837. dispose(): void;
  48838. /**
  48839. * CustomMeshes are not supported by this gizmo
  48840. * @param mesh The mesh to replace the default mesh of the gizmo
  48841. */
  48842. setCustomMesh(mesh: Mesh): void;
  48843. }
  48844. }
  48845. declare module BABYLON {
  48846. /**
  48847. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48848. */
  48849. export class GizmoManager implements IDisposable {
  48850. private scene;
  48851. /**
  48852. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48853. */
  48854. gizmos: {
  48855. positionGizmo: Nullable<PositionGizmo>;
  48856. rotationGizmo: Nullable<RotationGizmo>;
  48857. scaleGizmo: Nullable<ScaleGizmo>;
  48858. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48859. };
  48860. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48861. clearGizmoOnEmptyPointerEvent: boolean;
  48862. /** Fires an event when the manager is attached to a mesh */
  48863. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48864. private _gizmosEnabled;
  48865. private _pointerObserver;
  48866. private _attachedMesh;
  48867. private _boundingBoxColor;
  48868. private _defaultUtilityLayer;
  48869. private _defaultKeepDepthUtilityLayer;
  48870. /**
  48871. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48872. */
  48873. boundingBoxDragBehavior: SixDofDragBehavior;
  48874. /**
  48875. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48876. */
  48877. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48878. /**
  48879. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48880. */
  48881. usePointerToAttachGizmos: boolean;
  48882. /**
  48883. * Utility layer that the bounding box gizmo belongs to
  48884. */
  48885. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48886. /**
  48887. * Utility layer that all gizmos besides bounding box belong to
  48888. */
  48889. get utilityLayer(): UtilityLayerRenderer;
  48890. /**
  48891. * Instatiates a gizmo manager
  48892. * @param scene the scene to overlay the gizmos on top of
  48893. */
  48894. constructor(scene: Scene);
  48895. /**
  48896. * Attaches a set of gizmos to the specified mesh
  48897. * @param mesh The mesh the gizmo's should be attached to
  48898. */
  48899. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48900. /**
  48901. * If the position gizmo is enabled
  48902. */
  48903. set positionGizmoEnabled(value: boolean);
  48904. get positionGizmoEnabled(): boolean;
  48905. /**
  48906. * If the rotation gizmo is enabled
  48907. */
  48908. set rotationGizmoEnabled(value: boolean);
  48909. get rotationGizmoEnabled(): boolean;
  48910. /**
  48911. * If the scale gizmo is enabled
  48912. */
  48913. set scaleGizmoEnabled(value: boolean);
  48914. get scaleGizmoEnabled(): boolean;
  48915. /**
  48916. * If the boundingBox gizmo is enabled
  48917. */
  48918. set boundingBoxGizmoEnabled(value: boolean);
  48919. get boundingBoxGizmoEnabled(): boolean;
  48920. /**
  48921. * Disposes of the gizmo manager
  48922. */
  48923. dispose(): void;
  48924. }
  48925. }
  48926. declare module BABYLON {
  48927. /**
  48928. * A directional light is defined by a direction (what a surprise!).
  48929. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48930. * 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.
  48931. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48932. */
  48933. export class DirectionalLight extends ShadowLight {
  48934. private _shadowFrustumSize;
  48935. /**
  48936. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48937. */
  48938. get shadowFrustumSize(): number;
  48939. /**
  48940. * Specifies a fix frustum size for the shadow generation.
  48941. */
  48942. set shadowFrustumSize(value: number);
  48943. private _shadowOrthoScale;
  48944. /**
  48945. * Gets the shadow projection scale against the optimal computed one.
  48946. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48947. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48948. */
  48949. get shadowOrthoScale(): number;
  48950. /**
  48951. * Sets the shadow projection scale against the optimal computed one.
  48952. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48953. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48954. */
  48955. set shadowOrthoScale(value: number);
  48956. /**
  48957. * Automatically compute the projection matrix to best fit (including all the casters)
  48958. * on each frame.
  48959. */
  48960. autoUpdateExtends: boolean;
  48961. /**
  48962. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48963. * on each frame. autoUpdateExtends must be set to true for this to work
  48964. */
  48965. autoCalcShadowZBounds: boolean;
  48966. private _orthoLeft;
  48967. private _orthoRight;
  48968. private _orthoTop;
  48969. private _orthoBottom;
  48970. /**
  48971. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48972. * The directional light is emitted from everywhere in the given direction.
  48973. * It can cast shadows.
  48974. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48975. * @param name The friendly name of the light
  48976. * @param direction The direction of the light
  48977. * @param scene The scene the light belongs to
  48978. */
  48979. constructor(name: string, direction: Vector3, scene: Scene);
  48980. /**
  48981. * Returns the string "DirectionalLight".
  48982. * @return The class name
  48983. */
  48984. getClassName(): string;
  48985. /**
  48986. * Returns the integer 1.
  48987. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48988. */
  48989. getTypeID(): number;
  48990. /**
  48991. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48992. * Returns the DirectionalLight Shadow projection matrix.
  48993. */
  48994. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48995. /**
  48996. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48997. * Returns the DirectionalLight Shadow projection matrix.
  48998. */
  48999. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49000. /**
  49001. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49002. * Returns the DirectionalLight Shadow projection matrix.
  49003. */
  49004. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49005. protected _buildUniformLayout(): void;
  49006. /**
  49007. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49008. * @param effect The effect to update
  49009. * @param lightIndex The index of the light in the effect to update
  49010. * @returns The directional light
  49011. */
  49012. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49013. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49014. /**
  49015. * Gets the minZ used for shadow according to both the scene and the light.
  49016. *
  49017. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49018. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49019. * @param activeCamera The camera we are returning the min for
  49020. * @returns the depth min z
  49021. */
  49022. getDepthMinZ(activeCamera: Camera): number;
  49023. /**
  49024. * Gets the maxZ used for shadow according to both the scene and the light.
  49025. *
  49026. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49027. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49028. * @param activeCamera The camera we are returning the max for
  49029. * @returns the depth max z
  49030. */
  49031. getDepthMaxZ(activeCamera: Camera): number;
  49032. /**
  49033. * Prepares the list of defines specific to the light type.
  49034. * @param defines the list of defines
  49035. * @param lightIndex defines the index of the light for the effect
  49036. */
  49037. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49038. }
  49039. }
  49040. declare module BABYLON {
  49041. /**
  49042. * Class containing static functions to help procedurally build meshes
  49043. */
  49044. export class HemisphereBuilder {
  49045. /**
  49046. * Creates a hemisphere mesh
  49047. * @param name defines the name of the mesh
  49048. * @param options defines the options used to create the mesh
  49049. * @param scene defines the hosting scene
  49050. * @returns the hemisphere mesh
  49051. */
  49052. static CreateHemisphere(name: string, options: {
  49053. segments?: number;
  49054. diameter?: number;
  49055. sideOrientation?: number;
  49056. }, scene: any): Mesh;
  49057. }
  49058. }
  49059. declare module BABYLON {
  49060. /**
  49061. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49062. * These values define a cone of light starting from the position, emitting toward the direction.
  49063. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49064. * and the exponent defines the speed of the decay of the light with distance (reach).
  49065. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49066. */
  49067. export class SpotLight extends ShadowLight {
  49068. private _angle;
  49069. private _innerAngle;
  49070. private _cosHalfAngle;
  49071. private _lightAngleScale;
  49072. private _lightAngleOffset;
  49073. /**
  49074. * Gets the cone angle of the spot light in Radians.
  49075. */
  49076. get angle(): number;
  49077. /**
  49078. * Sets the cone angle of the spot light in Radians.
  49079. */
  49080. set angle(value: number);
  49081. /**
  49082. * Only used in gltf falloff mode, this defines the angle where
  49083. * the directional falloff will start before cutting at angle which could be seen
  49084. * as outer angle.
  49085. */
  49086. get innerAngle(): number;
  49087. /**
  49088. * Only used in gltf falloff mode, this defines the angle where
  49089. * the directional falloff will start before cutting at angle which could be seen
  49090. * as outer angle.
  49091. */
  49092. set innerAngle(value: number);
  49093. private _shadowAngleScale;
  49094. /**
  49095. * Allows scaling the angle of the light for shadow generation only.
  49096. */
  49097. get shadowAngleScale(): number;
  49098. /**
  49099. * Allows scaling the angle of the light for shadow generation only.
  49100. */
  49101. set shadowAngleScale(value: number);
  49102. /**
  49103. * The light decay speed with the distance from the emission spot.
  49104. */
  49105. exponent: number;
  49106. private _projectionTextureMatrix;
  49107. /**
  49108. * Allows reading the projecton texture
  49109. */
  49110. get projectionTextureMatrix(): Matrix;
  49111. protected _projectionTextureLightNear: number;
  49112. /**
  49113. * Gets the near clip of the Spotlight for texture projection.
  49114. */
  49115. get projectionTextureLightNear(): number;
  49116. /**
  49117. * Sets the near clip of the Spotlight for texture projection.
  49118. */
  49119. set projectionTextureLightNear(value: number);
  49120. protected _projectionTextureLightFar: number;
  49121. /**
  49122. * Gets the far clip of the Spotlight for texture projection.
  49123. */
  49124. get projectionTextureLightFar(): number;
  49125. /**
  49126. * Sets the far clip of the Spotlight for texture projection.
  49127. */
  49128. set projectionTextureLightFar(value: number);
  49129. protected _projectionTextureUpDirection: Vector3;
  49130. /**
  49131. * Gets the Up vector of the Spotlight for texture projection.
  49132. */
  49133. get projectionTextureUpDirection(): Vector3;
  49134. /**
  49135. * Sets the Up vector of the Spotlight for texture projection.
  49136. */
  49137. set projectionTextureUpDirection(value: Vector3);
  49138. private _projectionTexture;
  49139. /**
  49140. * Gets the projection texture of the light.
  49141. */
  49142. get projectionTexture(): Nullable<BaseTexture>;
  49143. /**
  49144. * Sets the projection texture of the light.
  49145. */
  49146. set projectionTexture(value: Nullable<BaseTexture>);
  49147. private _projectionTextureViewLightDirty;
  49148. private _projectionTextureProjectionLightDirty;
  49149. private _projectionTextureDirty;
  49150. private _projectionTextureViewTargetVector;
  49151. private _projectionTextureViewLightMatrix;
  49152. private _projectionTextureProjectionLightMatrix;
  49153. private _projectionTextureScalingMatrix;
  49154. /**
  49155. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49156. * It can cast shadows.
  49157. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49158. * @param name The light friendly name
  49159. * @param position The position of the spot light in the scene
  49160. * @param direction The direction of the light in the scene
  49161. * @param angle The cone angle of the light in Radians
  49162. * @param exponent The light decay speed with the distance from the emission spot
  49163. * @param scene The scene the lights belongs to
  49164. */
  49165. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49166. /**
  49167. * Returns the string "SpotLight".
  49168. * @returns the class name
  49169. */
  49170. getClassName(): string;
  49171. /**
  49172. * Returns the integer 2.
  49173. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49174. */
  49175. getTypeID(): number;
  49176. /**
  49177. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49178. */
  49179. protected _setDirection(value: Vector3): void;
  49180. /**
  49181. * Overrides the position setter to recompute the projection texture view light Matrix.
  49182. */
  49183. protected _setPosition(value: Vector3): void;
  49184. /**
  49185. * 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.
  49186. * Returns the SpotLight.
  49187. */
  49188. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49189. protected _computeProjectionTextureViewLightMatrix(): void;
  49190. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49191. /**
  49192. * Main function for light texture projection matrix computing.
  49193. */
  49194. protected _computeProjectionTextureMatrix(): void;
  49195. protected _buildUniformLayout(): void;
  49196. private _computeAngleValues;
  49197. /**
  49198. * Sets the passed Effect "effect" with the Light textures.
  49199. * @param effect The effect to update
  49200. * @param lightIndex The index of the light in the effect to update
  49201. * @returns The light
  49202. */
  49203. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49204. /**
  49205. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49206. * @param effect The effect to update
  49207. * @param lightIndex The index of the light in the effect to update
  49208. * @returns The spot light
  49209. */
  49210. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49211. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49212. /**
  49213. * Disposes the light and the associated resources.
  49214. */
  49215. dispose(): void;
  49216. /**
  49217. * Prepares the list of defines specific to the light type.
  49218. * @param defines the list of defines
  49219. * @param lightIndex defines the index of the light for the effect
  49220. */
  49221. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49222. }
  49223. }
  49224. declare module BABYLON {
  49225. /**
  49226. * Gizmo that enables viewing a light
  49227. */
  49228. export class LightGizmo extends Gizmo {
  49229. private _lightMesh;
  49230. private _material;
  49231. private _cachedPosition;
  49232. private _cachedForward;
  49233. private _attachedMeshParent;
  49234. /**
  49235. * Creates a LightGizmo
  49236. * @param gizmoLayer The utility layer the gizmo will be added to
  49237. */
  49238. constructor(gizmoLayer?: UtilityLayerRenderer);
  49239. private _light;
  49240. /**
  49241. * The light that the gizmo is attached to
  49242. */
  49243. set light(light: Nullable<Light>);
  49244. get light(): Nullable<Light>;
  49245. /**
  49246. * Gets the material used to render the light gizmo
  49247. */
  49248. get material(): StandardMaterial;
  49249. /**
  49250. * @hidden
  49251. * Updates the gizmo to match the attached mesh's position/rotation
  49252. */
  49253. protected _update(): void;
  49254. private static _Scale;
  49255. /**
  49256. * Creates the lines for a light mesh
  49257. */
  49258. private static _CreateLightLines;
  49259. /**
  49260. * Disposes of the light gizmo
  49261. */
  49262. dispose(): void;
  49263. private static _CreateHemisphericLightMesh;
  49264. private static _CreatePointLightMesh;
  49265. private static _CreateSpotLightMesh;
  49266. private static _CreateDirectionalLightMesh;
  49267. }
  49268. }
  49269. declare module BABYLON {
  49270. /** @hidden */
  49271. export var backgroundFragmentDeclaration: {
  49272. name: string;
  49273. shader: string;
  49274. };
  49275. }
  49276. declare module BABYLON {
  49277. /** @hidden */
  49278. export var backgroundUboDeclaration: {
  49279. name: string;
  49280. shader: string;
  49281. };
  49282. }
  49283. declare module BABYLON {
  49284. /** @hidden */
  49285. export var backgroundPixelShader: {
  49286. name: string;
  49287. shader: string;
  49288. };
  49289. }
  49290. declare module BABYLON {
  49291. /** @hidden */
  49292. export var backgroundVertexDeclaration: {
  49293. name: string;
  49294. shader: string;
  49295. };
  49296. }
  49297. declare module BABYLON {
  49298. /** @hidden */
  49299. export var backgroundVertexShader: {
  49300. name: string;
  49301. shader: string;
  49302. };
  49303. }
  49304. declare module BABYLON {
  49305. /**
  49306. * Background material used to create an efficient environement around your scene.
  49307. */
  49308. export class BackgroundMaterial extends PushMaterial {
  49309. /**
  49310. * Standard reflectance value at parallel view angle.
  49311. */
  49312. static StandardReflectance0: number;
  49313. /**
  49314. * Standard reflectance value at grazing angle.
  49315. */
  49316. static StandardReflectance90: number;
  49317. protected _primaryColor: Color3;
  49318. /**
  49319. * Key light Color (multiply against the environement texture)
  49320. */
  49321. primaryColor: Color3;
  49322. protected __perceptualColor: Nullable<Color3>;
  49323. /**
  49324. * Experimental Internal Use Only.
  49325. *
  49326. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49327. * This acts as a helper to set the primary color to a more "human friendly" value.
  49328. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49329. * output color as close as possible from the chosen value.
  49330. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49331. * part of lighting setup.)
  49332. */
  49333. get _perceptualColor(): Nullable<Color3>;
  49334. set _perceptualColor(value: Nullable<Color3>);
  49335. protected _primaryColorShadowLevel: float;
  49336. /**
  49337. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49338. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49339. */
  49340. get primaryColorShadowLevel(): float;
  49341. set primaryColorShadowLevel(value: float);
  49342. protected _primaryColorHighlightLevel: float;
  49343. /**
  49344. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49345. * The primary color is used at the level chosen to define what the white area would look.
  49346. */
  49347. get primaryColorHighlightLevel(): float;
  49348. set primaryColorHighlightLevel(value: float);
  49349. protected _reflectionTexture: Nullable<BaseTexture>;
  49350. /**
  49351. * Reflection Texture used in the material.
  49352. * Should be author in a specific way for the best result (refer to the documentation).
  49353. */
  49354. reflectionTexture: Nullable<BaseTexture>;
  49355. protected _reflectionBlur: float;
  49356. /**
  49357. * Reflection Texture level of blur.
  49358. *
  49359. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49360. * texture twice.
  49361. */
  49362. reflectionBlur: float;
  49363. protected _diffuseTexture: Nullable<BaseTexture>;
  49364. /**
  49365. * Diffuse Texture used in the material.
  49366. * Should be author in a specific way for the best result (refer to the documentation).
  49367. */
  49368. diffuseTexture: Nullable<BaseTexture>;
  49369. protected _shadowLights: Nullable<IShadowLight[]>;
  49370. /**
  49371. * Specify the list of lights casting shadow on the material.
  49372. * All scene shadow lights will be included if null.
  49373. */
  49374. shadowLights: Nullable<IShadowLight[]>;
  49375. protected _shadowLevel: float;
  49376. /**
  49377. * Helps adjusting the shadow to a softer level if required.
  49378. * 0 means black shadows and 1 means no shadows.
  49379. */
  49380. shadowLevel: float;
  49381. protected _sceneCenter: Vector3;
  49382. /**
  49383. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49384. * It is usually zero but might be interesting to modify according to your setup.
  49385. */
  49386. sceneCenter: Vector3;
  49387. protected _opacityFresnel: boolean;
  49388. /**
  49389. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49390. * This helps ensuring a nice transition when the camera goes under the ground.
  49391. */
  49392. opacityFresnel: boolean;
  49393. protected _reflectionFresnel: boolean;
  49394. /**
  49395. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49396. * This helps adding a mirror texture on the ground.
  49397. */
  49398. reflectionFresnel: boolean;
  49399. protected _reflectionFalloffDistance: number;
  49400. /**
  49401. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49402. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49403. */
  49404. reflectionFalloffDistance: number;
  49405. protected _reflectionAmount: number;
  49406. /**
  49407. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49408. */
  49409. reflectionAmount: number;
  49410. protected _reflectionReflectance0: number;
  49411. /**
  49412. * This specifies the weight of the reflection at grazing angle.
  49413. */
  49414. reflectionReflectance0: number;
  49415. protected _reflectionReflectance90: number;
  49416. /**
  49417. * This specifies the weight of the reflection at a perpendicular point of view.
  49418. */
  49419. reflectionReflectance90: number;
  49420. /**
  49421. * Sets the reflection reflectance fresnel values according to the default standard
  49422. * empirically know to work well :-)
  49423. */
  49424. set reflectionStandardFresnelWeight(value: number);
  49425. protected _useRGBColor: boolean;
  49426. /**
  49427. * Helps to directly use the maps channels instead of their level.
  49428. */
  49429. useRGBColor: boolean;
  49430. protected _enableNoise: boolean;
  49431. /**
  49432. * This helps reducing the banding effect that could occur on the background.
  49433. */
  49434. enableNoise: boolean;
  49435. /**
  49436. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49437. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49438. * Recommended to be keep at 1.0 except for special cases.
  49439. */
  49440. get fovMultiplier(): number;
  49441. set fovMultiplier(value: number);
  49442. private _fovMultiplier;
  49443. /**
  49444. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49445. */
  49446. useEquirectangularFOV: boolean;
  49447. private _maxSimultaneousLights;
  49448. /**
  49449. * Number of Simultaneous lights allowed on the material.
  49450. */
  49451. maxSimultaneousLights: int;
  49452. /**
  49453. * Default configuration related to image processing available in the Background Material.
  49454. */
  49455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49456. /**
  49457. * Keep track of the image processing observer to allow dispose and replace.
  49458. */
  49459. private _imageProcessingObserver;
  49460. /**
  49461. * Attaches a new image processing configuration to the PBR Material.
  49462. * @param configuration (if null the scene configuration will be use)
  49463. */
  49464. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49465. /**
  49466. * Gets the image processing configuration used either in this material.
  49467. */
  49468. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49469. /**
  49470. * Sets the Default image processing configuration used either in the this material.
  49471. *
  49472. * If sets to null, the scene one is in use.
  49473. */
  49474. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49475. /**
  49476. * Gets wether the color curves effect is enabled.
  49477. */
  49478. get cameraColorCurvesEnabled(): boolean;
  49479. /**
  49480. * Sets wether the color curves effect is enabled.
  49481. */
  49482. set cameraColorCurvesEnabled(value: boolean);
  49483. /**
  49484. * Gets wether the color grading effect is enabled.
  49485. */
  49486. get cameraColorGradingEnabled(): boolean;
  49487. /**
  49488. * Gets wether the color grading effect is enabled.
  49489. */
  49490. set cameraColorGradingEnabled(value: boolean);
  49491. /**
  49492. * Gets wether tonemapping is enabled or not.
  49493. */
  49494. get cameraToneMappingEnabled(): boolean;
  49495. /**
  49496. * Sets wether tonemapping is enabled or not
  49497. */
  49498. set cameraToneMappingEnabled(value: boolean);
  49499. /**
  49500. * The camera exposure used on this material.
  49501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49502. * This corresponds to a photographic exposure.
  49503. */
  49504. get cameraExposure(): float;
  49505. /**
  49506. * The camera exposure used on this material.
  49507. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49508. * This corresponds to a photographic exposure.
  49509. */
  49510. set cameraExposure(value: float);
  49511. /**
  49512. * Gets The camera contrast used on this material.
  49513. */
  49514. get cameraContrast(): float;
  49515. /**
  49516. * Sets The camera contrast used on this material.
  49517. */
  49518. set cameraContrast(value: float);
  49519. /**
  49520. * Gets the Color Grading 2D Lookup Texture.
  49521. */
  49522. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49523. /**
  49524. * Sets the Color Grading 2D Lookup Texture.
  49525. */
  49526. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49527. /**
  49528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49530. * 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;
  49531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49532. */
  49533. get cameraColorCurves(): Nullable<ColorCurves>;
  49534. /**
  49535. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49536. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49537. * 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;
  49538. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49539. */
  49540. set cameraColorCurves(value: Nullable<ColorCurves>);
  49541. /**
  49542. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49543. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49544. */
  49545. switchToBGR: boolean;
  49546. private _renderTargets;
  49547. private _reflectionControls;
  49548. private _white;
  49549. private _primaryShadowColor;
  49550. private _primaryHighlightColor;
  49551. /**
  49552. * Instantiates a Background Material in the given scene
  49553. * @param name The friendly name of the material
  49554. * @param scene The scene to add the material to
  49555. */
  49556. constructor(name: string, scene: Scene);
  49557. /**
  49558. * Gets a boolean indicating that current material needs to register RTT
  49559. */
  49560. get hasRenderTargetTextures(): boolean;
  49561. /**
  49562. * The entire material has been created in order to prevent overdraw.
  49563. * @returns false
  49564. */
  49565. needAlphaTesting(): boolean;
  49566. /**
  49567. * The entire material has been created in order to prevent overdraw.
  49568. * @returns true if blending is enable
  49569. */
  49570. needAlphaBlending(): boolean;
  49571. /**
  49572. * Checks wether the material is ready to be rendered for a given mesh.
  49573. * @param mesh The mesh to render
  49574. * @param subMesh The submesh to check against
  49575. * @param useInstances Specify wether or not the material is used with instances
  49576. * @returns true if all the dependencies are ready (Textures, Effects...)
  49577. */
  49578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49579. /**
  49580. * Compute the primary color according to the chosen perceptual color.
  49581. */
  49582. private _computePrimaryColorFromPerceptualColor;
  49583. /**
  49584. * Compute the highlights and shadow colors according to their chosen levels.
  49585. */
  49586. private _computePrimaryColors;
  49587. /**
  49588. * Build the uniform buffer used in the material.
  49589. */
  49590. buildUniformLayout(): void;
  49591. /**
  49592. * Unbind the material.
  49593. */
  49594. unbind(): void;
  49595. /**
  49596. * Bind only the world matrix to the material.
  49597. * @param world The world matrix to bind.
  49598. */
  49599. bindOnlyWorldMatrix(world: Matrix): void;
  49600. /**
  49601. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49602. * @param world The world matrix to bind.
  49603. * @param subMesh The submesh to bind for.
  49604. */
  49605. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49606. /**
  49607. * Checks to see if a texture is used in the material.
  49608. * @param texture - Base texture to use.
  49609. * @returns - Boolean specifying if a texture is used in the material.
  49610. */
  49611. hasTexture(texture: BaseTexture): boolean;
  49612. /**
  49613. * Dispose the material.
  49614. * @param forceDisposeEffect Force disposal of the associated effect.
  49615. * @param forceDisposeTextures Force disposal of the associated textures.
  49616. */
  49617. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49618. /**
  49619. * Clones the material.
  49620. * @param name The cloned name.
  49621. * @returns The cloned material.
  49622. */
  49623. clone(name: string): BackgroundMaterial;
  49624. /**
  49625. * Serializes the current material to its JSON representation.
  49626. * @returns The JSON representation.
  49627. */
  49628. serialize(): any;
  49629. /**
  49630. * Gets the class name of the material
  49631. * @returns "BackgroundMaterial"
  49632. */
  49633. getClassName(): string;
  49634. /**
  49635. * Parse a JSON input to create back a background material.
  49636. * @param source The JSON data to parse
  49637. * @param scene The scene to create the parsed material in
  49638. * @param rootUrl The root url of the assets the material depends upon
  49639. * @returns the instantiated BackgroundMaterial.
  49640. */
  49641. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49642. }
  49643. }
  49644. declare module BABYLON {
  49645. /**
  49646. * Represents the different options available during the creation of
  49647. * a Environment helper.
  49648. *
  49649. * This can control the default ground, skybox and image processing setup of your scene.
  49650. */
  49651. export interface IEnvironmentHelperOptions {
  49652. /**
  49653. * Specifies wether or not to create a ground.
  49654. * True by default.
  49655. */
  49656. createGround: boolean;
  49657. /**
  49658. * Specifies the ground size.
  49659. * 15 by default.
  49660. */
  49661. groundSize: number;
  49662. /**
  49663. * The texture used on the ground for the main color.
  49664. * Comes from the BabylonJS CDN by default.
  49665. *
  49666. * Remarks: Can be either a texture or a url.
  49667. */
  49668. groundTexture: string | BaseTexture;
  49669. /**
  49670. * The color mixed in the ground texture by default.
  49671. * BabylonJS clearColor by default.
  49672. */
  49673. groundColor: Color3;
  49674. /**
  49675. * Specifies the ground opacity.
  49676. * 1 by default.
  49677. */
  49678. groundOpacity: number;
  49679. /**
  49680. * Enables the ground to receive shadows.
  49681. * True by default.
  49682. */
  49683. enableGroundShadow: boolean;
  49684. /**
  49685. * Helps preventing the shadow to be fully black on the ground.
  49686. * 0.5 by default.
  49687. */
  49688. groundShadowLevel: number;
  49689. /**
  49690. * Creates a mirror texture attach to the ground.
  49691. * false by default.
  49692. */
  49693. enableGroundMirror: boolean;
  49694. /**
  49695. * Specifies the ground mirror size ratio.
  49696. * 0.3 by default as the default kernel is 64.
  49697. */
  49698. groundMirrorSizeRatio: number;
  49699. /**
  49700. * Specifies the ground mirror blur kernel size.
  49701. * 64 by default.
  49702. */
  49703. groundMirrorBlurKernel: number;
  49704. /**
  49705. * Specifies the ground mirror visibility amount.
  49706. * 1 by default
  49707. */
  49708. groundMirrorAmount: number;
  49709. /**
  49710. * Specifies the ground mirror reflectance weight.
  49711. * This uses the standard weight of the background material to setup the fresnel effect
  49712. * of the mirror.
  49713. * 1 by default.
  49714. */
  49715. groundMirrorFresnelWeight: number;
  49716. /**
  49717. * Specifies the ground mirror Falloff distance.
  49718. * This can helps reducing the size of the reflection.
  49719. * 0 by Default.
  49720. */
  49721. groundMirrorFallOffDistance: number;
  49722. /**
  49723. * Specifies the ground mirror texture type.
  49724. * Unsigned Int by Default.
  49725. */
  49726. groundMirrorTextureType: number;
  49727. /**
  49728. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49729. * the shown objects.
  49730. */
  49731. groundYBias: number;
  49732. /**
  49733. * Specifies wether or not to create a skybox.
  49734. * True by default.
  49735. */
  49736. createSkybox: boolean;
  49737. /**
  49738. * Specifies the skybox size.
  49739. * 20 by default.
  49740. */
  49741. skyboxSize: number;
  49742. /**
  49743. * The texture used on the skybox for the main color.
  49744. * Comes from the BabylonJS CDN by default.
  49745. *
  49746. * Remarks: Can be either a texture or a url.
  49747. */
  49748. skyboxTexture: string | BaseTexture;
  49749. /**
  49750. * The color mixed in the skybox texture by default.
  49751. * BabylonJS clearColor by default.
  49752. */
  49753. skyboxColor: Color3;
  49754. /**
  49755. * The background rotation around the Y axis of the scene.
  49756. * This helps aligning the key lights of your scene with the background.
  49757. * 0 by default.
  49758. */
  49759. backgroundYRotation: number;
  49760. /**
  49761. * Compute automatically the size of the elements to best fit with the scene.
  49762. */
  49763. sizeAuto: boolean;
  49764. /**
  49765. * Default position of the rootMesh if autoSize is not true.
  49766. */
  49767. rootPosition: Vector3;
  49768. /**
  49769. * Sets up the image processing in the scene.
  49770. * true by default.
  49771. */
  49772. setupImageProcessing: boolean;
  49773. /**
  49774. * The texture used as your environment texture in the scene.
  49775. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49776. *
  49777. * Remarks: Can be either a texture or a url.
  49778. */
  49779. environmentTexture: string | BaseTexture;
  49780. /**
  49781. * The value of the exposure to apply to the scene.
  49782. * 0.6 by default if setupImageProcessing is true.
  49783. */
  49784. cameraExposure: number;
  49785. /**
  49786. * The value of the contrast to apply to the scene.
  49787. * 1.6 by default if setupImageProcessing is true.
  49788. */
  49789. cameraContrast: number;
  49790. /**
  49791. * Specifies wether or not tonemapping should be enabled in the scene.
  49792. * true by default if setupImageProcessing is true.
  49793. */
  49794. toneMappingEnabled: boolean;
  49795. }
  49796. /**
  49797. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49798. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49799. * It also helps with the default setup of your imageProcessing configuration.
  49800. */
  49801. export class EnvironmentHelper {
  49802. /**
  49803. * Default ground texture URL.
  49804. */
  49805. private static _groundTextureCDNUrl;
  49806. /**
  49807. * Default skybox texture URL.
  49808. */
  49809. private static _skyboxTextureCDNUrl;
  49810. /**
  49811. * Default environment texture URL.
  49812. */
  49813. private static _environmentTextureCDNUrl;
  49814. /**
  49815. * Creates the default options for the helper.
  49816. */
  49817. private static _getDefaultOptions;
  49818. private _rootMesh;
  49819. /**
  49820. * Gets the root mesh created by the helper.
  49821. */
  49822. get rootMesh(): Mesh;
  49823. private _skybox;
  49824. /**
  49825. * Gets the skybox created by the helper.
  49826. */
  49827. get skybox(): Nullable<Mesh>;
  49828. private _skyboxTexture;
  49829. /**
  49830. * Gets the skybox texture created by the helper.
  49831. */
  49832. get skyboxTexture(): Nullable<BaseTexture>;
  49833. private _skyboxMaterial;
  49834. /**
  49835. * Gets the skybox material created by the helper.
  49836. */
  49837. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49838. private _ground;
  49839. /**
  49840. * Gets the ground mesh created by the helper.
  49841. */
  49842. get ground(): Nullable<Mesh>;
  49843. private _groundTexture;
  49844. /**
  49845. * Gets the ground texture created by the helper.
  49846. */
  49847. get groundTexture(): Nullable<BaseTexture>;
  49848. private _groundMirror;
  49849. /**
  49850. * Gets the ground mirror created by the helper.
  49851. */
  49852. get groundMirror(): Nullable<MirrorTexture>;
  49853. /**
  49854. * Gets the ground mirror render list to helps pushing the meshes
  49855. * you wish in the ground reflection.
  49856. */
  49857. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49858. private _groundMaterial;
  49859. /**
  49860. * Gets the ground material created by the helper.
  49861. */
  49862. get groundMaterial(): Nullable<BackgroundMaterial>;
  49863. /**
  49864. * Stores the creation options.
  49865. */
  49866. private readonly _scene;
  49867. private _options;
  49868. /**
  49869. * This observable will be notified with any error during the creation of the environment,
  49870. * mainly texture creation errors.
  49871. */
  49872. onErrorObservable: Observable<{
  49873. message?: string;
  49874. exception?: any;
  49875. }>;
  49876. /**
  49877. * constructor
  49878. * @param options Defines the options we want to customize the helper
  49879. * @param scene The scene to add the material to
  49880. */
  49881. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49882. /**
  49883. * Updates the background according to the new options
  49884. * @param options
  49885. */
  49886. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49887. /**
  49888. * Sets the primary color of all the available elements.
  49889. * @param color the main color to affect to the ground and the background
  49890. */
  49891. setMainColor(color: Color3): void;
  49892. /**
  49893. * Setup the image processing according to the specified options.
  49894. */
  49895. private _setupImageProcessing;
  49896. /**
  49897. * Setup the environment texture according to the specified options.
  49898. */
  49899. private _setupEnvironmentTexture;
  49900. /**
  49901. * Setup the background according to the specified options.
  49902. */
  49903. private _setupBackground;
  49904. /**
  49905. * Get the scene sizes according to the setup.
  49906. */
  49907. private _getSceneSize;
  49908. /**
  49909. * Setup the ground according to the specified options.
  49910. */
  49911. private _setupGround;
  49912. /**
  49913. * Setup the ground material according to the specified options.
  49914. */
  49915. private _setupGroundMaterial;
  49916. /**
  49917. * Setup the ground diffuse texture according to the specified options.
  49918. */
  49919. private _setupGroundDiffuseTexture;
  49920. /**
  49921. * Setup the ground mirror texture according to the specified options.
  49922. */
  49923. private _setupGroundMirrorTexture;
  49924. /**
  49925. * Setup the ground to receive the mirror texture.
  49926. */
  49927. private _setupMirrorInGroundMaterial;
  49928. /**
  49929. * Setup the skybox according to the specified options.
  49930. */
  49931. private _setupSkybox;
  49932. /**
  49933. * Setup the skybox material according to the specified options.
  49934. */
  49935. private _setupSkyboxMaterial;
  49936. /**
  49937. * Setup the skybox reflection texture according to the specified options.
  49938. */
  49939. private _setupSkyboxReflectionTexture;
  49940. private _errorHandler;
  49941. /**
  49942. * Dispose all the elements created by the Helper.
  49943. */
  49944. dispose(): void;
  49945. }
  49946. }
  49947. declare module BABYLON {
  49948. /**
  49949. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49950. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49951. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49952. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49953. */
  49954. export class PhotoDome extends TransformNode {
  49955. /**
  49956. * Define the image as a Monoscopic panoramic 360 image.
  49957. */
  49958. static readonly MODE_MONOSCOPIC: number;
  49959. /**
  49960. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49961. */
  49962. static readonly MODE_TOPBOTTOM: number;
  49963. /**
  49964. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49965. */
  49966. static readonly MODE_SIDEBYSIDE: number;
  49967. private _useDirectMapping;
  49968. /**
  49969. * The texture being displayed on the sphere
  49970. */
  49971. protected _photoTexture: Texture;
  49972. /**
  49973. * Gets or sets the texture being displayed on the sphere
  49974. */
  49975. get photoTexture(): Texture;
  49976. set photoTexture(value: Texture);
  49977. /**
  49978. * Observable raised when an error occured while loading the 360 image
  49979. */
  49980. onLoadErrorObservable: Observable<string>;
  49981. /**
  49982. * The skybox material
  49983. */
  49984. protected _material: BackgroundMaterial;
  49985. /**
  49986. * The surface used for the skybox
  49987. */
  49988. protected _mesh: Mesh;
  49989. /**
  49990. * Gets the mesh used for the skybox.
  49991. */
  49992. get mesh(): Mesh;
  49993. /**
  49994. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49995. * Also see the options.resolution property.
  49996. */
  49997. get fovMultiplier(): number;
  49998. set fovMultiplier(value: number);
  49999. private _imageMode;
  50000. /**
  50001. * Gets or set the current video mode for the video. It can be:
  50002. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50003. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50004. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50005. */
  50006. get imageMode(): number;
  50007. set imageMode(value: number);
  50008. /**
  50009. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50010. * @param name Element's name, child elements will append suffixes for their own names.
  50011. * @param urlsOfPhoto defines the url of the photo to display
  50012. * @param options defines an object containing optional or exposed sub element properties
  50013. * @param onError defines a callback called when an error occured while loading the texture
  50014. */
  50015. constructor(name: string, urlOfPhoto: string, options: {
  50016. resolution?: number;
  50017. size?: number;
  50018. useDirectMapping?: boolean;
  50019. faceForward?: boolean;
  50020. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50021. private _onBeforeCameraRenderObserver;
  50022. private _changeImageMode;
  50023. /**
  50024. * Releases resources associated with this node.
  50025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50027. */
  50028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50029. }
  50030. }
  50031. declare module BABYLON {
  50032. /**
  50033. * Class used to host RGBD texture specific utilities
  50034. */
  50035. export class RGBDTextureTools {
  50036. /**
  50037. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50038. * @param texture the texture to expand.
  50039. */
  50040. static ExpandRGBDTexture(texture: Texture): void;
  50041. }
  50042. }
  50043. declare module BABYLON {
  50044. /**
  50045. * Class used to host texture specific utilities
  50046. */
  50047. export class BRDFTextureTools {
  50048. /**
  50049. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50050. * @param scene defines the hosting scene
  50051. * @returns the environment BRDF texture
  50052. */
  50053. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50054. private static _environmentBRDFBase64Texture;
  50055. }
  50056. }
  50057. declare module BABYLON {
  50058. /**
  50059. * @hidden
  50060. */
  50061. export interface IMaterialClearCoatDefines {
  50062. CLEARCOAT: boolean;
  50063. CLEARCOAT_DEFAULTIOR: boolean;
  50064. CLEARCOAT_TEXTURE: boolean;
  50065. CLEARCOAT_TEXTUREDIRECTUV: number;
  50066. CLEARCOAT_BUMP: boolean;
  50067. CLEARCOAT_BUMPDIRECTUV: number;
  50068. CLEARCOAT_TINT: boolean;
  50069. CLEARCOAT_TINT_TEXTURE: boolean;
  50070. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50071. /** @hidden */
  50072. _areTexturesDirty: boolean;
  50073. }
  50074. /**
  50075. * Define the code related to the clear coat parameters of the pbr material.
  50076. */
  50077. export class PBRClearCoatConfiguration {
  50078. /**
  50079. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50080. * The default fits with a polyurethane material.
  50081. */
  50082. private static readonly _DefaultIndexOfRefraction;
  50083. private _isEnabled;
  50084. /**
  50085. * Defines if the clear coat is enabled in the material.
  50086. */
  50087. isEnabled: boolean;
  50088. /**
  50089. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50090. */
  50091. intensity: number;
  50092. /**
  50093. * Defines the clear coat layer roughness.
  50094. */
  50095. roughness: number;
  50096. private _indexOfRefraction;
  50097. /**
  50098. * Defines the index of refraction of the clear coat.
  50099. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50100. * The default fits with a polyurethane material.
  50101. * Changing the default value is more performance intensive.
  50102. */
  50103. indexOfRefraction: number;
  50104. private _texture;
  50105. /**
  50106. * Stores the clear coat values in a texture.
  50107. */
  50108. texture: Nullable<BaseTexture>;
  50109. private _bumpTexture;
  50110. /**
  50111. * Define the clear coat specific bump texture.
  50112. */
  50113. bumpTexture: Nullable<BaseTexture>;
  50114. private _isTintEnabled;
  50115. /**
  50116. * Defines if the clear coat tint is enabled in the material.
  50117. */
  50118. isTintEnabled: boolean;
  50119. /**
  50120. * Defines the clear coat tint of the material.
  50121. * This is only use if tint is enabled
  50122. */
  50123. tintColor: Color3;
  50124. /**
  50125. * Defines the distance at which the tint color should be found in the
  50126. * clear coat media.
  50127. * This is only use if tint is enabled
  50128. */
  50129. tintColorAtDistance: number;
  50130. /**
  50131. * Defines the clear coat layer thickness.
  50132. * This is only use if tint is enabled
  50133. */
  50134. tintThickness: number;
  50135. private _tintTexture;
  50136. /**
  50137. * Stores the clear tint values in a texture.
  50138. * rgb is tint
  50139. * a is a thickness factor
  50140. */
  50141. tintTexture: Nullable<BaseTexture>;
  50142. /** @hidden */
  50143. private _internalMarkAllSubMeshesAsTexturesDirty;
  50144. /** @hidden */
  50145. _markAllSubMeshesAsTexturesDirty(): void;
  50146. /**
  50147. * Instantiate a new istance of clear coat configuration.
  50148. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50149. */
  50150. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50151. /**
  50152. * Gets wehter the submesh is ready to be used or not.
  50153. * @param defines the list of "defines" to update.
  50154. * @param scene defines the scene the material belongs to.
  50155. * @param engine defines the engine the material belongs to.
  50156. * @param disableBumpMap defines wether the material disables bump or not.
  50157. * @returns - boolean indicating that the submesh is ready or not.
  50158. */
  50159. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50160. /**
  50161. * Checks to see if a texture is used in the material.
  50162. * @param defines the list of "defines" to update.
  50163. * @param scene defines the scene to the material belongs to.
  50164. */
  50165. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50166. /**
  50167. * Binds the material data.
  50168. * @param uniformBuffer defines the Uniform buffer to fill in.
  50169. * @param scene defines the scene the material belongs to.
  50170. * @param engine defines the engine the material belongs to.
  50171. * @param disableBumpMap defines wether the material disables bump or not.
  50172. * @param isFrozen defines wether the material is frozen or not.
  50173. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50174. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50175. */
  50176. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50177. /**
  50178. * Checks to see if a texture is used in the material.
  50179. * @param texture - Base texture to use.
  50180. * @returns - Boolean specifying if a texture is used in the material.
  50181. */
  50182. hasTexture(texture: BaseTexture): boolean;
  50183. /**
  50184. * Returns an array of the actively used textures.
  50185. * @param activeTextures Array of BaseTextures
  50186. */
  50187. getActiveTextures(activeTextures: BaseTexture[]): void;
  50188. /**
  50189. * Returns the animatable textures.
  50190. * @param animatables Array of animatable textures.
  50191. */
  50192. getAnimatables(animatables: IAnimatable[]): void;
  50193. /**
  50194. * Disposes the resources of the material.
  50195. * @param forceDisposeTextures - Forces the disposal of all textures.
  50196. */
  50197. dispose(forceDisposeTextures?: boolean): void;
  50198. /**
  50199. * Get the current class name of the texture useful for serialization or dynamic coding.
  50200. * @returns "PBRClearCoatConfiguration"
  50201. */
  50202. getClassName(): string;
  50203. /**
  50204. * Add fallbacks to the effect fallbacks list.
  50205. * @param defines defines the Base texture to use.
  50206. * @param fallbacks defines the current fallback list.
  50207. * @param currentRank defines the current fallback rank.
  50208. * @returns the new fallback rank.
  50209. */
  50210. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50211. /**
  50212. * Add the required uniforms to the current list.
  50213. * @param uniforms defines the current uniform list.
  50214. */
  50215. static AddUniforms(uniforms: string[]): void;
  50216. /**
  50217. * Add the required samplers to the current list.
  50218. * @param samplers defines the current sampler list.
  50219. */
  50220. static AddSamplers(samplers: string[]): void;
  50221. /**
  50222. * Add the required uniforms to the current buffer.
  50223. * @param uniformBuffer defines the current uniform buffer.
  50224. */
  50225. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50226. /**
  50227. * Makes a duplicate of the current configuration into another one.
  50228. * @param clearCoatConfiguration define the config where to copy the info
  50229. */
  50230. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50231. /**
  50232. * Serializes this clear coat configuration.
  50233. * @returns - An object with the serialized config.
  50234. */
  50235. serialize(): any;
  50236. /**
  50237. * Parses a anisotropy Configuration from a serialized object.
  50238. * @param source - Serialized object.
  50239. * @param scene Defines the scene we are parsing for
  50240. * @param rootUrl Defines the rootUrl to load from
  50241. */
  50242. parse(source: any, scene: Scene, rootUrl: string): void;
  50243. }
  50244. }
  50245. declare module BABYLON {
  50246. /**
  50247. * @hidden
  50248. */
  50249. export interface IMaterialAnisotropicDefines {
  50250. ANISOTROPIC: boolean;
  50251. ANISOTROPIC_TEXTURE: boolean;
  50252. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50253. MAINUV1: boolean;
  50254. _areTexturesDirty: boolean;
  50255. _needUVs: boolean;
  50256. }
  50257. /**
  50258. * Define the code related to the anisotropic parameters of the pbr material.
  50259. */
  50260. export class PBRAnisotropicConfiguration {
  50261. private _isEnabled;
  50262. /**
  50263. * Defines if the anisotropy is enabled in the material.
  50264. */
  50265. isEnabled: boolean;
  50266. /**
  50267. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50268. */
  50269. intensity: number;
  50270. /**
  50271. * Defines if the effect is along the tangents, bitangents or in between.
  50272. * By default, the effect is "strectching" the highlights along the tangents.
  50273. */
  50274. direction: Vector2;
  50275. private _texture;
  50276. /**
  50277. * Stores the anisotropy values in a texture.
  50278. * rg is direction (like normal from -1 to 1)
  50279. * b is a intensity
  50280. */
  50281. texture: Nullable<BaseTexture>;
  50282. /** @hidden */
  50283. private _internalMarkAllSubMeshesAsTexturesDirty;
  50284. /** @hidden */
  50285. _markAllSubMeshesAsTexturesDirty(): void;
  50286. /**
  50287. * Instantiate a new istance of anisotropy configuration.
  50288. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50289. */
  50290. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50291. /**
  50292. * Specifies that the submesh is ready to be used.
  50293. * @param defines the list of "defines" to update.
  50294. * @param scene defines the scene the material belongs to.
  50295. * @returns - boolean indicating that the submesh is ready or not.
  50296. */
  50297. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50298. /**
  50299. * Checks to see if a texture is used in the material.
  50300. * @param defines the list of "defines" to update.
  50301. * @param mesh the mesh we are preparing the defines for.
  50302. * @param scene defines the scene the material belongs to.
  50303. */
  50304. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50305. /**
  50306. * Binds the material data.
  50307. * @param uniformBuffer defines the Uniform buffer to fill in.
  50308. * @param scene defines the scene the material belongs to.
  50309. * @param isFrozen defines wether the material is frozen or not.
  50310. */
  50311. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50312. /**
  50313. * Checks to see if a texture is used in the material.
  50314. * @param texture - Base texture to use.
  50315. * @returns - Boolean specifying if a texture is used in the material.
  50316. */
  50317. hasTexture(texture: BaseTexture): boolean;
  50318. /**
  50319. * Returns an array of the actively used textures.
  50320. * @param activeTextures Array of BaseTextures
  50321. */
  50322. getActiveTextures(activeTextures: BaseTexture[]): void;
  50323. /**
  50324. * Returns the animatable textures.
  50325. * @param animatables Array of animatable textures.
  50326. */
  50327. getAnimatables(animatables: IAnimatable[]): void;
  50328. /**
  50329. * Disposes the resources of the material.
  50330. * @param forceDisposeTextures - Forces the disposal of all textures.
  50331. */
  50332. dispose(forceDisposeTextures?: boolean): void;
  50333. /**
  50334. * Get the current class name of the texture useful for serialization or dynamic coding.
  50335. * @returns "PBRAnisotropicConfiguration"
  50336. */
  50337. getClassName(): string;
  50338. /**
  50339. * Add fallbacks to the effect fallbacks list.
  50340. * @param defines defines the Base texture to use.
  50341. * @param fallbacks defines the current fallback list.
  50342. * @param currentRank defines the current fallback rank.
  50343. * @returns the new fallback rank.
  50344. */
  50345. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50346. /**
  50347. * Add the required uniforms to the current list.
  50348. * @param uniforms defines the current uniform list.
  50349. */
  50350. static AddUniforms(uniforms: string[]): void;
  50351. /**
  50352. * Add the required uniforms to the current buffer.
  50353. * @param uniformBuffer defines the current uniform buffer.
  50354. */
  50355. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50356. /**
  50357. * Add the required samplers to the current list.
  50358. * @param samplers defines the current sampler list.
  50359. */
  50360. static AddSamplers(samplers: string[]): void;
  50361. /**
  50362. * Makes a duplicate of the current configuration into another one.
  50363. * @param anisotropicConfiguration define the config where to copy the info
  50364. */
  50365. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50366. /**
  50367. * Serializes this anisotropy configuration.
  50368. * @returns - An object with the serialized config.
  50369. */
  50370. serialize(): any;
  50371. /**
  50372. * Parses a anisotropy Configuration from a serialized object.
  50373. * @param source - Serialized object.
  50374. * @param scene Defines the scene we are parsing for
  50375. * @param rootUrl Defines the rootUrl to load from
  50376. */
  50377. parse(source: any, scene: Scene, rootUrl: string): void;
  50378. }
  50379. }
  50380. declare module BABYLON {
  50381. /**
  50382. * @hidden
  50383. */
  50384. export interface IMaterialBRDFDefines {
  50385. BRDF_V_HEIGHT_CORRELATED: boolean;
  50386. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50387. SPHERICAL_HARMONICS: boolean;
  50388. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50389. /** @hidden */
  50390. _areMiscDirty: boolean;
  50391. }
  50392. /**
  50393. * Define the code related to the BRDF parameters of the pbr material.
  50394. */
  50395. export class PBRBRDFConfiguration {
  50396. /**
  50397. * Default value used for the energy conservation.
  50398. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50399. */
  50400. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50401. /**
  50402. * Default value used for the Smith Visibility Height Correlated mode.
  50403. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50404. */
  50405. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50406. /**
  50407. * Default value used for the IBL diffuse part.
  50408. * This can help switching back to the polynomials mode globally which is a tiny bit
  50409. * less GPU intensive at the drawback of a lower quality.
  50410. */
  50411. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50412. /**
  50413. * Default value used for activating energy conservation for the specular workflow.
  50414. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50415. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50416. */
  50417. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50418. private _useEnergyConservation;
  50419. /**
  50420. * Defines if the material uses energy conservation.
  50421. */
  50422. useEnergyConservation: boolean;
  50423. private _useSmithVisibilityHeightCorrelated;
  50424. /**
  50425. * LEGACY Mode set to false
  50426. * Defines if the material uses height smith correlated visibility term.
  50427. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50428. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50429. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50430. * Not relying on height correlated will also disable energy conservation.
  50431. */
  50432. useSmithVisibilityHeightCorrelated: boolean;
  50433. private _useSphericalHarmonics;
  50434. /**
  50435. * LEGACY Mode set to false
  50436. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50437. * diffuse part of the IBL.
  50438. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50439. * to the ground truth.
  50440. */
  50441. useSphericalHarmonics: boolean;
  50442. private _useSpecularGlossinessInputEnergyConservation;
  50443. /**
  50444. * Defines if the material uses energy conservation, when the specular workflow is active.
  50445. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50446. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50447. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50448. */
  50449. useSpecularGlossinessInputEnergyConservation: boolean;
  50450. /** @hidden */
  50451. private _internalMarkAllSubMeshesAsMiscDirty;
  50452. /** @hidden */
  50453. _markAllSubMeshesAsMiscDirty(): void;
  50454. /**
  50455. * Instantiate a new istance of clear coat configuration.
  50456. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50457. */
  50458. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50459. /**
  50460. * Checks to see if a texture is used in the material.
  50461. * @param defines the list of "defines" to update.
  50462. */
  50463. prepareDefines(defines: IMaterialBRDFDefines): void;
  50464. /**
  50465. * Get the current class name of the texture useful for serialization or dynamic coding.
  50466. * @returns "PBRClearCoatConfiguration"
  50467. */
  50468. getClassName(): string;
  50469. /**
  50470. * Makes a duplicate of the current configuration into another one.
  50471. * @param brdfConfiguration define the config where to copy the info
  50472. */
  50473. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50474. /**
  50475. * Serializes this BRDF configuration.
  50476. * @returns - An object with the serialized config.
  50477. */
  50478. serialize(): any;
  50479. /**
  50480. * Parses a anisotropy Configuration from a serialized object.
  50481. * @param source - Serialized object.
  50482. * @param scene Defines the scene we are parsing for
  50483. * @param rootUrl Defines the rootUrl to load from
  50484. */
  50485. parse(source: any, scene: Scene, rootUrl: string): void;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. /**
  50490. * @hidden
  50491. */
  50492. export interface IMaterialSheenDefines {
  50493. SHEEN: boolean;
  50494. SHEEN_TEXTURE: boolean;
  50495. SHEEN_TEXTUREDIRECTUV: number;
  50496. SHEEN_LINKWITHALBEDO: boolean;
  50497. /** @hidden */
  50498. _areTexturesDirty: boolean;
  50499. }
  50500. /**
  50501. * Define the code related to the Sheen parameters of the pbr material.
  50502. */
  50503. export class PBRSheenConfiguration {
  50504. private _isEnabled;
  50505. /**
  50506. * Defines if the material uses sheen.
  50507. */
  50508. isEnabled: boolean;
  50509. private _linkSheenWithAlbedo;
  50510. /**
  50511. * Defines if the sheen is linked to the sheen color.
  50512. */
  50513. linkSheenWithAlbedo: boolean;
  50514. /**
  50515. * Defines the sheen intensity.
  50516. */
  50517. intensity: number;
  50518. /**
  50519. * Defines the sheen color.
  50520. */
  50521. color: Color3;
  50522. private _texture;
  50523. /**
  50524. * Stores the sheen tint values in a texture.
  50525. * rgb is tint
  50526. * a is a intensity
  50527. */
  50528. texture: Nullable<BaseTexture>;
  50529. /** @hidden */
  50530. private _internalMarkAllSubMeshesAsTexturesDirty;
  50531. /** @hidden */
  50532. _markAllSubMeshesAsTexturesDirty(): void;
  50533. /**
  50534. * Instantiate a new istance of clear coat configuration.
  50535. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50536. */
  50537. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50538. /**
  50539. * Specifies that the submesh is ready to be used.
  50540. * @param defines the list of "defines" to update.
  50541. * @param scene defines the scene the material belongs to.
  50542. * @returns - boolean indicating that the submesh is ready or not.
  50543. */
  50544. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50545. /**
  50546. * Checks to see if a texture is used in the material.
  50547. * @param defines the list of "defines" to update.
  50548. * @param scene defines the scene the material belongs to.
  50549. */
  50550. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50551. /**
  50552. * Binds the material data.
  50553. * @param uniformBuffer defines the Uniform buffer to fill in.
  50554. * @param scene defines the scene the material belongs to.
  50555. * @param isFrozen defines wether the material is frozen or not.
  50556. */
  50557. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50558. /**
  50559. * Checks to see if a texture is used in the material.
  50560. * @param texture - Base texture to use.
  50561. * @returns - Boolean specifying if a texture is used in the material.
  50562. */
  50563. hasTexture(texture: BaseTexture): boolean;
  50564. /**
  50565. * Returns an array of the actively used textures.
  50566. * @param activeTextures Array of BaseTextures
  50567. */
  50568. getActiveTextures(activeTextures: BaseTexture[]): void;
  50569. /**
  50570. * Returns the animatable textures.
  50571. * @param animatables Array of animatable textures.
  50572. */
  50573. getAnimatables(animatables: IAnimatable[]): void;
  50574. /**
  50575. * Disposes the resources of the material.
  50576. * @param forceDisposeTextures - Forces the disposal of all textures.
  50577. */
  50578. dispose(forceDisposeTextures?: boolean): void;
  50579. /**
  50580. * Get the current class name of the texture useful for serialization or dynamic coding.
  50581. * @returns "PBRSheenConfiguration"
  50582. */
  50583. getClassName(): string;
  50584. /**
  50585. * Add fallbacks to the effect fallbacks list.
  50586. * @param defines defines the Base texture to use.
  50587. * @param fallbacks defines the current fallback list.
  50588. * @param currentRank defines the current fallback rank.
  50589. * @returns the new fallback rank.
  50590. */
  50591. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50592. /**
  50593. * Add the required uniforms to the current list.
  50594. * @param uniforms defines the current uniform list.
  50595. */
  50596. static AddUniforms(uniforms: string[]): void;
  50597. /**
  50598. * Add the required uniforms to the current buffer.
  50599. * @param uniformBuffer defines the current uniform buffer.
  50600. */
  50601. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50602. /**
  50603. * Add the required samplers to the current list.
  50604. * @param samplers defines the current sampler list.
  50605. */
  50606. static AddSamplers(samplers: string[]): void;
  50607. /**
  50608. * Makes a duplicate of the current configuration into another one.
  50609. * @param sheenConfiguration define the config where to copy the info
  50610. */
  50611. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50612. /**
  50613. * Serializes this BRDF configuration.
  50614. * @returns - An object with the serialized config.
  50615. */
  50616. serialize(): any;
  50617. /**
  50618. * Parses a anisotropy Configuration from a serialized object.
  50619. * @param source - Serialized object.
  50620. * @param scene Defines the scene we are parsing for
  50621. * @param rootUrl Defines the rootUrl to load from
  50622. */
  50623. parse(source: any, scene: Scene, rootUrl: string): void;
  50624. }
  50625. }
  50626. declare module BABYLON {
  50627. /**
  50628. * @hidden
  50629. */
  50630. export interface IMaterialSubSurfaceDefines {
  50631. SUBSURFACE: boolean;
  50632. SS_REFRACTION: boolean;
  50633. SS_TRANSLUCENCY: boolean;
  50634. SS_SCATERRING: boolean;
  50635. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50636. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50637. SS_REFRACTIONMAP_3D: boolean;
  50638. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50639. SS_LODINREFRACTIONALPHA: boolean;
  50640. SS_GAMMAREFRACTION: boolean;
  50641. SS_RGBDREFRACTION: boolean;
  50642. SS_LINEARSPECULARREFRACTION: boolean;
  50643. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50644. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50645. /** @hidden */
  50646. _areTexturesDirty: boolean;
  50647. }
  50648. /**
  50649. * Define the code related to the sub surface parameters of the pbr material.
  50650. */
  50651. export class PBRSubSurfaceConfiguration {
  50652. private _isRefractionEnabled;
  50653. /**
  50654. * Defines if the refraction is enabled in the material.
  50655. */
  50656. isRefractionEnabled: boolean;
  50657. private _isTranslucencyEnabled;
  50658. /**
  50659. * Defines if the translucency is enabled in the material.
  50660. */
  50661. isTranslucencyEnabled: boolean;
  50662. private _isScatteringEnabled;
  50663. /**
  50664. * Defines the refraction intensity of the material.
  50665. * The refraction when enabled replaces the Diffuse part of the material.
  50666. * The intensity helps transitionning between diffuse and refraction.
  50667. */
  50668. refractionIntensity: number;
  50669. /**
  50670. * Defines the translucency intensity of the material.
  50671. * When translucency has been enabled, this defines how much of the "translucency"
  50672. * is addded to the diffuse part of the material.
  50673. */
  50674. translucencyIntensity: number;
  50675. /**
  50676. * Defines the scattering intensity of the material.
  50677. * When scattering has been enabled, this defines how much of the "scattered light"
  50678. * is addded to the diffuse part of the material.
  50679. */
  50680. scatteringIntensity: number;
  50681. private _thicknessTexture;
  50682. /**
  50683. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50684. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50685. * 0 would mean minimumThickness
  50686. * 1 would mean maximumThickness
  50687. * The other channels might be use as a mask to vary the different effects intensity.
  50688. */
  50689. thicknessTexture: Nullable<BaseTexture>;
  50690. private _refractionTexture;
  50691. /**
  50692. * Defines the texture to use for refraction.
  50693. */
  50694. refractionTexture: Nullable<BaseTexture>;
  50695. private _indexOfRefraction;
  50696. /**
  50697. * Defines the index of refraction used in the material.
  50698. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50699. */
  50700. indexOfRefraction: number;
  50701. private _invertRefractionY;
  50702. /**
  50703. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50704. */
  50705. invertRefractionY: boolean;
  50706. private _linkRefractionWithTransparency;
  50707. /**
  50708. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50709. * Materials half opaque for instance using refraction could benefit from this control.
  50710. */
  50711. linkRefractionWithTransparency: boolean;
  50712. /**
  50713. * Defines the minimum thickness stored in the thickness map.
  50714. * If no thickness map is defined, this value will be used to simulate thickness.
  50715. */
  50716. minimumThickness: number;
  50717. /**
  50718. * Defines the maximum thickness stored in the thickness map.
  50719. */
  50720. maximumThickness: number;
  50721. /**
  50722. * Defines the volume tint of the material.
  50723. * This is used for both translucency and scattering.
  50724. */
  50725. tintColor: Color3;
  50726. /**
  50727. * Defines the distance at which the tint color should be found in the media.
  50728. * This is used for refraction only.
  50729. */
  50730. tintColorAtDistance: number;
  50731. /**
  50732. * Defines how far each channel transmit through the media.
  50733. * It is defined as a color to simplify it selection.
  50734. */
  50735. diffusionDistance: Color3;
  50736. private _useMaskFromThicknessTexture;
  50737. /**
  50738. * Stores the intensity of the different subsurface effects in the thickness texture.
  50739. * * the green channel is the translucency intensity.
  50740. * * the blue channel is the scattering intensity.
  50741. * * the alpha channel is the refraction intensity.
  50742. */
  50743. useMaskFromThicknessTexture: boolean;
  50744. /** @hidden */
  50745. private _internalMarkAllSubMeshesAsTexturesDirty;
  50746. /** @hidden */
  50747. _markAllSubMeshesAsTexturesDirty(): void;
  50748. /**
  50749. * Instantiate a new istance of sub surface configuration.
  50750. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50751. */
  50752. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50753. /**
  50754. * Gets wehter the submesh is ready to be used or not.
  50755. * @param defines the list of "defines" to update.
  50756. * @param scene defines the scene the material belongs to.
  50757. * @returns - boolean indicating that the submesh is ready or not.
  50758. */
  50759. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50760. /**
  50761. * Checks to see if a texture is used in the material.
  50762. * @param defines the list of "defines" to update.
  50763. * @param scene defines the scene to the material belongs to.
  50764. */
  50765. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50766. /**
  50767. * Binds the material data.
  50768. * @param uniformBuffer defines the Uniform buffer to fill in.
  50769. * @param scene defines the scene the material belongs to.
  50770. * @param engine defines the engine the material belongs to.
  50771. * @param isFrozen defines wether the material is frozen or not.
  50772. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50773. */
  50774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50775. /**
  50776. * Unbinds the material from the mesh.
  50777. * @param activeEffect defines the effect that should be unbound from.
  50778. * @returns true if unbound, otherwise false
  50779. */
  50780. unbind(activeEffect: Effect): boolean;
  50781. /**
  50782. * Returns the texture used for refraction or null if none is used.
  50783. * @param scene defines the scene the material belongs to.
  50784. * @returns - Refraction texture if present. If no refraction texture and refraction
  50785. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50786. */
  50787. private _getRefractionTexture;
  50788. /**
  50789. * Returns true if alpha blending should be disabled.
  50790. */
  50791. get disableAlphaBlending(): boolean;
  50792. /**
  50793. * Fills the list of render target textures.
  50794. * @param renderTargets the list of render targets to update
  50795. */
  50796. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50797. /**
  50798. * Checks to see if a texture is used in the material.
  50799. * @param texture - Base texture to use.
  50800. * @returns - Boolean specifying if a texture is used in the material.
  50801. */
  50802. hasTexture(texture: BaseTexture): boolean;
  50803. /**
  50804. * Gets a boolean indicating that current material needs to register RTT
  50805. * @returns true if this uses a render target otherwise false.
  50806. */
  50807. hasRenderTargetTextures(): boolean;
  50808. /**
  50809. * Returns an array of the actively used textures.
  50810. * @param activeTextures Array of BaseTextures
  50811. */
  50812. getActiveTextures(activeTextures: BaseTexture[]): void;
  50813. /**
  50814. * Returns the animatable textures.
  50815. * @param animatables Array of animatable textures.
  50816. */
  50817. getAnimatables(animatables: IAnimatable[]): void;
  50818. /**
  50819. * Disposes the resources of the material.
  50820. * @param forceDisposeTextures - Forces the disposal of all textures.
  50821. */
  50822. dispose(forceDisposeTextures?: boolean): void;
  50823. /**
  50824. * Get the current class name of the texture useful for serialization or dynamic coding.
  50825. * @returns "PBRSubSurfaceConfiguration"
  50826. */
  50827. getClassName(): string;
  50828. /**
  50829. * Add fallbacks to the effect fallbacks list.
  50830. * @param defines defines the Base texture to use.
  50831. * @param fallbacks defines the current fallback list.
  50832. * @param currentRank defines the current fallback rank.
  50833. * @returns the new fallback rank.
  50834. */
  50835. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50836. /**
  50837. * Add the required uniforms to the current list.
  50838. * @param uniforms defines the current uniform list.
  50839. */
  50840. static AddUniforms(uniforms: string[]): void;
  50841. /**
  50842. * Add the required samplers to the current list.
  50843. * @param samplers defines the current sampler list.
  50844. */
  50845. static AddSamplers(samplers: string[]): void;
  50846. /**
  50847. * Add the required uniforms to the current buffer.
  50848. * @param uniformBuffer defines the current uniform buffer.
  50849. */
  50850. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50851. /**
  50852. * Makes a duplicate of the current configuration into another one.
  50853. * @param configuration define the config where to copy the info
  50854. */
  50855. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50856. /**
  50857. * Serializes this Sub Surface configuration.
  50858. * @returns - An object with the serialized config.
  50859. */
  50860. serialize(): any;
  50861. /**
  50862. * Parses a anisotropy Configuration from a serialized object.
  50863. * @param source - Serialized object.
  50864. * @param scene Defines the scene we are parsing for
  50865. * @param rootUrl Defines the rootUrl to load from
  50866. */
  50867. parse(source: any, scene: Scene, rootUrl: string): void;
  50868. }
  50869. }
  50870. declare module BABYLON {
  50871. /** @hidden */
  50872. export var pbrFragmentDeclaration: {
  50873. name: string;
  50874. shader: string;
  50875. };
  50876. }
  50877. declare module BABYLON {
  50878. /** @hidden */
  50879. export var pbrUboDeclaration: {
  50880. name: string;
  50881. shader: string;
  50882. };
  50883. }
  50884. declare module BABYLON {
  50885. /** @hidden */
  50886. export var pbrFragmentExtraDeclaration: {
  50887. name: string;
  50888. shader: string;
  50889. };
  50890. }
  50891. declare module BABYLON {
  50892. /** @hidden */
  50893. export var pbrFragmentSamplersDeclaration: {
  50894. name: string;
  50895. shader: string;
  50896. };
  50897. }
  50898. declare module BABYLON {
  50899. /** @hidden */
  50900. export var pbrHelperFunctions: {
  50901. name: string;
  50902. shader: string;
  50903. };
  50904. }
  50905. declare module BABYLON {
  50906. /** @hidden */
  50907. export var harmonicsFunctions: {
  50908. name: string;
  50909. shader: string;
  50910. };
  50911. }
  50912. declare module BABYLON {
  50913. /** @hidden */
  50914. export var pbrDirectLightingSetupFunctions: {
  50915. name: string;
  50916. shader: string;
  50917. };
  50918. }
  50919. declare module BABYLON {
  50920. /** @hidden */
  50921. export var pbrDirectLightingFalloffFunctions: {
  50922. name: string;
  50923. shader: string;
  50924. };
  50925. }
  50926. declare module BABYLON {
  50927. /** @hidden */
  50928. export var pbrBRDFFunctions: {
  50929. name: string;
  50930. shader: string;
  50931. };
  50932. }
  50933. declare module BABYLON {
  50934. /** @hidden */
  50935. export var pbrDirectLightingFunctions: {
  50936. name: string;
  50937. shader: string;
  50938. };
  50939. }
  50940. declare module BABYLON {
  50941. /** @hidden */
  50942. export var pbrIBLFunctions: {
  50943. name: string;
  50944. shader: string;
  50945. };
  50946. }
  50947. declare module BABYLON {
  50948. /** @hidden */
  50949. export var pbrDebug: {
  50950. name: string;
  50951. shader: string;
  50952. };
  50953. }
  50954. declare module BABYLON {
  50955. /** @hidden */
  50956. export var pbrPixelShader: {
  50957. name: string;
  50958. shader: string;
  50959. };
  50960. }
  50961. declare module BABYLON {
  50962. /** @hidden */
  50963. export var pbrVertexDeclaration: {
  50964. name: string;
  50965. shader: string;
  50966. };
  50967. }
  50968. declare module BABYLON {
  50969. /** @hidden */
  50970. export var pbrVertexShader: {
  50971. name: string;
  50972. shader: string;
  50973. };
  50974. }
  50975. declare module BABYLON {
  50976. /**
  50977. * Manages the defines for the PBR Material.
  50978. * @hidden
  50979. */
  50980. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50981. PBR: boolean;
  50982. MAINUV1: boolean;
  50983. MAINUV2: boolean;
  50984. UV1: boolean;
  50985. UV2: boolean;
  50986. ALBEDO: boolean;
  50987. ALBEDODIRECTUV: number;
  50988. VERTEXCOLOR: boolean;
  50989. AMBIENT: boolean;
  50990. AMBIENTDIRECTUV: number;
  50991. AMBIENTINGRAYSCALE: boolean;
  50992. OPACITY: boolean;
  50993. VERTEXALPHA: boolean;
  50994. OPACITYDIRECTUV: number;
  50995. OPACITYRGB: boolean;
  50996. ALPHATEST: boolean;
  50997. DEPTHPREPASS: boolean;
  50998. ALPHABLEND: boolean;
  50999. ALPHAFROMALBEDO: boolean;
  51000. ALPHATESTVALUE: string;
  51001. SPECULAROVERALPHA: boolean;
  51002. RADIANCEOVERALPHA: boolean;
  51003. ALPHAFRESNEL: boolean;
  51004. LINEARALPHAFRESNEL: boolean;
  51005. PREMULTIPLYALPHA: boolean;
  51006. EMISSIVE: boolean;
  51007. EMISSIVEDIRECTUV: number;
  51008. REFLECTIVITY: boolean;
  51009. REFLECTIVITYDIRECTUV: number;
  51010. SPECULARTERM: boolean;
  51011. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51012. MICROSURFACEAUTOMATIC: boolean;
  51013. LODBASEDMICROSFURACE: boolean;
  51014. MICROSURFACEMAP: boolean;
  51015. MICROSURFACEMAPDIRECTUV: number;
  51016. METALLICWORKFLOW: boolean;
  51017. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51018. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51019. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51020. AOSTOREINMETALMAPRED: boolean;
  51021. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51022. ENVIRONMENTBRDF: boolean;
  51023. ENVIRONMENTBRDF_RGBD: boolean;
  51024. NORMAL: boolean;
  51025. TANGENT: boolean;
  51026. BUMP: boolean;
  51027. BUMPDIRECTUV: number;
  51028. OBJECTSPACE_NORMALMAP: boolean;
  51029. PARALLAX: boolean;
  51030. PARALLAXOCCLUSION: boolean;
  51031. NORMALXYSCALE: boolean;
  51032. LIGHTMAP: boolean;
  51033. LIGHTMAPDIRECTUV: number;
  51034. USELIGHTMAPASSHADOWMAP: boolean;
  51035. GAMMALIGHTMAP: boolean;
  51036. RGBDLIGHTMAP: boolean;
  51037. REFLECTION: boolean;
  51038. REFLECTIONMAP_3D: boolean;
  51039. REFLECTIONMAP_SPHERICAL: boolean;
  51040. REFLECTIONMAP_PLANAR: boolean;
  51041. REFLECTIONMAP_CUBIC: boolean;
  51042. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51043. REFLECTIONMAP_PROJECTION: boolean;
  51044. REFLECTIONMAP_SKYBOX: boolean;
  51045. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  51046. REFLECTIONMAP_EXPLICIT: boolean;
  51047. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51048. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51049. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51050. INVERTCUBICMAP: boolean;
  51051. USESPHERICALFROMREFLECTIONMAP: boolean;
  51052. USEIRRADIANCEMAP: boolean;
  51053. SPHERICAL_HARMONICS: boolean;
  51054. USESPHERICALINVERTEX: boolean;
  51055. REFLECTIONMAP_OPPOSITEZ: boolean;
  51056. LODINREFLECTIONALPHA: boolean;
  51057. GAMMAREFLECTION: boolean;
  51058. RGBDREFLECTION: boolean;
  51059. LINEARSPECULARREFLECTION: boolean;
  51060. RADIANCEOCCLUSION: boolean;
  51061. HORIZONOCCLUSION: boolean;
  51062. INSTANCES: boolean;
  51063. NUM_BONE_INFLUENCERS: number;
  51064. BonesPerMesh: number;
  51065. BONETEXTURE: boolean;
  51066. NONUNIFORMSCALING: boolean;
  51067. MORPHTARGETS: boolean;
  51068. MORPHTARGETS_NORMAL: boolean;
  51069. MORPHTARGETS_TANGENT: boolean;
  51070. MORPHTARGETS_UV: boolean;
  51071. NUM_MORPH_INFLUENCERS: number;
  51072. IMAGEPROCESSING: boolean;
  51073. VIGNETTE: boolean;
  51074. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51075. VIGNETTEBLENDMODEOPAQUE: boolean;
  51076. TONEMAPPING: boolean;
  51077. TONEMAPPING_ACES: boolean;
  51078. CONTRAST: boolean;
  51079. COLORCURVES: boolean;
  51080. COLORGRADING: boolean;
  51081. COLORGRADING3D: boolean;
  51082. SAMPLER3DGREENDEPTH: boolean;
  51083. SAMPLER3DBGRMAP: boolean;
  51084. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51085. EXPOSURE: boolean;
  51086. MULTIVIEW: boolean;
  51087. USEPHYSICALLIGHTFALLOFF: boolean;
  51088. USEGLTFLIGHTFALLOFF: boolean;
  51089. TWOSIDEDLIGHTING: boolean;
  51090. SHADOWFLOAT: boolean;
  51091. CLIPPLANE: boolean;
  51092. CLIPPLANE2: boolean;
  51093. CLIPPLANE3: boolean;
  51094. CLIPPLANE4: boolean;
  51095. CLIPPLANE5: boolean;
  51096. CLIPPLANE6: boolean;
  51097. POINTSIZE: boolean;
  51098. FOG: boolean;
  51099. LOGARITHMICDEPTH: boolean;
  51100. FORCENORMALFORWARD: boolean;
  51101. SPECULARAA: boolean;
  51102. CLEARCOAT: boolean;
  51103. CLEARCOAT_DEFAULTIOR: boolean;
  51104. CLEARCOAT_TEXTURE: boolean;
  51105. CLEARCOAT_TEXTUREDIRECTUV: number;
  51106. CLEARCOAT_BUMP: boolean;
  51107. CLEARCOAT_BUMPDIRECTUV: number;
  51108. CLEARCOAT_TINT: boolean;
  51109. CLEARCOAT_TINT_TEXTURE: boolean;
  51110. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51111. ANISOTROPIC: boolean;
  51112. ANISOTROPIC_TEXTURE: boolean;
  51113. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51114. BRDF_V_HEIGHT_CORRELATED: boolean;
  51115. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51116. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51117. SHEEN: boolean;
  51118. SHEEN_TEXTURE: boolean;
  51119. SHEEN_TEXTUREDIRECTUV: number;
  51120. SHEEN_LINKWITHALBEDO: boolean;
  51121. SUBSURFACE: boolean;
  51122. SS_REFRACTION: boolean;
  51123. SS_TRANSLUCENCY: boolean;
  51124. SS_SCATERRING: boolean;
  51125. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51126. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51127. SS_REFRACTIONMAP_3D: boolean;
  51128. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51129. SS_LODINREFRACTIONALPHA: boolean;
  51130. SS_GAMMAREFRACTION: boolean;
  51131. SS_RGBDREFRACTION: boolean;
  51132. SS_LINEARSPECULARREFRACTION: boolean;
  51133. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51134. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51135. UNLIT: boolean;
  51136. DEBUGMODE: number;
  51137. /**
  51138. * Initializes the PBR Material defines.
  51139. */
  51140. constructor();
  51141. /**
  51142. * Resets the PBR Material defines.
  51143. */
  51144. reset(): void;
  51145. }
  51146. /**
  51147. * The Physically based material base class of BJS.
  51148. *
  51149. * This offers the main features of a standard PBR material.
  51150. * For more information, please refer to the documentation :
  51151. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51152. */
  51153. export abstract class PBRBaseMaterial extends PushMaterial {
  51154. /**
  51155. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51156. */
  51157. static readonly PBRMATERIAL_OPAQUE: number;
  51158. /**
  51159. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51160. */
  51161. static readonly PBRMATERIAL_ALPHATEST: number;
  51162. /**
  51163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51164. */
  51165. static readonly PBRMATERIAL_ALPHABLEND: number;
  51166. /**
  51167. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51168. * They are also discarded below the alpha cutoff threshold to improve performances.
  51169. */
  51170. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51171. /**
  51172. * Defines the default value of how much AO map is occluding the analytical lights
  51173. * (point spot...).
  51174. */
  51175. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51176. /**
  51177. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51178. */
  51179. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51180. /**
  51181. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51182. * to enhance interoperability with other engines.
  51183. */
  51184. static readonly LIGHTFALLOFF_GLTF: number;
  51185. /**
  51186. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51187. * to enhance interoperability with other materials.
  51188. */
  51189. static readonly LIGHTFALLOFF_STANDARD: number;
  51190. /**
  51191. * Intensity of the direct lights e.g. the four lights available in your scene.
  51192. * This impacts both the direct diffuse and specular highlights.
  51193. */
  51194. protected _directIntensity: number;
  51195. /**
  51196. * Intensity of the emissive part of the material.
  51197. * This helps controlling the emissive effect without modifying the emissive color.
  51198. */
  51199. protected _emissiveIntensity: number;
  51200. /**
  51201. * Intensity of the environment e.g. how much the environment will light the object
  51202. * either through harmonics for rough material or through the refelction for shiny ones.
  51203. */
  51204. protected _environmentIntensity: number;
  51205. /**
  51206. * This is a special control allowing the reduction of the specular highlights coming from the
  51207. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51208. */
  51209. protected _specularIntensity: number;
  51210. /**
  51211. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51212. */
  51213. private _lightingInfos;
  51214. /**
  51215. * Debug Control allowing disabling the bump map on this material.
  51216. */
  51217. protected _disableBumpMap: boolean;
  51218. /**
  51219. * AKA Diffuse Texture in standard nomenclature.
  51220. */
  51221. protected _albedoTexture: Nullable<BaseTexture>;
  51222. /**
  51223. * AKA Occlusion Texture in other nomenclature.
  51224. */
  51225. protected _ambientTexture: Nullable<BaseTexture>;
  51226. /**
  51227. * AKA Occlusion Texture Intensity in other nomenclature.
  51228. */
  51229. protected _ambientTextureStrength: number;
  51230. /**
  51231. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51232. * 1 means it completely occludes it
  51233. * 0 mean it has no impact
  51234. */
  51235. protected _ambientTextureImpactOnAnalyticalLights: number;
  51236. /**
  51237. * Stores the alpha values in a texture.
  51238. */
  51239. protected _opacityTexture: Nullable<BaseTexture>;
  51240. /**
  51241. * Stores the reflection values in a texture.
  51242. */
  51243. protected _reflectionTexture: Nullable<BaseTexture>;
  51244. /**
  51245. * Stores the emissive values in a texture.
  51246. */
  51247. protected _emissiveTexture: Nullable<BaseTexture>;
  51248. /**
  51249. * AKA Specular texture in other nomenclature.
  51250. */
  51251. protected _reflectivityTexture: Nullable<BaseTexture>;
  51252. /**
  51253. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51254. */
  51255. protected _metallicTexture: Nullable<BaseTexture>;
  51256. /**
  51257. * Specifies the metallic scalar of the metallic/roughness workflow.
  51258. * Can also be used to scale the metalness values of the metallic texture.
  51259. */
  51260. protected _metallic: Nullable<number>;
  51261. /**
  51262. * Specifies the roughness scalar of the metallic/roughness workflow.
  51263. * Can also be used to scale the roughness values of the metallic texture.
  51264. */
  51265. protected _roughness: Nullable<number>;
  51266. /**
  51267. * Specifies the an F0 factor to help configuring the material F0.
  51268. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51269. * to 0.5 the previously hard coded value stays the same.
  51270. * Can also be used to scale the F0 values of the metallic texture.
  51271. */
  51272. protected _metallicF0Factor: number;
  51273. /**
  51274. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51275. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51276. * your expectation as it multiplies with the texture data.
  51277. */
  51278. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51279. /**
  51280. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51281. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51282. */
  51283. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51284. /**
  51285. * Stores surface normal data used to displace a mesh in a texture.
  51286. */
  51287. protected _bumpTexture: Nullable<BaseTexture>;
  51288. /**
  51289. * Stores the pre-calculated light information of a mesh in a texture.
  51290. */
  51291. protected _lightmapTexture: Nullable<BaseTexture>;
  51292. /**
  51293. * The color of a material in ambient lighting.
  51294. */
  51295. protected _ambientColor: Color3;
  51296. /**
  51297. * AKA Diffuse Color in other nomenclature.
  51298. */
  51299. protected _albedoColor: Color3;
  51300. /**
  51301. * AKA Specular Color in other nomenclature.
  51302. */
  51303. protected _reflectivityColor: Color3;
  51304. /**
  51305. * The color applied when light is reflected from a material.
  51306. */
  51307. protected _reflectionColor: Color3;
  51308. /**
  51309. * The color applied when light is emitted from a material.
  51310. */
  51311. protected _emissiveColor: Color3;
  51312. /**
  51313. * AKA Glossiness in other nomenclature.
  51314. */
  51315. protected _microSurface: number;
  51316. /**
  51317. * Specifies that the material will use the light map as a show map.
  51318. */
  51319. protected _useLightmapAsShadowmap: boolean;
  51320. /**
  51321. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51322. * makes the reflect vector face the model (under horizon).
  51323. */
  51324. protected _useHorizonOcclusion: boolean;
  51325. /**
  51326. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51327. * too much the area relying on ambient texture to define their ambient occlusion.
  51328. */
  51329. protected _useRadianceOcclusion: boolean;
  51330. /**
  51331. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51332. */
  51333. protected _useAlphaFromAlbedoTexture: boolean;
  51334. /**
  51335. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51336. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51337. */
  51338. protected _useSpecularOverAlpha: boolean;
  51339. /**
  51340. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51341. */
  51342. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51343. /**
  51344. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51345. */
  51346. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51347. /**
  51348. * Specifies if the metallic texture contains the roughness information in its green channel.
  51349. */
  51350. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51351. /**
  51352. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51353. */
  51354. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51355. /**
  51356. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51357. */
  51358. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51359. /**
  51360. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51361. */
  51362. protected _useAmbientInGrayScale: boolean;
  51363. /**
  51364. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51365. * The material will try to infer what glossiness each pixel should be.
  51366. */
  51367. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51368. /**
  51369. * Defines the falloff type used in this material.
  51370. * It by default is Physical.
  51371. */
  51372. protected _lightFalloff: number;
  51373. /**
  51374. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51375. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51376. */
  51377. protected _useRadianceOverAlpha: boolean;
  51378. /**
  51379. * Allows using an object space normal map (instead of tangent space).
  51380. */
  51381. protected _useObjectSpaceNormalMap: boolean;
  51382. /**
  51383. * Allows using the bump map in parallax mode.
  51384. */
  51385. protected _useParallax: boolean;
  51386. /**
  51387. * Allows using the bump map in parallax occlusion mode.
  51388. */
  51389. protected _useParallaxOcclusion: boolean;
  51390. /**
  51391. * Controls the scale bias of the parallax mode.
  51392. */
  51393. protected _parallaxScaleBias: number;
  51394. /**
  51395. * If sets to true, disables all the lights affecting the material.
  51396. */
  51397. protected _disableLighting: boolean;
  51398. /**
  51399. * Number of Simultaneous lights allowed on the material.
  51400. */
  51401. protected _maxSimultaneousLights: number;
  51402. /**
  51403. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51404. */
  51405. protected _invertNormalMapX: boolean;
  51406. /**
  51407. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51408. */
  51409. protected _invertNormalMapY: boolean;
  51410. /**
  51411. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51412. */
  51413. protected _twoSidedLighting: boolean;
  51414. /**
  51415. * Defines the alpha limits in alpha test mode.
  51416. */
  51417. protected _alphaCutOff: number;
  51418. /**
  51419. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51420. */
  51421. protected _forceAlphaTest: boolean;
  51422. /**
  51423. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51424. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51425. */
  51426. protected _useAlphaFresnel: boolean;
  51427. /**
  51428. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51429. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51430. */
  51431. protected _useLinearAlphaFresnel: boolean;
  51432. /**
  51433. * The transparency mode of the material.
  51434. */
  51435. protected _transparencyMode: Nullable<number>;
  51436. /**
  51437. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51438. * from cos thetav and roughness:
  51439. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51440. */
  51441. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51442. /**
  51443. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51444. */
  51445. protected _forceIrradianceInFragment: boolean;
  51446. /**
  51447. * Force normal to face away from face.
  51448. */
  51449. protected _forceNormalForward: boolean;
  51450. /**
  51451. * Enables specular anti aliasing in the PBR shader.
  51452. * It will both interacts on the Geometry for analytical and IBL lighting.
  51453. * It also prefilter the roughness map based on the bump values.
  51454. */
  51455. protected _enableSpecularAntiAliasing: boolean;
  51456. /**
  51457. * Default configuration related to image processing available in the PBR Material.
  51458. */
  51459. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51460. /**
  51461. * Keep track of the image processing observer to allow dispose and replace.
  51462. */
  51463. private _imageProcessingObserver;
  51464. /**
  51465. * Attaches a new image processing configuration to the PBR Material.
  51466. * @param configuration
  51467. */
  51468. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51469. /**
  51470. * Stores the available render targets.
  51471. */
  51472. private _renderTargets;
  51473. /**
  51474. * Sets the global ambient color for the material used in lighting calculations.
  51475. */
  51476. private _globalAmbientColor;
  51477. /**
  51478. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51479. */
  51480. private _useLogarithmicDepth;
  51481. /**
  51482. * If set to true, no lighting calculations will be applied.
  51483. */
  51484. private _unlit;
  51485. private _debugMode;
  51486. /**
  51487. * @hidden
  51488. * This is reserved for the inspector.
  51489. * Defines the material debug mode.
  51490. * It helps seeing only some components of the material while troubleshooting.
  51491. */
  51492. debugMode: number;
  51493. /**
  51494. * @hidden
  51495. * This is reserved for the inspector.
  51496. * Specify from where on screen the debug mode should start.
  51497. * The value goes from -1 (full screen) to 1 (not visible)
  51498. * It helps with side by side comparison against the final render
  51499. * This defaults to -1
  51500. */
  51501. private debugLimit;
  51502. /**
  51503. * @hidden
  51504. * This is reserved for the inspector.
  51505. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51506. * You can use the factor to better multiply the final value.
  51507. */
  51508. private debugFactor;
  51509. /**
  51510. * Defines the clear coat layer parameters for the material.
  51511. */
  51512. readonly clearCoat: PBRClearCoatConfiguration;
  51513. /**
  51514. * Defines the anisotropic parameters for the material.
  51515. */
  51516. readonly anisotropy: PBRAnisotropicConfiguration;
  51517. /**
  51518. * Defines the BRDF parameters for the material.
  51519. */
  51520. readonly brdf: PBRBRDFConfiguration;
  51521. /**
  51522. * Defines the Sheen parameters for the material.
  51523. */
  51524. readonly sheen: PBRSheenConfiguration;
  51525. /**
  51526. * Defines the SubSurface parameters for the material.
  51527. */
  51528. readonly subSurface: PBRSubSurfaceConfiguration;
  51529. /**
  51530. * Custom callback helping to override the default shader used in the material.
  51531. */
  51532. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51533. protected _rebuildInParallel: boolean;
  51534. /**
  51535. * Instantiates a new PBRMaterial instance.
  51536. *
  51537. * @param name The material name
  51538. * @param scene The scene the material will be use in.
  51539. */
  51540. constructor(name: string, scene: Scene);
  51541. /**
  51542. * Gets a boolean indicating that current material needs to register RTT
  51543. */
  51544. get hasRenderTargetTextures(): boolean;
  51545. /**
  51546. * Gets the name of the material class.
  51547. */
  51548. getClassName(): string;
  51549. /**
  51550. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51551. */
  51552. get useLogarithmicDepth(): boolean;
  51553. /**
  51554. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51555. */
  51556. set useLogarithmicDepth(value: boolean);
  51557. /**
  51558. * Gets the current transparency mode.
  51559. */
  51560. get transparencyMode(): Nullable<number>;
  51561. /**
  51562. * Sets the transparency mode of the material.
  51563. *
  51564. * | Value | Type | Description |
  51565. * | ----- | ----------------------------------- | ----------- |
  51566. * | 0 | OPAQUE | |
  51567. * | 1 | ALPHATEST | |
  51568. * | 2 | ALPHABLEND | |
  51569. * | 3 | ALPHATESTANDBLEND | |
  51570. *
  51571. */
  51572. set transparencyMode(value: Nullable<number>);
  51573. /**
  51574. * Returns true if alpha blending should be disabled.
  51575. */
  51576. private get _disableAlphaBlending();
  51577. /**
  51578. * Specifies whether or not this material should be rendered in alpha blend mode.
  51579. */
  51580. needAlphaBlending(): boolean;
  51581. /**
  51582. * Specifies if the mesh will require alpha blending.
  51583. * @param mesh - BJS mesh.
  51584. */
  51585. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51586. /**
  51587. * Specifies whether or not this material should be rendered in alpha test mode.
  51588. */
  51589. needAlphaTesting(): boolean;
  51590. /**
  51591. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51592. */
  51593. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51594. /**
  51595. * Gets the texture used for the alpha test.
  51596. */
  51597. getAlphaTestTexture(): Nullable<BaseTexture>;
  51598. /**
  51599. * Specifies that the submesh is ready to be used.
  51600. * @param mesh - BJS mesh.
  51601. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51602. * @param useInstances - Specifies that instances should be used.
  51603. * @returns - boolean indicating that the submesh is ready or not.
  51604. */
  51605. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51606. /**
  51607. * Specifies if the material uses metallic roughness workflow.
  51608. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51609. */
  51610. isMetallicWorkflow(): boolean;
  51611. private _prepareEffect;
  51612. private _prepareDefines;
  51613. /**
  51614. * Force shader compilation
  51615. */
  51616. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51617. /**
  51618. * Initializes the uniform buffer layout for the shader.
  51619. */
  51620. buildUniformLayout(): void;
  51621. /**
  51622. * Unbinds the material from the mesh
  51623. */
  51624. unbind(): void;
  51625. /**
  51626. * Binds the submesh data.
  51627. * @param world - The world matrix.
  51628. * @param mesh - The BJS mesh.
  51629. * @param subMesh - A submesh of the BJS mesh.
  51630. */
  51631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51632. /**
  51633. * Returns the animatable textures.
  51634. * @returns - Array of animatable textures.
  51635. */
  51636. getAnimatables(): IAnimatable[];
  51637. /**
  51638. * Returns the texture used for reflections.
  51639. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51640. */
  51641. private _getReflectionTexture;
  51642. /**
  51643. * Returns an array of the actively used textures.
  51644. * @returns - Array of BaseTextures
  51645. */
  51646. getActiveTextures(): BaseTexture[];
  51647. /**
  51648. * Checks to see if a texture is used in the material.
  51649. * @param texture - Base texture to use.
  51650. * @returns - Boolean specifying if a texture is used in the material.
  51651. */
  51652. hasTexture(texture: BaseTexture): boolean;
  51653. /**
  51654. * Disposes the resources of the material.
  51655. * @param forceDisposeEffect - Forces the disposal of effects.
  51656. * @param forceDisposeTextures - Forces the disposal of all textures.
  51657. */
  51658. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51659. }
  51660. }
  51661. declare module BABYLON {
  51662. /**
  51663. * The Physically based material of BJS.
  51664. *
  51665. * This offers the main features of a standard PBR material.
  51666. * For more information, please refer to the documentation :
  51667. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51668. */
  51669. export class PBRMaterial extends PBRBaseMaterial {
  51670. /**
  51671. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51672. */
  51673. static readonly PBRMATERIAL_OPAQUE: number;
  51674. /**
  51675. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51676. */
  51677. static readonly PBRMATERIAL_ALPHATEST: number;
  51678. /**
  51679. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51680. */
  51681. static readonly PBRMATERIAL_ALPHABLEND: number;
  51682. /**
  51683. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51684. * They are also discarded below the alpha cutoff threshold to improve performances.
  51685. */
  51686. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51687. /**
  51688. * Defines the default value of how much AO map is occluding the analytical lights
  51689. * (point spot...).
  51690. */
  51691. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51692. /**
  51693. * Intensity of the direct lights e.g. the four lights available in your scene.
  51694. * This impacts both the direct diffuse and specular highlights.
  51695. */
  51696. directIntensity: number;
  51697. /**
  51698. * Intensity of the emissive part of the material.
  51699. * This helps controlling the emissive effect without modifying the emissive color.
  51700. */
  51701. emissiveIntensity: number;
  51702. /**
  51703. * Intensity of the environment e.g. how much the environment will light the object
  51704. * either through harmonics for rough material or through the refelction for shiny ones.
  51705. */
  51706. environmentIntensity: number;
  51707. /**
  51708. * This is a special control allowing the reduction of the specular highlights coming from the
  51709. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51710. */
  51711. specularIntensity: number;
  51712. /**
  51713. * Debug Control allowing disabling the bump map on this material.
  51714. */
  51715. disableBumpMap: boolean;
  51716. /**
  51717. * AKA Diffuse Texture in standard nomenclature.
  51718. */
  51719. albedoTexture: BaseTexture;
  51720. /**
  51721. * AKA Occlusion Texture in other nomenclature.
  51722. */
  51723. ambientTexture: BaseTexture;
  51724. /**
  51725. * AKA Occlusion Texture Intensity in other nomenclature.
  51726. */
  51727. ambientTextureStrength: number;
  51728. /**
  51729. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51730. * 1 means it completely occludes it
  51731. * 0 mean it has no impact
  51732. */
  51733. ambientTextureImpactOnAnalyticalLights: number;
  51734. /**
  51735. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51736. */
  51737. opacityTexture: BaseTexture;
  51738. /**
  51739. * Stores the reflection values in a texture.
  51740. */
  51741. reflectionTexture: Nullable<BaseTexture>;
  51742. /**
  51743. * Stores the emissive values in a texture.
  51744. */
  51745. emissiveTexture: BaseTexture;
  51746. /**
  51747. * AKA Specular texture in other nomenclature.
  51748. */
  51749. reflectivityTexture: BaseTexture;
  51750. /**
  51751. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51752. */
  51753. metallicTexture: BaseTexture;
  51754. /**
  51755. * Specifies the metallic scalar of the metallic/roughness workflow.
  51756. * Can also be used to scale the metalness values of the metallic texture.
  51757. */
  51758. metallic: Nullable<number>;
  51759. /**
  51760. * Specifies the roughness scalar of the metallic/roughness workflow.
  51761. * Can also be used to scale the roughness values of the metallic texture.
  51762. */
  51763. roughness: Nullable<number>;
  51764. /**
  51765. * Specifies the an F0 factor to help configuring the material F0.
  51766. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51767. * to 0.5 the previously hard coded value stays the same.
  51768. * Can also be used to scale the F0 values of the metallic texture.
  51769. */
  51770. metallicF0Factor: number;
  51771. /**
  51772. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51773. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51774. * your expectation as it multiplies with the texture data.
  51775. */
  51776. useMetallicF0FactorFromMetallicTexture: boolean;
  51777. /**
  51778. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51779. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51780. */
  51781. microSurfaceTexture: BaseTexture;
  51782. /**
  51783. * Stores surface normal data used to displace a mesh in a texture.
  51784. */
  51785. bumpTexture: BaseTexture;
  51786. /**
  51787. * Stores the pre-calculated light information of a mesh in a texture.
  51788. */
  51789. lightmapTexture: BaseTexture;
  51790. /**
  51791. * Stores the refracted light information in a texture.
  51792. */
  51793. get refractionTexture(): Nullable<BaseTexture>;
  51794. set refractionTexture(value: Nullable<BaseTexture>);
  51795. /**
  51796. * The color of a material in ambient lighting.
  51797. */
  51798. ambientColor: Color3;
  51799. /**
  51800. * AKA Diffuse Color in other nomenclature.
  51801. */
  51802. albedoColor: Color3;
  51803. /**
  51804. * AKA Specular Color in other nomenclature.
  51805. */
  51806. reflectivityColor: Color3;
  51807. /**
  51808. * The color reflected from the material.
  51809. */
  51810. reflectionColor: Color3;
  51811. /**
  51812. * The color emitted from the material.
  51813. */
  51814. emissiveColor: Color3;
  51815. /**
  51816. * AKA Glossiness in other nomenclature.
  51817. */
  51818. microSurface: number;
  51819. /**
  51820. * source material index of refraction (IOR)' / 'destination material IOR.
  51821. */
  51822. get indexOfRefraction(): number;
  51823. set indexOfRefraction(value: number);
  51824. /**
  51825. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51826. */
  51827. get invertRefractionY(): boolean;
  51828. set invertRefractionY(value: boolean);
  51829. /**
  51830. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51831. * Materials half opaque for instance using refraction could benefit from this control.
  51832. */
  51833. get linkRefractionWithTransparency(): boolean;
  51834. set linkRefractionWithTransparency(value: boolean);
  51835. /**
  51836. * If true, the light map contains occlusion information instead of lighting info.
  51837. */
  51838. useLightmapAsShadowmap: boolean;
  51839. /**
  51840. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51841. */
  51842. useAlphaFromAlbedoTexture: boolean;
  51843. /**
  51844. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51845. */
  51846. forceAlphaTest: boolean;
  51847. /**
  51848. * Defines the alpha limits in alpha test mode.
  51849. */
  51850. alphaCutOff: number;
  51851. /**
  51852. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51853. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51854. */
  51855. useSpecularOverAlpha: boolean;
  51856. /**
  51857. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51858. */
  51859. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51860. /**
  51861. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51862. */
  51863. useRoughnessFromMetallicTextureAlpha: boolean;
  51864. /**
  51865. * Specifies if the metallic texture contains the roughness information in its green channel.
  51866. */
  51867. useRoughnessFromMetallicTextureGreen: boolean;
  51868. /**
  51869. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51870. */
  51871. useMetallnessFromMetallicTextureBlue: boolean;
  51872. /**
  51873. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51874. */
  51875. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51876. /**
  51877. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51878. */
  51879. useAmbientInGrayScale: boolean;
  51880. /**
  51881. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51882. * The material will try to infer what glossiness each pixel should be.
  51883. */
  51884. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51885. /**
  51886. * BJS is using an harcoded light falloff based on a manually sets up range.
  51887. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51888. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51889. */
  51890. get usePhysicalLightFalloff(): boolean;
  51891. /**
  51892. * BJS is using an harcoded light falloff based on a manually sets up range.
  51893. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51894. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51895. */
  51896. set usePhysicalLightFalloff(value: boolean);
  51897. /**
  51898. * In order to support the falloff compatibility with gltf, a special mode has been added
  51899. * to reproduce the gltf light falloff.
  51900. */
  51901. get useGLTFLightFalloff(): boolean;
  51902. /**
  51903. * In order to support the falloff compatibility with gltf, a special mode has been added
  51904. * to reproduce the gltf light falloff.
  51905. */
  51906. set useGLTFLightFalloff(value: boolean);
  51907. /**
  51908. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51909. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51910. */
  51911. useRadianceOverAlpha: boolean;
  51912. /**
  51913. * Allows using an object space normal map (instead of tangent space).
  51914. */
  51915. useObjectSpaceNormalMap: boolean;
  51916. /**
  51917. * Allows using the bump map in parallax mode.
  51918. */
  51919. useParallax: boolean;
  51920. /**
  51921. * Allows using the bump map in parallax occlusion mode.
  51922. */
  51923. useParallaxOcclusion: boolean;
  51924. /**
  51925. * Controls the scale bias of the parallax mode.
  51926. */
  51927. parallaxScaleBias: number;
  51928. /**
  51929. * If sets to true, disables all the lights affecting the material.
  51930. */
  51931. disableLighting: boolean;
  51932. /**
  51933. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51934. */
  51935. forceIrradianceInFragment: boolean;
  51936. /**
  51937. * Number of Simultaneous lights allowed on the material.
  51938. */
  51939. maxSimultaneousLights: number;
  51940. /**
  51941. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51942. */
  51943. invertNormalMapX: boolean;
  51944. /**
  51945. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51946. */
  51947. invertNormalMapY: boolean;
  51948. /**
  51949. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51950. */
  51951. twoSidedLighting: boolean;
  51952. /**
  51953. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51954. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51955. */
  51956. useAlphaFresnel: boolean;
  51957. /**
  51958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51959. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51960. */
  51961. useLinearAlphaFresnel: boolean;
  51962. /**
  51963. * Let user defines the brdf lookup texture used for IBL.
  51964. * A default 8bit version is embedded but you could point at :
  51965. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51966. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51967. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51968. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51969. */
  51970. environmentBRDFTexture: Nullable<BaseTexture>;
  51971. /**
  51972. * Force normal to face away from face.
  51973. */
  51974. forceNormalForward: boolean;
  51975. /**
  51976. * Enables specular anti aliasing in the PBR shader.
  51977. * It will both interacts on the Geometry for analytical and IBL lighting.
  51978. * It also prefilter the roughness map based on the bump values.
  51979. */
  51980. enableSpecularAntiAliasing: boolean;
  51981. /**
  51982. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51983. * makes the reflect vector face the model (under horizon).
  51984. */
  51985. useHorizonOcclusion: boolean;
  51986. /**
  51987. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51988. * too much the area relying on ambient texture to define their ambient occlusion.
  51989. */
  51990. useRadianceOcclusion: boolean;
  51991. /**
  51992. * If set to true, no lighting calculations will be applied.
  51993. */
  51994. unlit: boolean;
  51995. /**
  51996. * Gets the image processing configuration used either in this material.
  51997. */
  51998. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51999. /**
  52000. * Sets the Default image processing configuration used either in the this material.
  52001. *
  52002. * If sets to null, the scene one is in use.
  52003. */
  52004. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52005. /**
  52006. * Gets wether the color curves effect is enabled.
  52007. */
  52008. get cameraColorCurvesEnabled(): boolean;
  52009. /**
  52010. * Sets wether the color curves effect is enabled.
  52011. */
  52012. set cameraColorCurvesEnabled(value: boolean);
  52013. /**
  52014. * Gets wether the color grading effect is enabled.
  52015. */
  52016. get cameraColorGradingEnabled(): boolean;
  52017. /**
  52018. * Gets wether the color grading effect is enabled.
  52019. */
  52020. set cameraColorGradingEnabled(value: boolean);
  52021. /**
  52022. * Gets wether tonemapping is enabled or not.
  52023. */
  52024. get cameraToneMappingEnabled(): boolean;
  52025. /**
  52026. * Sets wether tonemapping is enabled or not
  52027. */
  52028. set cameraToneMappingEnabled(value: boolean);
  52029. /**
  52030. * The camera exposure used on this material.
  52031. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52032. * This corresponds to a photographic exposure.
  52033. */
  52034. get cameraExposure(): number;
  52035. /**
  52036. * The camera exposure used on this material.
  52037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52038. * This corresponds to a photographic exposure.
  52039. */
  52040. set cameraExposure(value: number);
  52041. /**
  52042. * Gets The camera contrast used on this material.
  52043. */
  52044. get cameraContrast(): number;
  52045. /**
  52046. * Sets The camera contrast used on this material.
  52047. */
  52048. set cameraContrast(value: number);
  52049. /**
  52050. * Gets the Color Grading 2D Lookup Texture.
  52051. */
  52052. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52053. /**
  52054. * Sets the Color Grading 2D Lookup Texture.
  52055. */
  52056. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52057. /**
  52058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52060. * 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;
  52061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52062. */
  52063. get cameraColorCurves(): Nullable<ColorCurves>;
  52064. /**
  52065. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52066. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52067. * 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;
  52068. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52069. */
  52070. set cameraColorCurves(value: Nullable<ColorCurves>);
  52071. /**
  52072. * Instantiates a new PBRMaterial instance.
  52073. *
  52074. * @param name The material name
  52075. * @param scene The scene the material will be use in.
  52076. */
  52077. constructor(name: string, scene: Scene);
  52078. /**
  52079. * Returns the name of this material class.
  52080. */
  52081. getClassName(): string;
  52082. /**
  52083. * Makes a duplicate of the current material.
  52084. * @param name - name to use for the new material.
  52085. */
  52086. clone(name: string): PBRMaterial;
  52087. /**
  52088. * Serializes this PBR Material.
  52089. * @returns - An object with the serialized material.
  52090. */
  52091. serialize(): any;
  52092. /**
  52093. * Parses a PBR Material from a serialized object.
  52094. * @param source - Serialized object.
  52095. * @param scene - BJS scene instance.
  52096. * @param rootUrl - url for the scene object
  52097. * @returns - PBRMaterial
  52098. */
  52099. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52100. }
  52101. }
  52102. declare module BABYLON {
  52103. /**
  52104. * Direct draw surface info
  52105. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52106. */
  52107. export interface DDSInfo {
  52108. /**
  52109. * Width of the texture
  52110. */
  52111. width: number;
  52112. /**
  52113. * Width of the texture
  52114. */
  52115. height: number;
  52116. /**
  52117. * Number of Mipmaps for the texture
  52118. * @see https://en.wikipedia.org/wiki/Mipmap
  52119. */
  52120. mipmapCount: number;
  52121. /**
  52122. * If the textures format is a known fourCC format
  52123. * @see https://www.fourcc.org/
  52124. */
  52125. isFourCC: boolean;
  52126. /**
  52127. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52128. */
  52129. isRGB: boolean;
  52130. /**
  52131. * If the texture is a lumincance format
  52132. */
  52133. isLuminance: boolean;
  52134. /**
  52135. * If this is a cube texture
  52136. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52137. */
  52138. isCube: boolean;
  52139. /**
  52140. * If the texture is a compressed format eg. FOURCC_DXT1
  52141. */
  52142. isCompressed: boolean;
  52143. /**
  52144. * The dxgiFormat of the texture
  52145. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52146. */
  52147. dxgiFormat: number;
  52148. /**
  52149. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52150. */
  52151. textureType: number;
  52152. /**
  52153. * Sphericle polynomial created for the dds texture
  52154. */
  52155. sphericalPolynomial?: SphericalPolynomial;
  52156. }
  52157. /**
  52158. * Class used to provide DDS decompression tools
  52159. */
  52160. export class DDSTools {
  52161. /**
  52162. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52163. */
  52164. static StoreLODInAlphaChannel: boolean;
  52165. /**
  52166. * Gets DDS information from an array buffer
  52167. * @param arrayBuffer defines the array buffer to read data from
  52168. * @returns the DDS information
  52169. */
  52170. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  52171. private static _FloatView;
  52172. private static _Int32View;
  52173. private static _ToHalfFloat;
  52174. private static _FromHalfFloat;
  52175. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52176. private static _GetHalfFloatRGBAArrayBuffer;
  52177. private static _GetFloatRGBAArrayBuffer;
  52178. private static _GetFloatAsUIntRGBAArrayBuffer;
  52179. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52180. private static _GetRGBAArrayBuffer;
  52181. private static _ExtractLongWordOrder;
  52182. private static _GetRGBArrayBuffer;
  52183. private static _GetLuminanceArrayBuffer;
  52184. /**
  52185. * Uploads DDS Levels to a Babylon Texture
  52186. * @hidden
  52187. */
  52188. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52189. }
  52190. interface ThinEngine {
  52191. /**
  52192. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52193. * @param rootUrl defines the url where the file to load is located
  52194. * @param scene defines the current scene
  52195. * @param lodScale defines scale to apply to the mip map selection
  52196. * @param lodOffset defines offset to apply to the mip map selection
  52197. * @param onLoad defines an optional callback raised when the texture is loaded
  52198. * @param onError defines an optional callback raised if there is an issue to load the texture
  52199. * @param format defines the format of the data
  52200. * @param forcedExtension defines the extension to use to pick the right loader
  52201. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52202. * @returns the cube texture as an InternalTexture
  52203. */
  52204. 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;
  52205. }
  52206. }
  52207. declare module BABYLON {
  52208. /**
  52209. * Implementation of the DDS Texture Loader.
  52210. * @hidden
  52211. */
  52212. export class _DDSTextureLoader implements IInternalTextureLoader {
  52213. /**
  52214. * Defines wether the loader supports cascade loading the different faces.
  52215. */
  52216. readonly supportCascades: boolean;
  52217. /**
  52218. * This returns if the loader support the current file information.
  52219. * @param extension defines the file extension of the file being loaded
  52220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52221. * @param fallback defines the fallback internal texture if any
  52222. * @param isBase64 defines whether the texture is encoded as a base64
  52223. * @param isBuffer defines whether the texture data are stored as a buffer
  52224. * @returns true if the loader can load the specified file
  52225. */
  52226. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52227. /**
  52228. * Transform the url before loading if required.
  52229. * @param rootUrl the url of the texture
  52230. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52231. * @returns the transformed texture
  52232. */
  52233. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52234. /**
  52235. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52236. * @param rootUrl the url of the texture
  52237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52238. * @returns the fallback texture
  52239. */
  52240. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52241. /**
  52242. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52243. * @param data contains the texture data
  52244. * @param texture defines the BabylonJS internal texture
  52245. * @param createPolynomials will be true if polynomials have been requested
  52246. * @param onLoad defines the callback to trigger once the texture is ready
  52247. * @param onError defines the callback to trigger in case of error
  52248. */
  52249. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52250. /**
  52251. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52252. * @param data contains the texture data
  52253. * @param texture defines the BabylonJS internal texture
  52254. * @param callback defines the method to call once ready to upload
  52255. */
  52256. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52257. }
  52258. }
  52259. declare module BABYLON {
  52260. /**
  52261. * Implementation of the ENV Texture Loader.
  52262. * @hidden
  52263. */
  52264. export class _ENVTextureLoader implements IInternalTextureLoader {
  52265. /**
  52266. * Defines wether the loader supports cascade loading the different faces.
  52267. */
  52268. readonly supportCascades: boolean;
  52269. /**
  52270. * This returns if the loader support the current file information.
  52271. * @param extension defines the file extension of the file being loaded
  52272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52273. * @param fallback defines the fallback internal texture if any
  52274. * @param isBase64 defines whether the texture is encoded as a base64
  52275. * @param isBuffer defines whether the texture data are stored as a buffer
  52276. * @returns true if the loader can load the specified file
  52277. */
  52278. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52279. /**
  52280. * Transform the url before loading if required.
  52281. * @param rootUrl the url of the texture
  52282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52283. * @returns the transformed texture
  52284. */
  52285. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52286. /**
  52287. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52288. * @param rootUrl the url of the texture
  52289. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52290. * @returns the fallback texture
  52291. */
  52292. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52293. /**
  52294. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52295. * @param data contains the texture data
  52296. * @param texture defines the BabylonJS internal texture
  52297. * @param createPolynomials will be true if polynomials have been requested
  52298. * @param onLoad defines the callback to trigger once the texture is ready
  52299. * @param onError defines the callback to trigger in case of error
  52300. */
  52301. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52302. /**
  52303. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52304. * @param data contains the texture data
  52305. * @param texture defines the BabylonJS internal texture
  52306. * @param callback defines the method to call once ready to upload
  52307. */
  52308. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52309. }
  52310. }
  52311. declare module BABYLON {
  52312. /**
  52313. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52314. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52315. */
  52316. export class KhronosTextureContainer {
  52317. /** contents of the KTX container file */
  52318. arrayBuffer: any;
  52319. private static HEADER_LEN;
  52320. private static COMPRESSED_2D;
  52321. private static COMPRESSED_3D;
  52322. private static TEX_2D;
  52323. private static TEX_3D;
  52324. /**
  52325. * Gets the openGL type
  52326. */
  52327. glType: number;
  52328. /**
  52329. * Gets the openGL type size
  52330. */
  52331. glTypeSize: number;
  52332. /**
  52333. * Gets the openGL format
  52334. */
  52335. glFormat: number;
  52336. /**
  52337. * Gets the openGL internal format
  52338. */
  52339. glInternalFormat: number;
  52340. /**
  52341. * Gets the base internal format
  52342. */
  52343. glBaseInternalFormat: number;
  52344. /**
  52345. * Gets image width in pixel
  52346. */
  52347. pixelWidth: number;
  52348. /**
  52349. * Gets image height in pixel
  52350. */
  52351. pixelHeight: number;
  52352. /**
  52353. * Gets image depth in pixels
  52354. */
  52355. pixelDepth: number;
  52356. /**
  52357. * Gets the number of array elements
  52358. */
  52359. numberOfArrayElements: number;
  52360. /**
  52361. * Gets the number of faces
  52362. */
  52363. numberOfFaces: number;
  52364. /**
  52365. * Gets the number of mipmap levels
  52366. */
  52367. numberOfMipmapLevels: number;
  52368. /**
  52369. * Gets the bytes of key value data
  52370. */
  52371. bytesOfKeyValueData: number;
  52372. /**
  52373. * Gets the load type
  52374. */
  52375. loadType: number;
  52376. /**
  52377. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52378. */
  52379. isInvalid: boolean;
  52380. /**
  52381. * Creates a new KhronosTextureContainer
  52382. * @param arrayBuffer contents of the KTX container file
  52383. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52384. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52385. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52386. */
  52387. constructor(
  52388. /** contents of the KTX container file */
  52389. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52390. /**
  52391. * Uploads KTX content to a Babylon Texture.
  52392. * It is assumed that the texture has already been created & is currently bound
  52393. * @hidden
  52394. */
  52395. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52396. private _upload2DCompressedLevels;
  52397. }
  52398. }
  52399. declare module BABYLON {
  52400. /**
  52401. * Implementation of the KTX Texture Loader.
  52402. * @hidden
  52403. */
  52404. export class _KTXTextureLoader implements IInternalTextureLoader {
  52405. /**
  52406. * Defines wether the loader supports cascade loading the different faces.
  52407. */
  52408. readonly supportCascades: boolean;
  52409. /**
  52410. * This returns if the loader support the current file information.
  52411. * @param extension defines the file extension of the file being loaded
  52412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52413. * @param fallback defines the fallback internal texture if any
  52414. * @param isBase64 defines whether the texture is encoded as a base64
  52415. * @param isBuffer defines whether the texture data are stored as a buffer
  52416. * @returns true if the loader can load the specified file
  52417. */
  52418. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52419. /**
  52420. * Transform the url before loading if required.
  52421. * @param rootUrl the url of the texture
  52422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52423. * @returns the transformed texture
  52424. */
  52425. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52426. /**
  52427. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52428. * @param rootUrl the url of the texture
  52429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52430. * @returns the fallback texture
  52431. */
  52432. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52433. /**
  52434. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52435. * @param data contains the texture data
  52436. * @param texture defines the BabylonJS internal texture
  52437. * @param createPolynomials will be true if polynomials have been requested
  52438. * @param onLoad defines the callback to trigger once the texture is ready
  52439. * @param onError defines the callback to trigger in case of error
  52440. */
  52441. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52442. /**
  52443. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52444. * @param data contains the texture data
  52445. * @param texture defines the BabylonJS internal texture
  52446. * @param callback defines the method to call once ready to upload
  52447. */
  52448. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /** @hidden */
  52453. export var _forceSceneHelpersToBundle: boolean;
  52454. interface Scene {
  52455. /**
  52456. * Creates a default light for the scene.
  52457. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52458. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52459. */
  52460. createDefaultLight(replace?: boolean): void;
  52461. /**
  52462. * Creates a default camera for the scene.
  52463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52464. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52465. * @param replace has default false, when true replaces the active camera in the scene
  52466. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52467. */
  52468. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52469. /**
  52470. * Creates a default camera and a default light.
  52471. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52473. * @param replace has the default false, when true replaces the active camera/light in the scene
  52474. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52475. */
  52476. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52477. /**
  52478. * Creates a new sky box
  52479. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52480. * @param environmentTexture defines the texture to use as environment texture
  52481. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52482. * @param scale defines the overall scale of the skybox
  52483. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52484. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52485. * @returns a new mesh holding the sky box
  52486. */
  52487. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52488. /**
  52489. * Creates a new environment
  52490. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52491. * @param options defines the options you can use to configure the environment
  52492. * @returns the new EnvironmentHelper
  52493. */
  52494. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52495. /**
  52496. * Creates a new VREXperienceHelper
  52497. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52498. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52499. * @returns a new VREXperienceHelper
  52500. */
  52501. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52502. /**
  52503. * Creates a new WebXRDefaultExperience
  52504. * @see http://doc.babylonjs.com/how_to/webxr
  52505. * @param options experience options
  52506. * @returns a promise for a new WebXRDefaultExperience
  52507. */
  52508. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52509. }
  52510. }
  52511. declare module BABYLON {
  52512. /**
  52513. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52514. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52515. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52516. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52517. */
  52518. export class VideoDome extends TransformNode {
  52519. /**
  52520. * Define the video source as a Monoscopic panoramic 360 video.
  52521. */
  52522. static readonly MODE_MONOSCOPIC: number;
  52523. /**
  52524. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52525. */
  52526. static readonly MODE_TOPBOTTOM: number;
  52527. /**
  52528. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52529. */
  52530. static readonly MODE_SIDEBYSIDE: number;
  52531. private _halfDome;
  52532. private _useDirectMapping;
  52533. /**
  52534. * The video texture being displayed on the sphere
  52535. */
  52536. protected _videoTexture: VideoTexture;
  52537. /**
  52538. * Gets the video texture being displayed on the sphere
  52539. */
  52540. get videoTexture(): VideoTexture;
  52541. /**
  52542. * The skybox material
  52543. */
  52544. protected _material: BackgroundMaterial;
  52545. /**
  52546. * The surface used for the skybox
  52547. */
  52548. protected _mesh: Mesh;
  52549. /**
  52550. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52551. */
  52552. private _halfDomeMask;
  52553. /**
  52554. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52555. * Also see the options.resolution property.
  52556. */
  52557. get fovMultiplier(): number;
  52558. set fovMultiplier(value: number);
  52559. private _videoMode;
  52560. /**
  52561. * Gets or set the current video mode for the video. It can be:
  52562. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52563. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52564. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52565. */
  52566. get videoMode(): number;
  52567. set videoMode(value: number);
  52568. /**
  52569. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52570. *
  52571. */
  52572. get halfDome(): boolean;
  52573. /**
  52574. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52575. */
  52576. set halfDome(enabled: boolean);
  52577. /**
  52578. * Oberserver used in Stereoscopic VR Mode.
  52579. */
  52580. private _onBeforeCameraRenderObserver;
  52581. /**
  52582. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52583. * @param name Element's name, child elements will append suffixes for their own names.
  52584. * @param urlsOrVideo defines the url(s) or the video element to use
  52585. * @param options An object containing optional or exposed sub element properties
  52586. */
  52587. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52588. resolution?: number;
  52589. clickToPlay?: boolean;
  52590. autoPlay?: boolean;
  52591. loop?: boolean;
  52592. size?: number;
  52593. poster?: string;
  52594. faceForward?: boolean;
  52595. useDirectMapping?: boolean;
  52596. halfDomeMode?: boolean;
  52597. }, scene: Scene);
  52598. private _changeVideoMode;
  52599. /**
  52600. * Releases resources associated with this node.
  52601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52603. */
  52604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52605. }
  52606. }
  52607. declare module BABYLON {
  52608. /**
  52609. * This class can be used to get instrumentation data from a Babylon engine
  52610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52611. */
  52612. export class EngineInstrumentation implements IDisposable {
  52613. /**
  52614. * Define the instrumented engine.
  52615. */
  52616. engine: Engine;
  52617. private _captureGPUFrameTime;
  52618. private _gpuFrameTimeToken;
  52619. private _gpuFrameTime;
  52620. private _captureShaderCompilationTime;
  52621. private _shaderCompilationTime;
  52622. private _onBeginFrameObserver;
  52623. private _onEndFrameObserver;
  52624. private _onBeforeShaderCompilationObserver;
  52625. private _onAfterShaderCompilationObserver;
  52626. /**
  52627. * Gets the perf counter used for GPU frame time
  52628. */
  52629. get gpuFrameTimeCounter(): PerfCounter;
  52630. /**
  52631. * Gets the GPU frame time capture status
  52632. */
  52633. get captureGPUFrameTime(): boolean;
  52634. /**
  52635. * Enable or disable the GPU frame time capture
  52636. */
  52637. set captureGPUFrameTime(value: boolean);
  52638. /**
  52639. * Gets the perf counter used for shader compilation time
  52640. */
  52641. get shaderCompilationTimeCounter(): PerfCounter;
  52642. /**
  52643. * Gets the shader compilation time capture status
  52644. */
  52645. get captureShaderCompilationTime(): boolean;
  52646. /**
  52647. * Enable or disable the shader compilation time capture
  52648. */
  52649. set captureShaderCompilationTime(value: boolean);
  52650. /**
  52651. * Instantiates a new engine instrumentation.
  52652. * This class can be used to get instrumentation data from a Babylon engine
  52653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52654. * @param engine Defines the engine to instrument
  52655. */
  52656. constructor(
  52657. /**
  52658. * Define the instrumented engine.
  52659. */
  52660. engine: Engine);
  52661. /**
  52662. * Dispose and release associated resources.
  52663. */
  52664. dispose(): void;
  52665. }
  52666. }
  52667. declare module BABYLON {
  52668. /**
  52669. * This class can be used to get instrumentation data from a Babylon engine
  52670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52671. */
  52672. export class SceneInstrumentation implements IDisposable {
  52673. /**
  52674. * Defines the scene to instrument
  52675. */
  52676. scene: Scene;
  52677. private _captureActiveMeshesEvaluationTime;
  52678. private _activeMeshesEvaluationTime;
  52679. private _captureRenderTargetsRenderTime;
  52680. private _renderTargetsRenderTime;
  52681. private _captureFrameTime;
  52682. private _frameTime;
  52683. private _captureRenderTime;
  52684. private _renderTime;
  52685. private _captureInterFrameTime;
  52686. private _interFrameTime;
  52687. private _captureParticlesRenderTime;
  52688. private _particlesRenderTime;
  52689. private _captureSpritesRenderTime;
  52690. private _spritesRenderTime;
  52691. private _capturePhysicsTime;
  52692. private _physicsTime;
  52693. private _captureAnimationsTime;
  52694. private _animationsTime;
  52695. private _captureCameraRenderTime;
  52696. private _cameraRenderTime;
  52697. private _onBeforeActiveMeshesEvaluationObserver;
  52698. private _onAfterActiveMeshesEvaluationObserver;
  52699. private _onBeforeRenderTargetsRenderObserver;
  52700. private _onAfterRenderTargetsRenderObserver;
  52701. private _onAfterRenderObserver;
  52702. private _onBeforeDrawPhaseObserver;
  52703. private _onAfterDrawPhaseObserver;
  52704. private _onBeforeAnimationsObserver;
  52705. private _onBeforeParticlesRenderingObserver;
  52706. private _onAfterParticlesRenderingObserver;
  52707. private _onBeforeSpritesRenderingObserver;
  52708. private _onAfterSpritesRenderingObserver;
  52709. private _onBeforePhysicsObserver;
  52710. private _onAfterPhysicsObserver;
  52711. private _onAfterAnimationsObserver;
  52712. private _onBeforeCameraRenderObserver;
  52713. private _onAfterCameraRenderObserver;
  52714. /**
  52715. * Gets the perf counter used for active meshes evaluation time
  52716. */
  52717. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52718. /**
  52719. * Gets the active meshes evaluation time capture status
  52720. */
  52721. get captureActiveMeshesEvaluationTime(): boolean;
  52722. /**
  52723. * Enable or disable the active meshes evaluation time capture
  52724. */
  52725. set captureActiveMeshesEvaluationTime(value: boolean);
  52726. /**
  52727. * Gets the perf counter used for render targets render time
  52728. */
  52729. get renderTargetsRenderTimeCounter(): PerfCounter;
  52730. /**
  52731. * Gets the render targets render time capture status
  52732. */
  52733. get captureRenderTargetsRenderTime(): boolean;
  52734. /**
  52735. * Enable or disable the render targets render time capture
  52736. */
  52737. set captureRenderTargetsRenderTime(value: boolean);
  52738. /**
  52739. * Gets the perf counter used for particles render time
  52740. */
  52741. get particlesRenderTimeCounter(): PerfCounter;
  52742. /**
  52743. * Gets the particles render time capture status
  52744. */
  52745. get captureParticlesRenderTime(): boolean;
  52746. /**
  52747. * Enable or disable the particles render time capture
  52748. */
  52749. set captureParticlesRenderTime(value: boolean);
  52750. /**
  52751. * Gets the perf counter used for sprites render time
  52752. */
  52753. get spritesRenderTimeCounter(): PerfCounter;
  52754. /**
  52755. * Gets the sprites render time capture status
  52756. */
  52757. get captureSpritesRenderTime(): boolean;
  52758. /**
  52759. * Enable or disable the sprites render time capture
  52760. */
  52761. set captureSpritesRenderTime(value: boolean);
  52762. /**
  52763. * Gets the perf counter used for physics time
  52764. */
  52765. get physicsTimeCounter(): PerfCounter;
  52766. /**
  52767. * Gets the physics time capture status
  52768. */
  52769. get capturePhysicsTime(): boolean;
  52770. /**
  52771. * Enable or disable the physics time capture
  52772. */
  52773. set capturePhysicsTime(value: boolean);
  52774. /**
  52775. * Gets the perf counter used for animations time
  52776. */
  52777. get animationsTimeCounter(): PerfCounter;
  52778. /**
  52779. * Gets the animations time capture status
  52780. */
  52781. get captureAnimationsTime(): boolean;
  52782. /**
  52783. * Enable or disable the animations time capture
  52784. */
  52785. set captureAnimationsTime(value: boolean);
  52786. /**
  52787. * Gets the perf counter used for frame time capture
  52788. */
  52789. get frameTimeCounter(): PerfCounter;
  52790. /**
  52791. * Gets the frame time capture status
  52792. */
  52793. get captureFrameTime(): boolean;
  52794. /**
  52795. * Enable or disable the frame time capture
  52796. */
  52797. set captureFrameTime(value: boolean);
  52798. /**
  52799. * Gets the perf counter used for inter-frames time capture
  52800. */
  52801. get interFrameTimeCounter(): PerfCounter;
  52802. /**
  52803. * Gets the inter-frames time capture status
  52804. */
  52805. get captureInterFrameTime(): boolean;
  52806. /**
  52807. * Enable or disable the inter-frames time capture
  52808. */
  52809. set captureInterFrameTime(value: boolean);
  52810. /**
  52811. * Gets the perf counter used for render time capture
  52812. */
  52813. get renderTimeCounter(): PerfCounter;
  52814. /**
  52815. * Gets the render time capture status
  52816. */
  52817. get captureRenderTime(): boolean;
  52818. /**
  52819. * Enable or disable the render time capture
  52820. */
  52821. set captureRenderTime(value: boolean);
  52822. /**
  52823. * Gets the perf counter used for camera render time capture
  52824. */
  52825. get cameraRenderTimeCounter(): PerfCounter;
  52826. /**
  52827. * Gets the camera render time capture status
  52828. */
  52829. get captureCameraRenderTime(): boolean;
  52830. /**
  52831. * Enable or disable the camera render time capture
  52832. */
  52833. set captureCameraRenderTime(value: boolean);
  52834. /**
  52835. * Gets the perf counter used for draw calls
  52836. */
  52837. get drawCallsCounter(): PerfCounter;
  52838. /**
  52839. * Instantiates a new scene instrumentation.
  52840. * This class can be used to get instrumentation data from a Babylon engine
  52841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52842. * @param scene Defines the scene to instrument
  52843. */
  52844. constructor(
  52845. /**
  52846. * Defines the scene to instrument
  52847. */
  52848. scene: Scene);
  52849. /**
  52850. * Dispose and release associated resources.
  52851. */
  52852. dispose(): void;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. /** @hidden */
  52857. export var glowMapGenerationPixelShader: {
  52858. name: string;
  52859. shader: string;
  52860. };
  52861. }
  52862. declare module BABYLON {
  52863. /** @hidden */
  52864. export var glowMapGenerationVertexShader: {
  52865. name: string;
  52866. shader: string;
  52867. };
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Effect layer options. This helps customizing the behaviour
  52872. * of the effect layer.
  52873. */
  52874. export interface IEffectLayerOptions {
  52875. /**
  52876. * Multiplication factor apply to the canvas size to compute the render target size
  52877. * used to generated the objects (the smaller the faster).
  52878. */
  52879. mainTextureRatio: number;
  52880. /**
  52881. * Enforces a fixed size texture to ensure effect stability across devices.
  52882. */
  52883. mainTextureFixedSize?: number;
  52884. /**
  52885. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52886. */
  52887. alphaBlendingMode: number;
  52888. /**
  52889. * The camera attached to the layer.
  52890. */
  52891. camera: Nullable<Camera>;
  52892. /**
  52893. * The rendering group to draw the layer in.
  52894. */
  52895. renderingGroupId: number;
  52896. }
  52897. /**
  52898. * The effect layer Helps adding post process effect blended with the main pass.
  52899. *
  52900. * This can be for instance use to generate glow or higlight effects on the scene.
  52901. *
  52902. * The effect layer class can not be used directly and is intented to inherited from to be
  52903. * customized per effects.
  52904. */
  52905. export abstract class EffectLayer {
  52906. private _vertexBuffers;
  52907. private _indexBuffer;
  52908. private _cachedDefines;
  52909. private _effectLayerMapGenerationEffect;
  52910. private _effectLayerOptions;
  52911. private _mergeEffect;
  52912. protected _scene: Scene;
  52913. protected _engine: Engine;
  52914. protected _maxSize: number;
  52915. protected _mainTextureDesiredSize: ISize;
  52916. protected _mainTexture: RenderTargetTexture;
  52917. protected _shouldRender: boolean;
  52918. protected _postProcesses: PostProcess[];
  52919. protected _textures: BaseTexture[];
  52920. protected _emissiveTextureAndColor: {
  52921. texture: Nullable<BaseTexture>;
  52922. color: Color4;
  52923. };
  52924. /**
  52925. * The name of the layer
  52926. */
  52927. name: string;
  52928. /**
  52929. * The clear color of the texture used to generate the glow map.
  52930. */
  52931. neutralColor: Color4;
  52932. /**
  52933. * Specifies wether the highlight layer is enabled or not.
  52934. */
  52935. isEnabled: boolean;
  52936. /**
  52937. * Gets the camera attached to the layer.
  52938. */
  52939. get camera(): Nullable<Camera>;
  52940. /**
  52941. * Gets the rendering group id the layer should render in.
  52942. */
  52943. get renderingGroupId(): number;
  52944. set renderingGroupId(renderingGroupId: number);
  52945. /**
  52946. * An event triggered when the effect layer has been disposed.
  52947. */
  52948. onDisposeObservable: Observable<EffectLayer>;
  52949. /**
  52950. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52951. */
  52952. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52953. /**
  52954. * An event triggered when the generated texture is being merged in the scene.
  52955. */
  52956. onBeforeComposeObservable: Observable<EffectLayer>;
  52957. /**
  52958. * An event triggered when the mesh is rendered into the effect render target.
  52959. */
  52960. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52961. /**
  52962. * An event triggered after the mesh has been rendered into the effect render target.
  52963. */
  52964. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52965. /**
  52966. * An event triggered when the generated texture has been merged in the scene.
  52967. */
  52968. onAfterComposeObservable: Observable<EffectLayer>;
  52969. /**
  52970. * An event triggered when the efffect layer changes its size.
  52971. */
  52972. onSizeChangedObservable: Observable<EffectLayer>;
  52973. /** @hidden */
  52974. static _SceneComponentInitialization: (scene: Scene) => void;
  52975. /**
  52976. * Instantiates a new effect Layer and references it in the scene.
  52977. * @param name The name of the layer
  52978. * @param scene The scene to use the layer in
  52979. */
  52980. constructor(
  52981. /** The Friendly of the effect in the scene */
  52982. name: string, scene: Scene);
  52983. /**
  52984. * Get the effect name of the layer.
  52985. * @return The effect name
  52986. */
  52987. abstract getEffectName(): string;
  52988. /**
  52989. * Checks for the readiness of the element composing the layer.
  52990. * @param subMesh the mesh to check for
  52991. * @param useInstances specify wether or not to use instances to render the mesh
  52992. * @return true if ready otherwise, false
  52993. */
  52994. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52995. /**
  52996. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52997. * @returns true if the effect requires stencil during the main canvas render pass.
  52998. */
  52999. abstract needStencil(): boolean;
  53000. /**
  53001. * Create the merge effect. This is the shader use to blit the information back
  53002. * to the main canvas at the end of the scene rendering.
  53003. * @returns The effect containing the shader used to merge the effect on the main canvas
  53004. */
  53005. protected abstract _createMergeEffect(): Effect;
  53006. /**
  53007. * Creates the render target textures and post processes used in the effect layer.
  53008. */
  53009. protected abstract _createTextureAndPostProcesses(): void;
  53010. /**
  53011. * Implementation specific of rendering the generating effect on the main canvas.
  53012. * @param effect The effect used to render through
  53013. */
  53014. protected abstract _internalRender(effect: Effect): void;
  53015. /**
  53016. * Sets the required values for both the emissive texture and and the main color.
  53017. */
  53018. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53019. /**
  53020. * Free any resources and references associated to a mesh.
  53021. * Internal use
  53022. * @param mesh The mesh to free.
  53023. */
  53024. abstract _disposeMesh(mesh: Mesh): void;
  53025. /**
  53026. * Serializes this layer (Glow or Highlight for example)
  53027. * @returns a serialized layer object
  53028. */
  53029. abstract serialize?(): any;
  53030. /**
  53031. * Initializes the effect layer with the required options.
  53032. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53033. */
  53034. protected _init(options: Partial<IEffectLayerOptions>): void;
  53035. /**
  53036. * Generates the index buffer of the full screen quad blending to the main canvas.
  53037. */
  53038. private _generateIndexBuffer;
  53039. /**
  53040. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53041. */
  53042. private _generateVertexBuffer;
  53043. /**
  53044. * Sets the main texture desired size which is the closest power of two
  53045. * of the engine canvas size.
  53046. */
  53047. private _setMainTextureSize;
  53048. /**
  53049. * Creates the main texture for the effect layer.
  53050. */
  53051. protected _createMainTexture(): void;
  53052. /**
  53053. * Adds specific effects defines.
  53054. * @param defines The defines to add specifics to.
  53055. */
  53056. protected _addCustomEffectDefines(defines: string[]): void;
  53057. /**
  53058. * Checks for the readiness of the element composing the layer.
  53059. * @param subMesh the mesh to check for
  53060. * @param useInstances specify wether or not to use instances to render the mesh
  53061. * @param emissiveTexture the associated emissive texture used to generate the glow
  53062. * @return true if ready otherwise, false
  53063. */
  53064. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53065. /**
  53066. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53067. */
  53068. render(): void;
  53069. /**
  53070. * Determine if a given mesh will be used in the current effect.
  53071. * @param mesh mesh to test
  53072. * @returns true if the mesh will be used
  53073. */
  53074. hasMesh(mesh: AbstractMesh): boolean;
  53075. /**
  53076. * Returns true if the layer contains information to display, otherwise false.
  53077. * @returns true if the glow layer should be rendered
  53078. */
  53079. shouldRender(): boolean;
  53080. /**
  53081. * Returns true if the mesh should render, otherwise false.
  53082. * @param mesh The mesh to render
  53083. * @returns true if it should render otherwise false
  53084. */
  53085. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53086. /**
  53087. * Returns true if the mesh can be rendered, otherwise false.
  53088. * @param mesh The mesh to render
  53089. * @param material The material used on the mesh
  53090. * @returns true if it can be rendered otherwise false
  53091. */
  53092. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53093. /**
  53094. * Returns true if the mesh should render, otherwise false.
  53095. * @param mesh The mesh to render
  53096. * @returns true if it should render otherwise false
  53097. */
  53098. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53099. /**
  53100. * Renders the submesh passed in parameter to the generation map.
  53101. */
  53102. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53103. /**
  53104. * Defines wether the current material of the mesh should be use to render the effect.
  53105. * @param mesh defines the current mesh to render
  53106. */
  53107. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53108. /**
  53109. * Rebuild the required buffers.
  53110. * @hidden Internal use only.
  53111. */
  53112. _rebuild(): void;
  53113. /**
  53114. * Dispose only the render target textures and post process.
  53115. */
  53116. private _disposeTextureAndPostProcesses;
  53117. /**
  53118. * Dispose the highlight layer and free resources.
  53119. */
  53120. dispose(): void;
  53121. /**
  53122. * Gets the class name of the effect layer
  53123. * @returns the string with the class name of the effect layer
  53124. */
  53125. getClassName(): string;
  53126. /**
  53127. * Creates an effect layer from parsed effect layer data
  53128. * @param parsedEffectLayer defines effect layer data
  53129. * @param scene defines the current scene
  53130. * @param rootUrl defines the root URL containing the effect layer information
  53131. * @returns a parsed effect Layer
  53132. */
  53133. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53134. }
  53135. }
  53136. declare module BABYLON {
  53137. interface AbstractScene {
  53138. /**
  53139. * The list of effect layers (highlights/glow) added to the scene
  53140. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53141. * @see http://doc.babylonjs.com/how_to/glow_layer
  53142. */
  53143. effectLayers: Array<EffectLayer>;
  53144. /**
  53145. * Removes the given effect layer from this scene.
  53146. * @param toRemove defines the effect layer to remove
  53147. * @returns the index of the removed effect layer
  53148. */
  53149. removeEffectLayer(toRemove: EffectLayer): number;
  53150. /**
  53151. * Adds the given effect layer to this scene
  53152. * @param newEffectLayer defines the effect layer to add
  53153. */
  53154. addEffectLayer(newEffectLayer: EffectLayer): void;
  53155. }
  53156. /**
  53157. * Defines the layer scene component responsible to manage any effect layers
  53158. * in a given scene.
  53159. */
  53160. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53161. /**
  53162. * The component name helpfull to identify the component in the list of scene components.
  53163. */
  53164. readonly name: string;
  53165. /**
  53166. * The scene the component belongs to.
  53167. */
  53168. scene: Scene;
  53169. private _engine;
  53170. private _renderEffects;
  53171. private _needStencil;
  53172. private _previousStencilState;
  53173. /**
  53174. * Creates a new instance of the component for the given scene
  53175. * @param scene Defines the scene to register the component in
  53176. */
  53177. constructor(scene: Scene);
  53178. /**
  53179. * Registers the component in a given scene
  53180. */
  53181. register(): void;
  53182. /**
  53183. * Rebuilds the elements related to this component in case of
  53184. * context lost for instance.
  53185. */
  53186. rebuild(): void;
  53187. /**
  53188. * Serializes the component data to the specified json object
  53189. * @param serializationObject The object to serialize to
  53190. */
  53191. serialize(serializationObject: any): void;
  53192. /**
  53193. * Adds all the elements from the container to the scene
  53194. * @param container the container holding the elements
  53195. */
  53196. addFromContainer(container: AbstractScene): void;
  53197. /**
  53198. * Removes all the elements in the container from the scene
  53199. * @param container contains the elements to remove
  53200. * @param dispose if the removed element should be disposed (default: false)
  53201. */
  53202. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53203. /**
  53204. * Disposes the component and the associated ressources.
  53205. */
  53206. dispose(): void;
  53207. private _isReadyForMesh;
  53208. private _renderMainTexture;
  53209. private _setStencil;
  53210. private _setStencilBack;
  53211. private _draw;
  53212. private _drawCamera;
  53213. private _drawRenderingGroup;
  53214. }
  53215. }
  53216. declare module BABYLON {
  53217. /** @hidden */
  53218. export var glowMapMergePixelShader: {
  53219. name: string;
  53220. shader: string;
  53221. };
  53222. }
  53223. declare module BABYLON {
  53224. /** @hidden */
  53225. export var glowMapMergeVertexShader: {
  53226. name: string;
  53227. shader: string;
  53228. };
  53229. }
  53230. declare module BABYLON {
  53231. interface AbstractScene {
  53232. /**
  53233. * Return a the first highlight layer of the scene with a given name.
  53234. * @param name The name of the highlight layer to look for.
  53235. * @return The highlight layer if found otherwise null.
  53236. */
  53237. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53238. }
  53239. /**
  53240. * Glow layer options. This helps customizing the behaviour
  53241. * of the glow layer.
  53242. */
  53243. export interface IGlowLayerOptions {
  53244. /**
  53245. * Multiplication factor apply to the canvas size to compute the render target size
  53246. * used to generated the glowing objects (the smaller the faster).
  53247. */
  53248. mainTextureRatio: number;
  53249. /**
  53250. * Enforces a fixed size texture to ensure resize independant blur.
  53251. */
  53252. mainTextureFixedSize?: number;
  53253. /**
  53254. * How big is the kernel of the blur texture.
  53255. */
  53256. blurKernelSize: number;
  53257. /**
  53258. * The camera attached to the layer.
  53259. */
  53260. camera: Nullable<Camera>;
  53261. /**
  53262. * Enable MSAA by chosing the number of samples.
  53263. */
  53264. mainTextureSamples?: number;
  53265. /**
  53266. * The rendering group to draw the layer in.
  53267. */
  53268. renderingGroupId: number;
  53269. }
  53270. /**
  53271. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53272. *
  53273. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53274. *
  53275. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53276. */
  53277. export class GlowLayer extends EffectLayer {
  53278. /**
  53279. * Effect Name of the layer.
  53280. */
  53281. static readonly EffectName: string;
  53282. /**
  53283. * The default blur kernel size used for the glow.
  53284. */
  53285. static DefaultBlurKernelSize: number;
  53286. /**
  53287. * The default texture size ratio used for the glow.
  53288. */
  53289. static DefaultTextureRatio: number;
  53290. /**
  53291. * Sets the kernel size of the blur.
  53292. */
  53293. set blurKernelSize(value: number);
  53294. /**
  53295. * Gets the kernel size of the blur.
  53296. */
  53297. get blurKernelSize(): number;
  53298. /**
  53299. * Sets the glow intensity.
  53300. */
  53301. set intensity(value: number);
  53302. /**
  53303. * Gets the glow intensity.
  53304. */
  53305. get intensity(): number;
  53306. private _options;
  53307. private _intensity;
  53308. private _horizontalBlurPostprocess1;
  53309. private _verticalBlurPostprocess1;
  53310. private _horizontalBlurPostprocess2;
  53311. private _verticalBlurPostprocess2;
  53312. private _blurTexture1;
  53313. private _blurTexture2;
  53314. private _postProcesses1;
  53315. private _postProcesses2;
  53316. private _includedOnlyMeshes;
  53317. private _excludedMeshes;
  53318. private _meshesUsingTheirOwnMaterials;
  53319. /**
  53320. * Callback used to let the user override the color selection on a per mesh basis
  53321. */
  53322. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53323. /**
  53324. * Callback used to let the user override the texture selection on a per mesh basis
  53325. */
  53326. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53327. /**
  53328. * Instantiates a new glow Layer and references it to the scene.
  53329. * @param name The name of the layer
  53330. * @param scene The scene to use the layer in
  53331. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53332. */
  53333. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53334. /**
  53335. * Get the effect name of the layer.
  53336. * @return The effect name
  53337. */
  53338. getEffectName(): string;
  53339. /**
  53340. * Create the merge effect. This is the shader use to blit the information back
  53341. * to the main canvas at the end of the scene rendering.
  53342. */
  53343. protected _createMergeEffect(): Effect;
  53344. /**
  53345. * Creates the render target textures and post processes used in the glow layer.
  53346. */
  53347. protected _createTextureAndPostProcesses(): void;
  53348. /**
  53349. * Checks for the readiness of the element composing the layer.
  53350. * @param subMesh the mesh to check for
  53351. * @param useInstances specify wether or not to use instances to render the mesh
  53352. * @param emissiveTexture the associated emissive texture used to generate the glow
  53353. * @return true if ready otherwise, false
  53354. */
  53355. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53356. /**
  53357. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53358. */
  53359. needStencil(): boolean;
  53360. /**
  53361. * Returns true if the mesh can be rendered, otherwise false.
  53362. * @param mesh The mesh to render
  53363. * @param material The material used on the mesh
  53364. * @returns true if it can be rendered otherwise false
  53365. */
  53366. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53367. /**
  53368. * Implementation specific of rendering the generating effect on the main canvas.
  53369. * @param effect The effect used to render through
  53370. */
  53371. protected _internalRender(effect: Effect): void;
  53372. /**
  53373. * Sets the required values for both the emissive texture and and the main color.
  53374. */
  53375. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53376. /**
  53377. * Returns true if the mesh should render, otherwise false.
  53378. * @param mesh The mesh to render
  53379. * @returns true if it should render otherwise false
  53380. */
  53381. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53382. /**
  53383. * Adds specific effects defines.
  53384. * @param defines The defines to add specifics to.
  53385. */
  53386. protected _addCustomEffectDefines(defines: string[]): void;
  53387. /**
  53388. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53389. * @param mesh The mesh to exclude from the glow layer
  53390. */
  53391. addExcludedMesh(mesh: Mesh): void;
  53392. /**
  53393. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53394. * @param mesh The mesh to remove
  53395. */
  53396. removeExcludedMesh(mesh: Mesh): void;
  53397. /**
  53398. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53399. * @param mesh The mesh to include in the glow layer
  53400. */
  53401. addIncludedOnlyMesh(mesh: Mesh): void;
  53402. /**
  53403. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53404. * @param mesh The mesh to remove
  53405. */
  53406. removeIncludedOnlyMesh(mesh: Mesh): void;
  53407. /**
  53408. * Determine if a given mesh will be used in the glow layer
  53409. * @param mesh The mesh to test
  53410. * @returns true if the mesh will be highlighted by the current glow layer
  53411. */
  53412. hasMesh(mesh: AbstractMesh): boolean;
  53413. /**
  53414. * Defines wether the current material of the mesh should be use to render the effect.
  53415. * @param mesh defines the current mesh to render
  53416. */
  53417. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53418. /**
  53419. * Add a mesh to be rendered through its own material and not with emissive only.
  53420. * @param mesh The mesh for which we need to use its material
  53421. */
  53422. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53423. /**
  53424. * Remove a mesh from being rendered through its own material and not with emissive only.
  53425. * @param mesh The mesh for which we need to not use its material
  53426. */
  53427. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53428. /**
  53429. * Free any resources and references associated to a mesh.
  53430. * Internal use
  53431. * @param mesh The mesh to free.
  53432. * @hidden
  53433. */
  53434. _disposeMesh(mesh: Mesh): void;
  53435. /**
  53436. * Gets the class name of the effect layer
  53437. * @returns the string with the class name of the effect layer
  53438. */
  53439. getClassName(): string;
  53440. /**
  53441. * Serializes this glow layer
  53442. * @returns a serialized glow layer object
  53443. */
  53444. serialize(): any;
  53445. /**
  53446. * Creates a Glow Layer from parsed glow layer data
  53447. * @param parsedGlowLayer defines glow layer data
  53448. * @param scene defines the current scene
  53449. * @param rootUrl defines the root URL containing the glow layer information
  53450. * @returns a parsed Glow Layer
  53451. */
  53452. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53453. }
  53454. }
  53455. declare module BABYLON {
  53456. /** @hidden */
  53457. export var glowBlurPostProcessPixelShader: {
  53458. name: string;
  53459. shader: string;
  53460. };
  53461. }
  53462. declare module BABYLON {
  53463. interface AbstractScene {
  53464. /**
  53465. * Return a the first highlight layer of the scene with a given name.
  53466. * @param name The name of the highlight layer to look for.
  53467. * @return The highlight layer if found otherwise null.
  53468. */
  53469. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53470. }
  53471. /**
  53472. * Highlight layer options. This helps customizing the behaviour
  53473. * of the highlight layer.
  53474. */
  53475. export interface IHighlightLayerOptions {
  53476. /**
  53477. * Multiplication factor apply to the canvas size to compute the render target size
  53478. * used to generated the glowing objects (the smaller the faster).
  53479. */
  53480. mainTextureRatio: number;
  53481. /**
  53482. * Enforces a fixed size texture to ensure resize independant blur.
  53483. */
  53484. mainTextureFixedSize?: number;
  53485. /**
  53486. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53487. * of the picture to blur (the smaller the faster).
  53488. */
  53489. blurTextureSizeRatio: number;
  53490. /**
  53491. * How big in texel of the blur texture is the vertical blur.
  53492. */
  53493. blurVerticalSize: number;
  53494. /**
  53495. * How big in texel of the blur texture is the horizontal blur.
  53496. */
  53497. blurHorizontalSize: number;
  53498. /**
  53499. * Alpha blending mode used to apply the blur. Default is combine.
  53500. */
  53501. alphaBlendingMode: number;
  53502. /**
  53503. * The camera attached to the layer.
  53504. */
  53505. camera: Nullable<Camera>;
  53506. /**
  53507. * Should we display highlight as a solid stroke?
  53508. */
  53509. isStroke?: boolean;
  53510. /**
  53511. * The rendering group to draw the layer in.
  53512. */
  53513. renderingGroupId: number;
  53514. }
  53515. /**
  53516. * The highlight layer Helps adding a glow effect around a mesh.
  53517. *
  53518. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53519. * glowy meshes to your scene.
  53520. *
  53521. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53522. */
  53523. export class HighlightLayer extends EffectLayer {
  53524. name: string;
  53525. /**
  53526. * Effect Name of the highlight layer.
  53527. */
  53528. static readonly EffectName: string;
  53529. /**
  53530. * The neutral color used during the preparation of the glow effect.
  53531. * This is black by default as the blend operation is a blend operation.
  53532. */
  53533. static NeutralColor: Color4;
  53534. /**
  53535. * Stencil value used for glowing meshes.
  53536. */
  53537. static GlowingMeshStencilReference: number;
  53538. /**
  53539. * Stencil value used for the other meshes in the scene.
  53540. */
  53541. static NormalMeshStencilReference: number;
  53542. /**
  53543. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53544. */
  53545. innerGlow: boolean;
  53546. /**
  53547. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53548. */
  53549. outerGlow: boolean;
  53550. /**
  53551. * Specifies the horizontal size of the blur.
  53552. */
  53553. set blurHorizontalSize(value: number);
  53554. /**
  53555. * Specifies the vertical size of the blur.
  53556. */
  53557. set blurVerticalSize(value: number);
  53558. /**
  53559. * Gets the horizontal size of the blur.
  53560. */
  53561. get blurHorizontalSize(): number;
  53562. /**
  53563. * Gets the vertical size of the blur.
  53564. */
  53565. get blurVerticalSize(): number;
  53566. /**
  53567. * An event triggered when the highlight layer is being blurred.
  53568. */
  53569. onBeforeBlurObservable: Observable<HighlightLayer>;
  53570. /**
  53571. * An event triggered when the highlight layer has been blurred.
  53572. */
  53573. onAfterBlurObservable: Observable<HighlightLayer>;
  53574. private _instanceGlowingMeshStencilReference;
  53575. private _options;
  53576. private _downSamplePostprocess;
  53577. private _horizontalBlurPostprocess;
  53578. private _verticalBlurPostprocess;
  53579. private _blurTexture;
  53580. private _meshes;
  53581. private _excludedMeshes;
  53582. /**
  53583. * Instantiates a new highlight Layer and references it to the scene..
  53584. * @param name The name of the layer
  53585. * @param scene The scene to use the layer in
  53586. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53587. */
  53588. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53589. /**
  53590. * Get the effect name of the layer.
  53591. * @return The effect name
  53592. */
  53593. getEffectName(): string;
  53594. /**
  53595. * Create the merge effect. This is the shader use to blit the information back
  53596. * to the main canvas at the end of the scene rendering.
  53597. */
  53598. protected _createMergeEffect(): Effect;
  53599. /**
  53600. * Creates the render target textures and post processes used in the highlight layer.
  53601. */
  53602. protected _createTextureAndPostProcesses(): void;
  53603. /**
  53604. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53605. */
  53606. needStencil(): boolean;
  53607. /**
  53608. * Checks for the readiness of the element composing the layer.
  53609. * @param subMesh the mesh to check for
  53610. * @param useInstances specify wether or not to use instances to render the mesh
  53611. * @param emissiveTexture the associated emissive texture used to generate the glow
  53612. * @return true if ready otherwise, false
  53613. */
  53614. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53615. /**
  53616. * Implementation specific of rendering the generating effect on the main canvas.
  53617. * @param effect The effect used to render through
  53618. */
  53619. protected _internalRender(effect: Effect): void;
  53620. /**
  53621. * Returns true if the layer contains information to display, otherwise false.
  53622. */
  53623. shouldRender(): boolean;
  53624. /**
  53625. * Returns true if the mesh should render, otherwise false.
  53626. * @param mesh The mesh to render
  53627. * @returns true if it should render otherwise false
  53628. */
  53629. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53630. /**
  53631. * Sets the required values for both the emissive texture and and the main color.
  53632. */
  53633. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53634. /**
  53635. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53636. * @param mesh The mesh to exclude from the highlight layer
  53637. */
  53638. addExcludedMesh(mesh: Mesh): void;
  53639. /**
  53640. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53641. * @param mesh The mesh to highlight
  53642. */
  53643. removeExcludedMesh(mesh: Mesh): void;
  53644. /**
  53645. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53646. * @param mesh mesh to test
  53647. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53648. */
  53649. hasMesh(mesh: AbstractMesh): boolean;
  53650. /**
  53651. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53652. * @param mesh The mesh to highlight
  53653. * @param color The color of the highlight
  53654. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53655. */
  53656. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53657. /**
  53658. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53659. * @param mesh The mesh to highlight
  53660. */
  53661. removeMesh(mesh: Mesh): void;
  53662. /**
  53663. * Force the stencil to the normal expected value for none glowing parts
  53664. */
  53665. private _defaultStencilReference;
  53666. /**
  53667. * Free any resources and references associated to a mesh.
  53668. * Internal use
  53669. * @param mesh The mesh to free.
  53670. * @hidden
  53671. */
  53672. _disposeMesh(mesh: Mesh): void;
  53673. /**
  53674. * Dispose the highlight layer and free resources.
  53675. */
  53676. dispose(): void;
  53677. /**
  53678. * Gets the class name of the effect layer
  53679. * @returns the string with the class name of the effect layer
  53680. */
  53681. getClassName(): string;
  53682. /**
  53683. * Serializes this Highlight layer
  53684. * @returns a serialized Highlight layer object
  53685. */
  53686. serialize(): any;
  53687. /**
  53688. * Creates a Highlight layer from parsed Highlight layer data
  53689. * @param parsedHightlightLayer defines the Highlight layer data
  53690. * @param scene defines the current scene
  53691. * @param rootUrl defines the root URL containing the Highlight layer information
  53692. * @returns a parsed Highlight layer
  53693. */
  53694. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53695. }
  53696. }
  53697. declare module BABYLON {
  53698. interface AbstractScene {
  53699. /**
  53700. * The list of layers (background and foreground) of the scene
  53701. */
  53702. layers: Array<Layer>;
  53703. }
  53704. /**
  53705. * Defines the layer scene component responsible to manage any layers
  53706. * in a given scene.
  53707. */
  53708. export class LayerSceneComponent implements ISceneComponent {
  53709. /**
  53710. * The component name helpfull to identify the component in the list of scene components.
  53711. */
  53712. readonly name: string;
  53713. /**
  53714. * The scene the component belongs to.
  53715. */
  53716. scene: Scene;
  53717. private _engine;
  53718. /**
  53719. * Creates a new instance of the component for the given scene
  53720. * @param scene Defines the scene to register the component in
  53721. */
  53722. constructor(scene: Scene);
  53723. /**
  53724. * Registers the component in a given scene
  53725. */
  53726. register(): void;
  53727. /**
  53728. * Rebuilds the elements related to this component in case of
  53729. * context lost for instance.
  53730. */
  53731. rebuild(): void;
  53732. /**
  53733. * Disposes the component and the associated ressources.
  53734. */
  53735. dispose(): void;
  53736. private _draw;
  53737. private _drawCameraPredicate;
  53738. private _drawCameraBackground;
  53739. private _drawCameraForeground;
  53740. private _drawRenderTargetPredicate;
  53741. private _drawRenderTargetBackground;
  53742. private _drawRenderTargetForeground;
  53743. /**
  53744. * Adds all the elements from the container to the scene
  53745. * @param container the container holding the elements
  53746. */
  53747. addFromContainer(container: AbstractScene): void;
  53748. /**
  53749. * Removes all the elements in the container from the scene
  53750. * @param container contains the elements to remove
  53751. * @param dispose if the removed element should be disposed (default: false)
  53752. */
  53753. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53754. }
  53755. }
  53756. declare module BABYLON {
  53757. /** @hidden */
  53758. export var layerPixelShader: {
  53759. name: string;
  53760. shader: string;
  53761. };
  53762. }
  53763. declare module BABYLON {
  53764. /** @hidden */
  53765. export var layerVertexShader: {
  53766. name: string;
  53767. shader: string;
  53768. };
  53769. }
  53770. declare module BABYLON {
  53771. /**
  53772. * This represents a full screen 2d layer.
  53773. * This can be useful to display a picture in the background of your scene for instance.
  53774. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53775. */
  53776. export class Layer {
  53777. /**
  53778. * Define the name of the layer.
  53779. */
  53780. name: string;
  53781. /**
  53782. * Define the texture the layer should display.
  53783. */
  53784. texture: Nullable<Texture>;
  53785. /**
  53786. * Is the layer in background or foreground.
  53787. */
  53788. isBackground: boolean;
  53789. /**
  53790. * Define the color of the layer (instead of texture).
  53791. */
  53792. color: Color4;
  53793. /**
  53794. * Define the scale of the layer in order to zoom in out of the texture.
  53795. */
  53796. scale: Vector2;
  53797. /**
  53798. * Define an offset for the layer in order to shift the texture.
  53799. */
  53800. offset: Vector2;
  53801. /**
  53802. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53803. */
  53804. alphaBlendingMode: number;
  53805. /**
  53806. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53807. * Alpha test will not mix with the background color in case of transparency.
  53808. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53809. */
  53810. alphaTest: boolean;
  53811. /**
  53812. * Define a mask to restrict the layer to only some of the scene cameras.
  53813. */
  53814. layerMask: number;
  53815. /**
  53816. * Define the list of render target the layer is visible into.
  53817. */
  53818. renderTargetTextures: RenderTargetTexture[];
  53819. /**
  53820. * Define if the layer is only used in renderTarget or if it also
  53821. * renders in the main frame buffer of the canvas.
  53822. */
  53823. renderOnlyInRenderTargetTextures: boolean;
  53824. private _scene;
  53825. private _vertexBuffers;
  53826. private _indexBuffer;
  53827. private _effect;
  53828. private _previousDefines;
  53829. /**
  53830. * An event triggered when the layer is disposed.
  53831. */
  53832. onDisposeObservable: Observable<Layer>;
  53833. private _onDisposeObserver;
  53834. /**
  53835. * Back compatibility with callback before the onDisposeObservable existed.
  53836. * The set callback will be triggered when the layer has been disposed.
  53837. */
  53838. set onDispose(callback: () => void);
  53839. /**
  53840. * An event triggered before rendering the scene
  53841. */
  53842. onBeforeRenderObservable: Observable<Layer>;
  53843. private _onBeforeRenderObserver;
  53844. /**
  53845. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53846. * The set callback will be triggered just before rendering the layer.
  53847. */
  53848. set onBeforeRender(callback: () => void);
  53849. /**
  53850. * An event triggered after rendering the scene
  53851. */
  53852. onAfterRenderObservable: Observable<Layer>;
  53853. private _onAfterRenderObserver;
  53854. /**
  53855. * Back compatibility with callback before the onAfterRenderObservable existed.
  53856. * The set callback will be triggered just after rendering the layer.
  53857. */
  53858. set onAfterRender(callback: () => void);
  53859. /**
  53860. * Instantiates a new layer.
  53861. * This represents a full screen 2d layer.
  53862. * This can be useful to display a picture in the background of your scene for instance.
  53863. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53864. * @param name Define the name of the layer in the scene
  53865. * @param imgUrl Define the url of the texture to display in the layer
  53866. * @param scene Define the scene the layer belongs to
  53867. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53868. * @param color Defines a color for the layer
  53869. */
  53870. constructor(
  53871. /**
  53872. * Define the name of the layer.
  53873. */
  53874. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53875. private _createIndexBuffer;
  53876. /** @hidden */
  53877. _rebuild(): void;
  53878. /**
  53879. * Renders the layer in the scene.
  53880. */
  53881. render(): void;
  53882. /**
  53883. * Disposes and releases the associated ressources.
  53884. */
  53885. dispose(): void;
  53886. }
  53887. }
  53888. declare module BABYLON {
  53889. /** @hidden */
  53890. export var lensFlarePixelShader: {
  53891. name: string;
  53892. shader: string;
  53893. };
  53894. }
  53895. declare module BABYLON {
  53896. /** @hidden */
  53897. export var lensFlareVertexShader: {
  53898. name: string;
  53899. shader: string;
  53900. };
  53901. }
  53902. declare module BABYLON {
  53903. /**
  53904. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53905. * It is usually composed of several `lensFlare`.
  53906. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53907. */
  53908. export class LensFlareSystem {
  53909. /**
  53910. * Define the name of the lens flare system
  53911. */
  53912. name: string;
  53913. /**
  53914. * List of lens flares used in this system.
  53915. */
  53916. lensFlares: LensFlare[];
  53917. /**
  53918. * Define a limit from the border the lens flare can be visible.
  53919. */
  53920. borderLimit: number;
  53921. /**
  53922. * Define a viewport border we do not want to see the lens flare in.
  53923. */
  53924. viewportBorder: number;
  53925. /**
  53926. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53927. */
  53928. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53929. /**
  53930. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53931. */
  53932. layerMask: number;
  53933. /**
  53934. * Define the id of the lens flare system in the scene.
  53935. * (equal to name by default)
  53936. */
  53937. id: string;
  53938. private _scene;
  53939. private _emitter;
  53940. private _vertexBuffers;
  53941. private _indexBuffer;
  53942. private _effect;
  53943. private _positionX;
  53944. private _positionY;
  53945. private _isEnabled;
  53946. /** @hidden */
  53947. static _SceneComponentInitialization: (scene: Scene) => void;
  53948. /**
  53949. * Instantiates a lens flare system.
  53950. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53951. * It is usually composed of several `lensFlare`.
  53952. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53953. * @param name Define the name of the lens flare system in the scene
  53954. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53955. * @param scene Define the scene the lens flare system belongs to
  53956. */
  53957. constructor(
  53958. /**
  53959. * Define the name of the lens flare system
  53960. */
  53961. name: string, emitter: any, scene: Scene);
  53962. /**
  53963. * Define if the lens flare system is enabled.
  53964. */
  53965. get isEnabled(): boolean;
  53966. set isEnabled(value: boolean);
  53967. /**
  53968. * Get the scene the effects belongs to.
  53969. * @returns the scene holding the lens flare system
  53970. */
  53971. getScene(): Scene;
  53972. /**
  53973. * Get the emitter of the lens flare system.
  53974. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53975. * @returns the emitter of the lens flare system
  53976. */
  53977. getEmitter(): any;
  53978. /**
  53979. * Set the emitter of the lens flare system.
  53980. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53981. * @param newEmitter Define the new emitter of the system
  53982. */
  53983. setEmitter(newEmitter: any): void;
  53984. /**
  53985. * Get the lens flare system emitter position.
  53986. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53987. * @returns the position
  53988. */
  53989. getEmitterPosition(): Vector3;
  53990. /**
  53991. * @hidden
  53992. */
  53993. computeEffectivePosition(globalViewport: Viewport): boolean;
  53994. /** @hidden */
  53995. _isVisible(): boolean;
  53996. /**
  53997. * @hidden
  53998. */
  53999. render(): boolean;
  54000. /**
  54001. * Dispose and release the lens flare with its associated resources.
  54002. */
  54003. dispose(): void;
  54004. /**
  54005. * Parse a lens flare system from a JSON repressentation
  54006. * @param parsedLensFlareSystem Define the JSON to parse
  54007. * @param scene Define the scene the parsed system should be instantiated in
  54008. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54009. * @returns the parsed system
  54010. */
  54011. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54012. /**
  54013. * Serialize the current Lens Flare System into a JSON representation.
  54014. * @returns the serialized JSON
  54015. */
  54016. serialize(): any;
  54017. }
  54018. }
  54019. declare module BABYLON {
  54020. /**
  54021. * This represents one of the lens effect in a `lensFlareSystem`.
  54022. * It controls one of the indiviual texture used in the effect.
  54023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54024. */
  54025. export class LensFlare {
  54026. /**
  54027. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54028. */
  54029. size: number;
  54030. /**
  54031. * 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.
  54032. */
  54033. position: number;
  54034. /**
  54035. * Define the lens color.
  54036. */
  54037. color: Color3;
  54038. /**
  54039. * Define the lens texture.
  54040. */
  54041. texture: Nullable<Texture>;
  54042. /**
  54043. * Define the alpha mode to render this particular lens.
  54044. */
  54045. alphaMode: number;
  54046. private _system;
  54047. /**
  54048. * Creates a new Lens Flare.
  54049. * This represents one of the lens effect in a `lensFlareSystem`.
  54050. * It controls one of the indiviual texture used in the effect.
  54051. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54052. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54053. * @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.
  54054. * @param color Define the lens color
  54055. * @param imgUrl Define the lens texture url
  54056. * @param system Define the `lensFlareSystem` this flare is part of
  54057. * @returns The newly created Lens Flare
  54058. */
  54059. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54060. /**
  54061. * Instantiates a new Lens Flare.
  54062. * This represents one of the lens effect in a `lensFlareSystem`.
  54063. * It controls one of the indiviual texture used in the effect.
  54064. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54065. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54066. * @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.
  54067. * @param color Define the lens color
  54068. * @param imgUrl Define the lens texture url
  54069. * @param system Define the `lensFlareSystem` this flare is part of
  54070. */
  54071. constructor(
  54072. /**
  54073. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54074. */
  54075. size: number,
  54076. /**
  54077. * 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.
  54078. */
  54079. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54080. /**
  54081. * Dispose and release the lens flare with its associated resources.
  54082. */
  54083. dispose(): void;
  54084. }
  54085. }
  54086. declare module BABYLON {
  54087. interface AbstractScene {
  54088. /**
  54089. * The list of lens flare system added to the scene
  54090. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54091. */
  54092. lensFlareSystems: Array<LensFlareSystem>;
  54093. /**
  54094. * Removes the given lens flare system from this scene.
  54095. * @param toRemove The lens flare system to remove
  54096. * @returns The index of the removed lens flare system
  54097. */
  54098. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54099. /**
  54100. * Adds the given lens flare system to this scene
  54101. * @param newLensFlareSystem The lens flare system to add
  54102. */
  54103. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54104. /**
  54105. * Gets a lens flare system using its name
  54106. * @param name defines the name to look for
  54107. * @returns the lens flare system or null if not found
  54108. */
  54109. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54110. /**
  54111. * Gets a lens flare system using its id
  54112. * @param id defines the id to look for
  54113. * @returns the lens flare system or null if not found
  54114. */
  54115. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54116. }
  54117. /**
  54118. * Defines the lens flare scene component responsible to manage any lens flares
  54119. * in a given scene.
  54120. */
  54121. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54122. /**
  54123. * The component name helpfull to identify the component in the list of scene components.
  54124. */
  54125. readonly name: string;
  54126. /**
  54127. * The scene the component belongs to.
  54128. */
  54129. scene: Scene;
  54130. /**
  54131. * Creates a new instance of the component for the given scene
  54132. * @param scene Defines the scene to register the component in
  54133. */
  54134. constructor(scene: Scene);
  54135. /**
  54136. * Registers the component in a given scene
  54137. */
  54138. register(): void;
  54139. /**
  54140. * Rebuilds the elements related to this component in case of
  54141. * context lost for instance.
  54142. */
  54143. rebuild(): void;
  54144. /**
  54145. * Adds all the elements from the container to the scene
  54146. * @param container the container holding the elements
  54147. */
  54148. addFromContainer(container: AbstractScene): void;
  54149. /**
  54150. * Removes all the elements in the container from the scene
  54151. * @param container contains the elements to remove
  54152. * @param dispose if the removed element should be disposed (default: false)
  54153. */
  54154. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54155. /**
  54156. * Serializes the component data to the specified json object
  54157. * @param serializationObject The object to serialize to
  54158. */
  54159. serialize(serializationObject: any): void;
  54160. /**
  54161. * Disposes the component and the associated ressources.
  54162. */
  54163. dispose(): void;
  54164. private _draw;
  54165. }
  54166. }
  54167. declare module BABYLON {
  54168. /** @hidden */
  54169. export var depthPixelShader: {
  54170. name: string;
  54171. shader: string;
  54172. };
  54173. }
  54174. declare module BABYLON {
  54175. /** @hidden */
  54176. export var depthVertexShader: {
  54177. name: string;
  54178. shader: string;
  54179. };
  54180. }
  54181. declare module BABYLON {
  54182. /**
  54183. * This represents a depth renderer in Babylon.
  54184. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54185. */
  54186. export class DepthRenderer {
  54187. private _scene;
  54188. private _depthMap;
  54189. private _effect;
  54190. private readonly _storeNonLinearDepth;
  54191. private readonly _clearColor;
  54192. /** Get if the depth renderer is using packed depth or not */
  54193. readonly isPacked: boolean;
  54194. private _cachedDefines;
  54195. private _camera;
  54196. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54197. enabled: boolean;
  54198. /**
  54199. * Specifiess that the depth renderer will only be used within
  54200. * the camera it is created for.
  54201. * This can help forcing its rendering during the camera processing.
  54202. */
  54203. useOnlyInActiveCamera: boolean;
  54204. /** @hidden */
  54205. static _SceneComponentInitialization: (scene: Scene) => void;
  54206. /**
  54207. * Instantiates a depth renderer
  54208. * @param scene The scene the renderer belongs to
  54209. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54210. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54211. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54212. */
  54213. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54214. /**
  54215. * Creates the depth rendering effect and checks if the effect is ready.
  54216. * @param subMesh The submesh to be used to render the depth map of
  54217. * @param useInstances If multiple world instances should be used
  54218. * @returns if the depth renderer is ready to render the depth map
  54219. */
  54220. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54221. /**
  54222. * Gets the texture which the depth map will be written to.
  54223. * @returns The depth map texture
  54224. */
  54225. getDepthMap(): RenderTargetTexture;
  54226. /**
  54227. * Disposes of the depth renderer.
  54228. */
  54229. dispose(): void;
  54230. }
  54231. }
  54232. declare module BABYLON {
  54233. /** @hidden */
  54234. export var minmaxReduxPixelShader: {
  54235. name: string;
  54236. shader: string;
  54237. };
  54238. }
  54239. declare module BABYLON {
  54240. /**
  54241. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54242. * and maximum values from all values of the texture.
  54243. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54244. * The source values are read from the red channel of the texture.
  54245. */
  54246. export class MinMaxReducer {
  54247. /**
  54248. * Observable triggered when the computation has been performed
  54249. */
  54250. onAfterReductionPerformed: Observable<{
  54251. min: number;
  54252. max: number;
  54253. }>;
  54254. protected _camera: Camera;
  54255. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54256. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54257. protected _postProcessManager: PostProcessManager;
  54258. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54259. protected _forceFullscreenViewport: boolean;
  54260. /**
  54261. * Creates a min/max reducer
  54262. * @param camera The camera to use for the post processes
  54263. */
  54264. constructor(camera: Camera);
  54265. /**
  54266. * Gets the texture used to read the values from.
  54267. */
  54268. get sourceTexture(): Nullable<RenderTargetTexture>;
  54269. /**
  54270. * Sets the source texture to read the values from.
  54271. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54272. * because in such textures '1' value must not be taken into account to compute the maximum
  54273. * as this value is used to clear the texture.
  54274. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54275. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54276. * @param depthRedux Indicates if the texture is a depth texture or not
  54277. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54278. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54279. */
  54280. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54281. /**
  54282. * Defines the refresh rate of the computation.
  54283. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54284. */
  54285. get refreshRate(): number;
  54286. set refreshRate(value: number);
  54287. protected _activated: boolean;
  54288. /**
  54289. * Gets the activation status of the reducer
  54290. */
  54291. get activated(): boolean;
  54292. /**
  54293. * Activates the reduction computation.
  54294. * When activated, the observers registered in onAfterReductionPerformed are
  54295. * called after the compuation is performed
  54296. */
  54297. activate(): void;
  54298. /**
  54299. * Deactivates the reduction computation.
  54300. */
  54301. deactivate(): void;
  54302. /**
  54303. * Disposes the min/max reducer
  54304. * @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.
  54305. */
  54306. dispose(disposeAll?: boolean): void;
  54307. }
  54308. }
  54309. declare module BABYLON {
  54310. /**
  54311. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54312. */
  54313. export class DepthReducer extends MinMaxReducer {
  54314. private _depthRenderer;
  54315. private _depthRendererId;
  54316. /**
  54317. * Gets the depth renderer used for the computation.
  54318. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54319. */
  54320. get depthRenderer(): Nullable<DepthRenderer>;
  54321. /**
  54322. * Creates a depth reducer
  54323. * @param camera The camera used to render the depth texture
  54324. */
  54325. constructor(camera: Camera);
  54326. /**
  54327. * Sets the depth renderer to use to generate the depth map
  54328. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54329. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54330. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54331. */
  54332. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54333. /** @hidden */
  54334. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54335. /**
  54336. * Activates the reduction computation.
  54337. * When activated, the observers registered in onAfterReductionPerformed are
  54338. * called after the compuation is performed
  54339. */
  54340. activate(): void;
  54341. /**
  54342. * Deactivates the reduction computation.
  54343. */
  54344. deactivate(): void;
  54345. /**
  54346. * Disposes the depth reducer
  54347. * @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.
  54348. */
  54349. dispose(disposeAll?: boolean): void;
  54350. }
  54351. }
  54352. declare module BABYLON {
  54353. /**
  54354. * A CSM implementation allowing casting shadows on large scenes.
  54355. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54356. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54357. */
  54358. export class CascadedShadowGenerator extends ShadowGenerator {
  54359. private static readonly frustumCornersNDCSpace;
  54360. /**
  54361. * Name of the CSM class
  54362. */
  54363. static CLASSNAME: string;
  54364. /**
  54365. * Defines the default number of cascades used by the CSM.
  54366. */
  54367. static readonly DEFAULT_CASCADES_COUNT: number;
  54368. /**
  54369. * Defines the minimum number of cascades used by the CSM.
  54370. */
  54371. static readonly MIN_CASCADES_COUNT: number;
  54372. /**
  54373. * Defines the maximum number of cascades used by the CSM.
  54374. */
  54375. static readonly MAX_CASCADES_COUNT: number;
  54376. protected _validateFilter(filter: number): number;
  54377. /**
  54378. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54379. */
  54380. penumbraDarkness: number;
  54381. private _numCascades;
  54382. /**
  54383. * Gets or set the number of cascades used by the CSM.
  54384. */
  54385. get numCascades(): number;
  54386. set numCascades(value: number);
  54387. /**
  54388. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54389. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54390. */
  54391. stabilizeCascades: boolean;
  54392. private _freezeShadowCastersBoundingInfo;
  54393. private _freezeShadowCastersBoundingInfoObservable;
  54394. /**
  54395. * Enables or disables the shadow casters bounding info computation.
  54396. * If your shadow casters don't move, you can disable this feature.
  54397. * If it is enabled, the bounding box computation is done every frame.
  54398. */
  54399. get freezeShadowCastersBoundingInfo(): boolean;
  54400. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54401. private _scbiMin;
  54402. private _scbiMax;
  54403. protected _computeShadowCastersBoundingInfo(): void;
  54404. protected _shadowCastersBoundingInfo: BoundingInfo;
  54405. /**
  54406. * Gets or sets the shadow casters bounding info.
  54407. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54408. * so that the system won't overwrite the bounds you provide
  54409. */
  54410. get shadowCastersBoundingInfo(): BoundingInfo;
  54411. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54412. protected _breaksAreDirty: boolean;
  54413. protected _minDistance: number;
  54414. protected _maxDistance: number;
  54415. /**
  54416. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54417. *
  54418. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54419. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54420. * @param min minimal distance for the breaks (default to 0.)
  54421. * @param max maximal distance for the breaks (default to 1.)
  54422. */
  54423. setMinMaxDistance(min: number, max: number): void;
  54424. /** Gets the minimal distance used in the cascade break computation */
  54425. get minDistance(): number;
  54426. /** Gets the maximal distance used in the cascade break computation */
  54427. get maxDistance(): number;
  54428. /**
  54429. * Gets the class name of that object
  54430. * @returns "CascadedShadowGenerator"
  54431. */
  54432. getClassName(): string;
  54433. private _cascadeMinExtents;
  54434. private _cascadeMaxExtents;
  54435. /**
  54436. * Gets a cascade minimum extents
  54437. * @param cascadeIndex index of the cascade
  54438. * @returns the minimum cascade extents
  54439. */
  54440. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54441. /**
  54442. * Gets a cascade maximum extents
  54443. * @param cascadeIndex index of the cascade
  54444. * @returns the maximum cascade extents
  54445. */
  54446. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54447. private _cascades;
  54448. private _currentLayer;
  54449. private _viewSpaceFrustumsZ;
  54450. private _viewMatrices;
  54451. private _projectionMatrices;
  54452. private _transformMatrices;
  54453. private _transformMatricesAsArray;
  54454. private _frustumLengths;
  54455. private _lightSizeUVCorrection;
  54456. private _depthCorrection;
  54457. private _frustumCornersWorldSpace;
  54458. private _frustumCenter;
  54459. private _shadowCameraPos;
  54460. private _shadowMaxZ;
  54461. /**
  54462. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54463. * It defaults to camera.maxZ
  54464. */
  54465. get shadowMaxZ(): number;
  54466. /**
  54467. * Sets the shadow max z distance.
  54468. */
  54469. set shadowMaxZ(value: number);
  54470. protected _debug: boolean;
  54471. /**
  54472. * Gets or sets the debug flag.
  54473. * When enabled, the cascades are materialized by different colors on the screen.
  54474. */
  54475. get debug(): boolean;
  54476. set debug(dbg: boolean);
  54477. private _depthClamp;
  54478. /**
  54479. * Gets or sets the depth clamping value.
  54480. *
  54481. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54482. * to account for the shadow casters far away.
  54483. *
  54484. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54485. */
  54486. get depthClamp(): boolean;
  54487. set depthClamp(value: boolean);
  54488. private _cascadeBlendPercentage;
  54489. /**
  54490. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54491. * It defaults to 0.1 (10% blending).
  54492. */
  54493. get cascadeBlendPercentage(): number;
  54494. set cascadeBlendPercentage(value: number);
  54495. private _lambda;
  54496. /**
  54497. * Gets or set the lambda parameter.
  54498. * This parameter is used to split the camera frustum and create the cascades.
  54499. * 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.
  54500. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54501. */
  54502. get lambda(): number;
  54503. set lambda(value: number);
  54504. /**
  54505. * Gets the view matrix corresponding to a given cascade
  54506. * @param cascadeNum cascade to retrieve the view matrix from
  54507. * @returns the cascade view matrix
  54508. */
  54509. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54510. /**
  54511. * Gets the projection matrix corresponding to a given cascade
  54512. * @param cascadeNum cascade to retrieve the projection matrix from
  54513. * @returns the cascade projection matrix
  54514. */
  54515. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54516. /**
  54517. * Gets the transformation matrix corresponding to a given cascade
  54518. * @param cascadeNum cascade to retrieve the transformation matrix from
  54519. * @returns the cascade transformation matrix
  54520. */
  54521. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54522. private _depthRenderer;
  54523. /**
  54524. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54525. *
  54526. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54527. *
  54528. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54529. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54530. * @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
  54531. */
  54532. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54533. private _depthReducer;
  54534. private _autoCalcDepthBounds;
  54535. /**
  54536. * Gets or sets the autoCalcDepthBounds property.
  54537. *
  54538. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54539. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54540. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54541. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54542. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54543. */
  54544. get autoCalcDepthBounds(): boolean;
  54545. set autoCalcDepthBounds(value: boolean);
  54546. /**
  54547. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54548. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54549. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54550. * for setting the refresh rate on the renderer yourself!
  54551. */
  54552. get autoCalcDepthBoundsRefreshRate(): number;
  54553. set autoCalcDepthBoundsRefreshRate(value: number);
  54554. /**
  54555. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54556. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54557. * you change the camera near/far planes!
  54558. */
  54559. splitFrustum(): void;
  54560. private _splitFrustum;
  54561. private _computeMatrices;
  54562. private _computeFrustumInWorldSpace;
  54563. private _computeCascadeFrustum;
  54564. /** @hidden */
  54565. static _SceneComponentInitialization: (scene: Scene) => void;
  54566. /**
  54567. * Creates a Cascaded Shadow Generator object.
  54568. * A ShadowGenerator is the required tool to use the shadows.
  54569. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54570. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54571. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54572. * @param light The directional light object generating the shadows.
  54573. * @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.
  54574. */
  54575. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54576. protected _initializeGenerator(): void;
  54577. protected _createTargetRenderTexture(): void;
  54578. protected _initializeShadowMap(): void;
  54579. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54580. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54581. /**
  54582. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54583. * @param defines Defines of the material we want to update
  54584. * @param lightIndex Index of the light in the enabled light list of the material
  54585. */
  54586. prepareDefines(defines: any, lightIndex: number): void;
  54587. /**
  54588. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54589. * defined in the generator but impacting the effect).
  54590. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54591. * @param effect The effect we are binfing the information for
  54592. */
  54593. bindShadowLight(lightIndex: string, effect: Effect): void;
  54594. /**
  54595. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54596. * (eq to view projection * shadow projection matrices)
  54597. * @returns The transform matrix used to create the shadow map
  54598. */
  54599. getTransformMatrix(): Matrix;
  54600. /**
  54601. * Disposes the ShadowGenerator.
  54602. * Returns nothing.
  54603. */
  54604. dispose(): void;
  54605. /**
  54606. * Serializes the shadow generator setup to a json object.
  54607. * @returns The serialized JSON object
  54608. */
  54609. serialize(): any;
  54610. /**
  54611. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54612. * @param parsedShadowGenerator The JSON object to parse
  54613. * @param scene The scene to create the shadow map for
  54614. * @returns The parsed shadow generator
  54615. */
  54616. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54617. }
  54618. }
  54619. declare module BABYLON {
  54620. /**
  54621. * Defines the shadow generator component responsible to manage any shadow generators
  54622. * in a given scene.
  54623. */
  54624. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54625. /**
  54626. * The component name helpfull to identify the component in the list of scene components.
  54627. */
  54628. readonly name: string;
  54629. /**
  54630. * The scene the component belongs to.
  54631. */
  54632. scene: Scene;
  54633. /**
  54634. * Creates a new instance of the component for the given scene
  54635. * @param scene Defines the scene to register the component in
  54636. */
  54637. constructor(scene: Scene);
  54638. /**
  54639. * Registers the component in a given scene
  54640. */
  54641. register(): void;
  54642. /**
  54643. * Rebuilds the elements related to this component in case of
  54644. * context lost for instance.
  54645. */
  54646. rebuild(): void;
  54647. /**
  54648. * Serializes the component data to the specified json object
  54649. * @param serializationObject The object to serialize to
  54650. */
  54651. serialize(serializationObject: any): void;
  54652. /**
  54653. * Adds all the elements from the container to the scene
  54654. * @param container the container holding the elements
  54655. */
  54656. addFromContainer(container: AbstractScene): void;
  54657. /**
  54658. * Removes all the elements in the container from the scene
  54659. * @param container contains the elements to remove
  54660. * @param dispose if the removed element should be disposed (default: false)
  54661. */
  54662. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54663. /**
  54664. * Rebuilds the elements related to this component in case of
  54665. * context lost for instance.
  54666. */
  54667. dispose(): void;
  54668. private _gatherRenderTargets;
  54669. }
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * A point light is a light defined by an unique point in world space.
  54674. * The light is emitted in every direction from this point.
  54675. * A good example of a point light is a standard light bulb.
  54676. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54677. */
  54678. export class PointLight extends ShadowLight {
  54679. private _shadowAngle;
  54680. /**
  54681. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54682. * This specifies what angle the shadow will use to be created.
  54683. *
  54684. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54685. */
  54686. get shadowAngle(): number;
  54687. /**
  54688. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54689. * This specifies what angle the shadow will use to be created.
  54690. *
  54691. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54692. */
  54693. set shadowAngle(value: number);
  54694. /**
  54695. * Gets the direction if it has been set.
  54696. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54697. */
  54698. get direction(): Vector3;
  54699. /**
  54700. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54701. */
  54702. set direction(value: Vector3);
  54703. /**
  54704. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54705. * A PointLight emits the light in every direction.
  54706. * It can cast shadows.
  54707. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54708. * ```javascript
  54709. * var pointLight = new PointLight("pl", camera.position, scene);
  54710. * ```
  54711. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54712. * @param name The light friendly name
  54713. * @param position The position of the point light in the scene
  54714. * @param scene The scene the lights belongs to
  54715. */
  54716. constructor(name: string, position: Vector3, scene: Scene);
  54717. /**
  54718. * Returns the string "PointLight"
  54719. * @returns the class name
  54720. */
  54721. getClassName(): string;
  54722. /**
  54723. * Returns the integer 0.
  54724. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54725. */
  54726. getTypeID(): number;
  54727. /**
  54728. * Specifies wether or not the shadowmap should be a cube texture.
  54729. * @returns true if the shadowmap needs to be a cube texture.
  54730. */
  54731. needCube(): boolean;
  54732. /**
  54733. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54734. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54735. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54736. */
  54737. getShadowDirection(faceIndex?: number): Vector3;
  54738. /**
  54739. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54740. * - fov = PI / 2
  54741. * - aspect ratio : 1.0
  54742. * - z-near and far equal to the active camera minZ and maxZ.
  54743. * Returns the PointLight.
  54744. */
  54745. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54746. protected _buildUniformLayout(): void;
  54747. /**
  54748. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54749. * @param effect The effect to update
  54750. * @param lightIndex The index of the light in the effect to update
  54751. * @returns The point light
  54752. */
  54753. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54754. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54755. /**
  54756. * Prepares the list of defines specific to the light type.
  54757. * @param defines the list of defines
  54758. * @param lightIndex defines the index of the light for the effect
  54759. */
  54760. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54761. }
  54762. }
  54763. declare module BABYLON {
  54764. /**
  54765. * Header information of HDR texture files.
  54766. */
  54767. export interface HDRInfo {
  54768. /**
  54769. * The height of the texture in pixels.
  54770. */
  54771. height: number;
  54772. /**
  54773. * The width of the texture in pixels.
  54774. */
  54775. width: number;
  54776. /**
  54777. * The index of the beginning of the data in the binary file.
  54778. */
  54779. dataPosition: number;
  54780. }
  54781. /**
  54782. * This groups tools to convert HDR texture to native colors array.
  54783. */
  54784. export class HDRTools {
  54785. private static Ldexp;
  54786. private static Rgbe2float;
  54787. private static readStringLine;
  54788. /**
  54789. * Reads header information from an RGBE texture stored in a native array.
  54790. * More information on this format are available here:
  54791. * https://en.wikipedia.org/wiki/RGBE_image_format
  54792. *
  54793. * @param uint8array The binary file stored in native array.
  54794. * @return The header information.
  54795. */
  54796. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54797. /**
  54798. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54799. * This RGBE texture needs to store the information as a panorama.
  54800. *
  54801. * More information on this format are available here:
  54802. * https://en.wikipedia.org/wiki/RGBE_image_format
  54803. *
  54804. * @param buffer The binary file stored in an array buffer.
  54805. * @param size The expected size of the extracted cubemap.
  54806. * @return The Cube Map information.
  54807. */
  54808. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54809. /**
  54810. * Returns the pixels data extracted from an RGBE texture.
  54811. * This pixels will be stored left to right up to down in the R G B order in one array.
  54812. *
  54813. * More information on this format are available here:
  54814. * https://en.wikipedia.org/wiki/RGBE_image_format
  54815. *
  54816. * @param uint8array The binary file stored in an array buffer.
  54817. * @param hdrInfo The header information of the file.
  54818. * @return The pixels data in RGB right to left up to down order.
  54819. */
  54820. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54821. private static RGBE_ReadPixels_RLE;
  54822. }
  54823. }
  54824. declare module BABYLON {
  54825. /**
  54826. * This represents a texture coming from an HDR input.
  54827. *
  54828. * The only supported format is currently panorama picture stored in RGBE format.
  54829. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54830. */
  54831. export class HDRCubeTexture extends BaseTexture {
  54832. private static _facesMapping;
  54833. private _generateHarmonics;
  54834. private _noMipmap;
  54835. private _textureMatrix;
  54836. private _size;
  54837. private _onLoad;
  54838. private _onError;
  54839. /**
  54840. * The texture URL.
  54841. */
  54842. url: string;
  54843. /**
  54844. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54845. */
  54846. coordinatesMode: number;
  54847. protected _isBlocking: boolean;
  54848. /**
  54849. * Sets wether or not the texture is blocking during loading.
  54850. */
  54851. set isBlocking(value: boolean);
  54852. /**
  54853. * Gets wether or not the texture is blocking during loading.
  54854. */
  54855. get isBlocking(): boolean;
  54856. protected _rotationY: number;
  54857. /**
  54858. * Sets texture matrix rotation angle around Y axis in radians.
  54859. */
  54860. set rotationY(value: number);
  54861. /**
  54862. * Gets texture matrix rotation angle around Y axis radians.
  54863. */
  54864. get rotationY(): number;
  54865. /**
  54866. * Gets or sets the center of the bounding box associated with the cube texture
  54867. * It must define where the camera used to render the texture was set
  54868. */
  54869. boundingBoxPosition: Vector3;
  54870. private _boundingBoxSize;
  54871. /**
  54872. * Gets or sets the size of the bounding box associated with the cube texture
  54873. * When defined, the cubemap will switch to local mode
  54874. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54875. * @example https://www.babylonjs-playground.com/#RNASML
  54876. */
  54877. set boundingBoxSize(value: Vector3);
  54878. get boundingBoxSize(): Vector3;
  54879. /**
  54880. * Instantiates an HDRTexture from the following parameters.
  54881. *
  54882. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54883. * @param scene The scene the texture will be used in
  54884. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54885. * @param noMipmap Forces to not generate the mipmap if true
  54886. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54887. * @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)
  54888. * @param reserved Reserved flag for internal use.
  54889. */
  54890. 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>);
  54891. /**
  54892. * Get the current class name of the texture useful for serialization or dynamic coding.
  54893. * @returns "HDRCubeTexture"
  54894. */
  54895. getClassName(): string;
  54896. /**
  54897. * Occurs when the file is raw .hdr file.
  54898. */
  54899. private loadTexture;
  54900. clone(): HDRCubeTexture;
  54901. delayLoad(): void;
  54902. /**
  54903. * Get the texture reflection matrix used to rotate/transform the reflection.
  54904. * @returns the reflection matrix
  54905. */
  54906. getReflectionTextureMatrix(): Matrix;
  54907. /**
  54908. * Set the texture reflection matrix used to rotate/transform the reflection.
  54909. * @param value Define the reflection matrix to set
  54910. */
  54911. setReflectionTextureMatrix(value: Matrix): void;
  54912. /**
  54913. * Parses a JSON representation of an HDR Texture in order to create the texture
  54914. * @param parsedTexture Define the JSON representation
  54915. * @param scene Define the scene the texture should be created in
  54916. * @param rootUrl Define the root url in case we need to load relative dependencies
  54917. * @returns the newly created texture after parsing
  54918. */
  54919. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54920. serialize(): any;
  54921. }
  54922. }
  54923. declare module BABYLON {
  54924. /**
  54925. * Class used to control physics engine
  54926. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54927. */
  54928. export class PhysicsEngine implements IPhysicsEngine {
  54929. private _physicsPlugin;
  54930. /**
  54931. * Global value used to control the smallest number supported by the simulation
  54932. */
  54933. static Epsilon: number;
  54934. private _impostors;
  54935. private _joints;
  54936. private _subTimeStep;
  54937. /**
  54938. * Gets the gravity vector used by the simulation
  54939. */
  54940. gravity: Vector3;
  54941. /**
  54942. * Factory used to create the default physics plugin.
  54943. * @returns The default physics plugin
  54944. */
  54945. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54946. /**
  54947. * Creates a new Physics Engine
  54948. * @param gravity defines the gravity vector used by the simulation
  54949. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54950. */
  54951. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54952. /**
  54953. * Sets the gravity vector used by the simulation
  54954. * @param gravity defines the gravity vector to use
  54955. */
  54956. setGravity(gravity: Vector3): void;
  54957. /**
  54958. * Set the time step of the physics engine.
  54959. * Default is 1/60.
  54960. * To slow it down, enter 1/600 for example.
  54961. * To speed it up, 1/30
  54962. * @param newTimeStep defines the new timestep to apply to this world.
  54963. */
  54964. setTimeStep(newTimeStep?: number): void;
  54965. /**
  54966. * Get the time step of the physics engine.
  54967. * @returns the current time step
  54968. */
  54969. getTimeStep(): number;
  54970. /**
  54971. * Set the sub time step of the physics engine.
  54972. * Default is 0 meaning there is no sub steps
  54973. * To increase physics resolution precision, set a small value (like 1 ms)
  54974. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54975. */
  54976. setSubTimeStep(subTimeStep?: number): void;
  54977. /**
  54978. * Get the sub time step of the physics engine.
  54979. * @returns the current sub time step
  54980. */
  54981. getSubTimeStep(): number;
  54982. /**
  54983. * Release all resources
  54984. */
  54985. dispose(): void;
  54986. /**
  54987. * Gets the name of the current physics plugin
  54988. * @returns the name of the plugin
  54989. */
  54990. getPhysicsPluginName(): string;
  54991. /**
  54992. * Adding a new impostor for the impostor tracking.
  54993. * This will be done by the impostor itself.
  54994. * @param impostor the impostor to add
  54995. */
  54996. addImpostor(impostor: PhysicsImpostor): void;
  54997. /**
  54998. * Remove an impostor from the engine.
  54999. * This impostor and its mesh will not longer be updated by the physics engine.
  55000. * @param impostor the impostor to remove
  55001. */
  55002. removeImpostor(impostor: PhysicsImpostor): void;
  55003. /**
  55004. * Add a joint to the physics engine
  55005. * @param mainImpostor defines the main impostor to which the joint is added.
  55006. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55007. * @param joint defines the joint that will connect both impostors.
  55008. */
  55009. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55010. /**
  55011. * Removes a joint from the simulation
  55012. * @param mainImpostor defines the impostor used with the joint
  55013. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55014. * @param joint defines the joint to remove
  55015. */
  55016. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55017. /**
  55018. * Called by the scene. No need to call it.
  55019. * @param delta defines the timespam between frames
  55020. */
  55021. _step(delta: number): void;
  55022. /**
  55023. * Gets the current plugin used to run the simulation
  55024. * @returns current plugin
  55025. */
  55026. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55027. /**
  55028. * Gets the list of physic impostors
  55029. * @returns an array of PhysicsImpostor
  55030. */
  55031. getImpostors(): Array<PhysicsImpostor>;
  55032. /**
  55033. * Gets the impostor for a physics enabled object
  55034. * @param object defines the object impersonated by the impostor
  55035. * @returns the PhysicsImpostor or null if not found
  55036. */
  55037. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55038. /**
  55039. * Gets the impostor for a physics body object
  55040. * @param body defines physics body used by the impostor
  55041. * @returns the PhysicsImpostor or null if not found
  55042. */
  55043. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55044. /**
  55045. * Does a raycast in the physics world
  55046. * @param from when should the ray start?
  55047. * @param to when should the ray end?
  55048. * @returns PhysicsRaycastResult
  55049. */
  55050. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55051. }
  55052. }
  55053. declare module BABYLON {
  55054. /** @hidden */
  55055. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55056. private _useDeltaForWorldStep;
  55057. world: any;
  55058. name: string;
  55059. private _physicsMaterials;
  55060. private _fixedTimeStep;
  55061. private _cannonRaycastResult;
  55062. private _raycastResult;
  55063. private _physicsBodysToRemoveAfterStep;
  55064. BJSCANNON: any;
  55065. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55066. setGravity(gravity: Vector3): void;
  55067. setTimeStep(timeStep: number): void;
  55068. getTimeStep(): number;
  55069. executeStep(delta: number): void;
  55070. private _removeMarkedPhysicsBodiesFromWorld;
  55071. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55073. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55074. private _processChildMeshes;
  55075. removePhysicsBody(impostor: PhysicsImpostor): void;
  55076. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55077. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55078. private _addMaterial;
  55079. private _checkWithEpsilon;
  55080. private _createShape;
  55081. private _createHeightmap;
  55082. private _minus90X;
  55083. private _plus90X;
  55084. private _tmpPosition;
  55085. private _tmpDeltaPosition;
  55086. private _tmpUnityRotation;
  55087. private _updatePhysicsBodyTransformation;
  55088. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55089. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55090. isSupported(): boolean;
  55091. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55092. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55093. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55094. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55095. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55096. getBodyMass(impostor: PhysicsImpostor): number;
  55097. getBodyFriction(impostor: PhysicsImpostor): number;
  55098. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55099. getBodyRestitution(impostor: PhysicsImpostor): number;
  55100. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55101. sleepBody(impostor: PhysicsImpostor): void;
  55102. wakeUpBody(impostor: PhysicsImpostor): void;
  55103. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55104. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55105. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55106. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55107. getRadius(impostor: PhysicsImpostor): number;
  55108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55109. dispose(): void;
  55110. private _extendNamespace;
  55111. /**
  55112. * Does a raycast in the physics world
  55113. * @param from when should the ray start?
  55114. * @param to when should the ray end?
  55115. * @returns PhysicsRaycastResult
  55116. */
  55117. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55118. }
  55119. }
  55120. declare module BABYLON {
  55121. /** @hidden */
  55122. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55123. world: any;
  55124. name: string;
  55125. BJSOIMO: any;
  55126. private _raycastResult;
  55127. constructor(iterations?: number, oimoInjection?: any);
  55128. setGravity(gravity: Vector3): void;
  55129. setTimeStep(timeStep: number): void;
  55130. getTimeStep(): number;
  55131. private _tmpImpostorsArray;
  55132. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55133. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55134. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55135. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55136. private _tmpPositionVector;
  55137. removePhysicsBody(impostor: PhysicsImpostor): void;
  55138. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55139. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55140. isSupported(): boolean;
  55141. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55142. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55143. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55144. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55145. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55146. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55147. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55148. getBodyMass(impostor: PhysicsImpostor): number;
  55149. getBodyFriction(impostor: PhysicsImpostor): number;
  55150. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55151. getBodyRestitution(impostor: PhysicsImpostor): number;
  55152. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55153. sleepBody(impostor: PhysicsImpostor): void;
  55154. wakeUpBody(impostor: PhysicsImpostor): void;
  55155. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55156. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55157. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55158. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55159. getRadius(impostor: PhysicsImpostor): number;
  55160. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55161. dispose(): void;
  55162. /**
  55163. * Does a raycast in the physics world
  55164. * @param from when should the ray start?
  55165. * @param to when should the ray end?
  55166. * @returns PhysicsRaycastResult
  55167. */
  55168. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55169. }
  55170. }
  55171. declare module BABYLON {
  55172. /**
  55173. * Class containing static functions to help procedurally build meshes
  55174. */
  55175. export class RibbonBuilder {
  55176. /**
  55177. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55178. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55179. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55180. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55181. * * 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
  55182. * * 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
  55183. * * 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
  55184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55185. * * 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
  55186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55187. * * 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
  55188. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55189. * * 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
  55190. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55192. * @param name defines the name of the mesh
  55193. * @param options defines the options used to create the mesh
  55194. * @param scene defines the hosting scene
  55195. * @returns the ribbon mesh
  55196. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55198. */
  55199. static CreateRibbon(name: string, options: {
  55200. pathArray: Vector3[][];
  55201. closeArray?: boolean;
  55202. closePath?: boolean;
  55203. offset?: number;
  55204. updatable?: boolean;
  55205. sideOrientation?: number;
  55206. frontUVs?: Vector4;
  55207. backUVs?: Vector4;
  55208. instance?: Mesh;
  55209. invertUV?: boolean;
  55210. uvs?: Vector2[];
  55211. colors?: Color4[];
  55212. }, scene?: Nullable<Scene>): Mesh;
  55213. }
  55214. }
  55215. declare module BABYLON {
  55216. /**
  55217. * Class containing static functions to help procedurally build meshes
  55218. */
  55219. export class ShapeBuilder {
  55220. /**
  55221. * 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.
  55222. * * 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.
  55223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55224. * * 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.
  55225. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55226. * * 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
  55227. * * 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
  55228. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55230. * * 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
  55231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55233. * @param name defines the name of the mesh
  55234. * @param options defines the options used to create the mesh
  55235. * @param scene defines the hosting scene
  55236. * @returns the extruded shape mesh
  55237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55239. */
  55240. static ExtrudeShape(name: string, options: {
  55241. shape: Vector3[];
  55242. path: Vector3[];
  55243. scale?: number;
  55244. rotation?: number;
  55245. cap?: number;
  55246. updatable?: boolean;
  55247. sideOrientation?: number;
  55248. frontUVs?: Vector4;
  55249. backUVs?: Vector4;
  55250. instance?: Mesh;
  55251. invertUV?: boolean;
  55252. }, scene?: Nullable<Scene>): Mesh;
  55253. /**
  55254. * Creates an custom extruded shape mesh.
  55255. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55256. * * 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.
  55257. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55258. * * 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
  55259. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55260. * * 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
  55261. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55262. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55263. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55264. * * 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
  55265. * * 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
  55266. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55268. * * 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
  55269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55271. * @param name defines the name of the mesh
  55272. * @param options defines the options used to create the mesh
  55273. * @param scene defines the hosting scene
  55274. * @returns the custom extruded shape mesh
  55275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55278. */
  55279. static ExtrudeShapeCustom(name: string, options: {
  55280. shape: Vector3[];
  55281. path: Vector3[];
  55282. scaleFunction?: any;
  55283. rotationFunction?: any;
  55284. ribbonCloseArray?: boolean;
  55285. ribbonClosePath?: boolean;
  55286. cap?: number;
  55287. updatable?: boolean;
  55288. sideOrientation?: number;
  55289. frontUVs?: Vector4;
  55290. backUVs?: Vector4;
  55291. instance?: Mesh;
  55292. invertUV?: boolean;
  55293. }, scene?: Nullable<Scene>): Mesh;
  55294. private static _ExtrudeShapeGeneric;
  55295. }
  55296. }
  55297. declare module BABYLON {
  55298. /**
  55299. * AmmoJS Physics plugin
  55300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55301. * @see https://github.com/kripken/ammo.js/
  55302. */
  55303. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55304. private _useDeltaForWorldStep;
  55305. /**
  55306. * Reference to the Ammo library
  55307. */
  55308. bjsAMMO: any;
  55309. /**
  55310. * Created ammoJS world which physics bodies are added to
  55311. */
  55312. world: any;
  55313. /**
  55314. * Name of the plugin
  55315. */
  55316. name: string;
  55317. private _timeStep;
  55318. private _fixedTimeStep;
  55319. private _maxSteps;
  55320. private _tmpQuaternion;
  55321. private _tmpAmmoTransform;
  55322. private _tmpAmmoQuaternion;
  55323. private _tmpAmmoConcreteContactResultCallback;
  55324. private _collisionConfiguration;
  55325. private _dispatcher;
  55326. private _overlappingPairCache;
  55327. private _solver;
  55328. private _softBodySolver;
  55329. private _tmpAmmoVectorA;
  55330. private _tmpAmmoVectorB;
  55331. private _tmpAmmoVectorC;
  55332. private _tmpAmmoVectorD;
  55333. private _tmpContactCallbackResult;
  55334. private _tmpAmmoVectorRCA;
  55335. private _tmpAmmoVectorRCB;
  55336. private _raycastResult;
  55337. private static readonly DISABLE_COLLISION_FLAG;
  55338. private static readonly KINEMATIC_FLAG;
  55339. private static readonly DISABLE_DEACTIVATION_FLAG;
  55340. /**
  55341. * Initializes the ammoJS plugin
  55342. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55343. * @param ammoInjection can be used to inject your own ammo reference
  55344. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55345. */
  55346. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55347. /**
  55348. * Sets the gravity of the physics world (m/(s^2))
  55349. * @param gravity Gravity to set
  55350. */
  55351. setGravity(gravity: Vector3): void;
  55352. /**
  55353. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55354. * @param timeStep timestep to use in seconds
  55355. */
  55356. setTimeStep(timeStep: number): void;
  55357. /**
  55358. * 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)
  55359. * @param fixedTimeStep fixedTimeStep to use in seconds
  55360. */
  55361. setFixedTimeStep(fixedTimeStep: number): void;
  55362. /**
  55363. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55364. * @param maxSteps the maximum number of steps by the physics engine per frame
  55365. */
  55366. setMaxSteps(maxSteps: number): void;
  55367. /**
  55368. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55369. * @returns the current timestep in seconds
  55370. */
  55371. getTimeStep(): number;
  55372. /**
  55373. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55374. */
  55375. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55376. private _isImpostorInContact;
  55377. private _isImpostorPairInContact;
  55378. private _stepSimulation;
  55379. /**
  55380. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55381. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55382. * After the step the babylon meshes are set to the position of the physics imposters
  55383. * @param delta amount of time to step forward
  55384. * @param impostors array of imposters to update before/after the step
  55385. */
  55386. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55387. /**
  55388. * Update babylon mesh to match physics world object
  55389. * @param impostor imposter to match
  55390. */
  55391. private _afterSoftStep;
  55392. /**
  55393. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55394. * @param impostor imposter to match
  55395. */
  55396. private _ropeStep;
  55397. /**
  55398. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55399. * @param impostor imposter to match
  55400. */
  55401. private _softbodyOrClothStep;
  55402. private _tmpVector;
  55403. private _tmpMatrix;
  55404. /**
  55405. * Applies an impulse on the imposter
  55406. * @param impostor imposter to apply impulse to
  55407. * @param force amount of force to be applied to the imposter
  55408. * @param contactPoint the location to apply the impulse on the imposter
  55409. */
  55410. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55411. /**
  55412. * Applies a force on the imposter
  55413. * @param impostor imposter to apply force
  55414. * @param force amount of force to be applied to the imposter
  55415. * @param contactPoint the location to apply the force on the imposter
  55416. */
  55417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55418. /**
  55419. * Creates a physics body using the plugin
  55420. * @param impostor the imposter to create the physics body on
  55421. */
  55422. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55423. /**
  55424. * Removes the physics body from the imposter and disposes of the body's memory
  55425. * @param impostor imposter to remove the physics body from
  55426. */
  55427. removePhysicsBody(impostor: PhysicsImpostor): void;
  55428. /**
  55429. * Generates a joint
  55430. * @param impostorJoint the imposter joint to create the joint with
  55431. */
  55432. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55433. /**
  55434. * Removes a joint
  55435. * @param impostorJoint the imposter joint to remove the joint from
  55436. */
  55437. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55438. private _addMeshVerts;
  55439. /**
  55440. * Initialise the soft body vertices to match its object's (mesh) vertices
  55441. * Softbody vertices (nodes) are in world space and to match this
  55442. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55443. * @param impostor to create the softbody for
  55444. */
  55445. private _softVertexData;
  55446. /**
  55447. * Create an impostor's soft body
  55448. * @param impostor to create the softbody for
  55449. */
  55450. private _createSoftbody;
  55451. /**
  55452. * Create cloth for an impostor
  55453. * @param impostor to create the softbody for
  55454. */
  55455. private _createCloth;
  55456. /**
  55457. * Create rope for an impostor
  55458. * @param impostor to create the softbody for
  55459. */
  55460. private _createRope;
  55461. /**
  55462. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55463. * @param impostor to create the custom physics shape for
  55464. */
  55465. private _createCustom;
  55466. private _addHullVerts;
  55467. private _createShape;
  55468. /**
  55469. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55470. * @param impostor imposter containing the physics body and babylon object
  55471. */
  55472. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55473. /**
  55474. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55475. * @param impostor imposter containing the physics body and babylon object
  55476. * @param newPosition new position
  55477. * @param newRotation new rotation
  55478. */
  55479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55480. /**
  55481. * If this plugin is supported
  55482. * @returns true if its supported
  55483. */
  55484. isSupported(): boolean;
  55485. /**
  55486. * Sets the linear velocity of the physics body
  55487. * @param impostor imposter to set the velocity on
  55488. * @param velocity velocity to set
  55489. */
  55490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55491. /**
  55492. * Sets the angular velocity of the physics body
  55493. * @param impostor imposter to set the velocity on
  55494. * @param velocity velocity to set
  55495. */
  55496. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55497. /**
  55498. * gets the linear velocity
  55499. * @param impostor imposter to get linear velocity from
  55500. * @returns linear velocity
  55501. */
  55502. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55503. /**
  55504. * gets the angular velocity
  55505. * @param impostor imposter to get angular velocity from
  55506. * @returns angular velocity
  55507. */
  55508. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55509. /**
  55510. * Sets the mass of physics body
  55511. * @param impostor imposter to set the mass on
  55512. * @param mass mass to set
  55513. */
  55514. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55515. /**
  55516. * Gets the mass of the physics body
  55517. * @param impostor imposter to get the mass from
  55518. * @returns mass
  55519. */
  55520. getBodyMass(impostor: PhysicsImpostor): number;
  55521. /**
  55522. * Gets friction of the impostor
  55523. * @param impostor impostor to get friction from
  55524. * @returns friction value
  55525. */
  55526. getBodyFriction(impostor: PhysicsImpostor): number;
  55527. /**
  55528. * Sets friction of the impostor
  55529. * @param impostor impostor to set friction on
  55530. * @param friction friction value
  55531. */
  55532. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55533. /**
  55534. * Gets restitution of the impostor
  55535. * @param impostor impostor to get restitution from
  55536. * @returns restitution value
  55537. */
  55538. getBodyRestitution(impostor: PhysicsImpostor): number;
  55539. /**
  55540. * Sets resitution of the impostor
  55541. * @param impostor impostor to set resitution on
  55542. * @param restitution resitution value
  55543. */
  55544. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55545. /**
  55546. * Gets pressure inside the impostor
  55547. * @param impostor impostor to get pressure from
  55548. * @returns pressure value
  55549. */
  55550. getBodyPressure(impostor: PhysicsImpostor): number;
  55551. /**
  55552. * Sets pressure inside a soft body impostor
  55553. * Cloth and rope must remain 0 pressure
  55554. * @param impostor impostor to set pressure on
  55555. * @param pressure pressure value
  55556. */
  55557. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55558. /**
  55559. * Gets stiffness of the impostor
  55560. * @param impostor impostor to get stiffness from
  55561. * @returns pressure value
  55562. */
  55563. getBodyStiffness(impostor: PhysicsImpostor): number;
  55564. /**
  55565. * Sets stiffness of the impostor
  55566. * @param impostor impostor to set stiffness on
  55567. * @param stiffness stiffness value from 0 to 1
  55568. */
  55569. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55570. /**
  55571. * Gets velocityIterations of the impostor
  55572. * @param impostor impostor to get velocity iterations from
  55573. * @returns velocityIterations value
  55574. */
  55575. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55576. /**
  55577. * Sets velocityIterations of the impostor
  55578. * @param impostor impostor to set velocity iterations on
  55579. * @param velocityIterations velocityIterations value
  55580. */
  55581. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55582. /**
  55583. * Gets positionIterations of the impostor
  55584. * @param impostor impostor to get position iterations from
  55585. * @returns positionIterations value
  55586. */
  55587. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55588. /**
  55589. * Sets positionIterations of the impostor
  55590. * @param impostor impostor to set position on
  55591. * @param positionIterations positionIterations value
  55592. */
  55593. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55594. /**
  55595. * Append an anchor to a cloth object
  55596. * @param impostor is the cloth impostor to add anchor to
  55597. * @param otherImpostor is the rigid impostor to anchor to
  55598. * @param width ratio across width from 0 to 1
  55599. * @param height ratio up height from 0 to 1
  55600. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55601. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55602. */
  55603. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55604. /**
  55605. * Append an hook to a rope object
  55606. * @param impostor is the rope impostor to add hook to
  55607. * @param otherImpostor is the rigid impostor to hook to
  55608. * @param length ratio along the rope from 0 to 1
  55609. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55610. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55611. */
  55612. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55613. /**
  55614. * Sleeps the physics body and stops it from being active
  55615. * @param impostor impostor to sleep
  55616. */
  55617. sleepBody(impostor: PhysicsImpostor): void;
  55618. /**
  55619. * Activates the physics body
  55620. * @param impostor impostor to activate
  55621. */
  55622. wakeUpBody(impostor: PhysicsImpostor): void;
  55623. /**
  55624. * Updates the distance parameters of the joint
  55625. * @param joint joint to update
  55626. * @param maxDistance maximum distance of the joint
  55627. * @param minDistance minimum distance of the joint
  55628. */
  55629. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55630. /**
  55631. * Sets a motor on the joint
  55632. * @param joint joint to set motor on
  55633. * @param speed speed of the motor
  55634. * @param maxForce maximum force of the motor
  55635. * @param motorIndex index of the motor
  55636. */
  55637. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55638. /**
  55639. * Sets the motors limit
  55640. * @param joint joint to set limit on
  55641. * @param upperLimit upper limit
  55642. * @param lowerLimit lower limit
  55643. */
  55644. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55645. /**
  55646. * Syncs the position and rotation of a mesh with the impostor
  55647. * @param mesh mesh to sync
  55648. * @param impostor impostor to update the mesh with
  55649. */
  55650. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55651. /**
  55652. * Gets the radius of the impostor
  55653. * @param impostor impostor to get radius from
  55654. * @returns the radius
  55655. */
  55656. getRadius(impostor: PhysicsImpostor): number;
  55657. /**
  55658. * Gets the box size of the impostor
  55659. * @param impostor impostor to get box size from
  55660. * @param result the resulting box size
  55661. */
  55662. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55663. /**
  55664. * Disposes of the impostor
  55665. */
  55666. dispose(): void;
  55667. /**
  55668. * Does a raycast in the physics world
  55669. * @param from when should the ray start?
  55670. * @param to when should the ray end?
  55671. * @returns PhysicsRaycastResult
  55672. */
  55673. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55674. }
  55675. }
  55676. declare module BABYLON {
  55677. interface AbstractScene {
  55678. /**
  55679. * The list of reflection probes added to the scene
  55680. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55681. */
  55682. reflectionProbes: Array<ReflectionProbe>;
  55683. /**
  55684. * Removes the given reflection probe from this scene.
  55685. * @param toRemove The reflection probe to remove
  55686. * @returns The index of the removed reflection probe
  55687. */
  55688. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55689. /**
  55690. * Adds the given reflection probe to this scene.
  55691. * @param newReflectionProbe The reflection probe to add
  55692. */
  55693. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55694. }
  55695. /**
  55696. * Class used to generate realtime reflection / refraction cube textures
  55697. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55698. */
  55699. export class ReflectionProbe {
  55700. /** defines the name of the probe */
  55701. name: string;
  55702. private _scene;
  55703. private _renderTargetTexture;
  55704. private _projectionMatrix;
  55705. private _viewMatrix;
  55706. private _target;
  55707. private _add;
  55708. private _attachedMesh;
  55709. private _invertYAxis;
  55710. /** Gets or sets probe position (center of the cube map) */
  55711. position: Vector3;
  55712. /**
  55713. * Creates a new reflection probe
  55714. * @param name defines the name of the probe
  55715. * @param size defines the texture resolution (for each face)
  55716. * @param scene defines the hosting scene
  55717. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55718. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55719. */
  55720. constructor(
  55721. /** defines the name of the probe */
  55722. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55723. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55724. get samples(): number;
  55725. set samples(value: number);
  55726. /** Gets or sets the refresh rate to use (on every frame by default) */
  55727. get refreshRate(): number;
  55728. set refreshRate(value: number);
  55729. /**
  55730. * Gets the hosting scene
  55731. * @returns a Scene
  55732. */
  55733. getScene(): Scene;
  55734. /** Gets the internal CubeTexture used to render to */
  55735. get cubeTexture(): RenderTargetTexture;
  55736. /** Gets the list of meshes to render */
  55737. get renderList(): Nullable<AbstractMesh[]>;
  55738. /**
  55739. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55740. * @param mesh defines the mesh to attach to
  55741. */
  55742. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55743. /**
  55744. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55745. * @param renderingGroupId The rendering group id corresponding to its index
  55746. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55747. */
  55748. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55749. /**
  55750. * Clean all associated resources
  55751. */
  55752. dispose(): void;
  55753. /**
  55754. * Converts the reflection probe information to a readable string for debug purpose.
  55755. * @param fullDetails Supports for multiple levels of logging within scene loading
  55756. * @returns the human readable reflection probe info
  55757. */
  55758. toString(fullDetails?: boolean): string;
  55759. /**
  55760. * Get the class name of the relfection probe.
  55761. * @returns "ReflectionProbe"
  55762. */
  55763. getClassName(): string;
  55764. /**
  55765. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55766. * @returns The JSON representation of the texture
  55767. */
  55768. serialize(): any;
  55769. /**
  55770. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55771. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55772. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55773. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55774. * @returns The parsed reflection probe if successful
  55775. */
  55776. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55777. }
  55778. }
  55779. declare module BABYLON {
  55780. /** @hidden */
  55781. export var _BabylonLoaderRegistered: boolean;
  55782. /**
  55783. * Helps setting up some configuration for the babylon file loader.
  55784. */
  55785. export class BabylonFileLoaderConfiguration {
  55786. /**
  55787. * The loader does not allow injecting custom physix engine into the plugins.
  55788. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55789. * So you could set this variable to your engine import to make it work.
  55790. */
  55791. static LoaderInjectedPhysicsEngine: any;
  55792. }
  55793. }
  55794. declare module BABYLON {
  55795. /**
  55796. * The Physically based simple base material of BJS.
  55797. *
  55798. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55799. * It is used as the base class for both the specGloss and metalRough conventions.
  55800. */
  55801. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55802. /**
  55803. * Number of Simultaneous lights allowed on the material.
  55804. */
  55805. maxSimultaneousLights: number;
  55806. /**
  55807. * If sets to true, disables all the lights affecting the material.
  55808. */
  55809. disableLighting: boolean;
  55810. /**
  55811. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55812. */
  55813. environmentTexture: BaseTexture;
  55814. /**
  55815. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55816. */
  55817. invertNormalMapX: boolean;
  55818. /**
  55819. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55820. */
  55821. invertNormalMapY: boolean;
  55822. /**
  55823. * Normal map used in the model.
  55824. */
  55825. normalTexture: BaseTexture;
  55826. /**
  55827. * Emissivie color used to self-illuminate the model.
  55828. */
  55829. emissiveColor: Color3;
  55830. /**
  55831. * Emissivie texture used to self-illuminate the model.
  55832. */
  55833. emissiveTexture: BaseTexture;
  55834. /**
  55835. * Occlusion Channel Strenght.
  55836. */
  55837. occlusionStrength: number;
  55838. /**
  55839. * Occlusion Texture of the material (adding extra occlusion effects).
  55840. */
  55841. occlusionTexture: BaseTexture;
  55842. /**
  55843. * Defines the alpha limits in alpha test mode.
  55844. */
  55845. alphaCutOff: number;
  55846. /**
  55847. * Gets the current double sided mode.
  55848. */
  55849. get doubleSided(): boolean;
  55850. /**
  55851. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55852. */
  55853. set doubleSided(value: boolean);
  55854. /**
  55855. * Stores the pre-calculated light information of a mesh in a texture.
  55856. */
  55857. lightmapTexture: BaseTexture;
  55858. /**
  55859. * If true, the light map contains occlusion information instead of lighting info.
  55860. */
  55861. useLightmapAsShadowmap: boolean;
  55862. /**
  55863. * Instantiates a new PBRMaterial instance.
  55864. *
  55865. * @param name The material name
  55866. * @param scene The scene the material will be use in.
  55867. */
  55868. constructor(name: string, scene: Scene);
  55869. getClassName(): string;
  55870. }
  55871. }
  55872. declare module BABYLON {
  55873. /**
  55874. * The PBR material of BJS following the metal roughness convention.
  55875. *
  55876. * This fits to the PBR convention in the GLTF definition:
  55877. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55878. */
  55879. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55880. /**
  55881. * The base color has two different interpretations depending on the value of metalness.
  55882. * When the material is a metal, the base color is the specific measured reflectance value
  55883. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55884. * of the material.
  55885. */
  55886. baseColor: Color3;
  55887. /**
  55888. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55889. * well as opacity information in the alpha channel.
  55890. */
  55891. baseTexture: BaseTexture;
  55892. /**
  55893. * Specifies the metallic scalar value of the material.
  55894. * Can also be used to scale the metalness values of the metallic texture.
  55895. */
  55896. metallic: number;
  55897. /**
  55898. * Specifies the roughness scalar value of the material.
  55899. * Can also be used to scale the roughness values of the metallic texture.
  55900. */
  55901. roughness: number;
  55902. /**
  55903. * Texture containing both the metallic value in the B channel and the
  55904. * roughness value in the G channel to keep better precision.
  55905. */
  55906. metallicRoughnessTexture: BaseTexture;
  55907. /**
  55908. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55909. *
  55910. * @param name The material name
  55911. * @param scene The scene the material will be use in.
  55912. */
  55913. constructor(name: string, scene: Scene);
  55914. /**
  55915. * Return the currrent class name of the material.
  55916. */
  55917. getClassName(): string;
  55918. /**
  55919. * Makes a duplicate of the current material.
  55920. * @param name - name to use for the new material.
  55921. */
  55922. clone(name: string): PBRMetallicRoughnessMaterial;
  55923. /**
  55924. * Serialize the material to a parsable JSON object.
  55925. */
  55926. serialize(): any;
  55927. /**
  55928. * Parses a JSON object correponding to the serialize function.
  55929. */
  55930. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55931. }
  55932. }
  55933. declare module BABYLON {
  55934. /**
  55935. * The PBR material of BJS following the specular glossiness convention.
  55936. *
  55937. * This fits to the PBR convention in the GLTF definition:
  55938. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55939. */
  55940. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55941. /**
  55942. * Specifies the diffuse color of the material.
  55943. */
  55944. diffuseColor: Color3;
  55945. /**
  55946. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55947. * channel.
  55948. */
  55949. diffuseTexture: BaseTexture;
  55950. /**
  55951. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55952. */
  55953. specularColor: Color3;
  55954. /**
  55955. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55956. */
  55957. glossiness: number;
  55958. /**
  55959. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55960. */
  55961. specularGlossinessTexture: BaseTexture;
  55962. /**
  55963. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55964. *
  55965. * @param name The material name
  55966. * @param scene The scene the material will be use in.
  55967. */
  55968. constructor(name: string, scene: Scene);
  55969. /**
  55970. * Return the currrent class name of the material.
  55971. */
  55972. getClassName(): string;
  55973. /**
  55974. * Makes a duplicate of the current material.
  55975. * @param name - name to use for the new material.
  55976. */
  55977. clone(name: string): PBRSpecularGlossinessMaterial;
  55978. /**
  55979. * Serialize the material to a parsable JSON object.
  55980. */
  55981. serialize(): any;
  55982. /**
  55983. * Parses a JSON object correponding to the serialize function.
  55984. */
  55985. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55986. }
  55987. }
  55988. declare module BABYLON {
  55989. /**
  55990. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55991. * It can help converting any input color in a desired output one. This can then be used to create effects
  55992. * from sepia, black and white to sixties or futuristic rendering...
  55993. *
  55994. * The only supported format is currently 3dl.
  55995. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55996. */
  55997. export class ColorGradingTexture extends BaseTexture {
  55998. /**
  55999. * The current texture matrix. (will always be identity in color grading texture)
  56000. */
  56001. private _textureMatrix;
  56002. /**
  56003. * The texture URL.
  56004. */
  56005. url: string;
  56006. /**
  56007. * Empty line regex stored for GC.
  56008. */
  56009. private static _noneEmptyLineRegex;
  56010. private _engine;
  56011. /**
  56012. * Instantiates a ColorGradingTexture from the following parameters.
  56013. *
  56014. * @param url The location of the color gradind data (currently only supporting 3dl)
  56015. * @param scene The scene the texture will be used in
  56016. */
  56017. constructor(url: string, scene: Scene);
  56018. /**
  56019. * Returns the texture matrix used in most of the material.
  56020. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56021. */
  56022. getTextureMatrix(): Matrix;
  56023. /**
  56024. * Occurs when the file being loaded is a .3dl LUT file.
  56025. */
  56026. private load3dlTexture;
  56027. /**
  56028. * Starts the loading process of the texture.
  56029. */
  56030. private loadTexture;
  56031. /**
  56032. * Clones the color gradind texture.
  56033. */
  56034. clone(): ColorGradingTexture;
  56035. /**
  56036. * Called during delayed load for textures.
  56037. */
  56038. delayLoad(): void;
  56039. /**
  56040. * Parses a color grading texture serialized by Babylon.
  56041. * @param parsedTexture The texture information being parsedTexture
  56042. * @param scene The scene to load the texture in
  56043. * @param rootUrl The root url of the data assets to load
  56044. * @return A color gradind texture
  56045. */
  56046. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56047. /**
  56048. * Serializes the LUT texture to json format.
  56049. */
  56050. serialize(): any;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56056. */
  56057. export class EquiRectangularCubeTexture extends BaseTexture {
  56058. /** The six faces of the cube. */
  56059. private static _FacesMapping;
  56060. private _noMipmap;
  56061. private _onLoad;
  56062. private _onError;
  56063. /** The size of the cubemap. */
  56064. private _size;
  56065. /** The buffer of the image. */
  56066. private _buffer;
  56067. /** The width of the input image. */
  56068. private _width;
  56069. /** The height of the input image. */
  56070. private _height;
  56071. /** The URL to the image. */
  56072. url: string;
  56073. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56074. coordinatesMode: number;
  56075. /**
  56076. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56077. * @param url The location of the image
  56078. * @param scene The scene the texture will be used in
  56079. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56080. * @param noMipmap Forces to not generate the mipmap if true
  56081. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56082. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56083. * @param onLoad — defines a callback called when texture is loaded
  56084. * @param onError — defines a callback called if there is an error
  56085. */
  56086. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56087. /**
  56088. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56089. */
  56090. private loadImage;
  56091. /**
  56092. * Convert the image buffer into a cubemap and create a CubeTexture.
  56093. */
  56094. private loadTexture;
  56095. /**
  56096. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56097. * @param buffer The ArrayBuffer that should be converted.
  56098. * @returns The buffer as Float32Array.
  56099. */
  56100. private getFloat32ArrayFromArrayBuffer;
  56101. /**
  56102. * Get the current class name of the texture useful for serialization or dynamic coding.
  56103. * @returns "EquiRectangularCubeTexture"
  56104. */
  56105. getClassName(): string;
  56106. /**
  56107. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56108. * @returns A clone of the current EquiRectangularCubeTexture.
  56109. */
  56110. clone(): EquiRectangularCubeTexture;
  56111. }
  56112. }
  56113. declare module BABYLON {
  56114. /**
  56115. * Based on jsTGALoader - Javascript loader for TGA file
  56116. * By Vincent Thibault
  56117. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56118. */
  56119. export class TGATools {
  56120. private static _TYPE_INDEXED;
  56121. private static _TYPE_RGB;
  56122. private static _TYPE_GREY;
  56123. private static _TYPE_RLE_INDEXED;
  56124. private static _TYPE_RLE_RGB;
  56125. private static _TYPE_RLE_GREY;
  56126. private static _ORIGIN_MASK;
  56127. private static _ORIGIN_SHIFT;
  56128. private static _ORIGIN_BL;
  56129. private static _ORIGIN_BR;
  56130. private static _ORIGIN_UL;
  56131. private static _ORIGIN_UR;
  56132. /**
  56133. * Gets the header of a TGA file
  56134. * @param data defines the TGA data
  56135. * @returns the header
  56136. */
  56137. static GetTGAHeader(data: Uint8Array): any;
  56138. /**
  56139. * Uploads TGA content to a Babylon Texture
  56140. * @hidden
  56141. */
  56142. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56143. /** @hidden */
  56144. 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;
  56145. /** @hidden */
  56146. 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;
  56147. /** @hidden */
  56148. 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;
  56149. /** @hidden */
  56150. 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;
  56151. /** @hidden */
  56152. 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;
  56153. /** @hidden */
  56154. 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;
  56155. }
  56156. }
  56157. declare module BABYLON {
  56158. /**
  56159. * Implementation of the TGA Texture Loader.
  56160. * @hidden
  56161. */
  56162. export class _TGATextureLoader implements IInternalTextureLoader {
  56163. /**
  56164. * Defines wether the loader supports cascade loading the different faces.
  56165. */
  56166. readonly supportCascades: boolean;
  56167. /**
  56168. * This returns if the loader support the current file information.
  56169. * @param extension defines the file extension of the file being loaded
  56170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56171. * @param fallback defines the fallback internal texture if any
  56172. * @param isBase64 defines whether the texture is encoded as a base64
  56173. * @param isBuffer defines whether the texture data are stored as a buffer
  56174. * @returns true if the loader can load the specified file
  56175. */
  56176. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56177. /**
  56178. * Transform the url before loading if required.
  56179. * @param rootUrl the url of the texture
  56180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56181. * @returns the transformed texture
  56182. */
  56183. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56184. /**
  56185. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56186. * @param rootUrl the url of the texture
  56187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56188. * @returns the fallback texture
  56189. */
  56190. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56191. /**
  56192. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56193. * @param data contains the texture data
  56194. * @param texture defines the BabylonJS internal texture
  56195. * @param createPolynomials will be true if polynomials have been requested
  56196. * @param onLoad defines the callback to trigger once the texture is ready
  56197. * @param onError defines the callback to trigger in case of error
  56198. */
  56199. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56200. /**
  56201. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56202. * @param data contains the texture data
  56203. * @param texture defines the BabylonJS internal texture
  56204. * @param callback defines the method to call once ready to upload
  56205. */
  56206. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56207. }
  56208. }
  56209. declare module BABYLON {
  56210. /**
  56211. * Info about the .basis files
  56212. */
  56213. class BasisFileInfo {
  56214. /**
  56215. * If the file has alpha
  56216. */
  56217. hasAlpha: boolean;
  56218. /**
  56219. * Info about each image of the basis file
  56220. */
  56221. images: Array<{
  56222. levels: Array<{
  56223. width: number;
  56224. height: number;
  56225. transcodedPixels: ArrayBufferView;
  56226. }>;
  56227. }>;
  56228. }
  56229. /**
  56230. * Result of transcoding a basis file
  56231. */
  56232. class TranscodeResult {
  56233. /**
  56234. * Info about the .basis file
  56235. */
  56236. fileInfo: BasisFileInfo;
  56237. /**
  56238. * Format to use when loading the file
  56239. */
  56240. format: number;
  56241. }
  56242. /**
  56243. * Configuration options for the Basis transcoder
  56244. */
  56245. export class BasisTranscodeConfiguration {
  56246. /**
  56247. * Supported compression formats used to determine the supported output format of the transcoder
  56248. */
  56249. supportedCompressionFormats?: {
  56250. /**
  56251. * etc1 compression format
  56252. */
  56253. etc1?: boolean;
  56254. /**
  56255. * s3tc compression format
  56256. */
  56257. s3tc?: boolean;
  56258. /**
  56259. * pvrtc compression format
  56260. */
  56261. pvrtc?: boolean;
  56262. /**
  56263. * etc2 compression format
  56264. */
  56265. etc2?: boolean;
  56266. };
  56267. /**
  56268. * If mipmap levels should be loaded for transcoded images (Default: true)
  56269. */
  56270. loadMipmapLevels?: boolean;
  56271. /**
  56272. * Index of a single image to load (Default: all images)
  56273. */
  56274. loadSingleImage?: number;
  56275. }
  56276. /**
  56277. * Used to load .Basis files
  56278. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56279. */
  56280. export class BasisTools {
  56281. private static _IgnoreSupportedFormats;
  56282. /**
  56283. * URL to use when loading the basis transcoder
  56284. */
  56285. static JSModuleURL: string;
  56286. /**
  56287. * URL to use when loading the wasm module for the transcoder
  56288. */
  56289. static WasmModuleURL: string;
  56290. /**
  56291. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56292. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56293. * @returns internal format corresponding to the Basis format
  56294. */
  56295. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56296. private static _WorkerPromise;
  56297. private static _Worker;
  56298. private static _actionId;
  56299. private static _CreateWorkerAsync;
  56300. /**
  56301. * Transcodes a loaded image file to compressed pixel data
  56302. * @param imageData image data to transcode
  56303. * @param config configuration options for the transcoding
  56304. * @returns a promise resulting in the transcoded image
  56305. */
  56306. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56307. /**
  56308. * Loads a texture from the transcode result
  56309. * @param texture texture load to
  56310. * @param transcodeResult the result of transcoding the basis file to load from
  56311. */
  56312. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56313. }
  56314. }
  56315. declare module BABYLON {
  56316. /**
  56317. * Loader for .basis file format
  56318. */
  56319. export class _BasisTextureLoader implements IInternalTextureLoader {
  56320. /**
  56321. * Defines whether the loader supports cascade loading the different faces.
  56322. */
  56323. readonly supportCascades: boolean;
  56324. /**
  56325. * This returns if the loader support the current file information.
  56326. * @param extension defines the file extension of the file being loaded
  56327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56328. * @param fallback defines the fallback internal texture if any
  56329. * @param isBase64 defines whether the texture is encoded as a base64
  56330. * @param isBuffer defines whether the texture data are stored as a buffer
  56331. * @returns true if the loader can load the specified file
  56332. */
  56333. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56334. /**
  56335. * Transform the url before loading if required.
  56336. * @param rootUrl the url of the texture
  56337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56338. * @returns the transformed texture
  56339. */
  56340. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56341. /**
  56342. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56343. * @param rootUrl the url of the texture
  56344. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56345. * @returns the fallback texture
  56346. */
  56347. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56348. /**
  56349. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56350. * @param data contains the texture data
  56351. * @param texture defines the BabylonJS internal texture
  56352. * @param createPolynomials will be true if polynomials have been requested
  56353. * @param onLoad defines the callback to trigger once the texture is ready
  56354. * @param onError defines the callback to trigger in case of error
  56355. */
  56356. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56357. /**
  56358. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56359. * @param data contains the texture data
  56360. * @param texture defines the BabylonJS internal texture
  56361. * @param callback defines the method to call once ready to upload
  56362. */
  56363. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56364. }
  56365. }
  56366. declare module BABYLON {
  56367. /**
  56368. * 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.
  56369. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56370. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56371. */
  56372. export class CustomProceduralTexture extends ProceduralTexture {
  56373. private _animate;
  56374. private _time;
  56375. private _config;
  56376. private _texturePath;
  56377. /**
  56378. * Instantiates a new Custom Procedural Texture.
  56379. * 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.
  56380. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56381. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56382. * @param name Define the name of the texture
  56383. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56384. * @param size Define the size of the texture to create
  56385. * @param scene Define the scene the texture belongs to
  56386. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56387. * @param generateMipMaps Define if the texture should creates mip maps or not
  56388. */
  56389. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56390. private _loadJson;
  56391. /**
  56392. * Is the texture ready to be used ? (rendered at least once)
  56393. * @returns true if ready, otherwise, false.
  56394. */
  56395. isReady(): boolean;
  56396. /**
  56397. * Render the texture to its associated render target.
  56398. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56399. */
  56400. render(useCameraPostProcess?: boolean): void;
  56401. /**
  56402. * Update the list of dependant textures samplers in the shader.
  56403. */
  56404. updateTextures(): void;
  56405. /**
  56406. * Update the uniform values of the procedural texture in the shader.
  56407. */
  56408. updateShaderUniforms(): void;
  56409. /**
  56410. * Define if the texture animates or not.
  56411. */
  56412. get animate(): boolean;
  56413. set animate(value: boolean);
  56414. }
  56415. }
  56416. declare module BABYLON {
  56417. /** @hidden */
  56418. export var noisePixelShader: {
  56419. name: string;
  56420. shader: string;
  56421. };
  56422. }
  56423. declare module BABYLON {
  56424. /**
  56425. * Class used to generate noise procedural textures
  56426. */
  56427. export class NoiseProceduralTexture extends ProceduralTexture {
  56428. private _time;
  56429. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56430. brightness: number;
  56431. /** Defines the number of octaves to process */
  56432. octaves: number;
  56433. /** Defines the level of persistence (0.8 by default) */
  56434. persistence: number;
  56435. /** Gets or sets animation speed factor (default is 1) */
  56436. animationSpeedFactor: number;
  56437. /**
  56438. * Creates a new NoiseProceduralTexture
  56439. * @param name defines the name fo the texture
  56440. * @param size defines the size of the texture (default is 256)
  56441. * @param scene defines the hosting scene
  56442. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56443. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56444. */
  56445. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56446. private _updateShaderUniforms;
  56447. protected _getDefines(): string;
  56448. /** Generate the current state of the procedural texture */
  56449. render(useCameraPostProcess?: boolean): void;
  56450. /**
  56451. * Serializes this noise procedural texture
  56452. * @returns a serialized noise procedural texture object
  56453. */
  56454. serialize(): any;
  56455. /**
  56456. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56457. * @param parsedTexture defines parsed texture data
  56458. * @param scene defines the current scene
  56459. * @param rootUrl defines the root URL containing noise procedural texture information
  56460. * @returns a parsed NoiseProceduralTexture
  56461. */
  56462. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56463. }
  56464. }
  56465. declare module BABYLON {
  56466. /**
  56467. * Raw cube texture where the raw buffers are passed in
  56468. */
  56469. export class RawCubeTexture extends CubeTexture {
  56470. /**
  56471. * Creates a cube texture where the raw buffers are passed in.
  56472. * @param scene defines the scene the texture is attached to
  56473. * @param data defines the array of data to use to create each face
  56474. * @param size defines the size of the textures
  56475. * @param format defines the format of the data
  56476. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56477. * @param generateMipMaps defines if the engine should generate the mip levels
  56478. * @param invertY defines if data must be stored with Y axis inverted
  56479. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56480. * @param compression defines the compression used (null by default)
  56481. */
  56482. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56483. /**
  56484. * Updates the raw cube texture.
  56485. * @param data defines the data to store
  56486. * @param format defines the data format
  56487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56488. * @param invertY defines if data must be stored with Y axis inverted
  56489. * @param compression defines the compression used (null by default)
  56490. * @param level defines which level of the texture to update
  56491. */
  56492. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56493. /**
  56494. * Updates a raw cube texture with RGBD encoded data.
  56495. * @param data defines the array of data [mipmap][face] to use to create each face
  56496. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56497. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56498. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56499. * @returns a promsie that resolves when the operation is complete
  56500. */
  56501. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56502. /**
  56503. * Clones the raw cube texture.
  56504. * @return a new cube texture
  56505. */
  56506. clone(): CubeTexture;
  56507. /** @hidden */
  56508. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56509. }
  56510. }
  56511. declare module BABYLON {
  56512. /**
  56513. * Class used to store 3D textures containing user data
  56514. */
  56515. export class RawTexture3D extends Texture {
  56516. /** Gets or sets the texture format to use */
  56517. format: number;
  56518. private _engine;
  56519. /**
  56520. * Create a new RawTexture3D
  56521. * @param data defines the data of the texture
  56522. * @param width defines the width of the texture
  56523. * @param height defines the height of the texture
  56524. * @param depth defines the depth of the texture
  56525. * @param format defines the texture format to use
  56526. * @param scene defines the hosting scene
  56527. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56528. * @param invertY defines if texture must be stored with Y axis inverted
  56529. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56530. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56531. */
  56532. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56533. /** Gets or sets the texture format to use */
  56534. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56535. /**
  56536. * Update the texture with new data
  56537. * @param data defines the data to store in the texture
  56538. */
  56539. update(data: ArrayBufferView): void;
  56540. }
  56541. }
  56542. declare module BABYLON {
  56543. /**
  56544. * Class used to store 2D array textures containing user data
  56545. */
  56546. export class RawTexture2DArray extends Texture {
  56547. /** Gets or sets the texture format to use */
  56548. format: number;
  56549. private _engine;
  56550. /**
  56551. * Create a new RawTexture2DArray
  56552. * @param data defines the data of the texture
  56553. * @param width defines the width of the texture
  56554. * @param height defines the height of the texture
  56555. * @param depth defines the number of layers of the texture
  56556. * @param format defines the texture format to use
  56557. * @param scene defines the hosting scene
  56558. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56559. * @param invertY defines if texture must be stored with Y axis inverted
  56560. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56562. */
  56563. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56564. /** Gets or sets the texture format to use */
  56565. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56566. /**
  56567. * Update the texture with new data
  56568. * @param data defines the data to store in the texture
  56569. */
  56570. update(data: ArrayBufferView): void;
  56571. }
  56572. }
  56573. declare module BABYLON {
  56574. /**
  56575. * Creates a refraction texture used by refraction channel of the standard material.
  56576. * It is like a mirror but to see through a material.
  56577. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56578. */
  56579. export class RefractionTexture extends RenderTargetTexture {
  56580. /**
  56581. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56582. * 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.
  56583. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56584. */
  56585. refractionPlane: Plane;
  56586. /**
  56587. * Define how deep under the surface we should see.
  56588. */
  56589. depth: number;
  56590. /**
  56591. * Creates a refraction texture used by refraction channel of the standard material.
  56592. * It is like a mirror but to see through a material.
  56593. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56594. * @param name Define the texture name
  56595. * @param size Define the size of the underlying texture
  56596. * @param scene Define the scene the refraction belongs to
  56597. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56598. */
  56599. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56600. /**
  56601. * Clone the refraction texture.
  56602. * @returns the cloned texture
  56603. */
  56604. clone(): RefractionTexture;
  56605. /**
  56606. * Serialize the texture to a JSON representation you could use in Parse later on
  56607. * @returns the serialized JSON representation
  56608. */
  56609. serialize(): any;
  56610. }
  56611. }
  56612. declare module BABYLON {
  56613. /**
  56614. * Defines the options related to the creation of an HtmlElementTexture
  56615. */
  56616. export interface IHtmlElementTextureOptions {
  56617. /**
  56618. * Defines wether mip maps should be created or not.
  56619. */
  56620. generateMipMaps?: boolean;
  56621. /**
  56622. * Defines the sampling mode of the texture.
  56623. */
  56624. samplingMode?: number;
  56625. /**
  56626. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56627. */
  56628. engine: Nullable<ThinEngine>;
  56629. /**
  56630. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56631. */
  56632. scene: Nullable<Scene>;
  56633. }
  56634. /**
  56635. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56636. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56637. * is automatically managed.
  56638. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56639. * in your application.
  56640. *
  56641. * As the update is not automatic, you need to call them manually.
  56642. */
  56643. export class HtmlElementTexture extends BaseTexture {
  56644. /**
  56645. * The texture URL.
  56646. */
  56647. element: HTMLVideoElement | HTMLCanvasElement;
  56648. private static readonly DefaultOptions;
  56649. private _textureMatrix;
  56650. private _engine;
  56651. private _isVideo;
  56652. private _generateMipMaps;
  56653. private _samplingMode;
  56654. /**
  56655. * Instantiates a HtmlElementTexture from the following parameters.
  56656. *
  56657. * @param name Defines the name of the texture
  56658. * @param element Defines the video or canvas the texture is filled with
  56659. * @param options Defines the other none mandatory texture creation options
  56660. */
  56661. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56662. private _createInternalTexture;
  56663. /**
  56664. * Returns the texture matrix used in most of the material.
  56665. */
  56666. getTextureMatrix(): Matrix;
  56667. /**
  56668. * Updates the content of the texture.
  56669. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56670. */
  56671. update(invertY?: Nullable<boolean>): void;
  56672. }
  56673. }
  56674. declare module BABYLON {
  56675. /**
  56676. * Enum used to define the target of a block
  56677. */
  56678. export enum NodeMaterialBlockTargets {
  56679. /** Vertex shader */
  56680. Vertex = 1,
  56681. /** Fragment shader */
  56682. Fragment = 2,
  56683. /** Neutral */
  56684. Neutral = 4,
  56685. /** Vertex and Fragment */
  56686. VertexAndFragment = 3
  56687. }
  56688. }
  56689. declare module BABYLON {
  56690. /**
  56691. * Defines the kind of connection point for node based material
  56692. */
  56693. export enum NodeMaterialBlockConnectionPointTypes {
  56694. /** Float */
  56695. Float = 1,
  56696. /** Int */
  56697. Int = 2,
  56698. /** Vector2 */
  56699. Vector2 = 4,
  56700. /** Vector3 */
  56701. Vector3 = 8,
  56702. /** Vector4 */
  56703. Vector4 = 16,
  56704. /** Color3 */
  56705. Color3 = 32,
  56706. /** Color4 */
  56707. Color4 = 64,
  56708. /** Matrix */
  56709. Matrix = 128,
  56710. /** Detect type based on connection */
  56711. AutoDetect = 1024,
  56712. /** Output type that will be defined by input type */
  56713. BasedOnInput = 2048
  56714. }
  56715. }
  56716. declare module BABYLON {
  56717. /**
  56718. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56719. */
  56720. export enum NodeMaterialBlockConnectionPointMode {
  56721. /** Value is an uniform */
  56722. Uniform = 0,
  56723. /** Value is a mesh attribute */
  56724. Attribute = 1,
  56725. /** Value is a varying between vertex and fragment shaders */
  56726. Varying = 2,
  56727. /** Mode is undefined */
  56728. Undefined = 3
  56729. }
  56730. }
  56731. declare module BABYLON {
  56732. /**
  56733. * Enum used to define system values e.g. values automatically provided by the system
  56734. */
  56735. export enum NodeMaterialSystemValues {
  56736. /** World */
  56737. World = 1,
  56738. /** View */
  56739. View = 2,
  56740. /** Projection */
  56741. Projection = 3,
  56742. /** ViewProjection */
  56743. ViewProjection = 4,
  56744. /** WorldView */
  56745. WorldView = 5,
  56746. /** WorldViewProjection */
  56747. WorldViewProjection = 6,
  56748. /** CameraPosition */
  56749. CameraPosition = 7,
  56750. /** Fog Color */
  56751. FogColor = 8,
  56752. /** Delta time */
  56753. DeltaTime = 9
  56754. }
  56755. }
  56756. declare module BABYLON {
  56757. /**
  56758. * Root class for all node material optimizers
  56759. */
  56760. export class NodeMaterialOptimizer {
  56761. /**
  56762. * Function used to optimize a NodeMaterial graph
  56763. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56764. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56765. */
  56766. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56767. }
  56768. }
  56769. declare module BABYLON {
  56770. /**
  56771. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56772. */
  56773. export class TransformBlock extends NodeMaterialBlock {
  56774. /**
  56775. * Defines the value to use to complement W value to transform it to a Vector4
  56776. */
  56777. complementW: number;
  56778. /**
  56779. * Defines the value to use to complement z value to transform it to a Vector4
  56780. */
  56781. complementZ: number;
  56782. /**
  56783. * Creates a new TransformBlock
  56784. * @param name defines the block name
  56785. */
  56786. constructor(name: string);
  56787. /**
  56788. * Gets the current class name
  56789. * @returns the class name
  56790. */
  56791. getClassName(): string;
  56792. /**
  56793. * Gets the vector input
  56794. */
  56795. get vector(): NodeMaterialConnectionPoint;
  56796. /**
  56797. * Gets the output component
  56798. */
  56799. get output(): NodeMaterialConnectionPoint;
  56800. /**
  56801. * Gets the matrix transform input
  56802. */
  56803. get transform(): NodeMaterialConnectionPoint;
  56804. protected _buildBlock(state: NodeMaterialBuildState): this;
  56805. serialize(): any;
  56806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56807. protected _dumpPropertiesCode(): string;
  56808. }
  56809. }
  56810. declare module BABYLON {
  56811. /**
  56812. * Block used to output the vertex position
  56813. */
  56814. export class VertexOutputBlock extends NodeMaterialBlock {
  56815. /**
  56816. * Creates a new VertexOutputBlock
  56817. * @param name defines the block name
  56818. */
  56819. constructor(name: string);
  56820. /**
  56821. * Gets the current class name
  56822. * @returns the class name
  56823. */
  56824. getClassName(): string;
  56825. /**
  56826. * Gets the vector input component
  56827. */
  56828. get vector(): NodeMaterialConnectionPoint;
  56829. protected _buildBlock(state: NodeMaterialBuildState): this;
  56830. }
  56831. }
  56832. declare module BABYLON {
  56833. /**
  56834. * Block used to output the final color
  56835. */
  56836. export class FragmentOutputBlock extends NodeMaterialBlock {
  56837. /**
  56838. * Create a new FragmentOutputBlock
  56839. * @param name defines the block name
  56840. */
  56841. constructor(name: string);
  56842. /**
  56843. * Gets the current class name
  56844. * @returns the class name
  56845. */
  56846. getClassName(): string;
  56847. /**
  56848. * Gets the rgba input component
  56849. */
  56850. get rgba(): NodeMaterialConnectionPoint;
  56851. /**
  56852. * Gets the rgb input component
  56853. */
  56854. get rgb(): NodeMaterialConnectionPoint;
  56855. /**
  56856. * Gets the a input component
  56857. */
  56858. get a(): NodeMaterialConnectionPoint;
  56859. protected _buildBlock(state: NodeMaterialBuildState): this;
  56860. }
  56861. }
  56862. declare module BABYLON {
  56863. /**
  56864. * Block used to read a reflection texture from a sampler
  56865. */
  56866. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56867. private _define3DName;
  56868. private _defineCubicName;
  56869. private _defineExplicitName;
  56870. private _defineProjectionName;
  56871. private _defineLocalCubicName;
  56872. private _defineSphericalName;
  56873. private _definePlanarName;
  56874. private _defineEquirectangularName;
  56875. private _defineMirroredEquirectangularFixedName;
  56876. private _defineEquirectangularFixedName;
  56877. private _defineSkyboxName;
  56878. private _cubeSamplerName;
  56879. private _2DSamplerName;
  56880. private _positionUVWName;
  56881. private _directionWName;
  56882. private _reflectionCoordsName;
  56883. private _reflection2DCoordsName;
  56884. private _reflectionColorName;
  56885. private _reflectionMatrixName;
  56886. /**
  56887. * Gets or sets the texture associated with the node
  56888. */
  56889. texture: Nullable<BaseTexture>;
  56890. /**
  56891. * Create a new TextureBlock
  56892. * @param name defines the block name
  56893. */
  56894. constructor(name: string);
  56895. /**
  56896. * Gets the current class name
  56897. * @returns the class name
  56898. */
  56899. getClassName(): string;
  56900. /**
  56901. * Gets the world position input component
  56902. */
  56903. get position(): NodeMaterialConnectionPoint;
  56904. /**
  56905. * Gets the world position input component
  56906. */
  56907. get worldPosition(): NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the world normal input component
  56910. */
  56911. get worldNormal(): NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the world input component
  56914. */
  56915. get world(): NodeMaterialConnectionPoint;
  56916. /**
  56917. * Gets the camera (or eye) position component
  56918. */
  56919. get cameraPosition(): NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the view input component
  56922. */
  56923. get view(): NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the rgb output component
  56926. */
  56927. get rgb(): NodeMaterialConnectionPoint;
  56928. /**
  56929. * Gets the r output component
  56930. */
  56931. get r(): NodeMaterialConnectionPoint;
  56932. /**
  56933. * Gets the g output component
  56934. */
  56935. get g(): NodeMaterialConnectionPoint;
  56936. /**
  56937. * Gets the b output component
  56938. */
  56939. get b(): NodeMaterialConnectionPoint;
  56940. autoConfigure(material: NodeMaterial): void;
  56941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56942. isReady(): boolean;
  56943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56944. private _injectVertexCode;
  56945. private _writeOutput;
  56946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56947. protected _dumpPropertiesCode(): string;
  56948. serialize(): any;
  56949. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56950. }
  56951. }
  56952. declare module BABYLON {
  56953. /**
  56954. * Interface used to configure the node material editor
  56955. */
  56956. export interface INodeMaterialEditorOptions {
  56957. /** Define the URl to load node editor script */
  56958. editorURL?: string;
  56959. }
  56960. /** @hidden */
  56961. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56962. NORMAL: boolean;
  56963. TANGENT: boolean;
  56964. UV1: boolean;
  56965. /** BONES */
  56966. NUM_BONE_INFLUENCERS: number;
  56967. BonesPerMesh: number;
  56968. BONETEXTURE: boolean;
  56969. /** MORPH TARGETS */
  56970. MORPHTARGETS: boolean;
  56971. MORPHTARGETS_NORMAL: boolean;
  56972. MORPHTARGETS_TANGENT: boolean;
  56973. MORPHTARGETS_UV: boolean;
  56974. NUM_MORPH_INFLUENCERS: number;
  56975. /** IMAGE PROCESSING */
  56976. IMAGEPROCESSING: boolean;
  56977. VIGNETTE: boolean;
  56978. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56979. VIGNETTEBLENDMODEOPAQUE: boolean;
  56980. TONEMAPPING: boolean;
  56981. TONEMAPPING_ACES: boolean;
  56982. CONTRAST: boolean;
  56983. EXPOSURE: boolean;
  56984. COLORCURVES: boolean;
  56985. COLORGRADING: boolean;
  56986. COLORGRADING3D: boolean;
  56987. SAMPLER3DGREENDEPTH: boolean;
  56988. SAMPLER3DBGRMAP: boolean;
  56989. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56990. /** MISC. */
  56991. BUMPDIRECTUV: number;
  56992. constructor();
  56993. setValue(name: string, value: boolean): void;
  56994. }
  56995. /**
  56996. * Class used to configure NodeMaterial
  56997. */
  56998. export interface INodeMaterialOptions {
  56999. /**
  57000. * Defines if blocks should emit comments
  57001. */
  57002. emitComments: boolean;
  57003. }
  57004. /**
  57005. * Class used to create a node based material built by assembling shader blocks
  57006. */
  57007. export class NodeMaterial extends PushMaterial {
  57008. private static _BuildIdGenerator;
  57009. private _options;
  57010. private _vertexCompilationState;
  57011. private _fragmentCompilationState;
  57012. private _sharedData;
  57013. private _buildId;
  57014. private _buildWasSuccessful;
  57015. private _cachedWorldViewMatrix;
  57016. private _cachedWorldViewProjectionMatrix;
  57017. private _optimizers;
  57018. private _animationFrame;
  57019. /** Define the Url to load node editor script */
  57020. static EditorURL: string;
  57021. /** Define the Url to load snippets */
  57022. static SnippetUrl: string;
  57023. private BJSNODEMATERIALEDITOR;
  57024. /** Get the inspector from bundle or global */
  57025. private _getGlobalNodeMaterialEditor;
  57026. /**
  57027. * Gets or sets data used by visual editor
  57028. * @see https://nme.babylonjs.com
  57029. */
  57030. editorData: any;
  57031. /**
  57032. * 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)
  57033. */
  57034. ignoreAlpha: boolean;
  57035. /**
  57036. * Defines the maximum number of lights that can be used in the material
  57037. */
  57038. maxSimultaneousLights: number;
  57039. /**
  57040. * Observable raised when the material is built
  57041. */
  57042. onBuildObservable: Observable<NodeMaterial>;
  57043. /**
  57044. * Gets or sets the root nodes of the material vertex shader
  57045. */
  57046. _vertexOutputNodes: NodeMaterialBlock[];
  57047. /**
  57048. * Gets or sets the root nodes of the material fragment (pixel) shader
  57049. */
  57050. _fragmentOutputNodes: NodeMaterialBlock[];
  57051. /** Gets or sets options to control the node material overall behavior */
  57052. get options(): INodeMaterialOptions;
  57053. set options(options: INodeMaterialOptions);
  57054. /**
  57055. * Default configuration related to image processing available in the standard Material.
  57056. */
  57057. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57058. /**
  57059. * Gets the image processing configuration used either in this material.
  57060. */
  57061. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57062. /**
  57063. * Sets the Default image processing configuration used either in the this material.
  57064. *
  57065. * If sets to null, the scene one is in use.
  57066. */
  57067. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57068. /**
  57069. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57070. */
  57071. attachedBlocks: NodeMaterialBlock[];
  57072. /**
  57073. * Create a new node based material
  57074. * @param name defines the material name
  57075. * @param scene defines the hosting scene
  57076. * @param options defines creation option
  57077. */
  57078. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57079. /**
  57080. * Gets the current class name of the material e.g. "NodeMaterial"
  57081. * @returns the class name
  57082. */
  57083. getClassName(): string;
  57084. /**
  57085. * Keep track of the image processing observer to allow dispose and replace.
  57086. */
  57087. private _imageProcessingObserver;
  57088. /**
  57089. * Attaches a new image processing configuration to the Standard Material.
  57090. * @param configuration
  57091. */
  57092. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57093. /**
  57094. * Get a block by its name
  57095. * @param name defines the name of the block to retrieve
  57096. * @returns the required block or null if not found
  57097. */
  57098. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57099. /**
  57100. * Get a block by its name
  57101. * @param predicate defines the predicate used to find the good candidate
  57102. * @returns the required block or null if not found
  57103. */
  57104. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57105. /**
  57106. * Get an input block by its name
  57107. * @param predicate defines the predicate used to find the good candidate
  57108. * @returns the required input block or null if not found
  57109. */
  57110. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57111. /**
  57112. * Gets the list of input blocks attached to this material
  57113. * @returns an array of InputBlocks
  57114. */
  57115. getInputBlocks(): InputBlock[];
  57116. /**
  57117. * Adds a new optimizer to the list of optimizers
  57118. * @param optimizer defines the optimizers to add
  57119. * @returns the current material
  57120. */
  57121. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57122. /**
  57123. * Remove an optimizer from the list of optimizers
  57124. * @param optimizer defines the optimizers to remove
  57125. * @returns the current material
  57126. */
  57127. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57128. /**
  57129. * Add a new block to the list of output nodes
  57130. * @param node defines the node to add
  57131. * @returns the current material
  57132. */
  57133. addOutputNode(node: NodeMaterialBlock): this;
  57134. /**
  57135. * Remove a block from the list of root nodes
  57136. * @param node defines the node to remove
  57137. * @returns the current material
  57138. */
  57139. removeOutputNode(node: NodeMaterialBlock): this;
  57140. private _addVertexOutputNode;
  57141. private _removeVertexOutputNode;
  57142. private _addFragmentOutputNode;
  57143. private _removeFragmentOutputNode;
  57144. /**
  57145. * Specifies if the material will require alpha blending
  57146. * @returns a boolean specifying if alpha blending is needed
  57147. */
  57148. needAlphaBlending(): boolean;
  57149. /**
  57150. * Specifies if this material should be rendered in alpha test mode
  57151. * @returns a boolean specifying if an alpha test is needed.
  57152. */
  57153. needAlphaTesting(): boolean;
  57154. private _initializeBlock;
  57155. private _resetDualBlocks;
  57156. /**
  57157. * Remove a block from the current node material
  57158. * @param block defines the block to remove
  57159. */
  57160. removeBlock(block: NodeMaterialBlock): void;
  57161. /**
  57162. * Build the material and generates the inner effect
  57163. * @param verbose defines if the build should log activity
  57164. */
  57165. build(verbose?: boolean): void;
  57166. /**
  57167. * Runs an otpimization phase to try to improve the shader code
  57168. */
  57169. optimize(): void;
  57170. private _prepareDefinesForAttributes;
  57171. /**
  57172. * Get if the submesh is ready to be used and all its information available.
  57173. * Child classes can use it to update shaders
  57174. * @param mesh defines the mesh to check
  57175. * @param subMesh defines which submesh to check
  57176. * @param useInstances specifies that instances should be used
  57177. * @returns a boolean indicating that the submesh is ready or not
  57178. */
  57179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57180. /**
  57181. * Get a string representing the shaders built by the current node graph
  57182. */
  57183. get compiledShaders(): string;
  57184. /**
  57185. * Binds the world matrix to the material
  57186. * @param world defines the world transformation matrix
  57187. */
  57188. bindOnlyWorldMatrix(world: Matrix): void;
  57189. /**
  57190. * Binds the submesh to this material by preparing the effect and shader to draw
  57191. * @param world defines the world transformation matrix
  57192. * @param mesh defines the mesh containing the submesh
  57193. * @param subMesh defines the submesh to bind the material to
  57194. */
  57195. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57196. /**
  57197. * Gets the active textures from the material
  57198. * @returns an array of textures
  57199. */
  57200. getActiveTextures(): BaseTexture[];
  57201. /**
  57202. * Gets the list of texture blocks
  57203. * @returns an array of texture blocks
  57204. */
  57205. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57206. /**
  57207. * Specifies if the material uses a texture
  57208. * @param texture defines the texture to check against the material
  57209. * @returns a boolean specifying if the material uses the texture
  57210. */
  57211. hasTexture(texture: BaseTexture): boolean;
  57212. /**
  57213. * Disposes the material
  57214. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57215. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57216. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57217. */
  57218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57219. /** Creates the node editor window. */
  57220. private _createNodeEditor;
  57221. /**
  57222. * Launch the node material editor
  57223. * @param config Define the configuration of the editor
  57224. * @return a promise fulfilled when the node editor is visible
  57225. */
  57226. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57227. /**
  57228. * Clear the current material
  57229. */
  57230. clear(): void;
  57231. /**
  57232. * Clear the current material and set it to a default state
  57233. */
  57234. setToDefault(): void;
  57235. /**
  57236. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57237. * @param url defines the url to load from
  57238. * @returns a promise that will fullfil when the material is fully loaded
  57239. */
  57240. loadAsync(url: string): Promise<void>;
  57241. private _gatherBlocks;
  57242. /**
  57243. * Generate a string containing the code declaration required to create an equivalent of this material
  57244. * @returns a string
  57245. */
  57246. generateCode(): string;
  57247. /**
  57248. * Serializes this material in a JSON representation
  57249. * @returns the serialized material object
  57250. */
  57251. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57252. private _restoreConnections;
  57253. /**
  57254. * Clear the current graph and load a new one from a serialization object
  57255. * @param source defines the JSON representation of the material
  57256. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57257. */
  57258. loadFromSerialization(source: any, rootUrl?: string): void;
  57259. /**
  57260. * Creates a node material from parsed material data
  57261. * @param source defines the JSON representation of the material
  57262. * @param scene defines the hosting scene
  57263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57264. * @returns a new node material
  57265. */
  57266. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57267. /**
  57268. * Creates a node material from a snippet saved by the node material editor
  57269. * @param snippetId defines the snippet to load
  57270. * @param scene defines the hosting scene
  57271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57272. * @returns a promise that will resolve to the new node material
  57273. */
  57274. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57275. /**
  57276. * Creates a new node material set to default basic configuration
  57277. * @param name defines the name of the material
  57278. * @param scene defines the hosting scene
  57279. * @returns a new NodeMaterial
  57280. */
  57281. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57282. }
  57283. }
  57284. declare module BABYLON {
  57285. /**
  57286. * Block used to read a texture from a sampler
  57287. */
  57288. export class TextureBlock extends NodeMaterialBlock {
  57289. private _defineName;
  57290. private _linearDefineName;
  57291. private _tempTextureRead;
  57292. private _samplerName;
  57293. private _transformedUVName;
  57294. private _textureTransformName;
  57295. private _textureInfoName;
  57296. private _mainUVName;
  57297. private _mainUVDefineName;
  57298. /**
  57299. * Gets or sets the texture associated with the node
  57300. */
  57301. texture: Nullable<Texture>;
  57302. /**
  57303. * Create a new TextureBlock
  57304. * @param name defines the block name
  57305. */
  57306. constructor(name: string);
  57307. /**
  57308. * Gets the current class name
  57309. * @returns the class name
  57310. */
  57311. getClassName(): string;
  57312. /**
  57313. * Gets the uv input component
  57314. */
  57315. get uv(): NodeMaterialConnectionPoint;
  57316. /**
  57317. * Gets the rgba output component
  57318. */
  57319. get rgba(): NodeMaterialConnectionPoint;
  57320. /**
  57321. * Gets the rgb output component
  57322. */
  57323. get rgb(): NodeMaterialConnectionPoint;
  57324. /**
  57325. * Gets the r output component
  57326. */
  57327. get r(): NodeMaterialConnectionPoint;
  57328. /**
  57329. * Gets the g output component
  57330. */
  57331. get g(): NodeMaterialConnectionPoint;
  57332. /**
  57333. * Gets the b output component
  57334. */
  57335. get b(): NodeMaterialConnectionPoint;
  57336. /**
  57337. * Gets the a output component
  57338. */
  57339. get a(): NodeMaterialConnectionPoint;
  57340. get target(): NodeMaterialBlockTargets;
  57341. autoConfigure(material: NodeMaterial): void;
  57342. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57344. isReady(): boolean;
  57345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57346. private get _isMixed();
  57347. private _injectVertexCode;
  57348. private _writeTextureRead;
  57349. private _writeOutput;
  57350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57351. protected _dumpPropertiesCode(): string;
  57352. serialize(): any;
  57353. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57354. }
  57355. }
  57356. declare module BABYLON {
  57357. /**
  57358. * Class used to store shared data between 2 NodeMaterialBuildState
  57359. */
  57360. export class NodeMaterialBuildStateSharedData {
  57361. /**
  57362. * Gets the list of emitted varyings
  57363. */
  57364. temps: string[];
  57365. /**
  57366. * Gets the list of emitted varyings
  57367. */
  57368. varyings: string[];
  57369. /**
  57370. * Gets the varying declaration string
  57371. */
  57372. varyingDeclaration: string;
  57373. /**
  57374. * Input blocks
  57375. */
  57376. inputBlocks: InputBlock[];
  57377. /**
  57378. * Input blocks
  57379. */
  57380. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57381. /**
  57382. * Bindable blocks (Blocks that need to set data to the effect)
  57383. */
  57384. bindableBlocks: NodeMaterialBlock[];
  57385. /**
  57386. * List of blocks that can provide a compilation fallback
  57387. */
  57388. blocksWithFallbacks: NodeMaterialBlock[];
  57389. /**
  57390. * List of blocks that can provide a define update
  57391. */
  57392. blocksWithDefines: NodeMaterialBlock[];
  57393. /**
  57394. * List of blocks that can provide a repeatable content
  57395. */
  57396. repeatableContentBlocks: NodeMaterialBlock[];
  57397. /**
  57398. * List of blocks that can provide a dynamic list of uniforms
  57399. */
  57400. dynamicUniformBlocks: NodeMaterialBlock[];
  57401. /**
  57402. * List of blocks that can block the isReady function for the material
  57403. */
  57404. blockingBlocks: NodeMaterialBlock[];
  57405. /**
  57406. * Gets the list of animated inputs
  57407. */
  57408. animatedInputs: InputBlock[];
  57409. /**
  57410. * Build Id used to avoid multiple recompilations
  57411. */
  57412. buildId: number;
  57413. /** List of emitted variables */
  57414. variableNames: {
  57415. [key: string]: number;
  57416. };
  57417. /** List of emitted defines */
  57418. defineNames: {
  57419. [key: string]: number;
  57420. };
  57421. /** Should emit comments? */
  57422. emitComments: boolean;
  57423. /** Emit build activity */
  57424. verbose: boolean;
  57425. /** Gets or sets the hosting scene */
  57426. scene: Scene;
  57427. /**
  57428. * Gets the compilation hints emitted at compilation time
  57429. */
  57430. hints: {
  57431. needWorldViewMatrix: boolean;
  57432. needWorldViewProjectionMatrix: boolean;
  57433. needAlphaBlending: boolean;
  57434. needAlphaTesting: boolean;
  57435. };
  57436. /**
  57437. * List of compilation checks
  57438. */
  57439. checks: {
  57440. emitVertex: boolean;
  57441. emitFragment: boolean;
  57442. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57443. };
  57444. /** Creates a new shared data */
  57445. constructor();
  57446. /**
  57447. * Emits console errors and exceptions if there is a failing check
  57448. */
  57449. emitErrors(): void;
  57450. }
  57451. }
  57452. declare module BABYLON {
  57453. /**
  57454. * Class used to store node based material build state
  57455. */
  57456. export class NodeMaterialBuildState {
  57457. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57458. supportUniformBuffers: boolean;
  57459. /**
  57460. * Gets the list of emitted attributes
  57461. */
  57462. attributes: string[];
  57463. /**
  57464. * Gets the list of emitted uniforms
  57465. */
  57466. uniforms: string[];
  57467. /**
  57468. * Gets the list of emitted constants
  57469. */
  57470. constants: string[];
  57471. /**
  57472. * Gets the list of emitted samplers
  57473. */
  57474. samplers: string[];
  57475. /**
  57476. * Gets the list of emitted functions
  57477. */
  57478. functions: {
  57479. [key: string]: string;
  57480. };
  57481. /**
  57482. * Gets the list of emitted extensions
  57483. */
  57484. extensions: {
  57485. [key: string]: string;
  57486. };
  57487. /**
  57488. * Gets the target of the compilation state
  57489. */
  57490. target: NodeMaterialBlockTargets;
  57491. /**
  57492. * Gets the list of emitted counters
  57493. */
  57494. counters: {
  57495. [key: string]: number;
  57496. };
  57497. /**
  57498. * Shared data between multiple NodeMaterialBuildState instances
  57499. */
  57500. sharedData: NodeMaterialBuildStateSharedData;
  57501. /** @hidden */
  57502. _vertexState: NodeMaterialBuildState;
  57503. /** @hidden */
  57504. _attributeDeclaration: string;
  57505. /** @hidden */
  57506. _uniformDeclaration: string;
  57507. /** @hidden */
  57508. _constantDeclaration: string;
  57509. /** @hidden */
  57510. _samplerDeclaration: string;
  57511. /** @hidden */
  57512. _varyingTransfer: string;
  57513. private _repeatableContentAnchorIndex;
  57514. /** @hidden */
  57515. _builtCompilationString: string;
  57516. /**
  57517. * Gets the emitted compilation strings
  57518. */
  57519. compilationString: string;
  57520. /**
  57521. * Finalize the compilation strings
  57522. * @param state defines the current compilation state
  57523. */
  57524. finalize(state: NodeMaterialBuildState): void;
  57525. /** @hidden */
  57526. get _repeatableContentAnchor(): string;
  57527. /** @hidden */
  57528. _getFreeVariableName(prefix: string): string;
  57529. /** @hidden */
  57530. _getFreeDefineName(prefix: string): string;
  57531. /** @hidden */
  57532. _excludeVariableName(name: string): void;
  57533. /** @hidden */
  57534. _emit2DSampler(name: string): void;
  57535. /** @hidden */
  57536. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57537. /** @hidden */
  57538. _emitExtension(name: string, extension: string): void;
  57539. /** @hidden */
  57540. _emitFunction(name: string, code: string, comments: string): void;
  57541. /** @hidden */
  57542. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57543. replaceStrings?: {
  57544. search: RegExp;
  57545. replace: string;
  57546. }[];
  57547. repeatKey?: string;
  57548. }): string;
  57549. /** @hidden */
  57550. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57551. repeatKey?: string;
  57552. removeAttributes?: boolean;
  57553. removeUniforms?: boolean;
  57554. removeVaryings?: boolean;
  57555. removeIfDef?: boolean;
  57556. replaceStrings?: {
  57557. search: RegExp;
  57558. replace: string;
  57559. }[];
  57560. }, storeKey?: string): void;
  57561. /** @hidden */
  57562. _registerTempVariable(name: string): boolean;
  57563. /** @hidden */
  57564. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57565. /** @hidden */
  57566. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57567. /** @hidden */
  57568. _emitFloat(value: number): string;
  57569. }
  57570. }
  57571. declare module BABYLON {
  57572. /**
  57573. * Defines a block that can be used inside a node based material
  57574. */
  57575. export class NodeMaterialBlock {
  57576. private _buildId;
  57577. private _buildTarget;
  57578. private _target;
  57579. private _isFinalMerger;
  57580. private _isInput;
  57581. protected _isUnique: boolean;
  57582. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57583. inputsAreExclusive: boolean;
  57584. /** @hidden */
  57585. _codeVariableName: string;
  57586. /** @hidden */
  57587. _inputs: NodeMaterialConnectionPoint[];
  57588. /** @hidden */
  57589. _outputs: NodeMaterialConnectionPoint[];
  57590. /** @hidden */
  57591. _preparationId: number;
  57592. /**
  57593. * Gets or sets the name of the block
  57594. */
  57595. name: string;
  57596. /**
  57597. * Gets or sets the unique id of the node
  57598. */
  57599. uniqueId: number;
  57600. /**
  57601. * Gets or sets the comments associated with this block
  57602. */
  57603. comments: string;
  57604. /**
  57605. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57606. */
  57607. get isUnique(): boolean;
  57608. /**
  57609. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57610. */
  57611. get isFinalMerger(): boolean;
  57612. /**
  57613. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57614. */
  57615. get isInput(): boolean;
  57616. /**
  57617. * Gets or sets the build Id
  57618. */
  57619. get buildId(): number;
  57620. set buildId(value: number);
  57621. /**
  57622. * Gets or sets the target of the block
  57623. */
  57624. get target(): NodeMaterialBlockTargets;
  57625. set target(value: NodeMaterialBlockTargets);
  57626. /**
  57627. * Gets the list of input points
  57628. */
  57629. get inputs(): NodeMaterialConnectionPoint[];
  57630. /** Gets the list of output points */
  57631. get outputs(): NodeMaterialConnectionPoint[];
  57632. /**
  57633. * Find an input by its name
  57634. * @param name defines the name of the input to look for
  57635. * @returns the input or null if not found
  57636. */
  57637. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57638. /**
  57639. * Find an output by its name
  57640. * @param name defines the name of the outputto look for
  57641. * @returns the output or null if not found
  57642. */
  57643. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57644. /**
  57645. * Creates a new NodeMaterialBlock
  57646. * @param name defines the block name
  57647. * @param target defines the target of that block (Vertex by default)
  57648. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57649. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57650. */
  57651. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57652. /**
  57653. * Initialize the block and prepare the context for build
  57654. * @param state defines the state that will be used for the build
  57655. */
  57656. initialize(state: NodeMaterialBuildState): void;
  57657. /**
  57658. * Bind data to effect. Will only be called for blocks with isBindable === true
  57659. * @param effect defines the effect to bind data to
  57660. * @param nodeMaterial defines the hosting NodeMaterial
  57661. * @param mesh defines the mesh that will be rendered
  57662. */
  57663. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57664. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57665. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57666. protected _writeFloat(value: number): string;
  57667. /**
  57668. * Gets the current class name e.g. "NodeMaterialBlock"
  57669. * @returns the class name
  57670. */
  57671. getClassName(): string;
  57672. /**
  57673. * Register a new input. Must be called inside a block constructor
  57674. * @param name defines the connection point name
  57675. * @param type defines the connection point type
  57676. * @param isOptional defines a boolean indicating that this input can be omitted
  57677. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57678. * @returns the current block
  57679. */
  57680. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57681. /**
  57682. * Register a new output. Must be called inside a block constructor
  57683. * @param name defines the connection point name
  57684. * @param type defines the connection point type
  57685. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57686. * @returns the current block
  57687. */
  57688. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57689. /**
  57690. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57691. * @param forOutput defines an optional connection point to check compatibility with
  57692. * @returns the first available input or null
  57693. */
  57694. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57695. /**
  57696. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57697. * @param forBlock defines an optional block to check compatibility with
  57698. * @returns the first available input or null
  57699. */
  57700. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57701. /**
  57702. * Gets the sibling of the given output
  57703. * @param current defines the current output
  57704. * @returns the next output in the list or null
  57705. */
  57706. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57707. /**
  57708. * Connect current block with another block
  57709. * @param other defines the block to connect with
  57710. * @param options define the various options to help pick the right connections
  57711. * @returns the current block
  57712. */
  57713. connectTo(other: NodeMaterialBlock, options?: {
  57714. input?: string;
  57715. output?: string;
  57716. outputSwizzle?: string;
  57717. }): this | undefined;
  57718. protected _buildBlock(state: NodeMaterialBuildState): void;
  57719. /**
  57720. * Add uniforms, samplers and uniform buffers at compilation time
  57721. * @param state defines the state to update
  57722. * @param nodeMaterial defines the node material requesting the update
  57723. * @param defines defines the material defines to update
  57724. * @param uniformBuffers defines the list of uniform buffer names
  57725. */
  57726. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57727. /**
  57728. * Add potential fallbacks if shader compilation fails
  57729. * @param mesh defines the mesh to be rendered
  57730. * @param fallbacks defines the current prioritized list of fallbacks
  57731. */
  57732. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57733. /**
  57734. * Initialize defines for shader compilation
  57735. * @param mesh defines the mesh to be rendered
  57736. * @param nodeMaterial defines the node material requesting the update
  57737. * @param defines defines the material defines to update
  57738. * @param useInstances specifies that instances should be used
  57739. */
  57740. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57741. /**
  57742. * Update defines for shader compilation
  57743. * @param mesh defines the mesh to be rendered
  57744. * @param nodeMaterial defines the node material requesting the update
  57745. * @param defines defines the material defines to update
  57746. * @param useInstances specifies that instances should be used
  57747. */
  57748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57749. /**
  57750. * Lets the block try to connect some inputs automatically
  57751. * @param material defines the hosting NodeMaterial
  57752. */
  57753. autoConfigure(material: NodeMaterial): void;
  57754. /**
  57755. * Function called when a block is declared as repeatable content generator
  57756. * @param vertexShaderState defines the current compilation state for the vertex shader
  57757. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57758. * @param mesh defines the mesh to be rendered
  57759. * @param defines defines the material defines to update
  57760. */
  57761. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57762. /**
  57763. * Checks if the block is ready
  57764. * @param mesh defines the mesh to be rendered
  57765. * @param nodeMaterial defines the node material requesting the update
  57766. * @param defines defines the material defines to update
  57767. * @param useInstances specifies that instances should be used
  57768. * @returns true if the block is ready
  57769. */
  57770. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57771. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57772. private _processBuild;
  57773. /**
  57774. * Compile the current node and generate the shader code
  57775. * @param state defines the current compilation state (uniforms, samplers, current string)
  57776. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57777. * @returns true if already built
  57778. */
  57779. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57780. protected _inputRename(name: string): string;
  57781. protected _outputRename(name: string): string;
  57782. protected _dumpPropertiesCode(): string;
  57783. /** @hidden */
  57784. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57785. /** @hidden */
  57786. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57787. /**
  57788. * Clone the current block to a new identical block
  57789. * @param scene defines the hosting scene
  57790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57791. * @returns a copy of the current block
  57792. */
  57793. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57794. /**
  57795. * Serializes this block in a JSON representation
  57796. * @returns the serialized block object
  57797. */
  57798. serialize(): any;
  57799. /** @hidden */
  57800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57801. /**
  57802. * Release resources
  57803. */
  57804. dispose(): void;
  57805. }
  57806. }
  57807. declare module BABYLON {
  57808. /**
  57809. * Enum defining the type of animations supported by InputBlock
  57810. */
  57811. export enum AnimatedInputBlockTypes {
  57812. /** No animation */
  57813. None = 0,
  57814. /** Time based animation. Will only work for floats */
  57815. Time = 1
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. /**
  57820. * Block used to expose an input value
  57821. */
  57822. export class InputBlock extends NodeMaterialBlock {
  57823. private _mode;
  57824. private _associatedVariableName;
  57825. private _storedValue;
  57826. private _valueCallback;
  57827. private _type;
  57828. private _animationType;
  57829. /** Gets or set a value used to limit the range of float values */
  57830. min: number;
  57831. /** Gets or set a value used to limit the range of float values */
  57832. max: number;
  57833. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57834. isBoolean: boolean;
  57835. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57836. matrixMode: number;
  57837. /** @hidden */
  57838. _systemValue: Nullable<NodeMaterialSystemValues>;
  57839. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57840. visibleInInspector: boolean;
  57841. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57842. isConstant: boolean;
  57843. /** Gets or sets the group to use to display this block in the Inspector */
  57844. groupInInspector: string;
  57845. /**
  57846. * Gets or sets the connection point type (default is float)
  57847. */
  57848. get type(): NodeMaterialBlockConnectionPointTypes;
  57849. /**
  57850. * Creates a new InputBlock
  57851. * @param name defines the block name
  57852. * @param target defines the target of that block (Vertex by default)
  57853. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57854. */
  57855. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57856. /**
  57857. * Gets the output component
  57858. */
  57859. get output(): NodeMaterialConnectionPoint;
  57860. /**
  57861. * Set the source of this connection point to a vertex attribute
  57862. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57863. * @returns the current connection point
  57864. */
  57865. setAsAttribute(attributeName?: string): InputBlock;
  57866. /**
  57867. * Set the source of this connection point to a system value
  57868. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57869. * @returns the current connection point
  57870. */
  57871. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57872. /**
  57873. * Gets or sets the value of that point.
  57874. * Please note that this value will be ignored if valueCallback is defined
  57875. */
  57876. get value(): any;
  57877. set value(value: any);
  57878. /**
  57879. * Gets or sets a callback used to get the value of that point.
  57880. * Please note that setting this value will force the connection point to ignore the value property
  57881. */
  57882. get valueCallback(): () => any;
  57883. set valueCallback(value: () => any);
  57884. /**
  57885. * Gets or sets the associated variable name in the shader
  57886. */
  57887. get associatedVariableName(): string;
  57888. set associatedVariableName(value: string);
  57889. /** Gets or sets the type of animation applied to the input */
  57890. get animationType(): AnimatedInputBlockTypes;
  57891. set animationType(value: AnimatedInputBlockTypes);
  57892. /**
  57893. * Gets a boolean indicating that this connection point not defined yet
  57894. */
  57895. get isUndefined(): boolean;
  57896. /**
  57897. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57898. * In this case the connection point name must be the name of the uniform to use.
  57899. * Can only be set on inputs
  57900. */
  57901. get isUniform(): boolean;
  57902. set isUniform(value: boolean);
  57903. /**
  57904. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57905. * In this case the connection point name must be the name of the attribute to use
  57906. * Can only be set on inputs
  57907. */
  57908. get isAttribute(): boolean;
  57909. set isAttribute(value: boolean);
  57910. /**
  57911. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57912. * Can only be set on exit points
  57913. */
  57914. get isVarying(): boolean;
  57915. set isVarying(value: boolean);
  57916. /**
  57917. * Gets a boolean indicating that the current connection point is a system value
  57918. */
  57919. get isSystemValue(): boolean;
  57920. /**
  57921. * Gets or sets the current well known value or null if not defined as a system value
  57922. */
  57923. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57924. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57925. /**
  57926. * Gets the current class name
  57927. * @returns the class name
  57928. */
  57929. getClassName(): string;
  57930. /**
  57931. * Animate the input if animationType !== None
  57932. * @param scene defines the rendering scene
  57933. */
  57934. animate(scene: Scene): void;
  57935. private _emitDefine;
  57936. initialize(state: NodeMaterialBuildState): void;
  57937. /**
  57938. * Set the input block to its default value (based on its type)
  57939. */
  57940. setDefaultValue(): void;
  57941. private _emitConstant;
  57942. private _emit;
  57943. /** @hidden */
  57944. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57945. /** @hidden */
  57946. _transmit(effect: Effect, scene: Scene): void;
  57947. protected _buildBlock(state: NodeMaterialBuildState): void;
  57948. protected _dumpPropertiesCode(): string;
  57949. serialize(): any;
  57950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57951. }
  57952. }
  57953. declare module BABYLON {
  57954. /**
  57955. * Enum used to define the compatibility state between two connection points
  57956. */
  57957. export enum NodeMaterialConnectionPointCompatibilityStates {
  57958. /** Points are compatibles */
  57959. Compatible = 0,
  57960. /** Points are incompatible because of their types */
  57961. TypeIncompatible = 1,
  57962. /** Points are incompatible because of their targets (vertex vs fragment) */
  57963. TargetIncompatible = 2
  57964. }
  57965. /**
  57966. * Defines the direction of a connection point
  57967. */
  57968. export enum NodeMaterialConnectionPointDirection {
  57969. /** Input */
  57970. Input = 0,
  57971. /** Output */
  57972. Output = 1
  57973. }
  57974. /**
  57975. * Defines a connection point for a block
  57976. */
  57977. export class NodeMaterialConnectionPoint {
  57978. /** @hidden */
  57979. _ownerBlock: NodeMaterialBlock;
  57980. /** @hidden */
  57981. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57982. private _endpoints;
  57983. private _associatedVariableName;
  57984. private _direction;
  57985. /** @hidden */
  57986. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57987. /** @hidden */
  57988. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57989. private _type;
  57990. /** @hidden */
  57991. _enforceAssociatedVariableName: boolean;
  57992. /** Gets the direction of the point */
  57993. get direction(): NodeMaterialConnectionPointDirection;
  57994. /**
  57995. * Gets or sets the additional types supported by this connection point
  57996. */
  57997. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57998. /**
  57999. * Gets or sets the additional types excluded by this connection point
  58000. */
  58001. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58002. /**
  58003. * Observable triggered when this point is connected
  58004. */
  58005. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58006. /**
  58007. * Gets or sets the associated variable name in the shader
  58008. */
  58009. get associatedVariableName(): string;
  58010. set associatedVariableName(value: string);
  58011. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58012. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58013. /**
  58014. * Gets or sets the connection point type (default is float)
  58015. */
  58016. get type(): NodeMaterialBlockConnectionPointTypes;
  58017. set type(value: NodeMaterialBlockConnectionPointTypes);
  58018. /**
  58019. * Gets or sets the connection point name
  58020. */
  58021. name: string;
  58022. /**
  58023. * Gets or sets a boolean indicating that this connection point can be omitted
  58024. */
  58025. isOptional: boolean;
  58026. /**
  58027. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58028. */
  58029. define: string;
  58030. /** @hidden */
  58031. _prioritizeVertex: boolean;
  58032. private _target;
  58033. /** Gets or sets the target of that connection point */
  58034. get target(): NodeMaterialBlockTargets;
  58035. set target(value: NodeMaterialBlockTargets);
  58036. /**
  58037. * Gets a boolean indicating that the current point is connected
  58038. */
  58039. get isConnected(): boolean;
  58040. /**
  58041. * Gets a boolean indicating that the current point is connected to an input block
  58042. */
  58043. get isConnectedToInputBlock(): boolean;
  58044. /**
  58045. * Gets a the connected input block (if any)
  58046. */
  58047. get connectInputBlock(): Nullable<InputBlock>;
  58048. /** Get the other side of the connection (if any) */
  58049. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58050. /** Get the block that owns this connection point */
  58051. get ownerBlock(): NodeMaterialBlock;
  58052. /** Get the block connected on the other side of this connection (if any) */
  58053. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58054. /** Get the block connected on the endpoints of this connection (if any) */
  58055. get connectedBlocks(): Array<NodeMaterialBlock>;
  58056. /** Gets the list of connected endpoints */
  58057. get endpoints(): NodeMaterialConnectionPoint[];
  58058. /** Gets a boolean indicating if that output point is connected to at least one input */
  58059. get hasEndpoints(): boolean;
  58060. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58061. get isConnectedInVertexShader(): boolean;
  58062. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58063. get isConnectedInFragmentShader(): boolean;
  58064. /**
  58065. * Creates a new connection point
  58066. * @param name defines the connection point name
  58067. * @param ownerBlock defines the block hosting this connection point
  58068. * @param direction defines the direction of the connection point
  58069. */
  58070. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58071. /**
  58072. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58073. * @returns the class name
  58074. */
  58075. getClassName(): string;
  58076. /**
  58077. * Gets a boolean indicating if the current point can be connected to another point
  58078. * @param connectionPoint defines the other connection point
  58079. * @returns a boolean
  58080. */
  58081. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58082. /**
  58083. * Gets a number indicating if the current point can be connected to another point
  58084. * @param connectionPoint defines the other connection point
  58085. * @returns a number defining the compatibility state
  58086. */
  58087. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58088. /**
  58089. * Connect this point to another connection point
  58090. * @param connectionPoint defines the other connection point
  58091. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58092. * @returns the current connection point
  58093. */
  58094. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58095. /**
  58096. * Disconnect this point from one of his endpoint
  58097. * @param endpoint defines the other connection point
  58098. * @returns the current connection point
  58099. */
  58100. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58101. /**
  58102. * Serializes this point in a JSON representation
  58103. * @returns the serialized point object
  58104. */
  58105. serialize(): any;
  58106. /**
  58107. * Release resources
  58108. */
  58109. dispose(): void;
  58110. }
  58111. }
  58112. declare module BABYLON {
  58113. /**
  58114. * Block used to add support for vertex skinning (bones)
  58115. */
  58116. export class BonesBlock extends NodeMaterialBlock {
  58117. /**
  58118. * Creates a new BonesBlock
  58119. * @param name defines the block name
  58120. */
  58121. constructor(name: string);
  58122. /**
  58123. * Initialize the block and prepare the context for build
  58124. * @param state defines the state that will be used for the build
  58125. */
  58126. initialize(state: NodeMaterialBuildState): void;
  58127. /**
  58128. * Gets the current class name
  58129. * @returns the class name
  58130. */
  58131. getClassName(): string;
  58132. /**
  58133. * Gets the matrix indices input component
  58134. */
  58135. get matricesIndices(): NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the matrix weights input component
  58138. */
  58139. get matricesWeights(): NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the extra matrix indices input component
  58142. */
  58143. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58144. /**
  58145. * Gets the extra matrix weights input component
  58146. */
  58147. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the world input component
  58150. */
  58151. get world(): NodeMaterialConnectionPoint;
  58152. /**
  58153. * Gets the output component
  58154. */
  58155. get output(): NodeMaterialConnectionPoint;
  58156. autoConfigure(material: NodeMaterial): void;
  58157. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58160. protected _buildBlock(state: NodeMaterialBuildState): this;
  58161. }
  58162. }
  58163. declare module BABYLON {
  58164. /**
  58165. * Block used to add support for instances
  58166. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58167. */
  58168. export class InstancesBlock extends NodeMaterialBlock {
  58169. /**
  58170. * Creates a new InstancesBlock
  58171. * @param name defines the block name
  58172. */
  58173. constructor(name: string);
  58174. /**
  58175. * Gets the current class name
  58176. * @returns the class name
  58177. */
  58178. getClassName(): string;
  58179. /**
  58180. * Gets the first world row input component
  58181. */
  58182. get world0(): NodeMaterialConnectionPoint;
  58183. /**
  58184. * Gets the second world row input component
  58185. */
  58186. get world1(): NodeMaterialConnectionPoint;
  58187. /**
  58188. * Gets the third world row input component
  58189. */
  58190. get world2(): NodeMaterialConnectionPoint;
  58191. /**
  58192. * Gets the forth world row input component
  58193. */
  58194. get world3(): NodeMaterialConnectionPoint;
  58195. /**
  58196. * Gets the world input component
  58197. */
  58198. get world(): NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the output component
  58201. */
  58202. get output(): NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the isntanceID component
  58205. */
  58206. get instanceID(): NodeMaterialConnectionPoint;
  58207. autoConfigure(material: NodeMaterial): void;
  58208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58209. protected _buildBlock(state: NodeMaterialBuildState): this;
  58210. }
  58211. }
  58212. declare module BABYLON {
  58213. /**
  58214. * Block used to add morph targets support to vertex shader
  58215. */
  58216. export class MorphTargetsBlock extends NodeMaterialBlock {
  58217. private _repeatableContentAnchor;
  58218. /**
  58219. * Create a new MorphTargetsBlock
  58220. * @param name defines the block name
  58221. */
  58222. constructor(name: string);
  58223. /**
  58224. * Gets the current class name
  58225. * @returns the class name
  58226. */
  58227. getClassName(): string;
  58228. /**
  58229. * Gets the position input component
  58230. */
  58231. get position(): NodeMaterialConnectionPoint;
  58232. /**
  58233. * Gets the normal input component
  58234. */
  58235. get normal(): NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the tangent input component
  58238. */
  58239. get tangent(): NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the tangent input component
  58242. */
  58243. get uv(): NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the position output component
  58246. */
  58247. get positionOutput(): NodeMaterialConnectionPoint;
  58248. /**
  58249. * Gets the normal output component
  58250. */
  58251. get normalOutput(): NodeMaterialConnectionPoint;
  58252. /**
  58253. * Gets the tangent output component
  58254. */
  58255. get tangentOutput(): NodeMaterialConnectionPoint;
  58256. /**
  58257. * Gets the tangent output component
  58258. */
  58259. get uvOutput(): NodeMaterialConnectionPoint;
  58260. initialize(state: NodeMaterialBuildState): void;
  58261. autoConfigure(material: NodeMaterial): void;
  58262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58263. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58264. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58265. protected _buildBlock(state: NodeMaterialBuildState): this;
  58266. }
  58267. }
  58268. declare module BABYLON {
  58269. /**
  58270. * Block used to get data information from a light
  58271. */
  58272. export class LightInformationBlock extends NodeMaterialBlock {
  58273. private _lightDataUniformName;
  58274. private _lightColorUniformName;
  58275. private _lightTypeDefineName;
  58276. /**
  58277. * Gets or sets the light associated with this block
  58278. */
  58279. light: Nullable<Light>;
  58280. /**
  58281. * Creates a new LightInformationBlock
  58282. * @param name defines the block name
  58283. */
  58284. constructor(name: string);
  58285. /**
  58286. * Gets the current class name
  58287. * @returns the class name
  58288. */
  58289. getClassName(): string;
  58290. /**
  58291. * Gets the world position input component
  58292. */
  58293. get worldPosition(): NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the direction output component
  58296. */
  58297. get direction(): NodeMaterialConnectionPoint;
  58298. /**
  58299. * Gets the direction output component
  58300. */
  58301. get color(): NodeMaterialConnectionPoint;
  58302. /**
  58303. * Gets the direction output component
  58304. */
  58305. get intensity(): NodeMaterialConnectionPoint;
  58306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58308. protected _buildBlock(state: NodeMaterialBuildState): this;
  58309. serialize(): any;
  58310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58311. }
  58312. }
  58313. declare module BABYLON {
  58314. /**
  58315. * Block used to add image processing support to fragment shader
  58316. */
  58317. export class ImageProcessingBlock extends NodeMaterialBlock {
  58318. /**
  58319. * Create a new ImageProcessingBlock
  58320. * @param name defines the block name
  58321. */
  58322. constructor(name: string);
  58323. /**
  58324. * Gets the current class name
  58325. * @returns the class name
  58326. */
  58327. getClassName(): string;
  58328. /**
  58329. * Gets the color input component
  58330. */
  58331. get color(): NodeMaterialConnectionPoint;
  58332. /**
  58333. * Gets the output component
  58334. */
  58335. get output(): NodeMaterialConnectionPoint;
  58336. /**
  58337. * Initialize the block and prepare the context for build
  58338. * @param state defines the state that will be used for the build
  58339. */
  58340. initialize(state: NodeMaterialBuildState): void;
  58341. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58344. protected _buildBlock(state: NodeMaterialBuildState): this;
  58345. }
  58346. }
  58347. declare module BABYLON {
  58348. /**
  58349. * Block used to pertub normals based on a normal map
  58350. */
  58351. export class PerturbNormalBlock extends NodeMaterialBlock {
  58352. private _tangentSpaceParameterName;
  58353. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58354. invertX: boolean;
  58355. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58356. invertY: boolean;
  58357. /**
  58358. * Create a new PerturbNormalBlock
  58359. * @param name defines the block name
  58360. */
  58361. constructor(name: string);
  58362. /**
  58363. * Gets the current class name
  58364. * @returns the class name
  58365. */
  58366. getClassName(): string;
  58367. /**
  58368. * Gets the world position input component
  58369. */
  58370. get worldPosition(): NodeMaterialConnectionPoint;
  58371. /**
  58372. * Gets the world normal input component
  58373. */
  58374. get worldNormal(): NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the uv input component
  58377. */
  58378. get uv(): NodeMaterialConnectionPoint;
  58379. /**
  58380. * Gets the normal map color input component
  58381. */
  58382. get normalMapColor(): NodeMaterialConnectionPoint;
  58383. /**
  58384. * Gets the strength input component
  58385. */
  58386. get strength(): NodeMaterialConnectionPoint;
  58387. /**
  58388. * Gets the output component
  58389. */
  58390. get output(): NodeMaterialConnectionPoint;
  58391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58393. autoConfigure(material: NodeMaterial): void;
  58394. protected _buildBlock(state: NodeMaterialBuildState): this;
  58395. protected _dumpPropertiesCode(): string;
  58396. serialize(): any;
  58397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58398. }
  58399. }
  58400. declare module BABYLON {
  58401. /**
  58402. * Block used to discard a pixel if a value is smaller than a cutoff
  58403. */
  58404. export class DiscardBlock extends NodeMaterialBlock {
  58405. /**
  58406. * Create a new DiscardBlock
  58407. * @param name defines the block name
  58408. */
  58409. constructor(name: string);
  58410. /**
  58411. * Gets the current class name
  58412. * @returns the class name
  58413. */
  58414. getClassName(): string;
  58415. /**
  58416. * Gets the color input component
  58417. */
  58418. get value(): NodeMaterialConnectionPoint;
  58419. /**
  58420. * Gets the cutoff input component
  58421. */
  58422. get cutoff(): NodeMaterialConnectionPoint;
  58423. protected _buildBlock(state: NodeMaterialBuildState): this;
  58424. }
  58425. }
  58426. declare module BABYLON {
  58427. /**
  58428. * Block used to test if the fragment shader is front facing
  58429. */
  58430. export class FrontFacingBlock extends NodeMaterialBlock {
  58431. /**
  58432. * Creates a new FrontFacingBlock
  58433. * @param name defines the block name
  58434. */
  58435. constructor(name: string);
  58436. /**
  58437. * Gets the current class name
  58438. * @returns the class name
  58439. */
  58440. getClassName(): string;
  58441. /**
  58442. * Gets the output component
  58443. */
  58444. get output(): NodeMaterialConnectionPoint;
  58445. protected _buildBlock(state: NodeMaterialBuildState): this;
  58446. }
  58447. }
  58448. declare module BABYLON {
  58449. /**
  58450. * Block used to get the derivative value on x and y of a given input
  58451. */
  58452. export class DerivativeBlock extends NodeMaterialBlock {
  58453. /**
  58454. * Create a new DerivativeBlock
  58455. * @param name defines the block name
  58456. */
  58457. constructor(name: string);
  58458. /**
  58459. * Gets the current class name
  58460. * @returns the class name
  58461. */
  58462. getClassName(): string;
  58463. /**
  58464. * Gets the input component
  58465. */
  58466. get input(): NodeMaterialConnectionPoint;
  58467. /**
  58468. * Gets the derivative output on x
  58469. */
  58470. get dx(): NodeMaterialConnectionPoint;
  58471. /**
  58472. * Gets the derivative output on y
  58473. */
  58474. get dy(): NodeMaterialConnectionPoint;
  58475. protected _buildBlock(state: NodeMaterialBuildState): this;
  58476. }
  58477. }
  58478. declare module BABYLON {
  58479. /**
  58480. * Block used to add support for scene fog
  58481. */
  58482. export class FogBlock extends NodeMaterialBlock {
  58483. private _fogDistanceName;
  58484. private _fogParameters;
  58485. /**
  58486. * Create a new FogBlock
  58487. * @param name defines the block name
  58488. */
  58489. constructor(name: string);
  58490. /**
  58491. * Gets the current class name
  58492. * @returns the class name
  58493. */
  58494. getClassName(): string;
  58495. /**
  58496. * Gets the world position input component
  58497. */
  58498. get worldPosition(): NodeMaterialConnectionPoint;
  58499. /**
  58500. * Gets the view input component
  58501. */
  58502. get view(): NodeMaterialConnectionPoint;
  58503. /**
  58504. * Gets the color input component
  58505. */
  58506. get input(): NodeMaterialConnectionPoint;
  58507. /**
  58508. * Gets the fog color input component
  58509. */
  58510. get fogColor(): NodeMaterialConnectionPoint;
  58511. /**
  58512. * Gets the output component
  58513. */
  58514. get output(): NodeMaterialConnectionPoint;
  58515. autoConfigure(material: NodeMaterial): void;
  58516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58517. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58518. protected _buildBlock(state: NodeMaterialBuildState): this;
  58519. }
  58520. }
  58521. declare module BABYLON {
  58522. /**
  58523. * Block used to add light in the fragment shader
  58524. */
  58525. export class LightBlock extends NodeMaterialBlock {
  58526. private _lightId;
  58527. /**
  58528. * Gets or sets the light associated with this block
  58529. */
  58530. light: Nullable<Light>;
  58531. /**
  58532. * Create a new LightBlock
  58533. * @param name defines the block name
  58534. */
  58535. constructor(name: string);
  58536. /**
  58537. * Gets the current class name
  58538. * @returns the class name
  58539. */
  58540. getClassName(): string;
  58541. /**
  58542. * Gets the world position input component
  58543. */
  58544. get worldPosition(): NodeMaterialConnectionPoint;
  58545. /**
  58546. * Gets the world normal input component
  58547. */
  58548. get worldNormal(): NodeMaterialConnectionPoint;
  58549. /**
  58550. * Gets the camera (or eye) position component
  58551. */
  58552. get cameraPosition(): NodeMaterialConnectionPoint;
  58553. /**
  58554. * Gets the glossiness component
  58555. */
  58556. get glossiness(): NodeMaterialConnectionPoint;
  58557. /**
  58558. * Gets the glossinness power component
  58559. */
  58560. get glossPower(): NodeMaterialConnectionPoint;
  58561. /**
  58562. * Gets the diffuse color component
  58563. */
  58564. get diffuseColor(): NodeMaterialConnectionPoint;
  58565. /**
  58566. * Gets the specular color component
  58567. */
  58568. get specularColor(): NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the diffuse output component
  58571. */
  58572. get diffuseOutput(): NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the specular output component
  58575. */
  58576. get specularOutput(): NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the shadow output component
  58579. */
  58580. get shadow(): NodeMaterialConnectionPoint;
  58581. autoConfigure(material: NodeMaterial): void;
  58582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58583. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58584. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58585. private _injectVertexCode;
  58586. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58587. serialize(): any;
  58588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58589. }
  58590. }
  58591. declare module BABYLON {
  58592. /**
  58593. * Block used to multiply 2 values
  58594. */
  58595. export class MultiplyBlock extends NodeMaterialBlock {
  58596. /**
  58597. * Creates a new MultiplyBlock
  58598. * @param name defines the block name
  58599. */
  58600. constructor(name: string);
  58601. /**
  58602. * Gets the current class name
  58603. * @returns the class name
  58604. */
  58605. getClassName(): string;
  58606. /**
  58607. * Gets the left operand input component
  58608. */
  58609. get left(): NodeMaterialConnectionPoint;
  58610. /**
  58611. * Gets the right operand input component
  58612. */
  58613. get right(): NodeMaterialConnectionPoint;
  58614. /**
  58615. * Gets the output component
  58616. */
  58617. get output(): NodeMaterialConnectionPoint;
  58618. protected _buildBlock(state: NodeMaterialBuildState): this;
  58619. }
  58620. }
  58621. declare module BABYLON {
  58622. /**
  58623. * Block used to add 2 vectors
  58624. */
  58625. export class AddBlock extends NodeMaterialBlock {
  58626. /**
  58627. * Creates a new AddBlock
  58628. * @param name defines the block name
  58629. */
  58630. constructor(name: string);
  58631. /**
  58632. * Gets the current class name
  58633. * @returns the class name
  58634. */
  58635. getClassName(): string;
  58636. /**
  58637. * Gets the left operand input component
  58638. */
  58639. get left(): NodeMaterialConnectionPoint;
  58640. /**
  58641. * Gets the right operand input component
  58642. */
  58643. get right(): NodeMaterialConnectionPoint;
  58644. /**
  58645. * Gets the output component
  58646. */
  58647. get output(): NodeMaterialConnectionPoint;
  58648. protected _buildBlock(state: NodeMaterialBuildState): this;
  58649. }
  58650. }
  58651. declare module BABYLON {
  58652. /**
  58653. * Block used to scale a vector by a float
  58654. */
  58655. export class ScaleBlock extends NodeMaterialBlock {
  58656. /**
  58657. * Creates a new ScaleBlock
  58658. * @param name defines the block name
  58659. */
  58660. constructor(name: string);
  58661. /**
  58662. * Gets the current class name
  58663. * @returns the class name
  58664. */
  58665. getClassName(): string;
  58666. /**
  58667. * Gets the input component
  58668. */
  58669. get input(): NodeMaterialConnectionPoint;
  58670. /**
  58671. * Gets the factor input component
  58672. */
  58673. get factor(): NodeMaterialConnectionPoint;
  58674. /**
  58675. * Gets the output component
  58676. */
  58677. get output(): NodeMaterialConnectionPoint;
  58678. protected _buildBlock(state: NodeMaterialBuildState): this;
  58679. }
  58680. }
  58681. declare module BABYLON {
  58682. /**
  58683. * Block used to clamp a float
  58684. */
  58685. export class ClampBlock extends NodeMaterialBlock {
  58686. /** Gets or sets the minimum range */
  58687. minimum: number;
  58688. /** Gets or sets the maximum range */
  58689. maximum: number;
  58690. /**
  58691. * Creates a new ClampBlock
  58692. * @param name defines the block name
  58693. */
  58694. constructor(name: string);
  58695. /**
  58696. * Gets the current class name
  58697. * @returns the class name
  58698. */
  58699. getClassName(): string;
  58700. /**
  58701. * Gets the value input component
  58702. */
  58703. get value(): NodeMaterialConnectionPoint;
  58704. /**
  58705. * Gets the output component
  58706. */
  58707. get output(): NodeMaterialConnectionPoint;
  58708. protected _buildBlock(state: NodeMaterialBuildState): this;
  58709. protected _dumpPropertiesCode(): string;
  58710. serialize(): any;
  58711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58712. }
  58713. }
  58714. declare module BABYLON {
  58715. /**
  58716. * Block used to apply a cross product between 2 vectors
  58717. */
  58718. export class CrossBlock extends NodeMaterialBlock {
  58719. /**
  58720. * Creates a new CrossBlock
  58721. * @param name defines the block name
  58722. */
  58723. constructor(name: string);
  58724. /**
  58725. * Gets the current class name
  58726. * @returns the class name
  58727. */
  58728. getClassName(): string;
  58729. /**
  58730. * Gets the left operand input component
  58731. */
  58732. get left(): NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the right operand input component
  58735. */
  58736. get right(): NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the output component
  58739. */
  58740. get output(): NodeMaterialConnectionPoint;
  58741. protected _buildBlock(state: NodeMaterialBuildState): this;
  58742. }
  58743. }
  58744. declare module BABYLON {
  58745. /**
  58746. * Block used to apply a dot product between 2 vectors
  58747. */
  58748. export class DotBlock extends NodeMaterialBlock {
  58749. /**
  58750. * Creates a new DotBlock
  58751. * @param name defines the block name
  58752. */
  58753. constructor(name: string);
  58754. /**
  58755. * Gets the current class name
  58756. * @returns the class name
  58757. */
  58758. getClassName(): string;
  58759. /**
  58760. * Gets the left operand input component
  58761. */
  58762. get left(): NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the right operand input component
  58765. */
  58766. get right(): NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the output component
  58769. */
  58770. get output(): NodeMaterialConnectionPoint;
  58771. protected _buildBlock(state: NodeMaterialBuildState): this;
  58772. }
  58773. }
  58774. declare module BABYLON {
  58775. /**
  58776. * Block used to remap a float from a range to a new one
  58777. */
  58778. export class RemapBlock extends NodeMaterialBlock {
  58779. /**
  58780. * Gets or sets the source range
  58781. */
  58782. sourceRange: Vector2;
  58783. /**
  58784. * Gets or sets the target range
  58785. */
  58786. targetRange: Vector2;
  58787. /**
  58788. * Creates a new RemapBlock
  58789. * @param name defines the block name
  58790. */
  58791. constructor(name: string);
  58792. /**
  58793. * Gets the current class name
  58794. * @returns the class name
  58795. */
  58796. getClassName(): string;
  58797. /**
  58798. * Gets the input component
  58799. */
  58800. get input(): NodeMaterialConnectionPoint;
  58801. /**
  58802. * Gets the source min input component
  58803. */
  58804. get sourceMin(): NodeMaterialConnectionPoint;
  58805. /**
  58806. * Gets the source max input component
  58807. */
  58808. get sourceMax(): NodeMaterialConnectionPoint;
  58809. /**
  58810. * Gets the target min input component
  58811. */
  58812. get targetMin(): NodeMaterialConnectionPoint;
  58813. /**
  58814. * Gets the target max input component
  58815. */
  58816. get targetMax(): NodeMaterialConnectionPoint;
  58817. /**
  58818. * Gets the output component
  58819. */
  58820. get output(): NodeMaterialConnectionPoint;
  58821. protected _buildBlock(state: NodeMaterialBuildState): this;
  58822. protected _dumpPropertiesCode(): string;
  58823. serialize(): any;
  58824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58825. }
  58826. }
  58827. declare module BABYLON {
  58828. /**
  58829. * Block used to normalize a vector
  58830. */
  58831. export class NormalizeBlock extends NodeMaterialBlock {
  58832. /**
  58833. * Creates a new NormalizeBlock
  58834. * @param name defines the block name
  58835. */
  58836. constructor(name: string);
  58837. /**
  58838. * Gets the current class name
  58839. * @returns the class name
  58840. */
  58841. getClassName(): string;
  58842. /**
  58843. * Gets the input component
  58844. */
  58845. get input(): NodeMaterialConnectionPoint;
  58846. /**
  58847. * Gets the output component
  58848. */
  58849. get output(): NodeMaterialConnectionPoint;
  58850. protected _buildBlock(state: NodeMaterialBuildState): this;
  58851. }
  58852. }
  58853. declare module BABYLON {
  58854. /**
  58855. * Operations supported by the Trigonometry block
  58856. */
  58857. export enum TrigonometryBlockOperations {
  58858. /** Cos */
  58859. Cos = 0,
  58860. /** Sin */
  58861. Sin = 1,
  58862. /** Abs */
  58863. Abs = 2,
  58864. /** Exp */
  58865. Exp = 3,
  58866. /** Exp2 */
  58867. Exp2 = 4,
  58868. /** Round */
  58869. Round = 5,
  58870. /** Floor */
  58871. Floor = 6,
  58872. /** Ceiling */
  58873. Ceiling = 7,
  58874. /** Square root */
  58875. Sqrt = 8,
  58876. /** Log */
  58877. Log = 9,
  58878. /** Tangent */
  58879. Tan = 10,
  58880. /** Arc tangent */
  58881. ArcTan = 11,
  58882. /** Arc cosinus */
  58883. ArcCos = 12,
  58884. /** Arc sinus */
  58885. ArcSin = 13,
  58886. /** Fraction */
  58887. Fract = 14,
  58888. /** Sign */
  58889. Sign = 15,
  58890. /** To radians (from degrees) */
  58891. Radians = 16,
  58892. /** To degrees (from radians) */
  58893. Degrees = 17
  58894. }
  58895. /**
  58896. * Block used to apply trigonometry operation to floats
  58897. */
  58898. export class TrigonometryBlock extends NodeMaterialBlock {
  58899. /**
  58900. * Gets or sets the operation applied by the block
  58901. */
  58902. operation: TrigonometryBlockOperations;
  58903. /**
  58904. * Creates a new TrigonometryBlock
  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 input component
  58915. */
  58916. get input(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the output component
  58919. */
  58920. get output(): NodeMaterialConnectionPoint;
  58921. protected _buildBlock(state: NodeMaterialBuildState): this;
  58922. serialize(): any;
  58923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58924. protected _dumpPropertiesCode(): string;
  58925. }
  58926. }
  58927. declare module BABYLON {
  58928. /**
  58929. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58930. */
  58931. export class ColorMergerBlock extends NodeMaterialBlock {
  58932. /**
  58933. * Create a new ColorMergerBlock
  58934. * @param name defines the block name
  58935. */
  58936. constructor(name: string);
  58937. /**
  58938. * Gets the current class name
  58939. * @returns the class name
  58940. */
  58941. getClassName(): string;
  58942. /**
  58943. * Gets the rgb component (input)
  58944. */
  58945. get rgbIn(): NodeMaterialConnectionPoint;
  58946. /**
  58947. * Gets the r component (input)
  58948. */
  58949. get r(): NodeMaterialConnectionPoint;
  58950. /**
  58951. * Gets the g component (input)
  58952. */
  58953. get g(): NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the b component (input)
  58956. */
  58957. get b(): NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the a component (input)
  58960. */
  58961. get a(): NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the rgba component (output)
  58964. */
  58965. get rgba(): NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the rgb component (output)
  58968. */
  58969. get rgbOut(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the rgb component (output)
  58972. * @deprecated Please use rgbOut instead.
  58973. */
  58974. get rgb(): NodeMaterialConnectionPoint;
  58975. protected _buildBlock(state: NodeMaterialBuildState): this;
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /**
  58980. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58981. */
  58982. export class VectorMergerBlock extends NodeMaterialBlock {
  58983. /**
  58984. * Create a new VectorMergerBlock
  58985. * @param name defines the block name
  58986. */
  58987. constructor(name: string);
  58988. /**
  58989. * Gets the current class name
  58990. * @returns the class name
  58991. */
  58992. getClassName(): string;
  58993. /**
  58994. * Gets the xyz component (input)
  58995. */
  58996. get xyzIn(): NodeMaterialConnectionPoint;
  58997. /**
  58998. * Gets the xy component (input)
  58999. */
  59000. get xyIn(): NodeMaterialConnectionPoint;
  59001. /**
  59002. * Gets the x component (input)
  59003. */
  59004. get x(): NodeMaterialConnectionPoint;
  59005. /**
  59006. * Gets the y component (input)
  59007. */
  59008. get y(): NodeMaterialConnectionPoint;
  59009. /**
  59010. * Gets the z component (input)
  59011. */
  59012. get z(): NodeMaterialConnectionPoint;
  59013. /**
  59014. * Gets the w component (input)
  59015. */
  59016. get w(): NodeMaterialConnectionPoint;
  59017. /**
  59018. * Gets the xyzw component (output)
  59019. */
  59020. get xyzw(): NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the xyz component (output)
  59023. */
  59024. get xyzOut(): NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the xy component (output)
  59027. */
  59028. get xyOut(): NodeMaterialConnectionPoint;
  59029. /**
  59030. * Gets the xy component (output)
  59031. * @deprecated Please use xyOut instead.
  59032. */
  59033. get xy(): NodeMaterialConnectionPoint;
  59034. /**
  59035. * Gets the xyz component (output)
  59036. * @deprecated Please use xyzOut instead.
  59037. */
  59038. get xyz(): NodeMaterialConnectionPoint;
  59039. protected _buildBlock(state: NodeMaterialBuildState): this;
  59040. }
  59041. }
  59042. declare module BABYLON {
  59043. /**
  59044. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59045. */
  59046. export class ColorSplitterBlock extends NodeMaterialBlock {
  59047. /**
  59048. * Create a new ColorSplitterBlock
  59049. * @param name defines the block name
  59050. */
  59051. constructor(name: string);
  59052. /**
  59053. * Gets the current class name
  59054. * @returns the class name
  59055. */
  59056. getClassName(): string;
  59057. /**
  59058. * Gets the rgba component (input)
  59059. */
  59060. get rgba(): NodeMaterialConnectionPoint;
  59061. /**
  59062. * Gets the rgb component (input)
  59063. */
  59064. get rgbIn(): NodeMaterialConnectionPoint;
  59065. /**
  59066. * Gets the rgb component (output)
  59067. */
  59068. get rgbOut(): NodeMaterialConnectionPoint;
  59069. /**
  59070. * Gets the r component (output)
  59071. */
  59072. get r(): NodeMaterialConnectionPoint;
  59073. /**
  59074. * Gets the g component (output)
  59075. */
  59076. get g(): NodeMaterialConnectionPoint;
  59077. /**
  59078. * Gets the b component (output)
  59079. */
  59080. get b(): NodeMaterialConnectionPoint;
  59081. /**
  59082. * Gets the a component (output)
  59083. */
  59084. get a(): NodeMaterialConnectionPoint;
  59085. protected _inputRename(name: string): string;
  59086. protected _outputRename(name: string): string;
  59087. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59088. }
  59089. }
  59090. declare module BABYLON {
  59091. /**
  59092. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59093. */
  59094. export class VectorSplitterBlock extends NodeMaterialBlock {
  59095. /**
  59096. * Create a new VectorSplitterBlock
  59097. * @param name defines the block name
  59098. */
  59099. constructor(name: string);
  59100. /**
  59101. * Gets the current class name
  59102. * @returns the class name
  59103. */
  59104. getClassName(): string;
  59105. /**
  59106. * Gets the xyzw component (input)
  59107. */
  59108. get xyzw(): NodeMaterialConnectionPoint;
  59109. /**
  59110. * Gets the xyz component (input)
  59111. */
  59112. get xyzIn(): NodeMaterialConnectionPoint;
  59113. /**
  59114. * Gets the xy component (input)
  59115. */
  59116. get xyIn(): NodeMaterialConnectionPoint;
  59117. /**
  59118. * Gets the xyz component (output)
  59119. */
  59120. get xyzOut(): NodeMaterialConnectionPoint;
  59121. /**
  59122. * Gets the xy component (output)
  59123. */
  59124. get xyOut(): NodeMaterialConnectionPoint;
  59125. /**
  59126. * Gets the x component (output)
  59127. */
  59128. get x(): NodeMaterialConnectionPoint;
  59129. /**
  59130. * Gets the y component (output)
  59131. */
  59132. get y(): NodeMaterialConnectionPoint;
  59133. /**
  59134. * Gets the z component (output)
  59135. */
  59136. get z(): NodeMaterialConnectionPoint;
  59137. /**
  59138. * Gets the w component (output)
  59139. */
  59140. get w(): NodeMaterialConnectionPoint;
  59141. protected _inputRename(name: string): string;
  59142. protected _outputRename(name: string): string;
  59143. protected _buildBlock(state: NodeMaterialBuildState): this;
  59144. }
  59145. }
  59146. declare module BABYLON {
  59147. /**
  59148. * Block used to lerp between 2 values
  59149. */
  59150. export class LerpBlock extends NodeMaterialBlock {
  59151. /**
  59152. * Creates a new LerpBlock
  59153. * @param name defines the block name
  59154. */
  59155. constructor(name: string);
  59156. /**
  59157. * Gets the current class name
  59158. * @returns the class name
  59159. */
  59160. getClassName(): string;
  59161. /**
  59162. * Gets the left operand input component
  59163. */
  59164. get left(): NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the right operand input component
  59167. */
  59168. get right(): NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the gradient operand input component
  59171. */
  59172. get gradient(): NodeMaterialConnectionPoint;
  59173. /**
  59174. * Gets the output component
  59175. */
  59176. get output(): NodeMaterialConnectionPoint;
  59177. protected _buildBlock(state: NodeMaterialBuildState): this;
  59178. }
  59179. }
  59180. declare module BABYLON {
  59181. /**
  59182. * Block used to divide 2 vectors
  59183. */
  59184. export class DivideBlock extends NodeMaterialBlock {
  59185. /**
  59186. * Creates a new DivideBlock
  59187. * @param name defines the block name
  59188. */
  59189. constructor(name: string);
  59190. /**
  59191. * Gets the current class name
  59192. * @returns the class name
  59193. */
  59194. getClassName(): string;
  59195. /**
  59196. * Gets the left operand input component
  59197. */
  59198. get left(): NodeMaterialConnectionPoint;
  59199. /**
  59200. * Gets the right operand input component
  59201. */
  59202. get right(): NodeMaterialConnectionPoint;
  59203. /**
  59204. * Gets the output component
  59205. */
  59206. get output(): NodeMaterialConnectionPoint;
  59207. protected _buildBlock(state: NodeMaterialBuildState): this;
  59208. }
  59209. }
  59210. declare module BABYLON {
  59211. /**
  59212. * Block used to subtract 2 vectors
  59213. */
  59214. export class SubtractBlock extends NodeMaterialBlock {
  59215. /**
  59216. * Creates a new SubtractBlock
  59217. * @param name defines the block name
  59218. */
  59219. constructor(name: string);
  59220. /**
  59221. * Gets the current class name
  59222. * @returns the class name
  59223. */
  59224. getClassName(): string;
  59225. /**
  59226. * Gets the left operand input component
  59227. */
  59228. get left(): NodeMaterialConnectionPoint;
  59229. /**
  59230. * Gets the right operand input component
  59231. */
  59232. get right(): NodeMaterialConnectionPoint;
  59233. /**
  59234. * Gets the output component
  59235. */
  59236. get output(): NodeMaterialConnectionPoint;
  59237. protected _buildBlock(state: NodeMaterialBuildState): this;
  59238. }
  59239. }
  59240. declare module BABYLON {
  59241. /**
  59242. * Block used to step a value
  59243. */
  59244. export class StepBlock extends NodeMaterialBlock {
  59245. /**
  59246. * Creates a new StepBlock
  59247. * @param name defines the block name
  59248. */
  59249. constructor(name: string);
  59250. /**
  59251. * Gets the current class name
  59252. * @returns the class name
  59253. */
  59254. getClassName(): string;
  59255. /**
  59256. * Gets the value operand input component
  59257. */
  59258. get value(): NodeMaterialConnectionPoint;
  59259. /**
  59260. * Gets the edge operand input component
  59261. */
  59262. get edge(): NodeMaterialConnectionPoint;
  59263. /**
  59264. * Gets the output component
  59265. */
  59266. get output(): NodeMaterialConnectionPoint;
  59267. protected _buildBlock(state: NodeMaterialBuildState): this;
  59268. }
  59269. }
  59270. declare module BABYLON {
  59271. /**
  59272. * Block used to get the opposite (1 - x) of a value
  59273. */
  59274. export class OneMinusBlock extends NodeMaterialBlock {
  59275. /**
  59276. * Creates a new OneMinusBlock
  59277. * @param name defines the block name
  59278. */
  59279. constructor(name: string);
  59280. /**
  59281. * Gets the current class name
  59282. * @returns the class name
  59283. */
  59284. getClassName(): string;
  59285. /**
  59286. * Gets the input component
  59287. */
  59288. get input(): NodeMaterialConnectionPoint;
  59289. /**
  59290. * Gets the output component
  59291. */
  59292. get output(): NodeMaterialConnectionPoint;
  59293. protected _buildBlock(state: NodeMaterialBuildState): this;
  59294. }
  59295. }
  59296. declare module BABYLON {
  59297. /**
  59298. * Block used to get the view direction
  59299. */
  59300. export class ViewDirectionBlock extends NodeMaterialBlock {
  59301. /**
  59302. * Creates a new ViewDirectionBlock
  59303. * @param name defines the block name
  59304. */
  59305. constructor(name: string);
  59306. /**
  59307. * Gets the current class name
  59308. * @returns the class name
  59309. */
  59310. getClassName(): string;
  59311. /**
  59312. * Gets the world position component
  59313. */
  59314. get worldPosition(): NodeMaterialConnectionPoint;
  59315. /**
  59316. * Gets the camera position component
  59317. */
  59318. get cameraPosition(): NodeMaterialConnectionPoint;
  59319. /**
  59320. * Gets the output component
  59321. */
  59322. get output(): NodeMaterialConnectionPoint;
  59323. autoConfigure(material: NodeMaterial): void;
  59324. protected _buildBlock(state: NodeMaterialBuildState): this;
  59325. }
  59326. }
  59327. declare module BABYLON {
  59328. /**
  59329. * Block used to compute fresnel value
  59330. */
  59331. export class FresnelBlock extends NodeMaterialBlock {
  59332. /**
  59333. * Create a new FresnelBlock
  59334. * @param name defines the block name
  59335. */
  59336. constructor(name: string);
  59337. /**
  59338. * Gets the current class name
  59339. * @returns the class name
  59340. */
  59341. getClassName(): string;
  59342. /**
  59343. * Gets the world normal input component
  59344. */
  59345. get worldNormal(): NodeMaterialConnectionPoint;
  59346. /**
  59347. * Gets the view direction input component
  59348. */
  59349. get viewDirection(): NodeMaterialConnectionPoint;
  59350. /**
  59351. * Gets the bias input component
  59352. */
  59353. get bias(): NodeMaterialConnectionPoint;
  59354. /**
  59355. * Gets the camera (or eye) position component
  59356. */
  59357. get power(): NodeMaterialConnectionPoint;
  59358. /**
  59359. * Gets the fresnel output component
  59360. */
  59361. get fresnel(): NodeMaterialConnectionPoint;
  59362. autoConfigure(material: NodeMaterial): void;
  59363. protected _buildBlock(state: NodeMaterialBuildState): this;
  59364. }
  59365. }
  59366. declare module BABYLON {
  59367. /**
  59368. * Block used to get the max of 2 values
  59369. */
  59370. export class MaxBlock extends NodeMaterialBlock {
  59371. /**
  59372. * Creates a new MaxBlock
  59373. * @param name defines the block name
  59374. */
  59375. constructor(name: string);
  59376. /**
  59377. * Gets the current class name
  59378. * @returns the class name
  59379. */
  59380. getClassName(): string;
  59381. /**
  59382. * Gets the left operand input component
  59383. */
  59384. get left(): NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the right operand input component
  59387. */
  59388. get right(): NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the output component
  59391. */
  59392. get output(): NodeMaterialConnectionPoint;
  59393. protected _buildBlock(state: NodeMaterialBuildState): this;
  59394. }
  59395. }
  59396. declare module BABYLON {
  59397. /**
  59398. * Block used to get the min of 2 values
  59399. */
  59400. export class MinBlock extends NodeMaterialBlock {
  59401. /**
  59402. * Creates a new MinBlock
  59403. * @param name defines the block name
  59404. */
  59405. constructor(name: string);
  59406. /**
  59407. * Gets the current class name
  59408. * @returns the class name
  59409. */
  59410. getClassName(): string;
  59411. /**
  59412. * Gets the left operand input component
  59413. */
  59414. get left(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the right operand input component
  59417. */
  59418. get right(): NodeMaterialConnectionPoint;
  59419. /**
  59420. * Gets the output component
  59421. */
  59422. get output(): NodeMaterialConnectionPoint;
  59423. protected _buildBlock(state: NodeMaterialBuildState): this;
  59424. }
  59425. }
  59426. declare module BABYLON {
  59427. /**
  59428. * Block used to get the distance between 2 values
  59429. */
  59430. export class DistanceBlock extends NodeMaterialBlock {
  59431. /**
  59432. * Creates a new DistanceBlock
  59433. * @param name defines the block name
  59434. */
  59435. constructor(name: string);
  59436. /**
  59437. * Gets the current class name
  59438. * @returns the class name
  59439. */
  59440. getClassName(): string;
  59441. /**
  59442. * Gets the left operand input component
  59443. */
  59444. get left(): NodeMaterialConnectionPoint;
  59445. /**
  59446. * Gets the right operand input component
  59447. */
  59448. get right(): NodeMaterialConnectionPoint;
  59449. /**
  59450. * Gets the output component
  59451. */
  59452. get output(): NodeMaterialConnectionPoint;
  59453. protected _buildBlock(state: NodeMaterialBuildState): this;
  59454. }
  59455. }
  59456. declare module BABYLON {
  59457. /**
  59458. * Block used to get the length of a vector
  59459. */
  59460. export class LengthBlock extends NodeMaterialBlock {
  59461. /**
  59462. * Creates a new LengthBlock
  59463. * @param name defines the block name
  59464. */
  59465. constructor(name: string);
  59466. /**
  59467. * Gets the current class name
  59468. * @returns the class name
  59469. */
  59470. getClassName(): string;
  59471. /**
  59472. * Gets the value input component
  59473. */
  59474. get value(): NodeMaterialConnectionPoint;
  59475. /**
  59476. * Gets the output component
  59477. */
  59478. get output(): NodeMaterialConnectionPoint;
  59479. protected _buildBlock(state: NodeMaterialBuildState): this;
  59480. }
  59481. }
  59482. declare module BABYLON {
  59483. /**
  59484. * Block used to get negative version of a value (i.e. x * -1)
  59485. */
  59486. export class NegateBlock extends NodeMaterialBlock {
  59487. /**
  59488. * Creates a new NegateBlock
  59489. * @param name defines the block name
  59490. */
  59491. constructor(name: string);
  59492. /**
  59493. * Gets the current class name
  59494. * @returns the class name
  59495. */
  59496. getClassName(): string;
  59497. /**
  59498. * Gets the value input component
  59499. */
  59500. get value(): NodeMaterialConnectionPoint;
  59501. /**
  59502. * Gets the output component
  59503. */
  59504. get output(): NodeMaterialConnectionPoint;
  59505. protected _buildBlock(state: NodeMaterialBuildState): this;
  59506. }
  59507. }
  59508. declare module BABYLON {
  59509. /**
  59510. * Block used to get the value of the first parameter raised to the power of the second
  59511. */
  59512. export class PowBlock extends NodeMaterialBlock {
  59513. /**
  59514. * Creates a new PowBlock
  59515. * @param name defines the block name
  59516. */
  59517. constructor(name: string);
  59518. /**
  59519. * Gets the current class name
  59520. * @returns the class name
  59521. */
  59522. getClassName(): string;
  59523. /**
  59524. * Gets the value operand input component
  59525. */
  59526. get value(): NodeMaterialConnectionPoint;
  59527. /**
  59528. * Gets the power operand input component
  59529. */
  59530. get power(): NodeMaterialConnectionPoint;
  59531. /**
  59532. * Gets the output component
  59533. */
  59534. get output(): NodeMaterialConnectionPoint;
  59535. protected _buildBlock(state: NodeMaterialBuildState): this;
  59536. }
  59537. }
  59538. declare module BABYLON {
  59539. /**
  59540. * Block used to get a random number
  59541. */
  59542. export class RandomNumberBlock extends NodeMaterialBlock {
  59543. /**
  59544. * Creates a new RandomNumberBlock
  59545. * @param name defines the block name
  59546. */
  59547. constructor(name: string);
  59548. /**
  59549. * Gets the current class name
  59550. * @returns the class name
  59551. */
  59552. getClassName(): string;
  59553. /**
  59554. * Gets the seed input component
  59555. */
  59556. get seed(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the output component
  59559. */
  59560. get output(): NodeMaterialConnectionPoint;
  59561. protected _buildBlock(state: NodeMaterialBuildState): this;
  59562. }
  59563. }
  59564. declare module BABYLON {
  59565. /**
  59566. * Block used to compute arc tangent of 2 values
  59567. */
  59568. export class ArcTan2Block extends NodeMaterialBlock {
  59569. /**
  59570. * Creates a new ArcTan2Block
  59571. * @param name defines the block name
  59572. */
  59573. constructor(name: string);
  59574. /**
  59575. * Gets the current class name
  59576. * @returns the class name
  59577. */
  59578. getClassName(): string;
  59579. /**
  59580. * Gets the x operand input component
  59581. */
  59582. get x(): NodeMaterialConnectionPoint;
  59583. /**
  59584. * Gets the y operand input component
  59585. */
  59586. get y(): NodeMaterialConnectionPoint;
  59587. /**
  59588. * Gets the output component
  59589. */
  59590. get output(): NodeMaterialConnectionPoint;
  59591. protected _buildBlock(state: NodeMaterialBuildState): this;
  59592. }
  59593. }
  59594. declare module BABYLON {
  59595. /**
  59596. * Block used to smooth step a value
  59597. */
  59598. export class SmoothStepBlock extends NodeMaterialBlock {
  59599. /**
  59600. * Creates a new SmoothStepBlock
  59601. * @param name defines the block name
  59602. */
  59603. constructor(name: string);
  59604. /**
  59605. * Gets the current class name
  59606. * @returns the class name
  59607. */
  59608. getClassName(): string;
  59609. /**
  59610. * Gets the value operand input component
  59611. */
  59612. get value(): NodeMaterialConnectionPoint;
  59613. /**
  59614. * Gets the first edge operand input component
  59615. */
  59616. get edge0(): NodeMaterialConnectionPoint;
  59617. /**
  59618. * Gets the second edge operand input component
  59619. */
  59620. get edge1(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the output component
  59623. */
  59624. get output(): NodeMaterialConnectionPoint;
  59625. protected _buildBlock(state: NodeMaterialBuildState): this;
  59626. }
  59627. }
  59628. declare module BABYLON {
  59629. /**
  59630. * Block used to get the reciprocal (1 / x) of a value
  59631. */
  59632. export class ReciprocalBlock extends NodeMaterialBlock {
  59633. /**
  59634. * Creates a new ReciprocalBlock
  59635. * @param name defines the block name
  59636. */
  59637. constructor(name: string);
  59638. /**
  59639. * Gets the current class name
  59640. * @returns the class name
  59641. */
  59642. getClassName(): string;
  59643. /**
  59644. * Gets the input component
  59645. */
  59646. get input(): NodeMaterialConnectionPoint;
  59647. /**
  59648. * Gets the output component
  59649. */
  59650. get output(): NodeMaterialConnectionPoint;
  59651. protected _buildBlock(state: NodeMaterialBuildState): this;
  59652. }
  59653. }
  59654. declare module BABYLON {
  59655. /**
  59656. * Block used to replace a color by another one
  59657. */
  59658. export class ReplaceColorBlock extends NodeMaterialBlock {
  59659. /**
  59660. * Creates a new ReplaceColorBlock
  59661. * @param name defines the block name
  59662. */
  59663. constructor(name: string);
  59664. /**
  59665. * Gets the current class name
  59666. * @returns the class name
  59667. */
  59668. getClassName(): string;
  59669. /**
  59670. * Gets the value input component
  59671. */
  59672. get value(): NodeMaterialConnectionPoint;
  59673. /**
  59674. * Gets the reference input component
  59675. */
  59676. get reference(): NodeMaterialConnectionPoint;
  59677. /**
  59678. * Gets the distance input component
  59679. */
  59680. get distance(): NodeMaterialConnectionPoint;
  59681. /**
  59682. * Gets the replacement input component
  59683. */
  59684. get replacement(): 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 posterize a value
  59695. * @see https://en.wikipedia.org/wiki/Posterization
  59696. */
  59697. export class PosterizeBlock extends NodeMaterialBlock {
  59698. /**
  59699. * Creates a new PosterizeBlock
  59700. * @param name defines the block name
  59701. */
  59702. constructor(name: string);
  59703. /**
  59704. * Gets the current class name
  59705. * @returns the class name
  59706. */
  59707. getClassName(): string;
  59708. /**
  59709. * Gets the value input component
  59710. */
  59711. get value(): NodeMaterialConnectionPoint;
  59712. /**
  59713. * Gets the steps input component
  59714. */
  59715. get steps(): NodeMaterialConnectionPoint;
  59716. /**
  59717. * Gets the output component
  59718. */
  59719. get output(): NodeMaterialConnectionPoint;
  59720. protected _buildBlock(state: NodeMaterialBuildState): this;
  59721. }
  59722. }
  59723. declare module BABYLON {
  59724. /**
  59725. * Operations supported by the Wave block
  59726. */
  59727. export enum WaveBlockKind {
  59728. /** SawTooth */
  59729. SawTooth = 0,
  59730. /** Square */
  59731. Square = 1,
  59732. /** Triangle */
  59733. Triangle = 2
  59734. }
  59735. /**
  59736. * Block used to apply wave operation to floats
  59737. */
  59738. export class WaveBlock extends NodeMaterialBlock {
  59739. /**
  59740. * Gets or sets the kibnd of wave to be applied by the block
  59741. */
  59742. kind: WaveBlockKind;
  59743. /**
  59744. * Creates a new WaveBlock
  59745. * @param name defines the block name
  59746. */
  59747. constructor(name: string);
  59748. /**
  59749. * Gets the current class name
  59750. * @returns the class name
  59751. */
  59752. getClassName(): string;
  59753. /**
  59754. * Gets the input component
  59755. */
  59756. get input(): NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the output component
  59759. */
  59760. get output(): NodeMaterialConnectionPoint;
  59761. protected _buildBlock(state: NodeMaterialBuildState): this;
  59762. serialize(): any;
  59763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59764. }
  59765. }
  59766. declare module BABYLON {
  59767. /**
  59768. * Class used to store a color step for the GradientBlock
  59769. */
  59770. export class GradientBlockColorStep {
  59771. /**
  59772. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59773. */
  59774. step: number;
  59775. /**
  59776. * Gets or sets the color associated with this step
  59777. */
  59778. color: Color3;
  59779. /**
  59780. * Creates a new GradientBlockColorStep
  59781. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59782. * @param color defines the color associated with this step
  59783. */
  59784. constructor(
  59785. /**
  59786. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59787. */
  59788. step: number,
  59789. /**
  59790. * Gets or sets the color associated with this step
  59791. */
  59792. color: Color3);
  59793. }
  59794. /**
  59795. * Block used to return a color from a gradient based on an input value between 0 and 1
  59796. */
  59797. export class GradientBlock extends NodeMaterialBlock {
  59798. /**
  59799. * Gets or sets the list of color steps
  59800. */
  59801. colorSteps: GradientBlockColorStep[];
  59802. /**
  59803. * Creates a new GradientBlock
  59804. * @param name defines the block name
  59805. */
  59806. constructor(name: string);
  59807. /**
  59808. * Gets the current class name
  59809. * @returns the class name
  59810. */
  59811. getClassName(): string;
  59812. /**
  59813. * Gets the gradient input component
  59814. */
  59815. get gradient(): NodeMaterialConnectionPoint;
  59816. /**
  59817. * Gets the output component
  59818. */
  59819. get output(): NodeMaterialConnectionPoint;
  59820. private _writeColorConstant;
  59821. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59822. serialize(): any;
  59823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59824. protected _dumpPropertiesCode(): string;
  59825. }
  59826. }
  59827. declare module BABYLON {
  59828. /**
  59829. * Block used to normalize lerp between 2 values
  59830. */
  59831. export class NLerpBlock extends NodeMaterialBlock {
  59832. /**
  59833. * Creates a new NLerpBlock
  59834. * @param name defines the block name
  59835. */
  59836. constructor(name: string);
  59837. /**
  59838. * Gets the current class name
  59839. * @returns the class name
  59840. */
  59841. getClassName(): string;
  59842. /**
  59843. * Gets the left operand input component
  59844. */
  59845. get left(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the right operand input component
  59848. */
  59849. get right(): NodeMaterialConnectionPoint;
  59850. /**
  59851. * Gets the gradient operand input component
  59852. */
  59853. get gradient(): NodeMaterialConnectionPoint;
  59854. /**
  59855. * Gets the output component
  59856. */
  59857. get output(): NodeMaterialConnectionPoint;
  59858. protected _buildBlock(state: NodeMaterialBuildState): this;
  59859. }
  59860. }
  59861. declare module BABYLON {
  59862. /**
  59863. * block used to Generate a Worley Noise 3D Noise Pattern
  59864. */
  59865. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59866. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59867. manhattanDistance: boolean;
  59868. /**
  59869. * Creates a new WorleyNoise3DBlock
  59870. * @param name defines the block name
  59871. */
  59872. constructor(name: string);
  59873. /**
  59874. * Gets the current class name
  59875. * @returns the class name
  59876. */
  59877. getClassName(): string;
  59878. /**
  59879. * Gets the seed input component
  59880. */
  59881. get seed(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the jitter input component
  59884. */
  59885. get jitter(): NodeMaterialConnectionPoint;
  59886. /**
  59887. * Gets the output component
  59888. */
  59889. get output(): NodeMaterialConnectionPoint;
  59890. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59891. /**
  59892. * Exposes the properties to the UI?
  59893. */
  59894. protected _dumpPropertiesCode(): string;
  59895. /**
  59896. * Exposes the properties to the Seralize?
  59897. */
  59898. serialize(): any;
  59899. /**
  59900. * Exposes the properties to the deseralize?
  59901. */
  59902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59903. }
  59904. }
  59905. declare module BABYLON {
  59906. /**
  59907. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59908. */
  59909. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59910. /**
  59911. * Creates a new SimplexPerlin3DBlock
  59912. * @param name defines the block name
  59913. */
  59914. constructor(name: string);
  59915. /**
  59916. * Gets the current class name
  59917. * @returns the class name
  59918. */
  59919. getClassName(): string;
  59920. /**
  59921. * Gets the seed operand input component
  59922. */
  59923. get seed(): NodeMaterialConnectionPoint;
  59924. /**
  59925. * Gets the output component
  59926. */
  59927. get output(): NodeMaterialConnectionPoint;
  59928. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59929. }
  59930. }
  59931. declare module BABYLON {
  59932. /**
  59933. * Block used to blend normals
  59934. */
  59935. export class NormalBlendBlock extends NodeMaterialBlock {
  59936. /**
  59937. * Creates a new NormalBlendBlock
  59938. * @param name defines the block name
  59939. */
  59940. constructor(name: string);
  59941. /**
  59942. * Gets the current class name
  59943. * @returns the class name
  59944. */
  59945. getClassName(): string;
  59946. /**
  59947. * Gets the first input component
  59948. */
  59949. get normalMap0(): NodeMaterialConnectionPoint;
  59950. /**
  59951. * Gets the second input component
  59952. */
  59953. get normalMap1(): NodeMaterialConnectionPoint;
  59954. /**
  59955. * Gets the output component
  59956. */
  59957. get output(): NodeMaterialConnectionPoint;
  59958. protected _buildBlock(state: NodeMaterialBuildState): this;
  59959. }
  59960. }
  59961. declare module BABYLON {
  59962. /**
  59963. * Block used to rotate a 2d vector by a given angle
  59964. */
  59965. export class Rotate2dBlock extends NodeMaterialBlock {
  59966. /**
  59967. * Creates a new Rotate2dBlock
  59968. * @param name defines the block name
  59969. */
  59970. constructor(name: string);
  59971. /**
  59972. * Gets the current class name
  59973. * @returns the class name
  59974. */
  59975. getClassName(): string;
  59976. /**
  59977. * Gets the input vector
  59978. */
  59979. get input(): NodeMaterialConnectionPoint;
  59980. /**
  59981. * Gets the input angle
  59982. */
  59983. get angle(): NodeMaterialConnectionPoint;
  59984. /**
  59985. * Gets the output component
  59986. */
  59987. get output(): NodeMaterialConnectionPoint;
  59988. autoConfigure(material: NodeMaterial): void;
  59989. protected _buildBlock(state: NodeMaterialBuildState): this;
  59990. }
  59991. }
  59992. declare module BABYLON {
  59993. /**
  59994. * Block used to get the reflected vector from a direction and a normal
  59995. */
  59996. export class ReflectBlock extends NodeMaterialBlock {
  59997. /**
  59998. * Creates a new ReflectBlock
  59999. * @param name defines the block name
  60000. */
  60001. constructor(name: string);
  60002. /**
  60003. * Gets the current class name
  60004. * @returns the class name
  60005. */
  60006. getClassName(): string;
  60007. /**
  60008. * Gets the incident component
  60009. */
  60010. get incident(): NodeMaterialConnectionPoint;
  60011. /**
  60012. * Gets the normal component
  60013. */
  60014. get normal(): NodeMaterialConnectionPoint;
  60015. /**
  60016. * Gets the output component
  60017. */
  60018. get output(): NodeMaterialConnectionPoint;
  60019. protected _buildBlock(state: NodeMaterialBuildState): this;
  60020. }
  60021. }
  60022. declare module BABYLON {
  60023. /**
  60024. * Block used to get the refracted vector from a direction and a normal
  60025. */
  60026. export class RefractBlock extends NodeMaterialBlock {
  60027. /**
  60028. * Creates a new RefractBlock
  60029. * @param name defines the block name
  60030. */
  60031. constructor(name: string);
  60032. /**
  60033. * Gets the current class name
  60034. * @returns the class name
  60035. */
  60036. getClassName(): string;
  60037. /**
  60038. * Gets the incident component
  60039. */
  60040. get incident(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the normal component
  60043. */
  60044. get normal(): NodeMaterialConnectionPoint;
  60045. /**
  60046. * Gets the index of refraction component
  60047. */
  60048. get ior(): NodeMaterialConnectionPoint;
  60049. /**
  60050. * Gets the output component
  60051. */
  60052. get output(): NodeMaterialConnectionPoint;
  60053. protected _buildBlock(state: NodeMaterialBuildState): this;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /**
  60058. * Block used to desaturate a color
  60059. */
  60060. export class DesaturateBlock extends NodeMaterialBlock {
  60061. /**
  60062. * Creates a new DesaturateBlock
  60063. * @param name defines the block name
  60064. */
  60065. constructor(name: string);
  60066. /**
  60067. * Gets the current class name
  60068. * @returns the class name
  60069. */
  60070. getClassName(): string;
  60071. /**
  60072. * Gets the color operand input component
  60073. */
  60074. get color(): NodeMaterialConnectionPoint;
  60075. /**
  60076. * Gets the level operand input component
  60077. */
  60078. get level(): NodeMaterialConnectionPoint;
  60079. /**
  60080. * Gets the output component
  60081. */
  60082. get output(): NodeMaterialConnectionPoint;
  60083. protected _buildBlock(state: NodeMaterialBuildState): this;
  60084. }
  60085. }
  60086. declare module BABYLON {
  60087. /**
  60088. * Effect Render Options
  60089. */
  60090. export interface IEffectRendererOptions {
  60091. /**
  60092. * Defines the vertices positions.
  60093. */
  60094. positions?: number[];
  60095. /**
  60096. * Defines the indices.
  60097. */
  60098. indices?: number[];
  60099. }
  60100. /**
  60101. * Helper class to render one or more effects
  60102. */
  60103. export class EffectRenderer {
  60104. private engine;
  60105. private static _DefaultOptions;
  60106. private _vertexBuffers;
  60107. private _indexBuffer;
  60108. private _ringBufferIndex;
  60109. private _ringScreenBuffer;
  60110. private _fullscreenViewport;
  60111. private _getNextFrameBuffer;
  60112. /**
  60113. * Creates an effect renderer
  60114. * @param engine the engine to use for rendering
  60115. * @param options defines the options of the effect renderer
  60116. */
  60117. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60118. /**
  60119. * Sets the current viewport in normalized coordinates 0-1
  60120. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60121. */
  60122. setViewport(viewport?: Viewport): void;
  60123. /**
  60124. * Binds the embedded attributes buffer to the effect.
  60125. * @param effect Defines the effect to bind the attributes for
  60126. */
  60127. bindBuffers(effect: Effect): void;
  60128. /**
  60129. * Sets the current effect wrapper to use during draw.
  60130. * The effect needs to be ready before calling this api.
  60131. * This also sets the default full screen position attribute.
  60132. * @param effectWrapper Defines the effect to draw with
  60133. */
  60134. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60135. /**
  60136. * Draws a full screen quad.
  60137. */
  60138. draw(): void;
  60139. /**
  60140. * renders one or more effects to a specified texture
  60141. * @param effectWrappers list of effects to renderer
  60142. * @param outputTexture texture to draw to, if null it will render to the screen
  60143. */
  60144. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60145. /**
  60146. * Disposes of the effect renderer
  60147. */
  60148. dispose(): void;
  60149. }
  60150. /**
  60151. * Options to create an EffectWrapper
  60152. */
  60153. interface EffectWrapperCreationOptions {
  60154. /**
  60155. * Engine to use to create the effect
  60156. */
  60157. engine: ThinEngine;
  60158. /**
  60159. * Fragment shader for the effect
  60160. */
  60161. fragmentShader: string;
  60162. /**
  60163. * Vertex shader for the effect
  60164. */
  60165. vertexShader?: string;
  60166. /**
  60167. * Attributes to use in the shader
  60168. */
  60169. attributeNames?: Array<string>;
  60170. /**
  60171. * Uniforms to use in the shader
  60172. */
  60173. uniformNames?: Array<string>;
  60174. /**
  60175. * Texture sampler names to use in the shader
  60176. */
  60177. samplerNames?: Array<string>;
  60178. /**
  60179. * The friendly name of the effect displayed in Spector.
  60180. */
  60181. name?: string;
  60182. }
  60183. /**
  60184. * Wraps an effect to be used for rendering
  60185. */
  60186. export class EffectWrapper {
  60187. /**
  60188. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60189. */
  60190. onApplyObservable: Observable<{}>;
  60191. /**
  60192. * The underlying effect
  60193. */
  60194. effect: Effect;
  60195. /**
  60196. * Creates an effect to be renderer
  60197. * @param creationOptions options to create the effect
  60198. */
  60199. constructor(creationOptions: EffectWrapperCreationOptions);
  60200. /**
  60201. * Disposes of the effect wrapper
  60202. */
  60203. dispose(): void;
  60204. }
  60205. }
  60206. declare module BABYLON {
  60207. /**
  60208. * Helper class to push actions to a pool of workers.
  60209. */
  60210. export class WorkerPool implements IDisposable {
  60211. private _workerInfos;
  60212. private _pendingActions;
  60213. /**
  60214. * Constructor
  60215. * @param workers Array of workers to use for actions
  60216. */
  60217. constructor(workers: Array<Worker>);
  60218. /**
  60219. * Terminates all workers and clears any pending actions.
  60220. */
  60221. dispose(): void;
  60222. /**
  60223. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60224. * pended until a worker has completed its action.
  60225. * @param action The action to perform. Call onComplete when the action is complete.
  60226. */
  60227. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60228. private _execute;
  60229. }
  60230. }
  60231. declare module BABYLON {
  60232. /**
  60233. * Configuration for Draco compression
  60234. */
  60235. export interface IDracoCompressionConfiguration {
  60236. /**
  60237. * Configuration for the decoder.
  60238. */
  60239. decoder: {
  60240. /**
  60241. * The url to the WebAssembly module.
  60242. */
  60243. wasmUrl?: string;
  60244. /**
  60245. * The url to the WebAssembly binary.
  60246. */
  60247. wasmBinaryUrl?: string;
  60248. /**
  60249. * The url to the fallback JavaScript module.
  60250. */
  60251. fallbackUrl?: string;
  60252. };
  60253. }
  60254. /**
  60255. * Draco compression (https://google.github.io/draco/)
  60256. *
  60257. * This class wraps the Draco module.
  60258. *
  60259. * **Encoder**
  60260. *
  60261. * The encoder is not currently implemented.
  60262. *
  60263. * **Decoder**
  60264. *
  60265. * 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.
  60266. *
  60267. * To update the configuration, use the following code:
  60268. * ```javascript
  60269. * DracoCompression.Configuration = {
  60270. * decoder: {
  60271. * wasmUrl: "<url to the WebAssembly library>",
  60272. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60273. * fallbackUrl: "<url to the fallback JavaScript library>",
  60274. * }
  60275. * };
  60276. * ```
  60277. *
  60278. * 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.
  60279. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60280. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60281. *
  60282. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60283. * ```javascript
  60284. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60285. * ```
  60286. *
  60287. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60288. */
  60289. export class DracoCompression implements IDisposable {
  60290. private _workerPoolPromise?;
  60291. private _decoderModulePromise?;
  60292. /**
  60293. * The configuration. Defaults to the following urls:
  60294. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60295. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60296. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60297. */
  60298. static Configuration: IDracoCompressionConfiguration;
  60299. /**
  60300. * Returns true if the decoder configuration is available.
  60301. */
  60302. static get DecoderAvailable(): boolean;
  60303. /**
  60304. * Default number of workers to create when creating the draco compression object.
  60305. */
  60306. static DefaultNumWorkers: number;
  60307. private static GetDefaultNumWorkers;
  60308. private static _Default;
  60309. /**
  60310. * Default instance for the draco compression object.
  60311. */
  60312. static get Default(): DracoCompression;
  60313. /**
  60314. * Constructor
  60315. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60316. */
  60317. constructor(numWorkers?: number);
  60318. /**
  60319. * Stop all async operations and release resources.
  60320. */
  60321. dispose(): void;
  60322. /**
  60323. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60324. * @returns a promise that resolves when ready
  60325. */
  60326. whenReadyAsync(): Promise<void>;
  60327. /**
  60328. * Decode Draco compressed mesh data to vertex data.
  60329. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60330. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60331. * @returns A promise that resolves with the decoded vertex data
  60332. */
  60333. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60334. [kind: string]: number;
  60335. }): Promise<VertexData>;
  60336. }
  60337. }
  60338. declare module BABYLON {
  60339. /**
  60340. * Class for building Constructive Solid Geometry
  60341. */
  60342. export class CSG {
  60343. private polygons;
  60344. /**
  60345. * The world matrix
  60346. */
  60347. matrix: Matrix;
  60348. /**
  60349. * Stores the position
  60350. */
  60351. position: Vector3;
  60352. /**
  60353. * Stores the rotation
  60354. */
  60355. rotation: Vector3;
  60356. /**
  60357. * Stores the rotation quaternion
  60358. */
  60359. rotationQuaternion: Nullable<Quaternion>;
  60360. /**
  60361. * Stores the scaling vector
  60362. */
  60363. scaling: Vector3;
  60364. /**
  60365. * Convert the Mesh to CSG
  60366. * @param mesh The Mesh to convert to CSG
  60367. * @returns A new CSG from the Mesh
  60368. */
  60369. static FromMesh(mesh: Mesh): CSG;
  60370. /**
  60371. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60372. * @param polygons Polygons used to construct a CSG solid
  60373. */
  60374. private static FromPolygons;
  60375. /**
  60376. * Clones, or makes a deep copy, of the CSG
  60377. * @returns A new CSG
  60378. */
  60379. clone(): CSG;
  60380. /**
  60381. * Unions this CSG with another CSG
  60382. * @param csg The CSG to union against this CSG
  60383. * @returns The unioned CSG
  60384. */
  60385. union(csg: CSG): CSG;
  60386. /**
  60387. * Unions this CSG with another CSG in place
  60388. * @param csg The CSG to union against this CSG
  60389. */
  60390. unionInPlace(csg: CSG): void;
  60391. /**
  60392. * Subtracts this CSG with another CSG
  60393. * @param csg The CSG to subtract against this CSG
  60394. * @returns A new CSG
  60395. */
  60396. subtract(csg: CSG): CSG;
  60397. /**
  60398. * Subtracts this CSG with another CSG in place
  60399. * @param csg The CSG to subtact against this CSG
  60400. */
  60401. subtractInPlace(csg: CSG): void;
  60402. /**
  60403. * Intersect this CSG with another CSG
  60404. * @param csg The CSG to intersect against this CSG
  60405. * @returns A new CSG
  60406. */
  60407. intersect(csg: CSG): CSG;
  60408. /**
  60409. * Intersects this CSG with another CSG in place
  60410. * @param csg The CSG to intersect against this CSG
  60411. */
  60412. intersectInPlace(csg: CSG): void;
  60413. /**
  60414. * Return a new CSG solid with solid and empty space switched. This solid is
  60415. * not modified.
  60416. * @returns A new CSG solid with solid and empty space switched
  60417. */
  60418. inverse(): CSG;
  60419. /**
  60420. * Inverses the CSG in place
  60421. */
  60422. inverseInPlace(): void;
  60423. /**
  60424. * This is used to keep meshes transformations so they can be restored
  60425. * when we build back a Babylon Mesh
  60426. * NB : All CSG operations are performed in world coordinates
  60427. * @param csg The CSG to copy the transform attributes from
  60428. * @returns This CSG
  60429. */
  60430. copyTransformAttributes(csg: CSG): CSG;
  60431. /**
  60432. * Build Raw mesh from CSG
  60433. * Coordinates here are in world space
  60434. * @param name The name of the mesh geometry
  60435. * @param scene The Scene
  60436. * @param keepSubMeshes Specifies if the submeshes should be kept
  60437. * @returns A new Mesh
  60438. */
  60439. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60440. /**
  60441. * Build Mesh from CSG taking material and transforms into account
  60442. * @param name The name of the Mesh
  60443. * @param material The material of the Mesh
  60444. * @param scene The Scene
  60445. * @param keepSubMeshes Specifies if submeshes should be kept
  60446. * @returns The new Mesh
  60447. */
  60448. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60449. }
  60450. }
  60451. declare module BABYLON {
  60452. /**
  60453. * Class used to create a trail following a mesh
  60454. */
  60455. export class TrailMesh extends Mesh {
  60456. private _generator;
  60457. private _autoStart;
  60458. private _running;
  60459. private _diameter;
  60460. private _length;
  60461. private _sectionPolygonPointsCount;
  60462. private _sectionVectors;
  60463. private _sectionNormalVectors;
  60464. private _beforeRenderObserver;
  60465. /**
  60466. * @constructor
  60467. * @param name The value used by scene.getMeshByName() to do a lookup.
  60468. * @param generator The mesh or transform node to generate a trail.
  60469. * @param scene The scene to add this mesh to.
  60470. * @param diameter Diameter of trailing mesh. Default is 1.
  60471. * @param length Length of trailing mesh. Default is 60.
  60472. * @param autoStart Automatically start trailing mesh. Default true.
  60473. */
  60474. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60475. /**
  60476. * "TrailMesh"
  60477. * @returns "TrailMesh"
  60478. */
  60479. getClassName(): string;
  60480. private _createMesh;
  60481. /**
  60482. * Start trailing mesh.
  60483. */
  60484. start(): void;
  60485. /**
  60486. * Stop trailing mesh.
  60487. */
  60488. stop(): void;
  60489. /**
  60490. * Update trailing mesh geometry.
  60491. */
  60492. update(): void;
  60493. /**
  60494. * Returns a new TrailMesh object.
  60495. * @param name is a string, the name given to the new mesh
  60496. * @param newGenerator use new generator object for cloned trail mesh
  60497. * @returns a new mesh
  60498. */
  60499. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60500. /**
  60501. * Serializes this trail mesh
  60502. * @param serializationObject object to write serialization to
  60503. */
  60504. serialize(serializationObject: any): void;
  60505. /**
  60506. * Parses a serialized trail mesh
  60507. * @param parsedMesh the serialized mesh
  60508. * @param scene the scene to create the trail mesh in
  60509. * @returns the created trail mesh
  60510. */
  60511. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60512. }
  60513. }
  60514. declare module BABYLON {
  60515. /**
  60516. * Class containing static functions to help procedurally build meshes
  60517. */
  60518. export class TiledBoxBuilder {
  60519. /**
  60520. * Creates a box mesh
  60521. * 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)
  60522. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60524. * * 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
  60525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60526. * @param name defines the name of the mesh
  60527. * @param options defines the options used to create the mesh
  60528. * @param scene defines the hosting scene
  60529. * @returns the box mesh
  60530. */
  60531. static CreateTiledBox(name: string, options: {
  60532. pattern?: number;
  60533. width?: number;
  60534. height?: number;
  60535. depth?: number;
  60536. tileSize?: number;
  60537. tileWidth?: number;
  60538. tileHeight?: number;
  60539. alignHorizontal?: number;
  60540. alignVertical?: number;
  60541. faceUV?: Vector4[];
  60542. faceColors?: Color4[];
  60543. sideOrientation?: number;
  60544. updatable?: boolean;
  60545. }, scene?: Nullable<Scene>): Mesh;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /**
  60550. * Class containing static functions to help procedurally build meshes
  60551. */
  60552. export class TorusKnotBuilder {
  60553. /**
  60554. * Creates a torus knot mesh
  60555. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60556. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60557. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60558. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60560. * * 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
  60561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60562. * @param name defines the name of the mesh
  60563. * @param options defines the options used to create the mesh
  60564. * @param scene defines the hosting scene
  60565. * @returns the torus knot mesh
  60566. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60567. */
  60568. static CreateTorusKnot(name: string, options: {
  60569. radius?: number;
  60570. tube?: number;
  60571. radialSegments?: number;
  60572. tubularSegments?: number;
  60573. p?: number;
  60574. q?: number;
  60575. updatable?: boolean;
  60576. sideOrientation?: number;
  60577. frontUVs?: Vector4;
  60578. backUVs?: Vector4;
  60579. }, scene: any): Mesh;
  60580. }
  60581. }
  60582. declare module BABYLON {
  60583. /**
  60584. * Polygon
  60585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60586. */
  60587. export class Polygon {
  60588. /**
  60589. * Creates a rectangle
  60590. * @param xmin bottom X coord
  60591. * @param ymin bottom Y coord
  60592. * @param xmax top X coord
  60593. * @param ymax top Y coord
  60594. * @returns points that make the resulting rectation
  60595. */
  60596. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60597. /**
  60598. * Creates a circle
  60599. * @param radius radius of circle
  60600. * @param cx scale in x
  60601. * @param cy scale in y
  60602. * @param numberOfSides number of sides that make up the circle
  60603. * @returns points that make the resulting circle
  60604. */
  60605. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60606. /**
  60607. * Creates a polygon from input string
  60608. * @param input Input polygon data
  60609. * @returns the parsed points
  60610. */
  60611. static Parse(input: string): Vector2[];
  60612. /**
  60613. * Starts building a polygon from x and y coordinates
  60614. * @param x x coordinate
  60615. * @param y y coordinate
  60616. * @returns the started path2
  60617. */
  60618. static StartingAt(x: number, y: number): Path2;
  60619. }
  60620. /**
  60621. * Builds a polygon
  60622. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60623. */
  60624. export class PolygonMeshBuilder {
  60625. private _points;
  60626. private _outlinepoints;
  60627. private _holes;
  60628. private _name;
  60629. private _scene;
  60630. private _epoints;
  60631. private _eholes;
  60632. private _addToepoint;
  60633. /**
  60634. * Babylon reference to the earcut plugin.
  60635. */
  60636. bjsEarcut: any;
  60637. /**
  60638. * Creates a PolygonMeshBuilder
  60639. * @param name name of the builder
  60640. * @param contours Path of the polygon
  60641. * @param scene scene to add to when creating the mesh
  60642. * @param earcutInjection can be used to inject your own earcut reference
  60643. */
  60644. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60645. /**
  60646. * Adds a whole within the polygon
  60647. * @param hole Array of points defining the hole
  60648. * @returns this
  60649. */
  60650. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60651. /**
  60652. * Creates the polygon
  60653. * @param updatable If the mesh should be updatable
  60654. * @param depth The depth of the mesh created
  60655. * @returns the created mesh
  60656. */
  60657. build(updatable?: boolean, depth?: number): Mesh;
  60658. /**
  60659. * Creates the polygon
  60660. * @param depth The depth of the mesh created
  60661. * @returns the created VertexData
  60662. */
  60663. buildVertexData(depth?: number): VertexData;
  60664. /**
  60665. * Adds a side to the polygon
  60666. * @param positions points that make the polygon
  60667. * @param normals normals of the polygon
  60668. * @param uvs uvs of the polygon
  60669. * @param indices indices of the polygon
  60670. * @param bounds bounds of the polygon
  60671. * @param points points of the polygon
  60672. * @param depth depth of the polygon
  60673. * @param flip flip of the polygon
  60674. */
  60675. private addSide;
  60676. }
  60677. }
  60678. declare module BABYLON {
  60679. /**
  60680. * Class containing static functions to help procedurally build meshes
  60681. */
  60682. export class PolygonBuilder {
  60683. /**
  60684. * Creates a polygon mesh
  60685. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60686. * * 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
  60687. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60689. * * 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)
  60690. * * Remember you can only change the shape positions, not their number when updating a polygon
  60691. * @param name defines the name of the mesh
  60692. * @param options defines the options used to create the mesh
  60693. * @param scene defines the hosting scene
  60694. * @param earcutInjection can be used to inject your own earcut reference
  60695. * @returns the polygon mesh
  60696. */
  60697. static CreatePolygon(name: string, options: {
  60698. shape: Vector3[];
  60699. holes?: Vector3[][];
  60700. depth?: number;
  60701. faceUV?: Vector4[];
  60702. faceColors?: Color4[];
  60703. updatable?: boolean;
  60704. sideOrientation?: number;
  60705. frontUVs?: Vector4;
  60706. backUVs?: Vector4;
  60707. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60708. /**
  60709. * Creates an extruded polygon mesh, with depth in the Y direction.
  60710. * * 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)
  60711. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60712. * @param name defines the name of the mesh
  60713. * @param options defines the options used to create the mesh
  60714. * @param scene defines the hosting scene
  60715. * @param earcutInjection can be used to inject your own earcut reference
  60716. * @returns the polygon mesh
  60717. */
  60718. static ExtrudePolygon(name: string, options: {
  60719. shape: Vector3[];
  60720. holes?: Vector3[][];
  60721. depth?: number;
  60722. faceUV?: Vector4[];
  60723. faceColors?: Color4[];
  60724. updatable?: boolean;
  60725. sideOrientation?: number;
  60726. frontUVs?: Vector4;
  60727. backUVs?: Vector4;
  60728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60729. }
  60730. }
  60731. declare module BABYLON {
  60732. /**
  60733. * Class containing static functions to help procedurally build meshes
  60734. */
  60735. export class LatheBuilder {
  60736. /**
  60737. * Creates lathe mesh.
  60738. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60739. * * 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
  60740. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60741. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60742. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60743. * * 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
  60744. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60745. * * 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
  60746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60747. * * 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
  60748. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60750. * @param name defines the name of the mesh
  60751. * @param options defines the options used to create the mesh
  60752. * @param scene defines the hosting scene
  60753. * @returns the lathe mesh
  60754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60755. */
  60756. static CreateLathe(name: string, options: {
  60757. shape: Vector3[];
  60758. radius?: number;
  60759. tessellation?: number;
  60760. clip?: number;
  60761. arc?: number;
  60762. closed?: boolean;
  60763. updatable?: boolean;
  60764. sideOrientation?: number;
  60765. frontUVs?: Vector4;
  60766. backUVs?: Vector4;
  60767. cap?: number;
  60768. invertUV?: boolean;
  60769. }, scene?: Nullable<Scene>): Mesh;
  60770. }
  60771. }
  60772. declare module BABYLON {
  60773. /**
  60774. * Class containing static functions to help procedurally build meshes
  60775. */
  60776. export class TiledPlaneBuilder {
  60777. /**
  60778. * Creates a tiled plane mesh
  60779. * * The parameter `pattern` will, depending on value, do nothing or
  60780. * * * flip (reflect about central vertical) alternate tiles across and up
  60781. * * * flip every tile on alternate rows
  60782. * * * rotate (180 degs) alternate tiles across and up
  60783. * * * rotate every tile on alternate rows
  60784. * * * flip and rotate alternate tiles across and up
  60785. * * * flip and rotate every tile on alternate rows
  60786. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60787. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60788. * * 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
  60789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60790. * * 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)
  60791. * * 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)
  60792. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60793. * @param name defines the name of the mesh
  60794. * @param options defines the options used to create the mesh
  60795. * @param scene defines the hosting scene
  60796. * @returns the box mesh
  60797. */
  60798. static CreateTiledPlane(name: string, options: {
  60799. pattern?: number;
  60800. tileSize?: number;
  60801. tileWidth?: number;
  60802. tileHeight?: number;
  60803. size?: number;
  60804. width?: number;
  60805. height?: number;
  60806. alignHorizontal?: number;
  60807. alignVertical?: number;
  60808. sideOrientation?: number;
  60809. frontUVs?: Vector4;
  60810. backUVs?: Vector4;
  60811. updatable?: boolean;
  60812. }, scene?: Nullable<Scene>): Mesh;
  60813. }
  60814. }
  60815. declare module BABYLON {
  60816. /**
  60817. * Class containing static functions to help procedurally build meshes
  60818. */
  60819. export class TubeBuilder {
  60820. /**
  60821. * Creates a tube mesh.
  60822. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60823. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60824. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60825. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60826. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60827. * * 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)
  60828. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60829. * * 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
  60830. * * 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
  60831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60832. * * 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
  60833. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60835. * @param name defines the name of the mesh
  60836. * @param options defines the options used to create the mesh
  60837. * @param scene defines the hosting scene
  60838. * @returns the tube mesh
  60839. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60840. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60841. */
  60842. static CreateTube(name: string, options: {
  60843. path: Vector3[];
  60844. radius?: number;
  60845. tessellation?: number;
  60846. radiusFunction?: {
  60847. (i: number, distance: number): number;
  60848. };
  60849. cap?: number;
  60850. arc?: number;
  60851. updatable?: boolean;
  60852. sideOrientation?: number;
  60853. frontUVs?: Vector4;
  60854. backUVs?: Vector4;
  60855. instance?: Mesh;
  60856. invertUV?: boolean;
  60857. }, scene?: Nullable<Scene>): Mesh;
  60858. }
  60859. }
  60860. declare module BABYLON {
  60861. /**
  60862. * Class containing static functions to help procedurally build meshes
  60863. */
  60864. export class IcoSphereBuilder {
  60865. /**
  60866. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60867. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60868. * * 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`)
  60869. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60870. * * 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
  60871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60872. * * 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
  60873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60874. * @param name defines the name of the mesh
  60875. * @param options defines the options used to create the mesh
  60876. * @param scene defines the hosting scene
  60877. * @returns the icosahedron mesh
  60878. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60879. */
  60880. static CreateIcoSphere(name: string, options: {
  60881. radius?: number;
  60882. radiusX?: number;
  60883. radiusY?: number;
  60884. radiusZ?: number;
  60885. flat?: boolean;
  60886. subdivisions?: number;
  60887. sideOrientation?: number;
  60888. frontUVs?: Vector4;
  60889. backUVs?: Vector4;
  60890. updatable?: boolean;
  60891. }, scene?: Nullable<Scene>): Mesh;
  60892. }
  60893. }
  60894. declare module BABYLON {
  60895. /**
  60896. * Class containing static functions to help procedurally build meshes
  60897. */
  60898. export class DecalBuilder {
  60899. /**
  60900. * Creates a decal mesh.
  60901. * 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
  60902. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60903. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60904. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60905. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60906. * @param name defines the name of the mesh
  60907. * @param sourceMesh defines the mesh where the decal must be applied
  60908. * @param options defines the options used to create the mesh
  60909. * @param scene defines the hosting scene
  60910. * @returns the decal mesh
  60911. * @see https://doc.babylonjs.com/how_to/decals
  60912. */
  60913. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60914. position?: Vector3;
  60915. normal?: Vector3;
  60916. size?: Vector3;
  60917. angle?: number;
  60918. }): Mesh;
  60919. }
  60920. }
  60921. declare module BABYLON {
  60922. /**
  60923. * Class containing static functions to help procedurally build meshes
  60924. */
  60925. export class MeshBuilder {
  60926. /**
  60927. * Creates a box mesh
  60928. * * The parameter `size` sets the size (float) of each box side (default 1)
  60929. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60930. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  60931. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60935. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60936. * @param name defines the name of the mesh
  60937. * @param options defines the options used to create the mesh
  60938. * @param scene defines the hosting scene
  60939. * @returns the box mesh
  60940. */
  60941. static CreateBox(name: string, options: {
  60942. size?: number;
  60943. width?: number;
  60944. height?: number;
  60945. depth?: number;
  60946. faceUV?: Vector4[];
  60947. faceColors?: Color4[];
  60948. sideOrientation?: number;
  60949. frontUVs?: Vector4;
  60950. backUVs?: Vector4;
  60951. updatable?: boolean;
  60952. }, scene?: Nullable<Scene>): Mesh;
  60953. /**
  60954. * Creates a tiled box mesh
  60955. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60957. * @param name defines the name of the mesh
  60958. * @param options defines the options used to create the mesh
  60959. * @param scene defines the hosting scene
  60960. * @returns the tiled box mesh
  60961. */
  60962. static CreateTiledBox(name: string, options: {
  60963. pattern?: number;
  60964. size?: number;
  60965. width?: number;
  60966. height?: number;
  60967. depth: number;
  60968. tileSize?: number;
  60969. tileWidth?: number;
  60970. tileHeight?: number;
  60971. faceUV?: Vector4[];
  60972. faceColors?: Color4[];
  60973. alignHorizontal?: number;
  60974. alignVertical?: number;
  60975. sideOrientation?: number;
  60976. updatable?: boolean;
  60977. }, scene?: Nullable<Scene>): Mesh;
  60978. /**
  60979. * Creates a sphere mesh
  60980. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60981. * * 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`)
  60982. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60983. * * 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
  60984. * * 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)
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60988. * @param name defines the name of the mesh
  60989. * @param options defines the options used to create the mesh
  60990. * @param scene defines the hosting scene
  60991. * @returns the sphere mesh
  60992. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60993. */
  60994. static CreateSphere(name: string, options: {
  60995. segments?: number;
  60996. diameter?: number;
  60997. diameterX?: number;
  60998. diameterY?: number;
  60999. diameterZ?: number;
  61000. arc?: number;
  61001. slice?: number;
  61002. sideOrientation?: number;
  61003. frontUVs?: Vector4;
  61004. backUVs?: Vector4;
  61005. updatable?: boolean;
  61006. }, scene?: Nullable<Scene>): Mesh;
  61007. /**
  61008. * Creates a plane polygonal mesh. By default, this is a disc
  61009. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61010. * * 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
  61011. * * 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
  61012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61013. * * 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
  61014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61015. * @param name defines the name of the mesh
  61016. * @param options defines the options used to create the mesh
  61017. * @param scene defines the hosting scene
  61018. * @returns the plane polygonal mesh
  61019. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61020. */
  61021. static CreateDisc(name: string, options: {
  61022. radius?: number;
  61023. tessellation?: number;
  61024. arc?: number;
  61025. updatable?: boolean;
  61026. sideOrientation?: number;
  61027. frontUVs?: Vector4;
  61028. backUVs?: Vector4;
  61029. }, scene?: Nullable<Scene>): Mesh;
  61030. /**
  61031. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61032. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61033. * * 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`)
  61034. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61035. * * 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
  61036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61037. * * 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
  61038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61039. * @param name defines the name of the mesh
  61040. * @param options defines the options used to create the mesh
  61041. * @param scene defines the hosting scene
  61042. * @returns the icosahedron mesh
  61043. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61044. */
  61045. static CreateIcoSphere(name: string, options: {
  61046. radius?: number;
  61047. radiusX?: number;
  61048. radiusY?: number;
  61049. radiusZ?: number;
  61050. flat?: boolean;
  61051. subdivisions?: number;
  61052. sideOrientation?: number;
  61053. frontUVs?: Vector4;
  61054. backUVs?: Vector4;
  61055. updatable?: boolean;
  61056. }, scene?: Nullable<Scene>): Mesh;
  61057. /**
  61058. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61059. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61060. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61061. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61062. * * 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
  61063. * * 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
  61064. * * 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
  61065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61066. * * 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
  61067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61068. * * 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
  61069. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61070. * * 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
  61071. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61073. * @param name defines the name of the mesh
  61074. * @param options defines the options used to create the mesh
  61075. * @param scene defines the hosting scene
  61076. * @returns the ribbon mesh
  61077. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61078. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61079. */
  61080. static CreateRibbon(name: string, options: {
  61081. pathArray: Vector3[][];
  61082. closeArray?: boolean;
  61083. closePath?: boolean;
  61084. offset?: number;
  61085. updatable?: boolean;
  61086. sideOrientation?: number;
  61087. frontUVs?: Vector4;
  61088. backUVs?: Vector4;
  61089. instance?: Mesh;
  61090. invertUV?: boolean;
  61091. uvs?: Vector2[];
  61092. colors?: Color4[];
  61093. }, scene?: Nullable<Scene>): Mesh;
  61094. /**
  61095. * Creates a cylinder or a cone mesh
  61096. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61097. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61098. * * 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.
  61099. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61100. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61101. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61102. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61103. * * 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).
  61104. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61105. * * 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).
  61106. * * 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
  61107. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61108. * * 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
  61109. * * 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.
  61110. * * If `enclose` is false, a ring surface is one element.
  61111. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61112. * * 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
  61113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61114. * * 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
  61115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61116. * @param name defines the name of the mesh
  61117. * @param options defines the options used to create the mesh
  61118. * @param scene defines the hosting scene
  61119. * @returns the cylinder mesh
  61120. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61121. */
  61122. static CreateCylinder(name: string, options: {
  61123. height?: number;
  61124. diameterTop?: number;
  61125. diameterBottom?: number;
  61126. diameter?: number;
  61127. tessellation?: number;
  61128. subdivisions?: number;
  61129. arc?: number;
  61130. faceColors?: Color4[];
  61131. faceUV?: Vector4[];
  61132. updatable?: boolean;
  61133. hasRings?: boolean;
  61134. enclose?: boolean;
  61135. cap?: number;
  61136. sideOrientation?: number;
  61137. frontUVs?: Vector4;
  61138. backUVs?: Vector4;
  61139. }, scene?: Nullable<Scene>): Mesh;
  61140. /**
  61141. * Creates a torus mesh
  61142. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61143. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61144. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61146. * * 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
  61147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61148. * @param name defines the name of the mesh
  61149. * @param options defines the options used to create the mesh
  61150. * @param scene defines the hosting scene
  61151. * @returns the torus mesh
  61152. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61153. */
  61154. static CreateTorus(name: string, options: {
  61155. diameter?: number;
  61156. thickness?: number;
  61157. tessellation?: number;
  61158. updatable?: boolean;
  61159. sideOrientation?: number;
  61160. frontUVs?: Vector4;
  61161. backUVs?: Vector4;
  61162. }, scene?: Nullable<Scene>): Mesh;
  61163. /**
  61164. * Creates a torus knot mesh
  61165. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61166. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61167. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61168. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61170. * * 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
  61171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61172. * @param name defines the name of the mesh
  61173. * @param options defines the options used to create the mesh
  61174. * @param scene defines the hosting scene
  61175. * @returns the torus knot mesh
  61176. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61177. */
  61178. static CreateTorusKnot(name: string, options: {
  61179. radius?: number;
  61180. tube?: number;
  61181. radialSegments?: number;
  61182. tubularSegments?: number;
  61183. p?: number;
  61184. q?: number;
  61185. updatable?: boolean;
  61186. sideOrientation?: number;
  61187. frontUVs?: Vector4;
  61188. backUVs?: Vector4;
  61189. }, scene?: Nullable<Scene>): Mesh;
  61190. /**
  61191. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61192. * * 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
  61193. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61194. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61195. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61196. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61197. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61198. * * 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
  61199. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61202. * @param name defines the name of the new line system
  61203. * @param options defines the options used to create the line system
  61204. * @param scene defines the hosting scene
  61205. * @returns a new line system mesh
  61206. */
  61207. static CreateLineSystem(name: string, options: {
  61208. lines: Vector3[][];
  61209. updatable?: boolean;
  61210. instance?: Nullable<LinesMesh>;
  61211. colors?: Nullable<Color4[][]>;
  61212. useVertexAlpha?: boolean;
  61213. }, scene: Nullable<Scene>): LinesMesh;
  61214. /**
  61215. * Creates a line mesh
  61216. * 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
  61217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61218. * * The parameter `points` is an array successive Vector3
  61219. * * 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
  61220. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61222. * * When updating an instance, remember that only point positions can change, not the number of points
  61223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61224. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61225. * @param name defines the name of the new line system
  61226. * @param options defines the options used to create the line system
  61227. * @param scene defines the hosting scene
  61228. * @returns a new line mesh
  61229. */
  61230. static CreateLines(name: string, options: {
  61231. points: Vector3[];
  61232. updatable?: boolean;
  61233. instance?: Nullable<LinesMesh>;
  61234. colors?: Color4[];
  61235. useVertexAlpha?: boolean;
  61236. }, scene?: Nullable<Scene>): LinesMesh;
  61237. /**
  61238. * Creates a dashed line mesh
  61239. * * 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
  61240. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61241. * * The parameter `points` is an array successive Vector3
  61242. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61243. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61244. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61245. * * 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
  61246. * * When updating an instance, remember that only point positions can change, not the number of points
  61247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61248. * @param name defines the name of the mesh
  61249. * @param options defines the options used to create the mesh
  61250. * @param scene defines the hosting scene
  61251. * @returns the dashed line mesh
  61252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61253. */
  61254. static CreateDashedLines(name: string, options: {
  61255. points: Vector3[];
  61256. dashSize?: number;
  61257. gapSize?: number;
  61258. dashNb?: number;
  61259. updatable?: boolean;
  61260. instance?: LinesMesh;
  61261. }, scene?: Nullable<Scene>): LinesMesh;
  61262. /**
  61263. * 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.
  61264. * * 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.
  61265. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61266. * * 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.
  61267. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61268. * * 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
  61269. * * 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
  61270. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61272. * * 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
  61273. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61275. * @param name defines the name of the mesh
  61276. * @param options defines the options used to create the mesh
  61277. * @param scene defines the hosting scene
  61278. * @returns the extruded shape mesh
  61279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61281. */
  61282. static ExtrudeShape(name: string, options: {
  61283. shape: Vector3[];
  61284. path: Vector3[];
  61285. scale?: number;
  61286. rotation?: number;
  61287. cap?: number;
  61288. updatable?: boolean;
  61289. sideOrientation?: number;
  61290. frontUVs?: Vector4;
  61291. backUVs?: Vector4;
  61292. instance?: Mesh;
  61293. invertUV?: boolean;
  61294. }, scene?: Nullable<Scene>): Mesh;
  61295. /**
  61296. * Creates an custom extruded shape mesh.
  61297. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61298. * * 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.
  61299. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61300. * * 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
  61301. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61302. * * 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
  61303. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61304. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61305. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61306. * * 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
  61307. * * 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
  61308. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61310. * * 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
  61311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61313. * @param name defines the name of the mesh
  61314. * @param options defines the options used to create the mesh
  61315. * @param scene defines the hosting scene
  61316. * @returns the custom extruded shape mesh
  61317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61320. */
  61321. static ExtrudeShapeCustom(name: string, options: {
  61322. shape: Vector3[];
  61323. path: Vector3[];
  61324. scaleFunction?: any;
  61325. rotationFunction?: any;
  61326. ribbonCloseArray?: boolean;
  61327. ribbonClosePath?: boolean;
  61328. cap?: number;
  61329. updatable?: boolean;
  61330. sideOrientation?: number;
  61331. frontUVs?: Vector4;
  61332. backUVs?: Vector4;
  61333. instance?: Mesh;
  61334. invertUV?: boolean;
  61335. }, scene?: Nullable<Scene>): Mesh;
  61336. /**
  61337. * Creates lathe mesh.
  61338. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61339. * * 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
  61340. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61341. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61342. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61343. * * 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
  61344. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61345. * * 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
  61346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61347. * * 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
  61348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61350. * @param name defines the name of the mesh
  61351. * @param options defines the options used to create the mesh
  61352. * @param scene defines the hosting scene
  61353. * @returns the lathe mesh
  61354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61355. */
  61356. static CreateLathe(name: string, options: {
  61357. shape: Vector3[];
  61358. radius?: number;
  61359. tessellation?: number;
  61360. clip?: number;
  61361. arc?: number;
  61362. closed?: boolean;
  61363. updatable?: boolean;
  61364. sideOrientation?: number;
  61365. frontUVs?: Vector4;
  61366. backUVs?: Vector4;
  61367. cap?: number;
  61368. invertUV?: boolean;
  61369. }, scene?: Nullable<Scene>): Mesh;
  61370. /**
  61371. * Creates a tiled plane mesh
  61372. * * You can set a limited pattern arrangement with the tiles
  61373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61374. * * 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
  61375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61376. * @param name defines the name of the mesh
  61377. * @param options defines the options used to create the mesh
  61378. * @param scene defines the hosting scene
  61379. * @returns the plane mesh
  61380. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61381. */
  61382. static CreateTiledPlane(name: string, options: {
  61383. pattern?: number;
  61384. tileSize?: number;
  61385. tileWidth?: number;
  61386. tileHeight?: number;
  61387. size?: number;
  61388. width?: number;
  61389. height?: number;
  61390. alignHorizontal?: number;
  61391. alignVertical?: number;
  61392. sideOrientation?: number;
  61393. frontUVs?: Vector4;
  61394. backUVs?: Vector4;
  61395. updatable?: boolean;
  61396. }, scene?: Nullable<Scene>): Mesh;
  61397. /**
  61398. * Creates a plane mesh
  61399. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61400. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61401. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61403. * * 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
  61404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61405. * @param name defines the name of the mesh
  61406. * @param options defines the options used to create the mesh
  61407. * @param scene defines the hosting scene
  61408. * @returns the plane mesh
  61409. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61410. */
  61411. static CreatePlane(name: string, options: {
  61412. size?: number;
  61413. width?: number;
  61414. height?: number;
  61415. sideOrientation?: number;
  61416. frontUVs?: Vector4;
  61417. backUVs?: Vector4;
  61418. updatable?: boolean;
  61419. sourcePlane?: Plane;
  61420. }, scene?: Nullable<Scene>): Mesh;
  61421. /**
  61422. * Creates a ground mesh
  61423. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61424. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61426. * @param name defines the name of the mesh
  61427. * @param options defines the options used to create the mesh
  61428. * @param scene defines the hosting scene
  61429. * @returns the ground mesh
  61430. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61431. */
  61432. static CreateGround(name: string, options: {
  61433. width?: number;
  61434. height?: number;
  61435. subdivisions?: number;
  61436. subdivisionsX?: number;
  61437. subdivisionsY?: number;
  61438. updatable?: boolean;
  61439. }, scene?: Nullable<Scene>): Mesh;
  61440. /**
  61441. * Creates a tiled ground mesh
  61442. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61443. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61444. * * 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
  61445. * * 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
  61446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61447. * @param name defines the name of the mesh
  61448. * @param options defines the options used to create the mesh
  61449. * @param scene defines the hosting scene
  61450. * @returns the tiled ground mesh
  61451. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61452. */
  61453. static CreateTiledGround(name: string, options: {
  61454. xmin: number;
  61455. zmin: number;
  61456. xmax: number;
  61457. zmax: number;
  61458. subdivisions?: {
  61459. w: number;
  61460. h: number;
  61461. };
  61462. precision?: {
  61463. w: number;
  61464. h: number;
  61465. };
  61466. updatable?: boolean;
  61467. }, scene?: Nullable<Scene>): Mesh;
  61468. /**
  61469. * Creates a ground mesh from a height map
  61470. * * The parameter `url` sets the URL of the height map image resource.
  61471. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61472. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61473. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61474. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61475. * * 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.
  61476. * * 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).
  61477. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61479. * @param name defines the name of the mesh
  61480. * @param url defines the url to the height map
  61481. * @param options defines the options used to create the mesh
  61482. * @param scene defines the hosting scene
  61483. * @returns the ground mesh
  61484. * @see https://doc.babylonjs.com/babylon101/height_map
  61485. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61486. */
  61487. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61488. width?: number;
  61489. height?: number;
  61490. subdivisions?: number;
  61491. minHeight?: number;
  61492. maxHeight?: number;
  61493. colorFilter?: Color3;
  61494. alphaFilter?: number;
  61495. updatable?: boolean;
  61496. onReady?: (mesh: GroundMesh) => void;
  61497. }, scene?: Nullable<Scene>): GroundMesh;
  61498. /**
  61499. * Creates a polygon mesh
  61500. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61501. * * 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
  61502. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * 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)
  61505. * * Remember you can only change the shape positions, not their number when updating a polygon
  61506. * @param name defines the name of the mesh
  61507. * @param options defines the options used to create the mesh
  61508. * @param scene defines the hosting scene
  61509. * @param earcutInjection can be used to inject your own earcut reference
  61510. * @returns the polygon mesh
  61511. */
  61512. static CreatePolygon(name: string, options: {
  61513. shape: Vector3[];
  61514. holes?: Vector3[][];
  61515. depth?: number;
  61516. faceUV?: Vector4[];
  61517. faceColors?: Color4[];
  61518. updatable?: boolean;
  61519. sideOrientation?: number;
  61520. frontUVs?: Vector4;
  61521. backUVs?: Vector4;
  61522. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61523. /**
  61524. * Creates an extruded polygon mesh, with depth in the Y direction.
  61525. * * 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)
  61526. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61527. * @param name defines the name of the mesh
  61528. * @param options defines the options used to create the mesh
  61529. * @param scene defines the hosting scene
  61530. * @param earcutInjection can be used to inject your own earcut reference
  61531. * @returns the polygon mesh
  61532. */
  61533. static ExtrudePolygon(name: string, options: {
  61534. shape: Vector3[];
  61535. holes?: Vector3[][];
  61536. depth?: number;
  61537. faceUV?: Vector4[];
  61538. faceColors?: Color4[];
  61539. updatable?: boolean;
  61540. sideOrientation?: number;
  61541. frontUVs?: Vector4;
  61542. backUVs?: Vector4;
  61543. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61544. /**
  61545. * Creates a tube mesh.
  61546. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61547. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61548. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61549. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61550. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61551. * * 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)
  61552. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61553. * * 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
  61554. * * 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
  61555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61556. * * 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
  61557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 tube mesh
  61563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61564. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61565. */
  61566. static CreateTube(name: string, options: {
  61567. path: Vector3[];
  61568. radius?: number;
  61569. tessellation?: number;
  61570. radiusFunction?: {
  61571. (i: number, distance: number): number;
  61572. };
  61573. cap?: number;
  61574. arc?: number;
  61575. updatable?: boolean;
  61576. sideOrientation?: number;
  61577. frontUVs?: Vector4;
  61578. backUVs?: Vector4;
  61579. instance?: Mesh;
  61580. invertUV?: boolean;
  61581. }, scene?: Nullable<Scene>): Mesh;
  61582. /**
  61583. * Creates a polyhedron mesh
  61584. * * 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
  61585. * * The parameter `size` (positive float, default 1) sets the polygon size
  61586. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61587. * * 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`
  61588. * * 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
  61589. * * 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)`)
  61590. * * 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
  61591. * * 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
  61592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61593. * * 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
  61594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61595. * @param name defines the name of the mesh
  61596. * @param options defines the options used to create the mesh
  61597. * @param scene defines the hosting scene
  61598. * @returns the polyhedron mesh
  61599. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61600. */
  61601. static CreatePolyhedron(name: string, options: {
  61602. type?: number;
  61603. size?: number;
  61604. sizeX?: number;
  61605. sizeY?: number;
  61606. sizeZ?: number;
  61607. custom?: any;
  61608. faceUV?: Vector4[];
  61609. faceColors?: Color4[];
  61610. flat?: boolean;
  61611. updatable?: boolean;
  61612. sideOrientation?: number;
  61613. frontUVs?: Vector4;
  61614. backUVs?: Vector4;
  61615. }, scene?: Nullable<Scene>): Mesh;
  61616. /**
  61617. * Creates a decal mesh.
  61618. * 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
  61619. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61620. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61621. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61622. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61623. * @param name defines the name of the mesh
  61624. * @param sourceMesh defines the mesh where the decal must be applied
  61625. * @param options defines the options used to create the mesh
  61626. * @param scene defines the hosting scene
  61627. * @returns the decal mesh
  61628. * @see https://doc.babylonjs.com/how_to/decals
  61629. */
  61630. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61631. position?: Vector3;
  61632. normal?: Vector3;
  61633. size?: Vector3;
  61634. angle?: number;
  61635. }): Mesh;
  61636. }
  61637. }
  61638. declare module BABYLON {
  61639. /**
  61640. * A simplifier interface for future simplification implementations
  61641. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61642. */
  61643. export interface ISimplifier {
  61644. /**
  61645. * Simplification of a given mesh according to the given settings.
  61646. * Since this requires computation, it is assumed that the function runs async.
  61647. * @param settings The settings of the simplification, including quality and distance
  61648. * @param successCallback A callback that will be called after the mesh was simplified.
  61649. * @param errorCallback in case of an error, this callback will be called. optional.
  61650. */
  61651. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61652. }
  61653. /**
  61654. * Expected simplification settings.
  61655. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61656. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61657. */
  61658. export interface ISimplificationSettings {
  61659. /**
  61660. * Gets or sets the expected quality
  61661. */
  61662. quality: number;
  61663. /**
  61664. * Gets or sets the distance when this optimized version should be used
  61665. */
  61666. distance: number;
  61667. /**
  61668. * Gets an already optimized mesh
  61669. */
  61670. optimizeMesh?: boolean;
  61671. }
  61672. /**
  61673. * Class used to specify simplification options
  61674. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61675. */
  61676. export class SimplificationSettings implements ISimplificationSettings {
  61677. /** expected quality */
  61678. quality: number;
  61679. /** distance when this optimized version should be used */
  61680. distance: number;
  61681. /** already optimized mesh */
  61682. optimizeMesh?: boolean | undefined;
  61683. /**
  61684. * Creates a SimplificationSettings
  61685. * @param quality expected quality
  61686. * @param distance distance when this optimized version should be used
  61687. * @param optimizeMesh already optimized mesh
  61688. */
  61689. constructor(
  61690. /** expected quality */
  61691. quality: number,
  61692. /** distance when this optimized version should be used */
  61693. distance: number,
  61694. /** already optimized mesh */
  61695. optimizeMesh?: boolean | undefined);
  61696. }
  61697. /**
  61698. * Interface used to define a simplification task
  61699. */
  61700. export interface ISimplificationTask {
  61701. /**
  61702. * Array of settings
  61703. */
  61704. settings: Array<ISimplificationSettings>;
  61705. /**
  61706. * Simplification type
  61707. */
  61708. simplificationType: SimplificationType;
  61709. /**
  61710. * Mesh to simplify
  61711. */
  61712. mesh: Mesh;
  61713. /**
  61714. * Callback called on success
  61715. */
  61716. successCallback?: () => void;
  61717. /**
  61718. * Defines if parallel processing can be used
  61719. */
  61720. parallelProcessing: boolean;
  61721. }
  61722. /**
  61723. * Queue used to order the simplification tasks
  61724. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61725. */
  61726. export class SimplificationQueue {
  61727. private _simplificationArray;
  61728. /**
  61729. * Gets a boolean indicating that the process is still running
  61730. */
  61731. running: boolean;
  61732. /**
  61733. * Creates a new queue
  61734. */
  61735. constructor();
  61736. /**
  61737. * Adds a new simplification task
  61738. * @param task defines a task to add
  61739. */
  61740. addTask(task: ISimplificationTask): void;
  61741. /**
  61742. * Execute next task
  61743. */
  61744. executeNext(): void;
  61745. /**
  61746. * Execute a simplification task
  61747. * @param task defines the task to run
  61748. */
  61749. runSimplification(task: ISimplificationTask): void;
  61750. private getSimplifier;
  61751. }
  61752. /**
  61753. * The implemented types of simplification
  61754. * At the moment only Quadratic Error Decimation is implemented
  61755. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61756. */
  61757. export enum SimplificationType {
  61758. /** Quadratic error decimation */
  61759. QUADRATIC = 0
  61760. }
  61761. }
  61762. declare module BABYLON {
  61763. interface Scene {
  61764. /** @hidden (Backing field) */
  61765. _simplificationQueue: SimplificationQueue;
  61766. /**
  61767. * Gets or sets the simplification queue attached to the scene
  61768. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61769. */
  61770. simplificationQueue: SimplificationQueue;
  61771. }
  61772. interface Mesh {
  61773. /**
  61774. * Simplify the mesh according to the given array of settings.
  61775. * Function will return immediately and will simplify async
  61776. * @param settings a collection of simplification settings
  61777. * @param parallelProcessing should all levels calculate parallel or one after the other
  61778. * @param simplificationType the type of simplification to run
  61779. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61780. * @returns the current mesh
  61781. */
  61782. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61783. }
  61784. /**
  61785. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61786. * created in a scene
  61787. */
  61788. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61789. /**
  61790. * The component name helpfull to identify the component in the list of scene components.
  61791. */
  61792. readonly name: string;
  61793. /**
  61794. * The scene the component belongs to.
  61795. */
  61796. scene: Scene;
  61797. /**
  61798. * Creates a new instance of the component for the given scene
  61799. * @param scene Defines the scene to register the component in
  61800. */
  61801. constructor(scene: Scene);
  61802. /**
  61803. * Registers the component in a given scene
  61804. */
  61805. register(): void;
  61806. /**
  61807. * Rebuilds the elements related to this component in case of
  61808. * context lost for instance.
  61809. */
  61810. rebuild(): void;
  61811. /**
  61812. * Disposes the component and the associated ressources
  61813. */
  61814. dispose(): void;
  61815. private _beforeCameraUpdate;
  61816. }
  61817. }
  61818. declare module BABYLON {
  61819. /**
  61820. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61821. */
  61822. export interface INavigationEnginePlugin {
  61823. /**
  61824. * plugin name
  61825. */
  61826. name: string;
  61827. /**
  61828. * Creates a navigation mesh
  61829. * @param meshes array of all the geometry used to compute the navigatio mesh
  61830. * @param parameters bunch of parameters used to filter geometry
  61831. */
  61832. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61833. /**
  61834. * Create a navigation mesh debug mesh
  61835. * @param scene is where the mesh will be added
  61836. * @returns debug display mesh
  61837. */
  61838. createDebugNavMesh(scene: Scene): Mesh;
  61839. /**
  61840. * Get a navigation mesh constrained position, closest to the parameter position
  61841. * @param position world position
  61842. * @returns the closest point to position constrained by the navigation mesh
  61843. */
  61844. getClosestPoint(position: Vector3): Vector3;
  61845. /**
  61846. * Get a navigation mesh constrained position, within a particular radius
  61847. * @param position world position
  61848. * @param maxRadius the maximum distance to the constrained world position
  61849. * @returns the closest point to position constrained by the navigation mesh
  61850. */
  61851. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61852. /**
  61853. * Compute the final position from a segment made of destination-position
  61854. * @param position world position
  61855. * @param destination world position
  61856. * @returns the resulting point along the navmesh
  61857. */
  61858. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61859. /**
  61860. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61861. * @param start world position
  61862. * @param end world position
  61863. * @returns array containing world position composing the path
  61864. */
  61865. computePath(start: Vector3, end: Vector3): Vector3[];
  61866. /**
  61867. * If this plugin is supported
  61868. * @returns true if plugin is supported
  61869. */
  61870. isSupported(): boolean;
  61871. /**
  61872. * Create a new Crowd so you can add agents
  61873. * @param maxAgents the maximum agent count in the crowd
  61874. * @param maxAgentRadius the maximum radius an agent can have
  61875. * @param scene to attach the crowd to
  61876. * @returns the crowd you can add agents to
  61877. */
  61878. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61879. /**
  61880. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61881. * The queries will try to find a solution within those bounds
  61882. * default is (1,1,1)
  61883. * @param extent x,y,z value that define the extent around the queries point of reference
  61884. */
  61885. setDefaultQueryExtent(extent: Vector3): void;
  61886. /**
  61887. * Get the Bounding box extent specified by setDefaultQueryExtent
  61888. * @returns the box extent values
  61889. */
  61890. getDefaultQueryExtent(): Vector3;
  61891. /**
  61892. * Release all resources
  61893. */
  61894. dispose(): void;
  61895. }
  61896. /**
  61897. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61898. */
  61899. export interface ICrowd {
  61900. /**
  61901. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61902. * You can attach anything to that node. The node position is updated in the scene update tick.
  61903. * @param pos world position that will be constrained by the navigation mesh
  61904. * @param parameters agent parameters
  61905. * @param transform hooked to the agent that will be update by the scene
  61906. * @returns agent index
  61907. */
  61908. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61909. /**
  61910. * Returns the agent position in world space
  61911. * @param index agent index returned by addAgent
  61912. * @returns world space position
  61913. */
  61914. getAgentPosition(index: number): Vector3;
  61915. /**
  61916. * Gets the agent velocity in world space
  61917. * @param index agent index returned by addAgent
  61918. * @returns world space velocity
  61919. */
  61920. getAgentVelocity(index: number): Vector3;
  61921. /**
  61922. * remove a particular agent previously created
  61923. * @param index agent index returned by addAgent
  61924. */
  61925. removeAgent(index: number): void;
  61926. /**
  61927. * get the list of all agents attached to this crowd
  61928. * @returns list of agent indices
  61929. */
  61930. getAgents(): number[];
  61931. /**
  61932. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61933. * @param deltaTime in seconds
  61934. */
  61935. update(deltaTime: number): void;
  61936. /**
  61937. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61938. * @param index agent index returned by addAgent
  61939. * @param destination targeted world position
  61940. */
  61941. agentGoto(index: number, destination: Vector3): void;
  61942. /**
  61943. * Teleport the agent to a new position
  61944. * @param index agent index returned by addAgent
  61945. * @param destination targeted world position
  61946. */
  61947. agentTeleport(index: number, destination: Vector3): void;
  61948. /**
  61949. * Update agent parameters
  61950. * @param index agent index returned by addAgent
  61951. * @param parameters agent parameters
  61952. */
  61953. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61954. /**
  61955. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61956. * The queries will try to find a solution within those bounds
  61957. * default is (1,1,1)
  61958. * @param extent x,y,z value that define the extent around the queries point of reference
  61959. */
  61960. setDefaultQueryExtent(extent: Vector3): void;
  61961. /**
  61962. * Get the Bounding box extent specified by setDefaultQueryExtent
  61963. * @returns the box extent values
  61964. */
  61965. getDefaultQueryExtent(): Vector3;
  61966. /**
  61967. * Release all resources
  61968. */
  61969. dispose(): void;
  61970. }
  61971. /**
  61972. * Configures an agent
  61973. */
  61974. export interface IAgentParameters {
  61975. /**
  61976. * Agent radius. [Limit: >= 0]
  61977. */
  61978. radius: number;
  61979. /**
  61980. * Agent height. [Limit: > 0]
  61981. */
  61982. height: number;
  61983. /**
  61984. * Maximum allowed acceleration. [Limit: >= 0]
  61985. */
  61986. maxAcceleration: number;
  61987. /**
  61988. * Maximum allowed speed. [Limit: >= 0]
  61989. */
  61990. maxSpeed: number;
  61991. /**
  61992. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61993. */
  61994. collisionQueryRange: number;
  61995. /**
  61996. * The path visibility optimization range. [Limit: > 0]
  61997. */
  61998. pathOptimizationRange: number;
  61999. /**
  62000. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62001. */
  62002. separationWeight: number;
  62003. }
  62004. /**
  62005. * Configures the navigation mesh creation
  62006. */
  62007. export interface INavMeshParameters {
  62008. /**
  62009. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62010. */
  62011. cs: number;
  62012. /**
  62013. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62014. */
  62015. ch: number;
  62016. /**
  62017. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62018. */
  62019. walkableSlopeAngle: number;
  62020. /**
  62021. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62022. * be considered walkable. [Limit: >= 3] [Units: vx]
  62023. */
  62024. walkableHeight: number;
  62025. /**
  62026. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62027. */
  62028. walkableClimb: number;
  62029. /**
  62030. * The distance to erode/shrink the walkable area of the heightfield away from
  62031. * obstructions. [Limit: >=0] [Units: vx]
  62032. */
  62033. walkableRadius: number;
  62034. /**
  62035. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62036. */
  62037. maxEdgeLen: number;
  62038. /**
  62039. * The maximum distance a simplfied contour's border edges should deviate
  62040. * the original raw contour. [Limit: >=0] [Units: vx]
  62041. */
  62042. maxSimplificationError: number;
  62043. /**
  62044. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62045. */
  62046. minRegionArea: number;
  62047. /**
  62048. * Any regions with a span count smaller than this value will, if possible,
  62049. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62050. */
  62051. mergeRegionArea: number;
  62052. /**
  62053. * The maximum number of vertices allowed for polygons generated during the
  62054. * contour to polygon conversion process. [Limit: >= 3]
  62055. */
  62056. maxVertsPerPoly: number;
  62057. /**
  62058. * Sets the sampling distance to use when generating the detail mesh.
  62059. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62060. */
  62061. detailSampleDist: number;
  62062. /**
  62063. * The maximum distance the detail mesh surface should deviate from heightfield
  62064. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62065. */
  62066. detailSampleMaxError: number;
  62067. }
  62068. }
  62069. declare module BABYLON {
  62070. /**
  62071. * RecastJS navigation plugin
  62072. */
  62073. export class RecastJSPlugin implements INavigationEnginePlugin {
  62074. /**
  62075. * Reference to the Recast library
  62076. */
  62077. bjsRECAST: any;
  62078. /**
  62079. * plugin name
  62080. */
  62081. name: string;
  62082. /**
  62083. * the first navmesh created. We might extend this to support multiple navmeshes
  62084. */
  62085. navMesh: any;
  62086. /**
  62087. * Initializes the recastJS plugin
  62088. * @param recastInjection can be used to inject your own recast reference
  62089. */
  62090. constructor(recastInjection?: any);
  62091. /**
  62092. * Creates a navigation mesh
  62093. * @param meshes array of all the geometry used to compute the navigatio mesh
  62094. * @param parameters bunch of parameters used to filter geometry
  62095. */
  62096. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62097. /**
  62098. * Create a navigation mesh debug mesh
  62099. * @param scene is where the mesh will be added
  62100. * @returns debug display mesh
  62101. */
  62102. createDebugNavMesh(scene: Scene): Mesh;
  62103. /**
  62104. * Get a navigation mesh constrained position, closest to the parameter position
  62105. * @param position world position
  62106. * @returns the closest point to position constrained by the navigation mesh
  62107. */
  62108. getClosestPoint(position: Vector3): Vector3;
  62109. /**
  62110. * Get a navigation mesh constrained position, within a particular radius
  62111. * @param position world position
  62112. * @param maxRadius the maximum distance to the constrained world position
  62113. * @returns the closest point to position constrained by the navigation mesh
  62114. */
  62115. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62116. /**
  62117. * Compute the final position from a segment made of destination-position
  62118. * @param position world position
  62119. * @param destination world position
  62120. * @returns the resulting point along the navmesh
  62121. */
  62122. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62123. /**
  62124. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62125. * @param start world position
  62126. * @param end world position
  62127. * @returns array containing world position composing the path
  62128. */
  62129. computePath(start: Vector3, end: Vector3): Vector3[];
  62130. /**
  62131. * Create a new Crowd so you can add agents
  62132. * @param maxAgents the maximum agent count in the crowd
  62133. * @param maxAgentRadius the maximum radius an agent can have
  62134. * @param scene to attach the crowd to
  62135. * @returns the crowd you can add agents to
  62136. */
  62137. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62138. /**
  62139. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62140. * The queries will try to find a solution within those bounds
  62141. * default is (1,1,1)
  62142. * @param extent x,y,z value that define the extent around the queries point of reference
  62143. */
  62144. setDefaultQueryExtent(extent: Vector3): void;
  62145. /**
  62146. * Get the Bounding box extent specified by setDefaultQueryExtent
  62147. * @returns the box extent values
  62148. */
  62149. getDefaultQueryExtent(): Vector3;
  62150. /**
  62151. * Disposes
  62152. */
  62153. dispose(): void;
  62154. /**
  62155. * If this plugin is supported
  62156. * @returns true if plugin is supported
  62157. */
  62158. isSupported(): boolean;
  62159. }
  62160. /**
  62161. * Recast detour crowd implementation
  62162. */
  62163. export class RecastJSCrowd implements ICrowd {
  62164. /**
  62165. * Recast/detour plugin
  62166. */
  62167. bjsRECASTPlugin: RecastJSPlugin;
  62168. /**
  62169. * Link to the detour crowd
  62170. */
  62171. recastCrowd: any;
  62172. /**
  62173. * One transform per agent
  62174. */
  62175. transforms: TransformNode[];
  62176. /**
  62177. * All agents created
  62178. */
  62179. agents: number[];
  62180. /**
  62181. * Link to the scene is kept to unregister the crowd from the scene
  62182. */
  62183. private _scene;
  62184. /**
  62185. * Observer for crowd updates
  62186. */
  62187. private _onBeforeAnimationsObserver;
  62188. /**
  62189. * Constructor
  62190. * @param plugin recastJS plugin
  62191. * @param maxAgents the maximum agent count in the crowd
  62192. * @param maxAgentRadius the maximum radius an agent can have
  62193. * @param scene to attach the crowd to
  62194. * @returns the crowd you can add agents to
  62195. */
  62196. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62197. /**
  62198. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62199. * You can attach anything to that node. The node position is updated in the scene update tick.
  62200. * @param pos world position that will be constrained by the navigation mesh
  62201. * @param parameters agent parameters
  62202. * @param transform hooked to the agent that will be update by the scene
  62203. * @returns agent index
  62204. */
  62205. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62206. /**
  62207. * Returns the agent position in world space
  62208. * @param index agent index returned by addAgent
  62209. * @returns world space position
  62210. */
  62211. getAgentPosition(index: number): Vector3;
  62212. /**
  62213. * Returns the agent velocity in world space
  62214. * @param index agent index returned by addAgent
  62215. * @returns world space velocity
  62216. */
  62217. getAgentVelocity(index: number): Vector3;
  62218. /**
  62219. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62220. * @param index agent index returned by addAgent
  62221. * @param destination targeted world position
  62222. */
  62223. agentGoto(index: number, destination: Vector3): void;
  62224. /**
  62225. * Teleport the agent to a new position
  62226. * @param index agent index returned by addAgent
  62227. * @param destination targeted world position
  62228. */
  62229. agentTeleport(index: number, destination: Vector3): void;
  62230. /**
  62231. * Update agent parameters
  62232. * @param index agent index returned by addAgent
  62233. * @param parameters agent parameters
  62234. */
  62235. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62236. /**
  62237. * remove a particular agent previously created
  62238. * @param index agent index returned by addAgent
  62239. */
  62240. removeAgent(index: number): void;
  62241. /**
  62242. * get the list of all agents attached to this crowd
  62243. * @returns list of agent indices
  62244. */
  62245. getAgents(): number[];
  62246. /**
  62247. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62248. * @param deltaTime in seconds
  62249. */
  62250. update(deltaTime: number): void;
  62251. /**
  62252. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62253. * The queries will try to find a solution within those bounds
  62254. * default is (1,1,1)
  62255. * @param extent x,y,z value that define the extent around the queries point of reference
  62256. */
  62257. setDefaultQueryExtent(extent: Vector3): void;
  62258. /**
  62259. * Get the Bounding box extent specified by setDefaultQueryExtent
  62260. * @returns the box extent values
  62261. */
  62262. getDefaultQueryExtent(): Vector3;
  62263. /**
  62264. * Release all resources
  62265. */
  62266. dispose(): void;
  62267. }
  62268. }
  62269. declare module BABYLON {
  62270. /**
  62271. * Class used to enable access to IndexedDB
  62272. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62273. */
  62274. export class Database implements IOfflineProvider {
  62275. private _callbackManifestChecked;
  62276. private _currentSceneUrl;
  62277. private _db;
  62278. private _enableSceneOffline;
  62279. private _enableTexturesOffline;
  62280. private _manifestVersionFound;
  62281. private _mustUpdateRessources;
  62282. private _hasReachedQuota;
  62283. private _isSupported;
  62284. private _idbFactory;
  62285. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62286. private static IsUASupportingBlobStorage;
  62287. /**
  62288. * Gets a boolean indicating if Database storate is enabled (off by default)
  62289. */
  62290. static IDBStorageEnabled: boolean;
  62291. /**
  62292. * Gets a boolean indicating if scene must be saved in the database
  62293. */
  62294. get enableSceneOffline(): boolean;
  62295. /**
  62296. * Gets a boolean indicating if textures must be saved in the database
  62297. */
  62298. get enableTexturesOffline(): boolean;
  62299. /**
  62300. * Creates a new Database
  62301. * @param urlToScene defines the url to load the scene
  62302. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62303. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62304. */
  62305. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62306. private static _ParseURL;
  62307. private static _ReturnFullUrlLocation;
  62308. private _checkManifestFile;
  62309. /**
  62310. * Open the database and make it available
  62311. * @param successCallback defines the callback to call on success
  62312. * @param errorCallback defines the callback to call on error
  62313. */
  62314. open(successCallback: () => void, errorCallback: () => void): void;
  62315. /**
  62316. * Loads an image from the database
  62317. * @param url defines the url to load from
  62318. * @param image defines the target DOM image
  62319. */
  62320. loadImage(url: string, image: HTMLImageElement): void;
  62321. private _loadImageFromDBAsync;
  62322. private _saveImageIntoDBAsync;
  62323. private _checkVersionFromDB;
  62324. private _loadVersionFromDBAsync;
  62325. private _saveVersionIntoDBAsync;
  62326. /**
  62327. * Loads a file from database
  62328. * @param url defines the URL to load from
  62329. * @param sceneLoaded defines a callback to call on success
  62330. * @param progressCallBack defines a callback to call when progress changed
  62331. * @param errorCallback defines a callback to call on error
  62332. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62333. */
  62334. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62335. private _loadFileAsync;
  62336. private _saveFileAsync;
  62337. /**
  62338. * Validates if xhr data is correct
  62339. * @param xhr defines the request to validate
  62340. * @param dataType defines the expected data type
  62341. * @returns true if data is correct
  62342. */
  62343. private static _ValidateXHRData;
  62344. }
  62345. }
  62346. declare module BABYLON {
  62347. /** @hidden */
  62348. export var gpuUpdateParticlesPixelShader: {
  62349. name: string;
  62350. shader: string;
  62351. };
  62352. }
  62353. declare module BABYLON {
  62354. /** @hidden */
  62355. export var gpuUpdateParticlesVertexShader: {
  62356. name: string;
  62357. shader: string;
  62358. };
  62359. }
  62360. declare module BABYLON {
  62361. /** @hidden */
  62362. export var clipPlaneFragmentDeclaration2: {
  62363. name: string;
  62364. shader: string;
  62365. };
  62366. }
  62367. declare module BABYLON {
  62368. /** @hidden */
  62369. export var gpuRenderParticlesPixelShader: {
  62370. name: string;
  62371. shader: string;
  62372. };
  62373. }
  62374. declare module BABYLON {
  62375. /** @hidden */
  62376. export var clipPlaneVertexDeclaration2: {
  62377. name: string;
  62378. shader: string;
  62379. };
  62380. }
  62381. declare module BABYLON {
  62382. /** @hidden */
  62383. export var gpuRenderParticlesVertexShader: {
  62384. name: string;
  62385. shader: string;
  62386. };
  62387. }
  62388. declare module BABYLON {
  62389. /**
  62390. * This represents a GPU particle system in Babylon
  62391. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62392. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62393. */
  62394. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62395. /**
  62396. * The layer mask we are rendering the particles through.
  62397. */
  62398. layerMask: number;
  62399. private _capacity;
  62400. private _activeCount;
  62401. private _currentActiveCount;
  62402. private _accumulatedCount;
  62403. private _renderEffect;
  62404. private _updateEffect;
  62405. private _buffer0;
  62406. private _buffer1;
  62407. private _spriteBuffer;
  62408. private _updateVAO;
  62409. private _renderVAO;
  62410. private _targetIndex;
  62411. private _sourceBuffer;
  62412. private _targetBuffer;
  62413. private _engine;
  62414. private _currentRenderId;
  62415. private _started;
  62416. private _stopped;
  62417. private _timeDelta;
  62418. private _randomTexture;
  62419. private _randomTexture2;
  62420. private _attributesStrideSize;
  62421. private _updateEffectOptions;
  62422. private _randomTextureSize;
  62423. private _actualFrame;
  62424. private readonly _rawTextureWidth;
  62425. /**
  62426. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62427. */
  62428. static get IsSupported(): boolean;
  62429. /**
  62430. * An event triggered when the system is disposed.
  62431. */
  62432. onDisposeObservable: Observable<GPUParticleSystem>;
  62433. /**
  62434. * Gets the maximum number of particles active at the same time.
  62435. * @returns The max number of active particles.
  62436. */
  62437. getCapacity(): number;
  62438. /**
  62439. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62440. * to override the particles.
  62441. */
  62442. forceDepthWrite: boolean;
  62443. /**
  62444. * Gets or set the number of active particles
  62445. */
  62446. get activeParticleCount(): number;
  62447. set activeParticleCount(value: number);
  62448. private _preWarmDone;
  62449. /**
  62450. * Is this system ready to be used/rendered
  62451. * @return true if the system is ready
  62452. */
  62453. isReady(): boolean;
  62454. /**
  62455. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62456. * @returns True if it has been started, otherwise false.
  62457. */
  62458. isStarted(): boolean;
  62459. /**
  62460. * Starts the particle system and begins to emit
  62461. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62462. */
  62463. start(delay?: number): void;
  62464. /**
  62465. * Stops the particle system.
  62466. */
  62467. stop(): void;
  62468. /**
  62469. * Remove all active particles
  62470. */
  62471. reset(): void;
  62472. /**
  62473. * Returns the string "GPUParticleSystem"
  62474. * @returns a string containing the class name
  62475. */
  62476. getClassName(): string;
  62477. private _colorGradientsTexture;
  62478. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62479. /**
  62480. * Adds a new color gradient
  62481. * @param gradient defines the gradient to use (between 0 and 1)
  62482. * @param color1 defines the color to affect to the specified gradient
  62483. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62484. * @returns the current particle system
  62485. */
  62486. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62487. /**
  62488. * Remove a specific color gradient
  62489. * @param gradient defines the gradient to remove
  62490. * @returns the current particle system
  62491. */
  62492. removeColorGradient(gradient: number): GPUParticleSystem;
  62493. private _angularSpeedGradientsTexture;
  62494. private _sizeGradientsTexture;
  62495. private _velocityGradientsTexture;
  62496. private _limitVelocityGradientsTexture;
  62497. private _dragGradientsTexture;
  62498. private _addFactorGradient;
  62499. /**
  62500. * Adds a new size gradient
  62501. * @param gradient defines the gradient to use (between 0 and 1)
  62502. * @param factor defines the size factor to affect to the specified gradient
  62503. * @returns the current particle system
  62504. */
  62505. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62506. /**
  62507. * Remove a specific size gradient
  62508. * @param gradient defines the gradient to remove
  62509. * @returns the current particle system
  62510. */
  62511. removeSizeGradient(gradient: number): GPUParticleSystem;
  62512. /**
  62513. * Adds a new angular speed gradient
  62514. * @param gradient defines the gradient to use (between 0 and 1)
  62515. * @param factor defines the angular speed to affect to the specified gradient
  62516. * @returns the current particle system
  62517. */
  62518. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62519. /**
  62520. * Remove a specific angular speed gradient
  62521. * @param gradient defines the gradient to remove
  62522. * @returns the current particle system
  62523. */
  62524. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62525. /**
  62526. * Adds a new velocity gradient
  62527. * @param gradient defines the gradient to use (between 0 and 1)
  62528. * @param factor defines the velocity to affect to the specified gradient
  62529. * @returns the current particle system
  62530. */
  62531. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62532. /**
  62533. * Remove a specific velocity gradient
  62534. * @param gradient defines the gradient to remove
  62535. * @returns the current particle system
  62536. */
  62537. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62538. /**
  62539. * Adds a new limit velocity gradient
  62540. * @param gradient defines the gradient to use (between 0 and 1)
  62541. * @param factor defines the limit velocity value to affect to the specified gradient
  62542. * @returns the current particle system
  62543. */
  62544. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62545. /**
  62546. * Remove a specific limit velocity gradient
  62547. * @param gradient defines the gradient to remove
  62548. * @returns the current particle system
  62549. */
  62550. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62551. /**
  62552. * Adds a new drag gradient
  62553. * @param gradient defines the gradient to use (between 0 and 1)
  62554. * @param factor defines the drag value to affect to the specified gradient
  62555. * @returns the current particle system
  62556. */
  62557. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62558. /**
  62559. * Remove a specific drag gradient
  62560. * @param gradient defines the gradient to remove
  62561. * @returns the current particle system
  62562. */
  62563. removeDragGradient(gradient: number): GPUParticleSystem;
  62564. /**
  62565. * Not supported by GPUParticleSystem
  62566. * @param gradient defines the gradient to use (between 0 and 1)
  62567. * @param factor defines the emit rate value to affect to the specified gradient
  62568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62569. * @returns the current particle system
  62570. */
  62571. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62572. /**
  62573. * Not supported by GPUParticleSystem
  62574. * @param gradient defines the gradient to remove
  62575. * @returns the current particle system
  62576. */
  62577. removeEmitRateGradient(gradient: number): IParticleSystem;
  62578. /**
  62579. * Not supported by GPUParticleSystem
  62580. * @param gradient defines the gradient to use (between 0 and 1)
  62581. * @param factor defines the start size value to affect to the specified gradient
  62582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62583. * @returns the current particle system
  62584. */
  62585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62586. /**
  62587. * Not supported by GPUParticleSystem
  62588. * @param gradient defines the gradient to remove
  62589. * @returns the current particle system
  62590. */
  62591. removeStartSizeGradient(gradient: number): IParticleSystem;
  62592. /**
  62593. * Not supported by GPUParticleSystem
  62594. * @param gradient defines the gradient to use (between 0 and 1)
  62595. * @param min defines the color remap minimal range
  62596. * @param max defines the color remap maximal range
  62597. * @returns the current particle system
  62598. */
  62599. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62600. /**
  62601. * Not supported by GPUParticleSystem
  62602. * @param gradient defines the gradient to remove
  62603. * @returns the current particle system
  62604. */
  62605. removeColorRemapGradient(): IParticleSystem;
  62606. /**
  62607. * Not supported by GPUParticleSystem
  62608. * @param gradient defines the gradient to use (between 0 and 1)
  62609. * @param min defines the alpha remap minimal range
  62610. * @param max defines the alpha remap maximal range
  62611. * @returns the current particle system
  62612. */
  62613. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62614. /**
  62615. * Not supported by GPUParticleSystem
  62616. * @param gradient defines the gradient to remove
  62617. * @returns the current particle system
  62618. */
  62619. removeAlphaRemapGradient(): IParticleSystem;
  62620. /**
  62621. * Not supported by GPUParticleSystem
  62622. * @param gradient defines the gradient to use (between 0 and 1)
  62623. * @param color defines the color to affect to the specified gradient
  62624. * @returns the current particle system
  62625. */
  62626. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62627. /**
  62628. * Not supported by GPUParticleSystem
  62629. * @param gradient defines the gradient to remove
  62630. * @returns the current particle system
  62631. */
  62632. removeRampGradient(): IParticleSystem;
  62633. /**
  62634. * Not supported by GPUParticleSystem
  62635. * @returns the list of ramp gradients
  62636. */
  62637. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62638. /**
  62639. * Not supported by GPUParticleSystem
  62640. * Gets or sets a boolean indicating that ramp gradients must be used
  62641. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62642. */
  62643. get useRampGradients(): boolean;
  62644. set useRampGradients(value: boolean);
  62645. /**
  62646. * Not supported by GPUParticleSystem
  62647. * @param gradient defines the gradient to use (between 0 and 1)
  62648. * @param factor defines the life time factor to affect to the specified gradient
  62649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62650. * @returns the current particle system
  62651. */
  62652. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62653. /**
  62654. * Not supported by GPUParticleSystem
  62655. * @param gradient defines the gradient to remove
  62656. * @returns the current particle system
  62657. */
  62658. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62659. /**
  62660. * Instantiates a GPU particle system.
  62661. * 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.
  62662. * @param name The name of the particle system
  62663. * @param options The options used to create the system
  62664. * @param scene The scene the particle system belongs to
  62665. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62666. */
  62667. constructor(name: string, options: Partial<{
  62668. capacity: number;
  62669. randomTextureSize: number;
  62670. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62671. protected _reset(): void;
  62672. private _createUpdateVAO;
  62673. private _createRenderVAO;
  62674. private _initialize;
  62675. /** @hidden */
  62676. _recreateUpdateEffect(): void;
  62677. /** @hidden */
  62678. _recreateRenderEffect(): void;
  62679. /**
  62680. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62681. * @param preWarm defines if we are in the pre-warmimg phase
  62682. */
  62683. animate(preWarm?: boolean): void;
  62684. private _createFactorGradientTexture;
  62685. private _createSizeGradientTexture;
  62686. private _createAngularSpeedGradientTexture;
  62687. private _createVelocityGradientTexture;
  62688. private _createLimitVelocityGradientTexture;
  62689. private _createDragGradientTexture;
  62690. private _createColorGradientTexture;
  62691. /**
  62692. * Renders the particle system in its current state
  62693. * @param preWarm defines if the system should only update the particles but not render them
  62694. * @returns the current number of particles
  62695. */
  62696. render(preWarm?: boolean): number;
  62697. /**
  62698. * Rebuilds the particle system
  62699. */
  62700. rebuild(): void;
  62701. private _releaseBuffers;
  62702. private _releaseVAOs;
  62703. /**
  62704. * Disposes the particle system and free the associated resources
  62705. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62706. */
  62707. dispose(disposeTexture?: boolean): void;
  62708. /**
  62709. * Clones the particle system.
  62710. * @param name The name of the cloned object
  62711. * @param newEmitter The new emitter to use
  62712. * @returns the cloned particle system
  62713. */
  62714. clone(name: string, newEmitter: any): GPUParticleSystem;
  62715. /**
  62716. * Serializes the particle system to a JSON object.
  62717. * @returns the JSON object
  62718. */
  62719. serialize(): any;
  62720. /**
  62721. * Parses a JSON object to create a GPU particle system.
  62722. * @param parsedParticleSystem The JSON object to parse
  62723. * @param scene The scene to create the particle system in
  62724. * @param rootUrl The root url to use to load external dependencies like texture
  62725. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62726. * @returns the parsed GPU particle system
  62727. */
  62728. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62729. }
  62730. }
  62731. declare module BABYLON {
  62732. /**
  62733. * Represents a set of particle systems working together to create a specific effect
  62734. */
  62735. export class ParticleSystemSet implements IDisposable {
  62736. /**
  62737. * Gets or sets base Assets URL
  62738. */
  62739. static BaseAssetsUrl: string;
  62740. private _emitterCreationOptions;
  62741. private _emitterNode;
  62742. /**
  62743. * Gets the particle system list
  62744. */
  62745. systems: IParticleSystem[];
  62746. /**
  62747. * Gets the emitter node used with this set
  62748. */
  62749. get emitterNode(): Nullable<TransformNode>;
  62750. /**
  62751. * Creates a new emitter mesh as a sphere
  62752. * @param options defines the options used to create the sphere
  62753. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62754. * @param scene defines the hosting scene
  62755. */
  62756. setEmitterAsSphere(options: {
  62757. diameter: number;
  62758. segments: number;
  62759. color: Color3;
  62760. }, renderingGroupId: number, scene: Scene): void;
  62761. /**
  62762. * Starts all particle systems of the set
  62763. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62764. */
  62765. start(emitter?: AbstractMesh): void;
  62766. /**
  62767. * Release all associated resources
  62768. */
  62769. dispose(): void;
  62770. /**
  62771. * Serialize the set into a JSON compatible object
  62772. * @returns a JSON compatible representation of the set
  62773. */
  62774. serialize(): any;
  62775. /**
  62776. * Parse a new ParticleSystemSet from a serialized source
  62777. * @param data defines a JSON compatible representation of the set
  62778. * @param scene defines the hosting scene
  62779. * @param gpu defines if we want GPU particles or CPU particles
  62780. * @returns a new ParticleSystemSet
  62781. */
  62782. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62783. }
  62784. }
  62785. declare module BABYLON {
  62786. /**
  62787. * This class is made for on one-liner static method to help creating particle system set.
  62788. */
  62789. export class ParticleHelper {
  62790. /**
  62791. * Gets or sets base Assets URL
  62792. */
  62793. static BaseAssetsUrl: string;
  62794. /**
  62795. * Create a default particle system that you can tweak
  62796. * @param emitter defines the emitter to use
  62797. * @param capacity defines the system capacity (default is 500 particles)
  62798. * @param scene defines the hosting scene
  62799. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62800. * @returns the new Particle system
  62801. */
  62802. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62803. /**
  62804. * This is the main static method (one-liner) of this helper to create different particle systems
  62805. * @param type This string represents the type to the particle system to create
  62806. * @param scene The scene where the particle system should live
  62807. * @param gpu If the system will use gpu
  62808. * @returns the ParticleSystemSet created
  62809. */
  62810. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62811. /**
  62812. * Static function used to export a particle system to a ParticleSystemSet variable.
  62813. * Please note that the emitter shape is not exported
  62814. * @param systems defines the particle systems to export
  62815. * @returns the created particle system set
  62816. */
  62817. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62818. }
  62819. }
  62820. declare module BABYLON {
  62821. interface Engine {
  62822. /**
  62823. * Create an effect to use with particle systems.
  62824. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62825. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62826. * @param uniformsNames defines a list of attribute names
  62827. * @param samplers defines an array of string used to represent textures
  62828. * @param defines defines the string containing the defines to use to compile the shaders
  62829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62830. * @param onCompiled defines a function to call when the effect creation is successful
  62831. * @param onError defines a function to call when the effect creation has failed
  62832. * @returns the new Effect
  62833. */
  62834. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62835. }
  62836. interface Mesh {
  62837. /**
  62838. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62839. * @returns an array of IParticleSystem
  62840. */
  62841. getEmittedParticleSystems(): IParticleSystem[];
  62842. /**
  62843. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62844. * @returns an array of IParticleSystem
  62845. */
  62846. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62847. }
  62848. /**
  62849. * @hidden
  62850. */
  62851. export var _IDoNeedToBeInTheBuild: number;
  62852. }
  62853. declare module BABYLON {
  62854. /** Defines the 4 color options */
  62855. export enum PointColor {
  62856. /** color value */
  62857. Color = 2,
  62858. /** uv value */
  62859. UV = 1,
  62860. /** random value */
  62861. Random = 0,
  62862. /** stated value */
  62863. Stated = 3
  62864. }
  62865. /**
  62866. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62867. * 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.
  62868. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62869. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62870. *
  62871. * Full documentation here : TO BE ENTERED
  62872. */
  62873. export class PointsCloudSystem implements IDisposable {
  62874. /**
  62875. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62876. * Example : var p = SPS.particles[i];
  62877. */
  62878. particles: CloudPoint[];
  62879. /**
  62880. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62881. */
  62882. nbParticles: number;
  62883. /**
  62884. * This a counter for your own usage. It's not set by any SPS functions.
  62885. */
  62886. counter: number;
  62887. /**
  62888. * The PCS name. This name is also given to the underlying mesh.
  62889. */
  62890. name: string;
  62891. /**
  62892. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62893. */
  62894. mesh: Mesh;
  62895. /**
  62896. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62897. * Please read :
  62898. */
  62899. vars: any;
  62900. /**
  62901. * @hidden
  62902. */
  62903. _size: number;
  62904. private _scene;
  62905. private _promises;
  62906. private _positions;
  62907. private _indices;
  62908. private _normals;
  62909. private _colors;
  62910. private _uvs;
  62911. private _indices32;
  62912. private _positions32;
  62913. private _colors32;
  62914. private _uvs32;
  62915. private _updatable;
  62916. private _isVisibilityBoxLocked;
  62917. private _alwaysVisible;
  62918. private _groups;
  62919. private _groupCounter;
  62920. private _computeParticleColor;
  62921. private _computeParticleTexture;
  62922. private _computeParticleRotation;
  62923. private _computeBoundingBox;
  62924. private _isReady;
  62925. /**
  62926. * Creates a PCS (Points Cloud System) object
  62927. * @param name (String) is the PCS name, this will be the underlying mesh name
  62928. * @param pointSize (number) is the size for each point
  62929. * @param scene (Scene) is the scene in which the PCS is added
  62930. * @param options defines the options of the PCS e.g.
  62931. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62932. */
  62933. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62934. updatable?: boolean;
  62935. });
  62936. /**
  62937. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62938. * If no points were added to the PCS, the returned mesh is just a single point.
  62939. * @returns a promise for the created mesh
  62940. */
  62941. buildMeshAsync(): Promise<Mesh>;
  62942. /**
  62943. * @hidden
  62944. */
  62945. private _buildMesh;
  62946. private _addParticle;
  62947. private _randomUnitVector;
  62948. private _getColorIndicesForCoord;
  62949. private _setPointsColorOrUV;
  62950. private _colorFromTexture;
  62951. private _calculateDensity;
  62952. /**
  62953. * Adds points to the PCS in random positions within a unit sphere
  62954. * @param nb (positive integer) the number of particles to be created from this model
  62955. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62956. * @returns the number of groups in the system
  62957. */
  62958. addPoints(nb: number, pointFunction?: any): number;
  62959. /**
  62960. * Adds points to the PCS from the surface of the model shape
  62961. * @param mesh is any Mesh object that will be used as a surface model for the points
  62962. * @param nb (positive integer) the number of particles to be created from this model
  62963. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62964. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62965. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62966. * @returns the number of groups in the system
  62967. */
  62968. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62969. /**
  62970. * Adds points to the PCS inside the model shape
  62971. * @param mesh is any Mesh object that will be used as a surface model for the points
  62972. * @param nb (positive integer) the number of particles to be created from this model
  62973. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62974. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62975. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62976. * @returns the number of groups in the system
  62977. */
  62978. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62979. /**
  62980. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62981. * This method calls `updateParticle()` for each particle of the SPS.
  62982. * For an animated SPS, it is usually called within the render loop.
  62983. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62984. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62985. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62986. * @returns the PCS.
  62987. */
  62988. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62989. /**
  62990. * Disposes the PCS.
  62991. */
  62992. dispose(): void;
  62993. /**
  62994. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62995. * doc :
  62996. * @returns the PCS.
  62997. */
  62998. refreshVisibleSize(): PointsCloudSystem;
  62999. /**
  63000. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63001. * @param size the size (float) of the visibility box
  63002. * note : this doesn't lock the PCS mesh bounding box.
  63003. * doc :
  63004. */
  63005. setVisibilityBox(size: number): void;
  63006. /**
  63007. * Gets whether the PCS is always visible or not
  63008. * doc :
  63009. */
  63010. get isAlwaysVisible(): boolean;
  63011. /**
  63012. * Sets the PCS as always visible or not
  63013. * doc :
  63014. */
  63015. set isAlwaysVisible(val: boolean);
  63016. /**
  63017. * Tells to `setParticles()` to compute the particle rotations or not
  63018. * Default value : false. The PCS is faster when it's set to false
  63019. * Note : particle rotations are only applied to parent particles
  63020. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63021. */
  63022. set computeParticleRotation(val: boolean);
  63023. /**
  63024. * Tells to `setParticles()` to compute the particle colors or not.
  63025. * Default value : true. The PCS is faster when it's set to false.
  63026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63027. */
  63028. set computeParticleColor(val: boolean);
  63029. set computeParticleTexture(val: boolean);
  63030. /**
  63031. * Gets if `setParticles()` computes the particle colors or not.
  63032. * Default value : false. The PCS is faster when it's set to false.
  63033. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63034. */
  63035. get computeParticleColor(): boolean;
  63036. /**
  63037. * Gets if `setParticles()` computes the particle textures or not.
  63038. * Default value : false. The PCS is faster when it's set to false.
  63039. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63040. */
  63041. get computeParticleTexture(): boolean;
  63042. /**
  63043. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63044. */
  63045. set computeBoundingBox(val: boolean);
  63046. /**
  63047. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63048. */
  63049. get computeBoundingBox(): boolean;
  63050. /**
  63051. * This function does nothing. It may be overwritten to set all the particle first values.
  63052. * The PCS doesn't call this function, you may have to call it by your own.
  63053. * doc :
  63054. */
  63055. initParticles(): void;
  63056. /**
  63057. * This function does nothing. It may be overwritten to recycle a particle
  63058. * The PCS doesn't call this function, you can to call it
  63059. * doc :
  63060. * @param particle The particle to recycle
  63061. * @returns the recycled particle
  63062. */
  63063. recycleParticle(particle: CloudPoint): CloudPoint;
  63064. /**
  63065. * Updates a particle : this function should be overwritten by the user.
  63066. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63067. * doc :
  63068. * @example : just set a particle position or velocity and recycle conditions
  63069. * @param particle The particle to update
  63070. * @returns the updated particle
  63071. */
  63072. updateParticle(particle: CloudPoint): CloudPoint;
  63073. /**
  63074. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63075. * This does nothing and may be overwritten by the user.
  63076. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63077. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63078. * @param update the boolean update value actually passed to setParticles()
  63079. */
  63080. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63081. /**
  63082. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63083. * This will be passed three parameters.
  63084. * This does nothing and may be overwritten by the user.
  63085. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63086. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63087. * @param update the boolean update value actually passed to setParticles()
  63088. */
  63089. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63090. }
  63091. }
  63092. declare module BABYLON {
  63093. /**
  63094. * Represents one particle of a points cloud system.
  63095. */
  63096. export class CloudPoint {
  63097. /**
  63098. * particle global index
  63099. */
  63100. idx: number;
  63101. /**
  63102. * The color of the particle
  63103. */
  63104. color: Nullable<Color4>;
  63105. /**
  63106. * The world space position of the particle.
  63107. */
  63108. position: Vector3;
  63109. /**
  63110. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63111. */
  63112. rotation: Vector3;
  63113. /**
  63114. * The world space rotation quaternion of the particle.
  63115. */
  63116. rotationQuaternion: Nullable<Quaternion>;
  63117. /**
  63118. * The uv of the particle.
  63119. */
  63120. uv: Nullable<Vector2>;
  63121. /**
  63122. * The current speed of the particle.
  63123. */
  63124. velocity: Vector3;
  63125. /**
  63126. * The pivot point in the particle local space.
  63127. */
  63128. pivot: Vector3;
  63129. /**
  63130. * Must the particle be translated from its pivot point in its local space ?
  63131. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63132. * Default : false
  63133. */
  63134. translateFromPivot: boolean;
  63135. /**
  63136. * Index of this particle in the global "positions" array (Internal use)
  63137. * @hidden
  63138. */
  63139. _pos: number;
  63140. /**
  63141. * @hidden Index of this particle in the global "indices" array (Internal use)
  63142. */
  63143. _ind: number;
  63144. /**
  63145. * Group this particle belongs to
  63146. */
  63147. _group: PointsGroup;
  63148. /**
  63149. * Group id of this particle
  63150. */
  63151. groupId: number;
  63152. /**
  63153. * Index of the particle in its group id (Internal use)
  63154. */
  63155. idxInGroup: number;
  63156. /**
  63157. * @hidden Particle BoundingInfo object (Internal use)
  63158. */
  63159. _boundingInfo: BoundingInfo;
  63160. /**
  63161. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63162. */
  63163. _pcs: PointsCloudSystem;
  63164. /**
  63165. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63166. */
  63167. _stillInvisible: boolean;
  63168. /**
  63169. * @hidden Last computed particle rotation matrix
  63170. */
  63171. _rotationMatrix: number[];
  63172. /**
  63173. * Parent particle Id, if any.
  63174. * Default null.
  63175. */
  63176. parentId: Nullable<number>;
  63177. /**
  63178. * @hidden Internal global position in the PCS.
  63179. */
  63180. _globalPosition: Vector3;
  63181. /**
  63182. * Creates a Point Cloud object.
  63183. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63184. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63185. * @param group (PointsGroup) is the group the particle belongs to
  63186. * @param groupId (integer) is the group identifier in the PCS.
  63187. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63188. * @param pcs defines the PCS it is associated to
  63189. */
  63190. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63191. /**
  63192. * get point size
  63193. */
  63194. get size(): Vector3;
  63195. /**
  63196. * Set point size
  63197. */
  63198. set size(scale: Vector3);
  63199. /**
  63200. * Legacy support, changed quaternion to rotationQuaternion
  63201. */
  63202. get quaternion(): Nullable<Quaternion>;
  63203. /**
  63204. * Legacy support, changed quaternion to rotationQuaternion
  63205. */
  63206. set quaternion(q: Nullable<Quaternion>);
  63207. /**
  63208. * Returns a boolean. True if the particle intersects a mesh, else false
  63209. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63210. * @param target is the object (point or mesh) what the intersection is computed against
  63211. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63212. * @returns true if it intersects
  63213. */
  63214. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63215. /**
  63216. * get the rotation matrix of the particle
  63217. * @hidden
  63218. */
  63219. getRotationMatrix(m: Matrix): void;
  63220. }
  63221. /**
  63222. * Represents a group of points in a points cloud system
  63223. * * PCS internal tool, don't use it manually.
  63224. */
  63225. export class PointsGroup {
  63226. /**
  63227. * The group id
  63228. * @hidden
  63229. */
  63230. groupID: number;
  63231. /**
  63232. * image data for group (internal use)
  63233. * @hidden
  63234. */
  63235. _groupImageData: Nullable<ArrayBufferView>;
  63236. /**
  63237. * Image Width (internal use)
  63238. * @hidden
  63239. */
  63240. _groupImgWidth: number;
  63241. /**
  63242. * Image Height (internal use)
  63243. * @hidden
  63244. */
  63245. _groupImgHeight: number;
  63246. /**
  63247. * Custom position function (internal use)
  63248. * @hidden
  63249. */
  63250. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63251. /**
  63252. * density per facet for surface points
  63253. * @hidden
  63254. */
  63255. _groupDensity: number[];
  63256. /**
  63257. * Only when points are colored by texture carries pointer to texture list array
  63258. * @hidden
  63259. */
  63260. _textureNb: number;
  63261. /**
  63262. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63263. * PCS internal tool, don't use it manually.
  63264. * @hidden
  63265. */
  63266. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63267. }
  63268. }
  63269. declare module BABYLON {
  63270. interface Scene {
  63271. /** @hidden (Backing field) */
  63272. _physicsEngine: Nullable<IPhysicsEngine>;
  63273. /** @hidden */
  63274. _physicsTimeAccumulator: number;
  63275. /**
  63276. * Gets the current physics engine
  63277. * @returns a IPhysicsEngine or null if none attached
  63278. */
  63279. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63280. /**
  63281. * Enables physics to the current scene
  63282. * @param gravity defines the scene's gravity for the physics engine
  63283. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63284. * @return a boolean indicating if the physics engine was initialized
  63285. */
  63286. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63287. /**
  63288. * Disables and disposes the physics engine associated with the scene
  63289. */
  63290. disablePhysicsEngine(): void;
  63291. /**
  63292. * Gets a boolean indicating if there is an active physics engine
  63293. * @returns a boolean indicating if there is an active physics engine
  63294. */
  63295. isPhysicsEnabled(): boolean;
  63296. /**
  63297. * Deletes a physics compound impostor
  63298. * @param compound defines the compound to delete
  63299. */
  63300. deleteCompoundImpostor(compound: any): void;
  63301. /**
  63302. * An event triggered when physic simulation is about to be run
  63303. */
  63304. onBeforePhysicsObservable: Observable<Scene>;
  63305. /**
  63306. * An event triggered when physic simulation has been done
  63307. */
  63308. onAfterPhysicsObservable: Observable<Scene>;
  63309. }
  63310. interface AbstractMesh {
  63311. /** @hidden */
  63312. _physicsImpostor: Nullable<PhysicsImpostor>;
  63313. /**
  63314. * Gets or sets impostor used for physic simulation
  63315. * @see http://doc.babylonjs.com/features/physics_engine
  63316. */
  63317. physicsImpostor: Nullable<PhysicsImpostor>;
  63318. /**
  63319. * Gets the current physics impostor
  63320. * @see http://doc.babylonjs.com/features/physics_engine
  63321. * @returns a physics impostor or null
  63322. */
  63323. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63324. /** Apply a physic impulse to the mesh
  63325. * @param force defines the force to apply
  63326. * @param contactPoint defines where to apply the force
  63327. * @returns the current mesh
  63328. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63329. */
  63330. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63331. /**
  63332. * Creates a physic joint between two meshes
  63333. * @param otherMesh defines the other mesh to use
  63334. * @param pivot1 defines the pivot to use on this mesh
  63335. * @param pivot2 defines the pivot to use on the other mesh
  63336. * @param options defines additional options (can be plugin dependent)
  63337. * @returns the current mesh
  63338. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63339. */
  63340. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63341. /** @hidden */
  63342. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63343. }
  63344. /**
  63345. * Defines the physics engine scene component responsible to manage a physics engine
  63346. */
  63347. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63348. /**
  63349. * The component name helpful to identify the component in the list of scene components.
  63350. */
  63351. readonly name: string;
  63352. /**
  63353. * The scene the component belongs to.
  63354. */
  63355. scene: Scene;
  63356. /**
  63357. * Creates a new instance of the component for the given scene
  63358. * @param scene Defines the scene to register the component in
  63359. */
  63360. constructor(scene: Scene);
  63361. /**
  63362. * Registers the component in a given scene
  63363. */
  63364. register(): void;
  63365. /**
  63366. * Rebuilds the elements related to this component in case of
  63367. * context lost for instance.
  63368. */
  63369. rebuild(): void;
  63370. /**
  63371. * Disposes the component and the associated ressources
  63372. */
  63373. dispose(): void;
  63374. }
  63375. }
  63376. declare module BABYLON {
  63377. /**
  63378. * A helper for physics simulations
  63379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63380. */
  63381. export class PhysicsHelper {
  63382. private _scene;
  63383. private _physicsEngine;
  63384. /**
  63385. * Initializes the Physics helper
  63386. * @param scene Babylon.js scene
  63387. */
  63388. constructor(scene: Scene);
  63389. /**
  63390. * Applies a radial explosion impulse
  63391. * @param origin the origin of the explosion
  63392. * @param radiusOrEventOptions the radius or the options of radial explosion
  63393. * @param strength the explosion strength
  63394. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63395. * @returns A physics radial explosion event, or null
  63396. */
  63397. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63398. /**
  63399. * Applies a radial explosion force
  63400. * @param origin the origin of the explosion
  63401. * @param radiusOrEventOptions the radius or the options of radial explosion
  63402. * @param strength the explosion strength
  63403. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63404. * @returns A physics radial explosion event, or null
  63405. */
  63406. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63407. /**
  63408. * Creates a gravitational field
  63409. * @param origin the origin of the explosion
  63410. * @param radiusOrEventOptions the radius or the options of radial explosion
  63411. * @param strength the explosion strength
  63412. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63413. * @returns A physics gravitational field event, or null
  63414. */
  63415. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63416. /**
  63417. * Creates a physics updraft event
  63418. * @param origin the origin of the updraft
  63419. * @param radiusOrEventOptions the radius or the options of the updraft
  63420. * @param strength the strength of the updraft
  63421. * @param height the height of the updraft
  63422. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63423. * @returns A physics updraft event, or null
  63424. */
  63425. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63426. /**
  63427. * Creates a physics vortex event
  63428. * @param origin the of the vortex
  63429. * @param radiusOrEventOptions the radius or the options of the vortex
  63430. * @param strength the strength of the vortex
  63431. * @param height the height of the vortex
  63432. * @returns a Physics vortex event, or null
  63433. * A physics vortex event or null
  63434. */
  63435. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63436. }
  63437. /**
  63438. * Represents a physics radial explosion event
  63439. */
  63440. class PhysicsRadialExplosionEvent {
  63441. private _scene;
  63442. private _options;
  63443. private _sphere;
  63444. private _dataFetched;
  63445. /**
  63446. * Initializes a radial explosioin event
  63447. * @param _scene BabylonJS scene
  63448. * @param _options The options for the vortex event
  63449. */
  63450. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63451. /**
  63452. * Returns the data related to the radial explosion event (sphere).
  63453. * @returns The radial explosion event data
  63454. */
  63455. getData(): PhysicsRadialExplosionEventData;
  63456. /**
  63457. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63458. * @param impostor A physics imposter
  63459. * @param origin the origin of the explosion
  63460. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63461. */
  63462. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63463. /**
  63464. * Triggers affecterd impostors callbacks
  63465. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63466. */
  63467. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63468. /**
  63469. * Disposes the sphere.
  63470. * @param force Specifies if the sphere should be disposed by force
  63471. */
  63472. dispose(force?: boolean): void;
  63473. /*** Helpers ***/
  63474. private _prepareSphere;
  63475. private _intersectsWithSphere;
  63476. }
  63477. /**
  63478. * Represents a gravitational field event
  63479. */
  63480. class PhysicsGravitationalFieldEvent {
  63481. private _physicsHelper;
  63482. private _scene;
  63483. private _origin;
  63484. private _options;
  63485. private _tickCallback;
  63486. private _sphere;
  63487. private _dataFetched;
  63488. /**
  63489. * Initializes the physics gravitational field event
  63490. * @param _physicsHelper A physics helper
  63491. * @param _scene BabylonJS scene
  63492. * @param _origin The origin position of the gravitational field event
  63493. * @param _options The options for the vortex event
  63494. */
  63495. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63496. /**
  63497. * Returns the data related to the gravitational field event (sphere).
  63498. * @returns A gravitational field event
  63499. */
  63500. getData(): PhysicsGravitationalFieldEventData;
  63501. /**
  63502. * Enables the gravitational field.
  63503. */
  63504. enable(): void;
  63505. /**
  63506. * Disables the gravitational field.
  63507. */
  63508. disable(): void;
  63509. /**
  63510. * Disposes the sphere.
  63511. * @param force The force to dispose from the gravitational field event
  63512. */
  63513. dispose(force?: boolean): void;
  63514. private _tick;
  63515. }
  63516. /**
  63517. * Represents a physics updraft event
  63518. */
  63519. class PhysicsUpdraftEvent {
  63520. private _scene;
  63521. private _origin;
  63522. private _options;
  63523. private _physicsEngine;
  63524. private _originTop;
  63525. private _originDirection;
  63526. private _tickCallback;
  63527. private _cylinder;
  63528. private _cylinderPosition;
  63529. private _dataFetched;
  63530. /**
  63531. * Initializes the physics updraft event
  63532. * @param _scene BabylonJS scene
  63533. * @param _origin The origin position of the updraft
  63534. * @param _options The options for the updraft event
  63535. */
  63536. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63537. /**
  63538. * Returns the data related to the updraft event (cylinder).
  63539. * @returns A physics updraft event
  63540. */
  63541. getData(): PhysicsUpdraftEventData;
  63542. /**
  63543. * Enables the updraft.
  63544. */
  63545. enable(): void;
  63546. /**
  63547. * Disables the updraft.
  63548. */
  63549. disable(): void;
  63550. /**
  63551. * Disposes the cylinder.
  63552. * @param force Specifies if the updraft should be disposed by force
  63553. */
  63554. dispose(force?: boolean): void;
  63555. private getImpostorHitData;
  63556. private _tick;
  63557. /*** Helpers ***/
  63558. private _prepareCylinder;
  63559. private _intersectsWithCylinder;
  63560. }
  63561. /**
  63562. * Represents a physics vortex event
  63563. */
  63564. class PhysicsVortexEvent {
  63565. private _scene;
  63566. private _origin;
  63567. private _options;
  63568. private _physicsEngine;
  63569. private _originTop;
  63570. private _tickCallback;
  63571. private _cylinder;
  63572. private _cylinderPosition;
  63573. private _dataFetched;
  63574. /**
  63575. * Initializes the physics vortex event
  63576. * @param _scene The BabylonJS scene
  63577. * @param _origin The origin position of the vortex
  63578. * @param _options The options for the vortex event
  63579. */
  63580. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63581. /**
  63582. * Returns the data related to the vortex event (cylinder).
  63583. * @returns The physics vortex event data
  63584. */
  63585. getData(): PhysicsVortexEventData;
  63586. /**
  63587. * Enables the vortex.
  63588. */
  63589. enable(): void;
  63590. /**
  63591. * Disables the cortex.
  63592. */
  63593. disable(): void;
  63594. /**
  63595. * Disposes the sphere.
  63596. * @param force
  63597. */
  63598. dispose(force?: boolean): void;
  63599. private getImpostorHitData;
  63600. private _tick;
  63601. /*** Helpers ***/
  63602. private _prepareCylinder;
  63603. private _intersectsWithCylinder;
  63604. }
  63605. /**
  63606. * Options fot the radial explosion event
  63607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63608. */
  63609. export class PhysicsRadialExplosionEventOptions {
  63610. /**
  63611. * The radius of the sphere for the radial explosion.
  63612. */
  63613. radius: number;
  63614. /**
  63615. * The strenth of the explosion.
  63616. */
  63617. strength: number;
  63618. /**
  63619. * The strenght of the force in correspondence to the distance of the affected object
  63620. */
  63621. falloff: PhysicsRadialImpulseFalloff;
  63622. /**
  63623. * Sphere options for the radial explosion.
  63624. */
  63625. sphere: {
  63626. segments: number;
  63627. diameter: number;
  63628. };
  63629. /**
  63630. * Sphere options for the radial explosion.
  63631. */
  63632. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63633. }
  63634. /**
  63635. * Options fot the updraft event
  63636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63637. */
  63638. export class PhysicsUpdraftEventOptions {
  63639. /**
  63640. * The radius of the cylinder for the vortex
  63641. */
  63642. radius: number;
  63643. /**
  63644. * The strenth of the updraft.
  63645. */
  63646. strength: number;
  63647. /**
  63648. * The height of the cylinder for the updraft.
  63649. */
  63650. height: number;
  63651. /**
  63652. * The mode for the the updraft.
  63653. */
  63654. updraftMode: PhysicsUpdraftMode;
  63655. }
  63656. /**
  63657. * Options fot the vortex event
  63658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63659. */
  63660. export class PhysicsVortexEventOptions {
  63661. /**
  63662. * The radius of the cylinder for the vortex
  63663. */
  63664. radius: number;
  63665. /**
  63666. * The strenth of the vortex.
  63667. */
  63668. strength: number;
  63669. /**
  63670. * The height of the cylinder for the vortex.
  63671. */
  63672. height: number;
  63673. /**
  63674. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63675. */
  63676. centripetalForceThreshold: number;
  63677. /**
  63678. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63679. */
  63680. centripetalForceMultiplier: number;
  63681. /**
  63682. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63683. */
  63684. centrifugalForceMultiplier: number;
  63685. /**
  63686. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63687. */
  63688. updraftForceMultiplier: number;
  63689. }
  63690. /**
  63691. * The strenght of the force in correspondence to the distance of the affected object
  63692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63693. */
  63694. export enum PhysicsRadialImpulseFalloff {
  63695. /** Defines that impulse is constant in strength across it's whole radius */
  63696. Constant = 0,
  63697. /** Defines that impulse gets weaker if it's further from the origin */
  63698. Linear = 1
  63699. }
  63700. /**
  63701. * The strength of the force in correspondence to the distance of the affected object
  63702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63703. */
  63704. export enum PhysicsUpdraftMode {
  63705. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63706. Center = 0,
  63707. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63708. Perpendicular = 1
  63709. }
  63710. /**
  63711. * Interface for a physics hit data
  63712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63713. */
  63714. export interface PhysicsHitData {
  63715. /**
  63716. * The force applied at the contact point
  63717. */
  63718. force: Vector3;
  63719. /**
  63720. * The contact point
  63721. */
  63722. contactPoint: Vector3;
  63723. /**
  63724. * The distance from the origin to the contact point
  63725. */
  63726. distanceFromOrigin: number;
  63727. }
  63728. /**
  63729. * Interface for radial explosion event data
  63730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63731. */
  63732. export interface PhysicsRadialExplosionEventData {
  63733. /**
  63734. * A sphere used for the radial explosion event
  63735. */
  63736. sphere: Mesh;
  63737. }
  63738. /**
  63739. * Interface for gravitational field event data
  63740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63741. */
  63742. export interface PhysicsGravitationalFieldEventData {
  63743. /**
  63744. * A sphere mesh used for the gravitational field event
  63745. */
  63746. sphere: Mesh;
  63747. }
  63748. /**
  63749. * Interface for updraft event data
  63750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63751. */
  63752. export interface PhysicsUpdraftEventData {
  63753. /**
  63754. * A cylinder used for the updraft event
  63755. */
  63756. cylinder: Mesh;
  63757. }
  63758. /**
  63759. * Interface for vortex event data
  63760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63761. */
  63762. export interface PhysicsVortexEventData {
  63763. /**
  63764. * A cylinder used for the vortex event
  63765. */
  63766. cylinder: Mesh;
  63767. }
  63768. /**
  63769. * Interface for an affected physics impostor
  63770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63771. */
  63772. export interface PhysicsAffectedImpostorWithData {
  63773. /**
  63774. * The impostor affected by the effect
  63775. */
  63776. impostor: PhysicsImpostor;
  63777. /**
  63778. * The data about the hit/horce from the explosion
  63779. */
  63780. hitData: PhysicsHitData;
  63781. }
  63782. }
  63783. declare module BABYLON {
  63784. /** @hidden */
  63785. export var blackAndWhitePixelShader: {
  63786. name: string;
  63787. shader: string;
  63788. };
  63789. }
  63790. declare module BABYLON {
  63791. /**
  63792. * Post process used to render in black and white
  63793. */
  63794. export class BlackAndWhitePostProcess extends PostProcess {
  63795. /**
  63796. * Linear about to convert he result to black and white (default: 1)
  63797. */
  63798. degree: number;
  63799. /**
  63800. * Creates a black and white post process
  63801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63802. * @param name The name of the effect.
  63803. * @param options The required width/height ratio to downsize to before computing the render pass.
  63804. * @param camera The camera to apply the render pass to.
  63805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63806. * @param engine The engine which the post process will be applied. (default: current engine)
  63807. * @param reusable If the post process can be reused on the same frame. (default: false)
  63808. */
  63809. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63810. }
  63811. }
  63812. declare module BABYLON {
  63813. /**
  63814. * This represents a set of one or more post processes in Babylon.
  63815. * A post process can be used to apply a shader to a texture after it is rendered.
  63816. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63817. */
  63818. export class PostProcessRenderEffect {
  63819. private _postProcesses;
  63820. private _getPostProcesses;
  63821. private _singleInstance;
  63822. private _cameras;
  63823. private _indicesForCamera;
  63824. /**
  63825. * Name of the effect
  63826. * @hidden
  63827. */
  63828. _name: string;
  63829. /**
  63830. * Instantiates a post process render effect.
  63831. * A post process can be used to apply a shader to a texture after it is rendered.
  63832. * @param engine The engine the effect is tied to
  63833. * @param name The name of the effect
  63834. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63835. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63836. */
  63837. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63838. /**
  63839. * Checks if all the post processes in the effect are supported.
  63840. */
  63841. get isSupported(): boolean;
  63842. /**
  63843. * Updates the current state of the effect
  63844. * @hidden
  63845. */
  63846. _update(): void;
  63847. /**
  63848. * Attaches the effect on cameras
  63849. * @param cameras The camera to attach to.
  63850. * @hidden
  63851. */
  63852. _attachCameras(cameras: Camera): void;
  63853. /**
  63854. * Attaches the effect on cameras
  63855. * @param cameras The camera to attach to.
  63856. * @hidden
  63857. */
  63858. _attachCameras(cameras: Camera[]): void;
  63859. /**
  63860. * Detaches the effect on cameras
  63861. * @param cameras The camera to detatch from.
  63862. * @hidden
  63863. */
  63864. _detachCameras(cameras: Camera): void;
  63865. /**
  63866. * Detatches the effect on cameras
  63867. * @param cameras The camera to detatch from.
  63868. * @hidden
  63869. */
  63870. _detachCameras(cameras: Camera[]): void;
  63871. /**
  63872. * Enables the effect on given cameras
  63873. * @param cameras The camera to enable.
  63874. * @hidden
  63875. */
  63876. _enable(cameras: Camera): void;
  63877. /**
  63878. * Enables the effect on given cameras
  63879. * @param cameras The camera to enable.
  63880. * @hidden
  63881. */
  63882. _enable(cameras: Nullable<Camera[]>): void;
  63883. /**
  63884. * Disables the effect on the given cameras
  63885. * @param cameras The camera to disable.
  63886. * @hidden
  63887. */
  63888. _disable(cameras: Camera): void;
  63889. /**
  63890. * Disables the effect on the given cameras
  63891. * @param cameras The camera to disable.
  63892. * @hidden
  63893. */
  63894. _disable(cameras: Nullable<Camera[]>): void;
  63895. /**
  63896. * Gets a list of the post processes contained in the effect.
  63897. * @param camera The camera to get the post processes on.
  63898. * @returns The list of the post processes in the effect.
  63899. */
  63900. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63901. }
  63902. }
  63903. declare module BABYLON {
  63904. /** @hidden */
  63905. export var extractHighlightsPixelShader: {
  63906. name: string;
  63907. shader: string;
  63908. };
  63909. }
  63910. declare module BABYLON {
  63911. /**
  63912. * 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.
  63913. */
  63914. export class ExtractHighlightsPostProcess extends PostProcess {
  63915. /**
  63916. * The luminance threshold, pixels below this value will be set to black.
  63917. */
  63918. threshold: number;
  63919. /** @hidden */
  63920. _exposure: number;
  63921. /**
  63922. * Post process which has the input texture to be used when performing highlight extraction
  63923. * @hidden
  63924. */
  63925. _inputPostProcess: Nullable<PostProcess>;
  63926. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63927. }
  63928. }
  63929. declare module BABYLON {
  63930. /** @hidden */
  63931. export var bloomMergePixelShader: {
  63932. name: string;
  63933. shader: string;
  63934. };
  63935. }
  63936. declare module BABYLON {
  63937. /**
  63938. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63939. */
  63940. export class BloomMergePostProcess extends PostProcess {
  63941. /** Weight of the bloom to be added to the original input. */
  63942. weight: number;
  63943. /**
  63944. * Creates a new instance of @see BloomMergePostProcess
  63945. * @param name The name of the effect.
  63946. * @param originalFromInput Post process which's input will be used for the merge.
  63947. * @param blurred Blurred highlights post process which's output will be used.
  63948. * @param weight Weight of the bloom to be added to the original input.
  63949. * @param options The required width/height ratio to downsize to before computing the render pass.
  63950. * @param camera The camera to apply the render pass to.
  63951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63952. * @param engine The engine which the post process will be applied. (default: current engine)
  63953. * @param reusable If the post process can be reused on the same frame. (default: false)
  63954. * @param textureType Type of textures used when performing the post process. (default: 0)
  63955. * @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)
  63956. */
  63957. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63958. /** Weight of the bloom to be added to the original input. */
  63959. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63960. }
  63961. }
  63962. declare module BABYLON {
  63963. /**
  63964. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63965. */
  63966. export class BloomEffect extends PostProcessRenderEffect {
  63967. private bloomScale;
  63968. /**
  63969. * @hidden Internal
  63970. */
  63971. _effects: Array<PostProcess>;
  63972. /**
  63973. * @hidden Internal
  63974. */
  63975. _downscale: ExtractHighlightsPostProcess;
  63976. private _blurX;
  63977. private _blurY;
  63978. private _merge;
  63979. /**
  63980. * The luminance threshold to find bright areas of the image to bloom.
  63981. */
  63982. get threshold(): number;
  63983. set threshold(value: number);
  63984. /**
  63985. * The strength of the bloom.
  63986. */
  63987. get weight(): number;
  63988. set weight(value: number);
  63989. /**
  63990. * Specifies the size of the bloom blur kernel, relative to the final output size
  63991. */
  63992. get kernel(): number;
  63993. set kernel(value: number);
  63994. /**
  63995. * Creates a new instance of @see BloomEffect
  63996. * @param scene The scene the effect belongs to.
  63997. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63998. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63999. * @param bloomWeight The the strength of bloom.
  64000. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64001. * @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)
  64002. */
  64003. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64004. /**
  64005. * Disposes each of the internal effects for a given camera.
  64006. * @param camera The camera to dispose the effect on.
  64007. */
  64008. disposeEffects(camera: Camera): void;
  64009. /**
  64010. * @hidden Internal
  64011. */
  64012. _updateEffects(): void;
  64013. /**
  64014. * Internal
  64015. * @returns if all the contained post processes are ready.
  64016. * @hidden
  64017. */
  64018. _isReady(): boolean;
  64019. }
  64020. }
  64021. declare module BABYLON {
  64022. /** @hidden */
  64023. export var chromaticAberrationPixelShader: {
  64024. name: string;
  64025. shader: string;
  64026. };
  64027. }
  64028. declare module BABYLON {
  64029. /**
  64030. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64031. */
  64032. export class ChromaticAberrationPostProcess extends PostProcess {
  64033. /**
  64034. * The amount of seperation of rgb channels (default: 30)
  64035. */
  64036. aberrationAmount: number;
  64037. /**
  64038. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64039. */
  64040. radialIntensity: number;
  64041. /**
  64042. * 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))
  64043. */
  64044. direction: Vector2;
  64045. /**
  64046. * 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))
  64047. */
  64048. centerPosition: Vector2;
  64049. /**
  64050. * Creates a new instance ChromaticAberrationPostProcess
  64051. * @param name The name of the effect.
  64052. * @param screenWidth The width of the screen to apply the effect on.
  64053. * @param screenHeight The height of the screen to apply the effect on.
  64054. * @param options The required width/height ratio to downsize to before computing the render pass.
  64055. * @param camera The camera to apply the render pass to.
  64056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64057. * @param engine The engine which the post process will be applied. (default: current engine)
  64058. * @param reusable If the post process can be reused on the same frame. (default: false)
  64059. * @param textureType Type of textures used when performing the post process. (default: 0)
  64060. * @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)
  64061. */
  64062. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64063. }
  64064. }
  64065. declare module BABYLON {
  64066. /** @hidden */
  64067. export var circleOfConfusionPixelShader: {
  64068. name: string;
  64069. shader: string;
  64070. };
  64071. }
  64072. declare module BABYLON {
  64073. /**
  64074. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64075. */
  64076. export class CircleOfConfusionPostProcess extends PostProcess {
  64077. /**
  64078. * 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.
  64079. */
  64080. lensSize: number;
  64081. /**
  64082. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64083. */
  64084. fStop: number;
  64085. /**
  64086. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64087. */
  64088. focusDistance: number;
  64089. /**
  64090. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64091. */
  64092. focalLength: number;
  64093. private _depthTexture;
  64094. /**
  64095. * Creates a new instance CircleOfConfusionPostProcess
  64096. * @param name The name of the effect.
  64097. * @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.
  64098. * @param options The required width/height ratio to downsize to before computing the render pass.
  64099. * @param camera The camera to apply the render pass to.
  64100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64101. * @param engine The engine which the post process will be applied. (default: current engine)
  64102. * @param reusable If the post process can be reused on the same frame. (default: false)
  64103. * @param textureType Type of textures used when performing the post process. (default: 0)
  64104. * @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)
  64105. */
  64106. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64107. /**
  64108. * 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.
  64109. */
  64110. set depthTexture(value: RenderTargetTexture);
  64111. }
  64112. }
  64113. declare module BABYLON {
  64114. /** @hidden */
  64115. export var colorCorrectionPixelShader: {
  64116. name: string;
  64117. shader: string;
  64118. };
  64119. }
  64120. declare module BABYLON {
  64121. /**
  64122. *
  64123. * This post-process allows the modification of rendered colors by using
  64124. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64125. *
  64126. * The object needs to be provided an url to a texture containing the color
  64127. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64128. * Use an image editing software to tweak the LUT to match your needs.
  64129. *
  64130. * For an example of a color LUT, see here:
  64131. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64132. * For explanations on color grading, see here:
  64133. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64134. *
  64135. */
  64136. export class ColorCorrectionPostProcess extends PostProcess {
  64137. private _colorTableTexture;
  64138. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64139. }
  64140. }
  64141. declare module BABYLON {
  64142. /** @hidden */
  64143. export var convolutionPixelShader: {
  64144. name: string;
  64145. shader: string;
  64146. };
  64147. }
  64148. declare module BABYLON {
  64149. /**
  64150. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64151. * input texture to perform effects such as edge detection or sharpening
  64152. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64153. */
  64154. export class ConvolutionPostProcess extends PostProcess {
  64155. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64156. kernel: number[];
  64157. /**
  64158. * Creates a new instance ConvolutionPostProcess
  64159. * @param name The name of the effect.
  64160. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64161. * @param options The required width/height ratio to downsize to before computing the render pass.
  64162. * @param camera The camera to apply the render pass to.
  64163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64164. * @param engine The engine which the post process will be applied. (default: current engine)
  64165. * @param reusable If the post process can be reused on the same frame. (default: false)
  64166. * @param textureType Type of textures used when performing the post process. (default: 0)
  64167. */
  64168. constructor(name: string,
  64169. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64170. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64171. /**
  64172. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64173. */
  64174. static EdgeDetect0Kernel: number[];
  64175. /**
  64176. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64177. */
  64178. static EdgeDetect1Kernel: number[];
  64179. /**
  64180. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64181. */
  64182. static EdgeDetect2Kernel: number[];
  64183. /**
  64184. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64185. */
  64186. static SharpenKernel: number[];
  64187. /**
  64188. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64189. */
  64190. static EmbossKernel: number[];
  64191. /**
  64192. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64193. */
  64194. static GaussianKernel: number[];
  64195. }
  64196. }
  64197. declare module BABYLON {
  64198. /**
  64199. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64200. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64201. * based on samples that have a large difference in distance than the center pixel.
  64202. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64203. */
  64204. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64205. direction: Vector2;
  64206. /**
  64207. * Creates a new instance CircleOfConfusionPostProcess
  64208. * @param name The name of the effect.
  64209. * @param scene The scene the effect belongs to.
  64210. * @param direction The direction the blur should be applied.
  64211. * @param kernel The size of the kernel used to blur.
  64212. * @param options The required width/height ratio to downsize to before computing the render pass.
  64213. * @param camera The camera to apply the render pass to.
  64214. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64215. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64217. * @param engine The engine which the post process will be applied. (default: current engine)
  64218. * @param reusable If the post process can be reused on the same frame. (default: false)
  64219. * @param textureType Type of textures used when performing the post process. (default: 0)
  64220. * @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)
  64221. */
  64222. 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);
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /** @hidden */
  64227. export var depthOfFieldMergePixelShader: {
  64228. name: string;
  64229. shader: string;
  64230. };
  64231. }
  64232. declare module BABYLON {
  64233. /**
  64234. * Options to be set when merging outputs from the default pipeline.
  64235. */
  64236. export class DepthOfFieldMergePostProcessOptions {
  64237. /**
  64238. * The original image to merge on top of
  64239. */
  64240. originalFromInput: PostProcess;
  64241. /**
  64242. * Parameters to perform the merge of the depth of field effect
  64243. */
  64244. depthOfField?: {
  64245. circleOfConfusion: PostProcess;
  64246. blurSteps: Array<PostProcess>;
  64247. };
  64248. /**
  64249. * Parameters to perform the merge of bloom effect
  64250. */
  64251. bloom?: {
  64252. blurred: PostProcess;
  64253. weight: number;
  64254. };
  64255. }
  64256. /**
  64257. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64258. */
  64259. export class DepthOfFieldMergePostProcess extends PostProcess {
  64260. private blurSteps;
  64261. /**
  64262. * Creates a new instance of DepthOfFieldMergePostProcess
  64263. * @param name The name of the effect.
  64264. * @param originalFromInput Post process which's input will be used for the merge.
  64265. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64266. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64267. * @param options The required width/height ratio to downsize to before computing the render pass.
  64268. * @param camera The camera to apply the render pass to.
  64269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64270. * @param engine The engine which the post process will be applied. (default: current engine)
  64271. * @param reusable If the post process can be reused on the same frame. (default: false)
  64272. * @param textureType Type of textures used when performing the post process. (default: 0)
  64273. * @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)
  64274. */
  64275. 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);
  64276. /**
  64277. * Updates the effect with the current post process compile time values and recompiles the shader.
  64278. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64279. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64280. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64281. * @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
  64282. * @param onCompiled Called when the shader has been compiled.
  64283. * @param onError Called if there is an error when compiling a shader.
  64284. */
  64285. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64286. }
  64287. }
  64288. declare module BABYLON {
  64289. /**
  64290. * Specifies the level of max blur that should be applied when using the depth of field effect
  64291. */
  64292. export enum DepthOfFieldEffectBlurLevel {
  64293. /**
  64294. * Subtle blur
  64295. */
  64296. Low = 0,
  64297. /**
  64298. * Medium blur
  64299. */
  64300. Medium = 1,
  64301. /**
  64302. * Large blur
  64303. */
  64304. High = 2
  64305. }
  64306. /**
  64307. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64308. */
  64309. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64310. private _circleOfConfusion;
  64311. /**
  64312. * @hidden Internal, blurs from high to low
  64313. */
  64314. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64315. private _depthOfFieldBlurY;
  64316. private _dofMerge;
  64317. /**
  64318. * @hidden Internal post processes in depth of field effect
  64319. */
  64320. _effects: Array<PostProcess>;
  64321. /**
  64322. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64323. */
  64324. set focalLength(value: number);
  64325. get focalLength(): number;
  64326. /**
  64327. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64328. */
  64329. set fStop(value: number);
  64330. get fStop(): number;
  64331. /**
  64332. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64333. */
  64334. set focusDistance(value: number);
  64335. get focusDistance(): number;
  64336. /**
  64337. * 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.
  64338. */
  64339. set lensSize(value: number);
  64340. get lensSize(): number;
  64341. /**
  64342. * Creates a new instance DepthOfFieldEffect
  64343. * @param scene The scene the effect belongs to.
  64344. * @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.
  64345. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64346. * @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)
  64347. */
  64348. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64349. /**
  64350. * Get the current class name of the current effet
  64351. * @returns "DepthOfFieldEffect"
  64352. */
  64353. getClassName(): string;
  64354. /**
  64355. * 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.
  64356. */
  64357. set depthTexture(value: RenderTargetTexture);
  64358. /**
  64359. * Disposes each of the internal effects for a given camera.
  64360. * @param camera The camera to dispose the effect on.
  64361. */
  64362. disposeEffects(camera: Camera): void;
  64363. /**
  64364. * @hidden Internal
  64365. */
  64366. _updateEffects(): void;
  64367. /**
  64368. * Internal
  64369. * @returns if all the contained post processes are ready.
  64370. * @hidden
  64371. */
  64372. _isReady(): boolean;
  64373. }
  64374. }
  64375. declare module BABYLON {
  64376. /** @hidden */
  64377. export var displayPassPixelShader: {
  64378. name: string;
  64379. shader: string;
  64380. };
  64381. }
  64382. declare module BABYLON {
  64383. /**
  64384. * DisplayPassPostProcess which produces an output the same as it's input
  64385. */
  64386. export class DisplayPassPostProcess extends PostProcess {
  64387. /**
  64388. * Creates the DisplayPassPostProcess
  64389. * @param name The name of the effect.
  64390. * @param options The required width/height ratio to downsize to before computing the render pass.
  64391. * @param camera The camera to apply the render pass to.
  64392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64393. * @param engine The engine which the post process will be applied. (default: current engine)
  64394. * @param reusable If the post process can be reused on the same frame. (default: false)
  64395. */
  64396. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64397. }
  64398. }
  64399. declare module BABYLON {
  64400. /** @hidden */
  64401. export var filterPixelShader: {
  64402. name: string;
  64403. shader: string;
  64404. };
  64405. }
  64406. declare module BABYLON {
  64407. /**
  64408. * Applies a kernel filter to the image
  64409. */
  64410. export class FilterPostProcess extends PostProcess {
  64411. /** The matrix to be applied to the image */
  64412. kernelMatrix: Matrix;
  64413. /**
  64414. *
  64415. * @param name The name of the effect.
  64416. * @param kernelMatrix The matrix to be applied to the image
  64417. * @param options The required width/height ratio to downsize to before computing the render pass.
  64418. * @param camera The camera to apply the render pass to.
  64419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64420. * @param engine The engine which the post process will be applied. (default: current engine)
  64421. * @param reusable If the post process can be reused on the same frame. (default: false)
  64422. */
  64423. constructor(name: string,
  64424. /** The matrix to be applied to the image */
  64425. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64426. }
  64427. }
  64428. declare module BABYLON {
  64429. /** @hidden */
  64430. export var fxaaPixelShader: {
  64431. name: string;
  64432. shader: string;
  64433. };
  64434. }
  64435. declare module BABYLON {
  64436. /** @hidden */
  64437. export var fxaaVertexShader: {
  64438. name: string;
  64439. shader: string;
  64440. };
  64441. }
  64442. declare module BABYLON {
  64443. /**
  64444. * Fxaa post process
  64445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64446. */
  64447. export class FxaaPostProcess extends PostProcess {
  64448. /** @hidden */
  64449. texelWidth: number;
  64450. /** @hidden */
  64451. texelHeight: number;
  64452. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64453. private _getDefines;
  64454. }
  64455. }
  64456. declare module BABYLON {
  64457. /** @hidden */
  64458. export var grainPixelShader: {
  64459. name: string;
  64460. shader: string;
  64461. };
  64462. }
  64463. declare module BABYLON {
  64464. /**
  64465. * The GrainPostProcess adds noise to the image at mid luminance levels
  64466. */
  64467. export class GrainPostProcess extends PostProcess {
  64468. /**
  64469. * The intensity of the grain added (default: 30)
  64470. */
  64471. intensity: number;
  64472. /**
  64473. * If the grain should be randomized on every frame
  64474. */
  64475. animated: boolean;
  64476. /**
  64477. * Creates a new instance of @see GrainPostProcess
  64478. * @param name The name of the effect.
  64479. * @param options The required width/height ratio to downsize to before computing the render pass.
  64480. * @param camera The camera to apply the render pass to.
  64481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64482. * @param engine The engine which the post process will be applied. (default: current engine)
  64483. * @param reusable If the post process can be reused on the same frame. (default: false)
  64484. * @param textureType Type of textures used when performing the post process. (default: 0)
  64485. * @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)
  64486. */
  64487. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64488. }
  64489. }
  64490. declare module BABYLON {
  64491. /** @hidden */
  64492. export var highlightsPixelShader: {
  64493. name: string;
  64494. shader: string;
  64495. };
  64496. }
  64497. declare module BABYLON {
  64498. /**
  64499. * Extracts highlights from the image
  64500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64501. */
  64502. export class HighlightsPostProcess extends PostProcess {
  64503. /**
  64504. * Extracts highlights from the image
  64505. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64506. * @param name The name of the effect.
  64507. * @param options The required width/height ratio to downsize to before computing the render pass.
  64508. * @param camera The camera to apply the render pass to.
  64509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64510. * @param engine The engine which the post process will be applied. (default: current engine)
  64511. * @param reusable If the post process can be reused on the same frame. (default: false)
  64512. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64513. */
  64514. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64515. }
  64516. }
  64517. declare module BABYLON {
  64518. /** @hidden */
  64519. export var mrtFragmentDeclaration: {
  64520. name: string;
  64521. shader: string;
  64522. };
  64523. }
  64524. declare module BABYLON {
  64525. /** @hidden */
  64526. export var geometryPixelShader: {
  64527. name: string;
  64528. shader: string;
  64529. };
  64530. }
  64531. declare module BABYLON {
  64532. /** @hidden */
  64533. export var geometryVertexShader: {
  64534. name: string;
  64535. shader: string;
  64536. };
  64537. }
  64538. declare module BABYLON {
  64539. /** @hidden */
  64540. interface ISavedTransformationMatrix {
  64541. world: Matrix;
  64542. viewProjection: Matrix;
  64543. }
  64544. /**
  64545. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64546. */
  64547. export class GeometryBufferRenderer {
  64548. /**
  64549. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64550. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64551. */
  64552. static readonly POSITION_TEXTURE_TYPE: number;
  64553. /**
  64554. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64555. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64556. */
  64557. static readonly VELOCITY_TEXTURE_TYPE: number;
  64558. /**
  64559. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64560. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64561. */
  64562. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64563. /**
  64564. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64565. * in order to compute objects velocities when enableVelocity is set to "true"
  64566. * @hidden
  64567. */
  64568. _previousTransformationMatrices: {
  64569. [index: number]: ISavedTransformationMatrix;
  64570. };
  64571. /**
  64572. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64573. * in order to compute objects velocities when enableVelocity is set to "true"
  64574. * @hidden
  64575. */
  64576. _previousBonesTransformationMatrices: {
  64577. [index: number]: Float32Array;
  64578. };
  64579. /**
  64580. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64581. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64582. */
  64583. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64584. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64585. renderTransparentMeshes: boolean;
  64586. private _scene;
  64587. private _multiRenderTarget;
  64588. private _ratio;
  64589. private _enablePosition;
  64590. private _enableVelocity;
  64591. private _enableReflectivity;
  64592. private _positionIndex;
  64593. private _velocityIndex;
  64594. private _reflectivityIndex;
  64595. protected _effect: Effect;
  64596. protected _cachedDefines: string;
  64597. /**
  64598. * Set the render list (meshes to be rendered) used in the G buffer.
  64599. */
  64600. set renderList(meshes: Mesh[]);
  64601. /**
  64602. * Gets wether or not G buffer are supported by the running hardware.
  64603. * This requires draw buffer supports
  64604. */
  64605. get isSupported(): boolean;
  64606. /**
  64607. * Returns the index of the given texture type in the G-Buffer textures array
  64608. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64609. * @returns the index of the given texture type in the G-Buffer textures array
  64610. */
  64611. getTextureIndex(textureType: number): number;
  64612. /**
  64613. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64614. */
  64615. get enablePosition(): boolean;
  64616. /**
  64617. * Sets whether or not objects positions are enabled for the G buffer.
  64618. */
  64619. set enablePosition(enable: boolean);
  64620. /**
  64621. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64622. */
  64623. get enableVelocity(): boolean;
  64624. /**
  64625. * Sets wether or not objects velocities are enabled for the G buffer.
  64626. */
  64627. set enableVelocity(enable: boolean);
  64628. /**
  64629. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64630. */
  64631. get enableReflectivity(): boolean;
  64632. /**
  64633. * Sets wether or not objects roughness are enabled for the G buffer.
  64634. */
  64635. set enableReflectivity(enable: boolean);
  64636. /**
  64637. * Gets the scene associated with the buffer.
  64638. */
  64639. get scene(): Scene;
  64640. /**
  64641. * Gets the ratio used by the buffer during its creation.
  64642. * How big is the buffer related to the main canvas.
  64643. */
  64644. get ratio(): number;
  64645. /** @hidden */
  64646. static _SceneComponentInitialization: (scene: Scene) => void;
  64647. /**
  64648. * Creates a new G Buffer for the scene
  64649. * @param scene The scene the buffer belongs to
  64650. * @param ratio How big is the buffer related to the main canvas.
  64651. */
  64652. constructor(scene: Scene, ratio?: number);
  64653. /**
  64654. * Checks wether everything is ready to render a submesh to the G buffer.
  64655. * @param subMesh the submesh to check readiness for
  64656. * @param useInstances is the mesh drawn using instance or not
  64657. * @returns true if ready otherwise false
  64658. */
  64659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64660. /**
  64661. * Gets the current underlying G Buffer.
  64662. * @returns the buffer
  64663. */
  64664. getGBuffer(): MultiRenderTarget;
  64665. /**
  64666. * Gets the number of samples used to render the buffer (anti aliasing).
  64667. */
  64668. get samples(): number;
  64669. /**
  64670. * Sets the number of samples used to render the buffer (anti aliasing).
  64671. */
  64672. set samples(value: number);
  64673. /**
  64674. * Disposes the renderer and frees up associated resources.
  64675. */
  64676. dispose(): void;
  64677. protected _createRenderTargets(): void;
  64678. private _copyBonesTransformationMatrices;
  64679. }
  64680. }
  64681. declare module BABYLON {
  64682. interface Scene {
  64683. /** @hidden (Backing field) */
  64684. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64685. /**
  64686. * Gets or Sets the current geometry buffer associated to the scene.
  64687. */
  64688. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64689. /**
  64690. * Enables a GeometryBufferRender and associates it with the scene
  64691. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64692. * @returns the GeometryBufferRenderer
  64693. */
  64694. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64695. /**
  64696. * Disables the GeometryBufferRender associated with the scene
  64697. */
  64698. disableGeometryBufferRenderer(): void;
  64699. }
  64700. /**
  64701. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64702. * in several rendering techniques.
  64703. */
  64704. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64705. /**
  64706. * The component name helpful to identify the component in the list of scene components.
  64707. */
  64708. readonly name: string;
  64709. /**
  64710. * The scene the component belongs to.
  64711. */
  64712. scene: Scene;
  64713. /**
  64714. * Creates a new instance of the component for the given scene
  64715. * @param scene Defines the scene to register the component in
  64716. */
  64717. constructor(scene: Scene);
  64718. /**
  64719. * Registers the component in a given scene
  64720. */
  64721. register(): void;
  64722. /**
  64723. * Rebuilds the elements related to this component in case of
  64724. * context lost for instance.
  64725. */
  64726. rebuild(): void;
  64727. /**
  64728. * Disposes the component and the associated ressources
  64729. */
  64730. dispose(): void;
  64731. private _gatherRenderTargets;
  64732. }
  64733. }
  64734. declare module BABYLON {
  64735. /** @hidden */
  64736. export var motionBlurPixelShader: {
  64737. name: string;
  64738. shader: string;
  64739. };
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64744. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64745. * As an example, all you have to do is to create the post-process:
  64746. * var mb = new BABYLON.MotionBlurPostProcess(
  64747. * 'mb', // The name of the effect.
  64748. * scene, // The scene containing the objects to blur according to their velocity.
  64749. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64750. * camera // The camera to apply the render pass to.
  64751. * );
  64752. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64753. */
  64754. export class MotionBlurPostProcess extends PostProcess {
  64755. /**
  64756. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64757. */
  64758. motionStrength: number;
  64759. /**
  64760. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64761. */
  64762. get motionBlurSamples(): number;
  64763. /**
  64764. * Sets the number of iterations to be used for motion blur quality
  64765. */
  64766. set motionBlurSamples(samples: number);
  64767. private _motionBlurSamples;
  64768. private _geometryBufferRenderer;
  64769. /**
  64770. * Creates a new instance MotionBlurPostProcess
  64771. * @param name The name of the effect.
  64772. * @param scene The scene containing the objects to blur according to their velocity.
  64773. * @param options The required width/height ratio to downsize to before computing the render pass.
  64774. * @param camera The camera to apply the render pass to.
  64775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64776. * @param engine The engine which the post process will be applied. (default: current engine)
  64777. * @param reusable If the post process can be reused on the same frame. (default: false)
  64778. * @param textureType Type of textures used when performing the post process. (default: 0)
  64779. * @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)
  64780. */
  64781. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64782. /**
  64783. * Excludes the given skinned mesh from computing bones velocities.
  64784. * 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.
  64785. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64786. */
  64787. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64788. /**
  64789. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64790. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64791. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64792. */
  64793. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64794. /**
  64795. * Disposes the post process.
  64796. * @param camera The camera to dispose the post process on.
  64797. */
  64798. dispose(camera?: Camera): void;
  64799. }
  64800. }
  64801. declare module BABYLON {
  64802. /** @hidden */
  64803. export var refractionPixelShader: {
  64804. name: string;
  64805. shader: string;
  64806. };
  64807. }
  64808. declare module BABYLON {
  64809. /**
  64810. * Post process which applies a refractin texture
  64811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64812. */
  64813. export class RefractionPostProcess extends PostProcess {
  64814. /** the base color of the refraction (used to taint the rendering) */
  64815. color: Color3;
  64816. /** simulated refraction depth */
  64817. depth: number;
  64818. /** the coefficient of the base color (0 to remove base color tainting) */
  64819. colorLevel: number;
  64820. private _refTexture;
  64821. private _ownRefractionTexture;
  64822. /**
  64823. * Gets or sets the refraction texture
  64824. * Please note that you are responsible for disposing the texture if you set it manually
  64825. */
  64826. get refractionTexture(): Texture;
  64827. set refractionTexture(value: Texture);
  64828. /**
  64829. * Initializes the RefractionPostProcess
  64830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64831. * @param name The name of the effect.
  64832. * @param refractionTextureUrl Url of the refraction texture to use
  64833. * @param color the base color of the refraction (used to taint the rendering)
  64834. * @param depth simulated refraction depth
  64835. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64836. * @param camera The camera to apply the render pass to.
  64837. * @param options The required width/height ratio to downsize to before computing the render pass.
  64838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64839. * @param engine The engine which the post process will be applied. (default: current engine)
  64840. * @param reusable If the post process can be reused on the same frame. (default: false)
  64841. */
  64842. constructor(name: string, refractionTextureUrl: string,
  64843. /** the base color of the refraction (used to taint the rendering) */
  64844. color: Color3,
  64845. /** simulated refraction depth */
  64846. depth: number,
  64847. /** the coefficient of the base color (0 to remove base color tainting) */
  64848. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64849. /**
  64850. * Disposes of the post process
  64851. * @param camera Camera to dispose post process on
  64852. */
  64853. dispose(camera: Camera): void;
  64854. }
  64855. }
  64856. declare module BABYLON {
  64857. /** @hidden */
  64858. export var sharpenPixelShader: {
  64859. name: string;
  64860. shader: string;
  64861. };
  64862. }
  64863. declare module BABYLON {
  64864. /**
  64865. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64866. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64867. */
  64868. export class SharpenPostProcess extends PostProcess {
  64869. /**
  64870. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64871. */
  64872. colorAmount: number;
  64873. /**
  64874. * How much sharpness should be applied (default: 0.3)
  64875. */
  64876. edgeAmount: number;
  64877. /**
  64878. * Creates a new instance ConvolutionPostProcess
  64879. * @param name The name of the effect.
  64880. * @param options The required width/height ratio to downsize to before computing the render pass.
  64881. * @param camera The camera to apply the render pass to.
  64882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64883. * @param engine The engine which the post process will be applied. (default: current engine)
  64884. * @param reusable If the post process can be reused on the same frame. (default: false)
  64885. * @param textureType Type of textures used when performing the post process. (default: 0)
  64886. * @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)
  64887. */
  64888. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /**
  64893. * PostProcessRenderPipeline
  64894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64895. */
  64896. export class PostProcessRenderPipeline {
  64897. private engine;
  64898. private _renderEffects;
  64899. private _renderEffectsForIsolatedPass;
  64900. /**
  64901. * List of inspectable custom properties (used by the Inspector)
  64902. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64903. */
  64904. inspectableCustomProperties: IInspectable[];
  64905. /**
  64906. * @hidden
  64907. */
  64908. protected _cameras: Camera[];
  64909. /** @hidden */
  64910. _name: string;
  64911. /**
  64912. * Gets pipeline name
  64913. */
  64914. get name(): string;
  64915. /** Gets the list of attached cameras */
  64916. get cameras(): Camera[];
  64917. /**
  64918. * Initializes a PostProcessRenderPipeline
  64919. * @param engine engine to add the pipeline to
  64920. * @param name name of the pipeline
  64921. */
  64922. constructor(engine: Engine, name: string);
  64923. /**
  64924. * Gets the class name
  64925. * @returns "PostProcessRenderPipeline"
  64926. */
  64927. getClassName(): string;
  64928. /**
  64929. * If all the render effects in the pipeline are supported
  64930. */
  64931. get isSupported(): boolean;
  64932. /**
  64933. * Adds an effect to the pipeline
  64934. * @param renderEffect the effect to add
  64935. */
  64936. addEffect(renderEffect: PostProcessRenderEffect): void;
  64937. /** @hidden */
  64938. _rebuild(): void;
  64939. /** @hidden */
  64940. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64941. /** @hidden */
  64942. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64943. /** @hidden */
  64944. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64945. /** @hidden */
  64946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64947. /** @hidden */
  64948. _attachCameras(cameras: Camera, unique: boolean): void;
  64949. /** @hidden */
  64950. _attachCameras(cameras: Camera[], unique: boolean): void;
  64951. /** @hidden */
  64952. _detachCameras(cameras: Camera): void;
  64953. /** @hidden */
  64954. _detachCameras(cameras: Nullable<Camera[]>): void;
  64955. /** @hidden */
  64956. _update(): void;
  64957. /** @hidden */
  64958. _reset(): void;
  64959. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64960. /**
  64961. * Disposes of the pipeline
  64962. */
  64963. dispose(): void;
  64964. }
  64965. }
  64966. declare module BABYLON {
  64967. /**
  64968. * PostProcessRenderPipelineManager class
  64969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64970. */
  64971. export class PostProcessRenderPipelineManager {
  64972. private _renderPipelines;
  64973. /**
  64974. * Initializes a PostProcessRenderPipelineManager
  64975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64976. */
  64977. constructor();
  64978. /**
  64979. * Gets the list of supported render pipelines
  64980. */
  64981. get supportedPipelines(): PostProcessRenderPipeline[];
  64982. /**
  64983. * Adds a pipeline to the manager
  64984. * @param renderPipeline The pipeline to add
  64985. */
  64986. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64987. /**
  64988. * Attaches a camera to the pipeline
  64989. * @param renderPipelineName The name of the pipeline to attach to
  64990. * @param cameras the camera to attach
  64991. * @param unique if the camera can be attached multiple times to the pipeline
  64992. */
  64993. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64994. /**
  64995. * Detaches a camera from the pipeline
  64996. * @param renderPipelineName The name of the pipeline to detach from
  64997. * @param cameras the camera to detach
  64998. */
  64999. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65000. /**
  65001. * Enables an effect by name on a pipeline
  65002. * @param renderPipelineName the name of the pipeline to enable the effect in
  65003. * @param renderEffectName the name of the effect to enable
  65004. * @param cameras the cameras that the effect should be enabled on
  65005. */
  65006. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65007. /**
  65008. * Disables an effect by name on a pipeline
  65009. * @param renderPipelineName the name of the pipeline to disable the effect in
  65010. * @param renderEffectName the name of the effect to disable
  65011. * @param cameras the cameras that the effect should be disabled on
  65012. */
  65013. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65014. /**
  65015. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65016. */
  65017. update(): void;
  65018. /** @hidden */
  65019. _rebuild(): void;
  65020. /**
  65021. * Disposes of the manager and pipelines
  65022. */
  65023. dispose(): void;
  65024. }
  65025. }
  65026. declare module BABYLON {
  65027. interface Scene {
  65028. /** @hidden (Backing field) */
  65029. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65030. /**
  65031. * Gets the postprocess render pipeline manager
  65032. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65033. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65034. */
  65035. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65036. }
  65037. /**
  65038. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65039. */
  65040. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65041. /**
  65042. * The component name helpfull to identify the component in the list of scene components.
  65043. */
  65044. readonly name: string;
  65045. /**
  65046. * The scene the component belongs to.
  65047. */
  65048. scene: Scene;
  65049. /**
  65050. * Creates a new instance of the component for the given scene
  65051. * @param scene Defines the scene to register the component in
  65052. */
  65053. constructor(scene: Scene);
  65054. /**
  65055. * Registers the component in a given scene
  65056. */
  65057. register(): void;
  65058. /**
  65059. * Rebuilds the elements related to this component in case of
  65060. * context lost for instance.
  65061. */
  65062. rebuild(): void;
  65063. /**
  65064. * Disposes the component and the associated ressources
  65065. */
  65066. dispose(): void;
  65067. private _gatherRenderTargets;
  65068. }
  65069. }
  65070. declare module BABYLON {
  65071. /**
  65072. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65073. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65074. */
  65075. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65076. private _scene;
  65077. private _camerasToBeAttached;
  65078. /**
  65079. * ID of the sharpen post process,
  65080. */
  65081. private readonly SharpenPostProcessId;
  65082. /**
  65083. * @ignore
  65084. * ID of the image processing post process;
  65085. */
  65086. readonly ImageProcessingPostProcessId: string;
  65087. /**
  65088. * @ignore
  65089. * ID of the Fast Approximate Anti-Aliasing post process;
  65090. */
  65091. readonly FxaaPostProcessId: string;
  65092. /**
  65093. * ID of the chromatic aberration post process,
  65094. */
  65095. private readonly ChromaticAberrationPostProcessId;
  65096. /**
  65097. * ID of the grain post process
  65098. */
  65099. private readonly GrainPostProcessId;
  65100. /**
  65101. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65102. */
  65103. sharpen: SharpenPostProcess;
  65104. private _sharpenEffect;
  65105. private bloom;
  65106. /**
  65107. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65108. */
  65109. depthOfField: DepthOfFieldEffect;
  65110. /**
  65111. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65112. */
  65113. fxaa: FxaaPostProcess;
  65114. /**
  65115. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65116. */
  65117. imageProcessing: ImageProcessingPostProcess;
  65118. /**
  65119. * Chromatic aberration post process which will shift rgb colors in the image
  65120. */
  65121. chromaticAberration: ChromaticAberrationPostProcess;
  65122. private _chromaticAberrationEffect;
  65123. /**
  65124. * Grain post process which add noise to the image
  65125. */
  65126. grain: GrainPostProcess;
  65127. private _grainEffect;
  65128. /**
  65129. * Glow post process which adds a glow to emissive areas of the image
  65130. */
  65131. private _glowLayer;
  65132. /**
  65133. * Animations which can be used to tweak settings over a period of time
  65134. */
  65135. animations: Animation[];
  65136. private _imageProcessingConfigurationObserver;
  65137. private _sharpenEnabled;
  65138. private _bloomEnabled;
  65139. private _depthOfFieldEnabled;
  65140. private _depthOfFieldBlurLevel;
  65141. private _fxaaEnabled;
  65142. private _imageProcessingEnabled;
  65143. private _defaultPipelineTextureType;
  65144. private _bloomScale;
  65145. private _chromaticAberrationEnabled;
  65146. private _grainEnabled;
  65147. private _buildAllowed;
  65148. /**
  65149. * Gets active scene
  65150. */
  65151. get scene(): Scene;
  65152. /**
  65153. * Enable or disable the sharpen process from the pipeline
  65154. */
  65155. set sharpenEnabled(enabled: boolean);
  65156. get sharpenEnabled(): boolean;
  65157. private _resizeObserver;
  65158. private _hardwareScaleLevel;
  65159. private _bloomKernel;
  65160. /**
  65161. * Specifies the size of the bloom blur kernel, relative to the final output size
  65162. */
  65163. get bloomKernel(): number;
  65164. set bloomKernel(value: number);
  65165. /**
  65166. * Specifies the weight of the bloom in the final rendering
  65167. */
  65168. private _bloomWeight;
  65169. /**
  65170. * Specifies the luma threshold for the area that will be blurred by the bloom
  65171. */
  65172. private _bloomThreshold;
  65173. private _hdr;
  65174. /**
  65175. * The strength of the bloom.
  65176. */
  65177. set bloomWeight(value: number);
  65178. get bloomWeight(): number;
  65179. /**
  65180. * The strength of the bloom.
  65181. */
  65182. set bloomThreshold(value: number);
  65183. get bloomThreshold(): number;
  65184. /**
  65185. * The scale of the bloom, lower value will provide better performance.
  65186. */
  65187. set bloomScale(value: number);
  65188. get bloomScale(): number;
  65189. /**
  65190. * Enable or disable the bloom from the pipeline
  65191. */
  65192. set bloomEnabled(enabled: boolean);
  65193. get bloomEnabled(): boolean;
  65194. private _rebuildBloom;
  65195. /**
  65196. * If the depth of field is enabled.
  65197. */
  65198. get depthOfFieldEnabled(): boolean;
  65199. set depthOfFieldEnabled(enabled: boolean);
  65200. /**
  65201. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65202. */
  65203. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65204. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65205. /**
  65206. * If the anti aliasing is enabled.
  65207. */
  65208. set fxaaEnabled(enabled: boolean);
  65209. get fxaaEnabled(): boolean;
  65210. private _samples;
  65211. /**
  65212. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65213. */
  65214. set samples(sampleCount: number);
  65215. get samples(): number;
  65216. /**
  65217. * If image processing is enabled.
  65218. */
  65219. set imageProcessingEnabled(enabled: boolean);
  65220. get imageProcessingEnabled(): boolean;
  65221. /**
  65222. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65223. */
  65224. set glowLayerEnabled(enabled: boolean);
  65225. get glowLayerEnabled(): boolean;
  65226. /**
  65227. * Gets the glow layer (or null if not defined)
  65228. */
  65229. get glowLayer(): Nullable<GlowLayer>;
  65230. /**
  65231. * Enable or disable the chromaticAberration process from the pipeline
  65232. */
  65233. set chromaticAberrationEnabled(enabled: boolean);
  65234. get chromaticAberrationEnabled(): boolean;
  65235. /**
  65236. * Enable or disable the grain process from the pipeline
  65237. */
  65238. set grainEnabled(enabled: boolean);
  65239. get grainEnabled(): boolean;
  65240. /**
  65241. * @constructor
  65242. * @param name - The rendering pipeline name (default: "")
  65243. * @param hdr - If high dynamic range textures should be used (default: true)
  65244. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65245. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65246. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65247. */
  65248. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65249. /**
  65250. * Get the class name
  65251. * @returns "DefaultRenderingPipeline"
  65252. */
  65253. getClassName(): string;
  65254. /**
  65255. * Force the compilation of the entire pipeline.
  65256. */
  65257. prepare(): void;
  65258. private _hasCleared;
  65259. private _prevPostProcess;
  65260. private _prevPrevPostProcess;
  65261. private _setAutoClearAndTextureSharing;
  65262. private _depthOfFieldSceneObserver;
  65263. private _buildPipeline;
  65264. private _disposePostProcesses;
  65265. /**
  65266. * Adds a camera to the pipeline
  65267. * @param camera the camera to be added
  65268. */
  65269. addCamera(camera: Camera): void;
  65270. /**
  65271. * Removes a camera from the pipeline
  65272. * @param camera the camera to remove
  65273. */
  65274. removeCamera(camera: Camera): void;
  65275. /**
  65276. * Dispose of the pipeline and stop all post processes
  65277. */
  65278. dispose(): void;
  65279. /**
  65280. * Serialize the rendering pipeline (Used when exporting)
  65281. * @returns the serialized object
  65282. */
  65283. serialize(): any;
  65284. /**
  65285. * Parse the serialized pipeline
  65286. * @param source Source pipeline.
  65287. * @param scene The scene to load the pipeline to.
  65288. * @param rootUrl The URL of the serialized pipeline.
  65289. * @returns An instantiated pipeline from the serialized object.
  65290. */
  65291. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65292. }
  65293. }
  65294. declare module BABYLON {
  65295. /** @hidden */
  65296. export var lensHighlightsPixelShader: {
  65297. name: string;
  65298. shader: string;
  65299. };
  65300. }
  65301. declare module BABYLON {
  65302. /** @hidden */
  65303. export var depthOfFieldPixelShader: {
  65304. name: string;
  65305. shader: string;
  65306. };
  65307. }
  65308. declare module BABYLON {
  65309. /**
  65310. * BABYLON.JS Chromatic Aberration GLSL Shader
  65311. * Author: Olivier Guyot
  65312. * Separates very slightly R, G and B colors on the edges of the screen
  65313. * Inspired by Francois Tarlier & Martins Upitis
  65314. */
  65315. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65316. /**
  65317. * @ignore
  65318. * The chromatic aberration PostProcess id in the pipeline
  65319. */
  65320. LensChromaticAberrationEffect: string;
  65321. /**
  65322. * @ignore
  65323. * The highlights enhancing PostProcess id in the pipeline
  65324. */
  65325. HighlightsEnhancingEffect: string;
  65326. /**
  65327. * @ignore
  65328. * The depth-of-field PostProcess id in the pipeline
  65329. */
  65330. LensDepthOfFieldEffect: string;
  65331. private _scene;
  65332. private _depthTexture;
  65333. private _grainTexture;
  65334. private _chromaticAberrationPostProcess;
  65335. private _highlightsPostProcess;
  65336. private _depthOfFieldPostProcess;
  65337. private _edgeBlur;
  65338. private _grainAmount;
  65339. private _chromaticAberration;
  65340. private _distortion;
  65341. private _highlightsGain;
  65342. private _highlightsThreshold;
  65343. private _dofDistance;
  65344. private _dofAperture;
  65345. private _dofDarken;
  65346. private _dofPentagon;
  65347. private _blurNoise;
  65348. /**
  65349. * @constructor
  65350. *
  65351. * Effect parameters are as follow:
  65352. * {
  65353. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65354. * edge_blur: number; // from 0 to x (1 for realism)
  65355. * distortion: number; // from 0 to x (1 for realism)
  65356. * grain_amount: number; // from 0 to 1
  65357. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65358. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65359. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65360. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65361. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65362. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65363. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65364. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65365. * }
  65366. * Note: if an effect parameter is unset, effect is disabled
  65367. *
  65368. * @param name The rendering pipeline name
  65369. * @param parameters - An object containing all parameters (see above)
  65370. * @param scene The scene linked to this pipeline
  65371. * @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)
  65372. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65373. */
  65374. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65375. /**
  65376. * Get the class name
  65377. * @returns "LensRenderingPipeline"
  65378. */
  65379. getClassName(): string;
  65380. /**
  65381. * Gets associated scene
  65382. */
  65383. get scene(): Scene;
  65384. /**
  65385. * Gets or sets the edge blur
  65386. */
  65387. get edgeBlur(): number;
  65388. set edgeBlur(value: number);
  65389. /**
  65390. * Gets or sets the grain amount
  65391. */
  65392. get grainAmount(): number;
  65393. set grainAmount(value: number);
  65394. /**
  65395. * Gets or sets the chromatic aberration amount
  65396. */
  65397. get chromaticAberration(): number;
  65398. set chromaticAberration(value: number);
  65399. /**
  65400. * Gets or sets the depth of field aperture
  65401. */
  65402. get dofAperture(): number;
  65403. set dofAperture(value: number);
  65404. /**
  65405. * Gets or sets the edge distortion
  65406. */
  65407. get edgeDistortion(): number;
  65408. set edgeDistortion(value: number);
  65409. /**
  65410. * Gets or sets the depth of field distortion
  65411. */
  65412. get dofDistortion(): number;
  65413. set dofDistortion(value: number);
  65414. /**
  65415. * Gets or sets the darken out of focus amount
  65416. */
  65417. get darkenOutOfFocus(): number;
  65418. set darkenOutOfFocus(value: number);
  65419. /**
  65420. * Gets or sets a boolean indicating if blur noise is enabled
  65421. */
  65422. get blurNoise(): boolean;
  65423. set blurNoise(value: boolean);
  65424. /**
  65425. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65426. */
  65427. get pentagonBokeh(): boolean;
  65428. set pentagonBokeh(value: boolean);
  65429. /**
  65430. * Gets or sets the highlight grain amount
  65431. */
  65432. get highlightsGain(): number;
  65433. set highlightsGain(value: number);
  65434. /**
  65435. * Gets or sets the highlight threshold
  65436. */
  65437. get highlightsThreshold(): number;
  65438. set highlightsThreshold(value: number);
  65439. /**
  65440. * Sets the amount of blur at the edges
  65441. * @param amount blur amount
  65442. */
  65443. setEdgeBlur(amount: number): void;
  65444. /**
  65445. * Sets edge blur to 0
  65446. */
  65447. disableEdgeBlur(): void;
  65448. /**
  65449. * Sets the amout of grain
  65450. * @param amount Amount of grain
  65451. */
  65452. setGrainAmount(amount: number): void;
  65453. /**
  65454. * Set grain amount to 0
  65455. */
  65456. disableGrain(): void;
  65457. /**
  65458. * Sets the chromatic aberration amount
  65459. * @param amount amount of chromatic aberration
  65460. */
  65461. setChromaticAberration(amount: number): void;
  65462. /**
  65463. * Sets chromatic aberration amount to 0
  65464. */
  65465. disableChromaticAberration(): void;
  65466. /**
  65467. * Sets the EdgeDistortion amount
  65468. * @param amount amount of EdgeDistortion
  65469. */
  65470. setEdgeDistortion(amount: number): void;
  65471. /**
  65472. * Sets edge distortion to 0
  65473. */
  65474. disableEdgeDistortion(): void;
  65475. /**
  65476. * Sets the FocusDistance amount
  65477. * @param amount amount of FocusDistance
  65478. */
  65479. setFocusDistance(amount: number): void;
  65480. /**
  65481. * Disables depth of field
  65482. */
  65483. disableDepthOfField(): void;
  65484. /**
  65485. * Sets the Aperture amount
  65486. * @param amount amount of Aperture
  65487. */
  65488. setAperture(amount: number): void;
  65489. /**
  65490. * Sets the DarkenOutOfFocus amount
  65491. * @param amount amount of DarkenOutOfFocus
  65492. */
  65493. setDarkenOutOfFocus(amount: number): void;
  65494. private _pentagonBokehIsEnabled;
  65495. /**
  65496. * Creates a pentagon bokeh effect
  65497. */
  65498. enablePentagonBokeh(): void;
  65499. /**
  65500. * Disables the pentagon bokeh effect
  65501. */
  65502. disablePentagonBokeh(): void;
  65503. /**
  65504. * Enables noise blur
  65505. */
  65506. enableNoiseBlur(): void;
  65507. /**
  65508. * Disables noise blur
  65509. */
  65510. disableNoiseBlur(): void;
  65511. /**
  65512. * Sets the HighlightsGain amount
  65513. * @param amount amount of HighlightsGain
  65514. */
  65515. setHighlightsGain(amount: number): void;
  65516. /**
  65517. * Sets the HighlightsThreshold amount
  65518. * @param amount amount of HighlightsThreshold
  65519. */
  65520. setHighlightsThreshold(amount: number): void;
  65521. /**
  65522. * Disables highlights
  65523. */
  65524. disableHighlights(): void;
  65525. /**
  65526. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65527. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65528. */
  65529. dispose(disableDepthRender?: boolean): void;
  65530. private _createChromaticAberrationPostProcess;
  65531. private _createHighlightsPostProcess;
  65532. private _createDepthOfFieldPostProcess;
  65533. private _createGrainTexture;
  65534. }
  65535. }
  65536. declare module BABYLON {
  65537. /** @hidden */
  65538. export var ssao2PixelShader: {
  65539. name: string;
  65540. shader: string;
  65541. };
  65542. }
  65543. declare module BABYLON {
  65544. /** @hidden */
  65545. export var ssaoCombinePixelShader: {
  65546. name: string;
  65547. shader: string;
  65548. };
  65549. }
  65550. declare module BABYLON {
  65551. /**
  65552. * Render pipeline to produce ssao effect
  65553. */
  65554. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65555. /**
  65556. * @ignore
  65557. * The PassPostProcess id in the pipeline that contains the original scene color
  65558. */
  65559. SSAOOriginalSceneColorEffect: string;
  65560. /**
  65561. * @ignore
  65562. * The SSAO PostProcess id in the pipeline
  65563. */
  65564. SSAORenderEffect: string;
  65565. /**
  65566. * @ignore
  65567. * The horizontal blur PostProcess id in the pipeline
  65568. */
  65569. SSAOBlurHRenderEffect: string;
  65570. /**
  65571. * @ignore
  65572. * The vertical blur PostProcess id in the pipeline
  65573. */
  65574. SSAOBlurVRenderEffect: string;
  65575. /**
  65576. * @ignore
  65577. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65578. */
  65579. SSAOCombineRenderEffect: string;
  65580. /**
  65581. * The output strength of the SSAO post-process. Default value is 1.0.
  65582. */
  65583. totalStrength: number;
  65584. /**
  65585. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65586. */
  65587. maxZ: number;
  65588. /**
  65589. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65590. */
  65591. minZAspect: number;
  65592. private _samples;
  65593. /**
  65594. * Number of samples used for the SSAO calculations. Default value is 8
  65595. */
  65596. set samples(n: number);
  65597. get samples(): number;
  65598. private _textureSamples;
  65599. /**
  65600. * Number of samples to use for antialiasing
  65601. */
  65602. set textureSamples(n: number);
  65603. get textureSamples(): number;
  65604. /**
  65605. * Ratio object used for SSAO ratio and blur ratio
  65606. */
  65607. private _ratio;
  65608. /**
  65609. * Dynamically generated sphere sampler.
  65610. */
  65611. private _sampleSphere;
  65612. /**
  65613. * Blur filter offsets
  65614. */
  65615. private _samplerOffsets;
  65616. private _expensiveBlur;
  65617. /**
  65618. * If bilateral blur should be used
  65619. */
  65620. set expensiveBlur(b: boolean);
  65621. get expensiveBlur(): boolean;
  65622. /**
  65623. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65624. */
  65625. radius: number;
  65626. /**
  65627. * The base color of the SSAO post-process
  65628. * The final result is "base + ssao" between [0, 1]
  65629. */
  65630. base: number;
  65631. /**
  65632. * Support test.
  65633. */
  65634. static get IsSupported(): boolean;
  65635. private _scene;
  65636. private _depthTexture;
  65637. private _normalTexture;
  65638. private _randomTexture;
  65639. private _originalColorPostProcess;
  65640. private _ssaoPostProcess;
  65641. private _blurHPostProcess;
  65642. private _blurVPostProcess;
  65643. private _ssaoCombinePostProcess;
  65644. /**
  65645. * Gets active scene
  65646. */
  65647. get scene(): Scene;
  65648. /**
  65649. * @constructor
  65650. * @param name The rendering pipeline name
  65651. * @param scene The scene linked to this pipeline
  65652. * @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 }
  65653. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65654. */
  65655. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65656. /**
  65657. * Get the class name
  65658. * @returns "SSAO2RenderingPipeline"
  65659. */
  65660. getClassName(): string;
  65661. /**
  65662. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65663. */
  65664. dispose(disableGeometryBufferRenderer?: boolean): void;
  65665. private _createBlurPostProcess;
  65666. /** @hidden */
  65667. _rebuild(): void;
  65668. private _bits;
  65669. private _radicalInverse_VdC;
  65670. private _hammersley;
  65671. private _hemisphereSample_uniform;
  65672. private _generateHemisphere;
  65673. private _createSSAOPostProcess;
  65674. private _createSSAOCombinePostProcess;
  65675. private _createRandomTexture;
  65676. /**
  65677. * Serialize the rendering pipeline (Used when exporting)
  65678. * @returns the serialized object
  65679. */
  65680. serialize(): any;
  65681. /**
  65682. * Parse the serialized pipeline
  65683. * @param source Source pipeline.
  65684. * @param scene The scene to load the pipeline to.
  65685. * @param rootUrl The URL of the serialized pipeline.
  65686. * @returns An instantiated pipeline from the serialized object.
  65687. */
  65688. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65689. }
  65690. }
  65691. declare module BABYLON {
  65692. /** @hidden */
  65693. export var ssaoPixelShader: {
  65694. name: string;
  65695. shader: string;
  65696. };
  65697. }
  65698. declare module BABYLON {
  65699. /**
  65700. * Render pipeline to produce ssao effect
  65701. */
  65702. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65703. /**
  65704. * @ignore
  65705. * The PassPostProcess id in the pipeline that contains the original scene color
  65706. */
  65707. SSAOOriginalSceneColorEffect: string;
  65708. /**
  65709. * @ignore
  65710. * The SSAO PostProcess id in the pipeline
  65711. */
  65712. SSAORenderEffect: string;
  65713. /**
  65714. * @ignore
  65715. * The horizontal blur PostProcess id in the pipeline
  65716. */
  65717. SSAOBlurHRenderEffect: string;
  65718. /**
  65719. * @ignore
  65720. * The vertical blur PostProcess id in the pipeline
  65721. */
  65722. SSAOBlurVRenderEffect: string;
  65723. /**
  65724. * @ignore
  65725. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65726. */
  65727. SSAOCombineRenderEffect: string;
  65728. /**
  65729. * The output strength of the SSAO post-process. Default value is 1.0.
  65730. */
  65731. totalStrength: number;
  65732. /**
  65733. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65734. */
  65735. radius: number;
  65736. /**
  65737. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65738. * Must not be equal to fallOff and superior to fallOff.
  65739. * Default value is 0.0075
  65740. */
  65741. area: number;
  65742. /**
  65743. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65744. * Must not be equal to area and inferior to area.
  65745. * Default value is 0.000001
  65746. */
  65747. fallOff: number;
  65748. /**
  65749. * The base color of the SSAO post-process
  65750. * The final result is "base + ssao" between [0, 1]
  65751. */
  65752. base: number;
  65753. private _scene;
  65754. private _depthTexture;
  65755. private _randomTexture;
  65756. private _originalColorPostProcess;
  65757. private _ssaoPostProcess;
  65758. private _blurHPostProcess;
  65759. private _blurVPostProcess;
  65760. private _ssaoCombinePostProcess;
  65761. private _firstUpdate;
  65762. /**
  65763. * Gets active scene
  65764. */
  65765. get scene(): Scene;
  65766. /**
  65767. * @constructor
  65768. * @param name - The rendering pipeline name
  65769. * @param scene - The scene linked to this pipeline
  65770. * @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 }
  65771. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65772. */
  65773. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65774. /**
  65775. * Get the class name
  65776. * @returns "SSAORenderingPipeline"
  65777. */
  65778. getClassName(): string;
  65779. /**
  65780. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65781. */
  65782. dispose(disableDepthRender?: boolean): void;
  65783. private _createBlurPostProcess;
  65784. /** @hidden */
  65785. _rebuild(): void;
  65786. private _createSSAOPostProcess;
  65787. private _createSSAOCombinePostProcess;
  65788. private _createRandomTexture;
  65789. }
  65790. }
  65791. declare module BABYLON {
  65792. /** @hidden */
  65793. export var screenSpaceReflectionPixelShader: {
  65794. name: string;
  65795. shader: string;
  65796. };
  65797. }
  65798. declare module BABYLON {
  65799. /**
  65800. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65801. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65802. */
  65803. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65804. /**
  65805. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65806. */
  65807. threshold: number;
  65808. /**
  65809. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65810. */
  65811. strength: number;
  65812. /**
  65813. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65814. */
  65815. reflectionSpecularFalloffExponent: number;
  65816. /**
  65817. * 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]
  65818. */
  65819. step: number;
  65820. /**
  65821. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65822. */
  65823. roughnessFactor: number;
  65824. private _geometryBufferRenderer;
  65825. private _enableSmoothReflections;
  65826. private _reflectionSamples;
  65827. private _smoothSteps;
  65828. /**
  65829. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65830. * @param name The name of the effect.
  65831. * @param scene The scene containing the objects to calculate reflections.
  65832. * @param options The required width/height ratio to downsize to before computing the render pass.
  65833. * @param camera The camera to apply the render pass to.
  65834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65835. * @param engine The engine which the post process will be applied. (default: current engine)
  65836. * @param reusable If the post process can be reused on the same frame. (default: false)
  65837. * @param textureType Type of textures used when performing the post process. (default: 0)
  65838. * @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)
  65839. */
  65840. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65841. /**
  65842. * Gets wether or not smoothing reflections is enabled.
  65843. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65844. */
  65845. get enableSmoothReflections(): boolean;
  65846. /**
  65847. * Sets wether or not smoothing reflections is enabled.
  65848. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65849. */
  65850. set enableSmoothReflections(enabled: boolean);
  65851. /**
  65852. * Gets the number of samples taken while computing reflections. More samples count is high,
  65853. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65854. */
  65855. get reflectionSamples(): number;
  65856. /**
  65857. * Sets the number of samples taken while computing reflections. More samples count is high,
  65858. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65859. */
  65860. set reflectionSamples(samples: number);
  65861. /**
  65862. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65863. * more the post-process will require GPU power and can generate a drop in FPS.
  65864. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65865. */
  65866. get smoothSteps(): number;
  65867. set smoothSteps(steps: number);
  65868. private _updateEffectDefines;
  65869. }
  65870. }
  65871. declare module BABYLON {
  65872. /** @hidden */
  65873. export var standardPixelShader: {
  65874. name: string;
  65875. shader: string;
  65876. };
  65877. }
  65878. declare module BABYLON {
  65879. /**
  65880. * Standard rendering pipeline
  65881. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65882. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65883. */
  65884. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65885. /**
  65886. * Public members
  65887. */
  65888. /**
  65889. * Post-process which contains the original scene color before the pipeline applies all the effects
  65890. */
  65891. originalPostProcess: Nullable<PostProcess>;
  65892. /**
  65893. * Post-process used to down scale an image x4
  65894. */
  65895. downSampleX4PostProcess: Nullable<PostProcess>;
  65896. /**
  65897. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65898. */
  65899. brightPassPostProcess: Nullable<PostProcess>;
  65900. /**
  65901. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65902. */
  65903. blurHPostProcesses: PostProcess[];
  65904. /**
  65905. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65906. */
  65907. blurVPostProcesses: PostProcess[];
  65908. /**
  65909. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65910. */
  65911. textureAdderPostProcess: Nullable<PostProcess>;
  65912. /**
  65913. * Post-process used to create volumetric lighting effect
  65914. */
  65915. volumetricLightPostProcess: Nullable<PostProcess>;
  65916. /**
  65917. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65918. */
  65919. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65920. /**
  65921. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65922. */
  65923. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65924. /**
  65925. * Post-process used to merge the volumetric light effect and the real scene color
  65926. */
  65927. volumetricLightMergePostProces: Nullable<PostProcess>;
  65928. /**
  65929. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65930. */
  65931. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65932. /**
  65933. * Base post-process used to calculate the average luminance of the final image for HDR
  65934. */
  65935. luminancePostProcess: Nullable<PostProcess>;
  65936. /**
  65937. * Post-processes used to create down sample post-processes in order to get
  65938. * the average luminance of the final image for HDR
  65939. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65940. */
  65941. luminanceDownSamplePostProcesses: PostProcess[];
  65942. /**
  65943. * Post-process used to create a HDR effect (light adaptation)
  65944. */
  65945. hdrPostProcess: Nullable<PostProcess>;
  65946. /**
  65947. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65948. */
  65949. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65950. /**
  65951. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65952. */
  65953. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65954. /**
  65955. * Post-process used to merge the final HDR post-process and the real scene color
  65956. */
  65957. hdrFinalPostProcess: Nullable<PostProcess>;
  65958. /**
  65959. * Post-process used to create a lens flare effect
  65960. */
  65961. lensFlarePostProcess: Nullable<PostProcess>;
  65962. /**
  65963. * Post-process that merges the result of the lens flare post-process and the real scene color
  65964. */
  65965. lensFlareComposePostProcess: Nullable<PostProcess>;
  65966. /**
  65967. * Post-process used to create a motion blur effect
  65968. */
  65969. motionBlurPostProcess: Nullable<PostProcess>;
  65970. /**
  65971. * Post-process used to create a depth of field effect
  65972. */
  65973. depthOfFieldPostProcess: Nullable<PostProcess>;
  65974. /**
  65975. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65976. */
  65977. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65978. /**
  65979. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65980. */
  65981. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65982. /**
  65983. * Represents the brightness threshold in order to configure the illuminated surfaces
  65984. */
  65985. brightThreshold: number;
  65986. /**
  65987. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65988. */
  65989. blurWidth: number;
  65990. /**
  65991. * Sets if the blur for highlighted surfaces must be only horizontal
  65992. */
  65993. horizontalBlur: boolean;
  65994. /**
  65995. * Gets the overall exposure used by the pipeline
  65996. */
  65997. get exposure(): number;
  65998. /**
  65999. * Sets the overall exposure used by the pipeline
  66000. */
  66001. set exposure(value: number);
  66002. /**
  66003. * Texture used typically to simulate "dirty" on camera lens
  66004. */
  66005. lensTexture: Nullable<Texture>;
  66006. /**
  66007. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66008. */
  66009. volumetricLightCoefficient: number;
  66010. /**
  66011. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66012. */
  66013. volumetricLightPower: number;
  66014. /**
  66015. * Used the set the blur intensity to smooth the volumetric lights
  66016. */
  66017. volumetricLightBlurScale: number;
  66018. /**
  66019. * Light (spot or directional) used to generate the volumetric lights rays
  66020. * The source light must have a shadow generate so the pipeline can get its
  66021. * depth map
  66022. */
  66023. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66024. /**
  66025. * For eye adaptation, represents the minimum luminance the eye can see
  66026. */
  66027. hdrMinimumLuminance: number;
  66028. /**
  66029. * For eye adaptation, represents the decrease luminance speed
  66030. */
  66031. hdrDecreaseRate: number;
  66032. /**
  66033. * For eye adaptation, represents the increase luminance speed
  66034. */
  66035. hdrIncreaseRate: number;
  66036. /**
  66037. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66038. */
  66039. get hdrAutoExposure(): boolean;
  66040. /**
  66041. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66042. */
  66043. set hdrAutoExposure(value: boolean);
  66044. /**
  66045. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66046. */
  66047. lensColorTexture: Nullable<Texture>;
  66048. /**
  66049. * The overall strengh for the lens flare effect
  66050. */
  66051. lensFlareStrength: number;
  66052. /**
  66053. * Dispersion coefficient for lens flare ghosts
  66054. */
  66055. lensFlareGhostDispersal: number;
  66056. /**
  66057. * Main lens flare halo width
  66058. */
  66059. lensFlareHaloWidth: number;
  66060. /**
  66061. * Based on the lens distortion effect, defines how much the lens flare result
  66062. * is distorted
  66063. */
  66064. lensFlareDistortionStrength: number;
  66065. /**
  66066. * Configures the blur intensity used for for lens flare (halo)
  66067. */
  66068. lensFlareBlurWidth: number;
  66069. /**
  66070. * Lens star texture must be used to simulate rays on the flares and is available
  66071. * in the documentation
  66072. */
  66073. lensStarTexture: Nullable<Texture>;
  66074. /**
  66075. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66076. * flare effect by taking account of the dirt texture
  66077. */
  66078. lensFlareDirtTexture: Nullable<Texture>;
  66079. /**
  66080. * Represents the focal length for the depth of field effect
  66081. */
  66082. depthOfFieldDistance: number;
  66083. /**
  66084. * Represents the blur intensity for the blurred part of the depth of field effect
  66085. */
  66086. depthOfFieldBlurWidth: number;
  66087. /**
  66088. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66089. */
  66090. get motionStrength(): number;
  66091. /**
  66092. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66093. */
  66094. set motionStrength(strength: number);
  66095. /**
  66096. * Gets wether or not the motion blur post-process is object based or screen based.
  66097. */
  66098. get objectBasedMotionBlur(): boolean;
  66099. /**
  66100. * Sets wether or not the motion blur post-process should be object based or screen based
  66101. */
  66102. set objectBasedMotionBlur(value: boolean);
  66103. /**
  66104. * List of animations for the pipeline (IAnimatable implementation)
  66105. */
  66106. animations: Animation[];
  66107. /**
  66108. * Private members
  66109. */
  66110. private _scene;
  66111. private _currentDepthOfFieldSource;
  66112. private _basePostProcess;
  66113. private _fixedExposure;
  66114. private _currentExposure;
  66115. private _hdrAutoExposure;
  66116. private _hdrCurrentLuminance;
  66117. private _motionStrength;
  66118. private _isObjectBasedMotionBlur;
  66119. private _floatTextureType;
  66120. private _camerasToBeAttached;
  66121. private _ratio;
  66122. private _bloomEnabled;
  66123. private _depthOfFieldEnabled;
  66124. private _vlsEnabled;
  66125. private _lensFlareEnabled;
  66126. private _hdrEnabled;
  66127. private _motionBlurEnabled;
  66128. private _fxaaEnabled;
  66129. private _screenSpaceReflectionsEnabled;
  66130. private _motionBlurSamples;
  66131. private _volumetricLightStepsCount;
  66132. private _samples;
  66133. /**
  66134. * @ignore
  66135. * Specifies if the bloom pipeline is enabled
  66136. */
  66137. get BloomEnabled(): boolean;
  66138. set BloomEnabled(enabled: boolean);
  66139. /**
  66140. * @ignore
  66141. * Specifies if the depth of field pipeline is enabed
  66142. */
  66143. get DepthOfFieldEnabled(): boolean;
  66144. set DepthOfFieldEnabled(enabled: boolean);
  66145. /**
  66146. * @ignore
  66147. * Specifies if the lens flare pipeline is enabed
  66148. */
  66149. get LensFlareEnabled(): boolean;
  66150. set LensFlareEnabled(enabled: boolean);
  66151. /**
  66152. * @ignore
  66153. * Specifies if the HDR pipeline is enabled
  66154. */
  66155. get HDREnabled(): boolean;
  66156. set HDREnabled(enabled: boolean);
  66157. /**
  66158. * @ignore
  66159. * Specifies if the volumetric lights scattering effect is enabled
  66160. */
  66161. get VLSEnabled(): boolean;
  66162. set VLSEnabled(enabled: boolean);
  66163. /**
  66164. * @ignore
  66165. * Specifies if the motion blur effect is enabled
  66166. */
  66167. get MotionBlurEnabled(): boolean;
  66168. set MotionBlurEnabled(enabled: boolean);
  66169. /**
  66170. * Specifies if anti-aliasing is enabled
  66171. */
  66172. get fxaaEnabled(): boolean;
  66173. set fxaaEnabled(enabled: boolean);
  66174. /**
  66175. * Specifies if screen space reflections are enabled.
  66176. */
  66177. get screenSpaceReflectionsEnabled(): boolean;
  66178. set screenSpaceReflectionsEnabled(enabled: boolean);
  66179. /**
  66180. * Specifies the number of steps used to calculate the volumetric lights
  66181. * Typically in interval [50, 200]
  66182. */
  66183. get volumetricLightStepsCount(): number;
  66184. set volumetricLightStepsCount(count: number);
  66185. /**
  66186. * Specifies the number of samples used for the motion blur effect
  66187. * Typically in interval [16, 64]
  66188. */
  66189. get motionBlurSamples(): number;
  66190. set motionBlurSamples(samples: number);
  66191. /**
  66192. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66193. */
  66194. get samples(): number;
  66195. set samples(sampleCount: number);
  66196. /**
  66197. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66198. * @constructor
  66199. * @param name The rendering pipeline name
  66200. * @param scene The scene linked to this pipeline
  66201. * @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)
  66202. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66203. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66204. */
  66205. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66206. private _buildPipeline;
  66207. private _createDownSampleX4PostProcess;
  66208. private _createBrightPassPostProcess;
  66209. private _createBlurPostProcesses;
  66210. private _createTextureAdderPostProcess;
  66211. private _createVolumetricLightPostProcess;
  66212. private _createLuminancePostProcesses;
  66213. private _createHdrPostProcess;
  66214. private _createLensFlarePostProcess;
  66215. private _createDepthOfFieldPostProcess;
  66216. private _createMotionBlurPostProcess;
  66217. private _getDepthTexture;
  66218. private _disposePostProcesses;
  66219. /**
  66220. * Dispose of the pipeline and stop all post processes
  66221. */
  66222. dispose(): void;
  66223. /**
  66224. * Serialize the rendering pipeline (Used when exporting)
  66225. * @returns the serialized object
  66226. */
  66227. serialize(): any;
  66228. /**
  66229. * Parse the serialized pipeline
  66230. * @param source Source pipeline.
  66231. * @param scene The scene to load the pipeline to.
  66232. * @param rootUrl The URL of the serialized pipeline.
  66233. * @returns An instantiated pipeline from the serialized object.
  66234. */
  66235. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66236. /**
  66237. * Luminance steps
  66238. */
  66239. static LuminanceSteps: number;
  66240. }
  66241. }
  66242. declare module BABYLON {
  66243. /** @hidden */
  66244. export var tonemapPixelShader: {
  66245. name: string;
  66246. shader: string;
  66247. };
  66248. }
  66249. declare module BABYLON {
  66250. /** Defines operator used for tonemapping */
  66251. export enum TonemappingOperator {
  66252. /** Hable */
  66253. Hable = 0,
  66254. /** Reinhard */
  66255. Reinhard = 1,
  66256. /** HejiDawson */
  66257. HejiDawson = 2,
  66258. /** Photographic */
  66259. Photographic = 3
  66260. }
  66261. /**
  66262. * Defines a post process to apply tone mapping
  66263. */
  66264. export class TonemapPostProcess extends PostProcess {
  66265. private _operator;
  66266. /** Defines the required exposure adjustement */
  66267. exposureAdjustment: number;
  66268. /**
  66269. * Creates a new TonemapPostProcess
  66270. * @param name defines the name of the postprocess
  66271. * @param _operator defines the operator to use
  66272. * @param exposureAdjustment defines the required exposure adjustement
  66273. * @param camera defines the camera to use (can be null)
  66274. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66275. * @param engine defines the hosting engine (can be ignore if camera is set)
  66276. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66277. */
  66278. constructor(name: string, _operator: TonemappingOperator,
  66279. /** Defines the required exposure adjustement */
  66280. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66281. }
  66282. }
  66283. declare module BABYLON {
  66284. /** @hidden */
  66285. export var volumetricLightScatteringPixelShader: {
  66286. name: string;
  66287. shader: string;
  66288. };
  66289. }
  66290. declare module BABYLON {
  66291. /** @hidden */
  66292. export var volumetricLightScatteringPassVertexShader: {
  66293. name: string;
  66294. shader: string;
  66295. };
  66296. }
  66297. declare module BABYLON {
  66298. /** @hidden */
  66299. export var volumetricLightScatteringPassPixelShader: {
  66300. name: string;
  66301. shader: string;
  66302. };
  66303. }
  66304. declare module BABYLON {
  66305. /**
  66306. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66307. */
  66308. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66309. private _volumetricLightScatteringPass;
  66310. private _volumetricLightScatteringRTT;
  66311. private _viewPort;
  66312. private _screenCoordinates;
  66313. private _cachedDefines;
  66314. /**
  66315. * If not undefined, the mesh position is computed from the attached node position
  66316. */
  66317. attachedNode: {
  66318. position: Vector3;
  66319. };
  66320. /**
  66321. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66322. */
  66323. customMeshPosition: Vector3;
  66324. /**
  66325. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66326. */
  66327. useCustomMeshPosition: boolean;
  66328. /**
  66329. * If the post-process should inverse the light scattering direction
  66330. */
  66331. invert: boolean;
  66332. /**
  66333. * The internal mesh used by the post-process
  66334. */
  66335. mesh: Mesh;
  66336. /**
  66337. * @hidden
  66338. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66339. */
  66340. get useDiffuseColor(): boolean;
  66341. set useDiffuseColor(useDiffuseColor: boolean);
  66342. /**
  66343. * Array containing the excluded meshes not rendered in the internal pass
  66344. */
  66345. excludedMeshes: AbstractMesh[];
  66346. /**
  66347. * Controls the overall intensity of the post-process
  66348. */
  66349. exposure: number;
  66350. /**
  66351. * Dissipates each sample's contribution in range [0, 1]
  66352. */
  66353. decay: number;
  66354. /**
  66355. * Controls the overall intensity of each sample
  66356. */
  66357. weight: number;
  66358. /**
  66359. * Controls the density of each sample
  66360. */
  66361. density: number;
  66362. /**
  66363. * @constructor
  66364. * @param name The post-process name
  66365. * @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)
  66366. * @param camera The camera that the post-process will be attached to
  66367. * @param mesh The mesh used to create the light scattering
  66368. * @param samples The post-process quality, default 100
  66369. * @param samplingModeThe post-process filtering mode
  66370. * @param engine The babylon engine
  66371. * @param reusable If the post-process is reusable
  66372. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66373. */
  66374. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66375. /**
  66376. * Returns the string "VolumetricLightScatteringPostProcess"
  66377. * @returns "VolumetricLightScatteringPostProcess"
  66378. */
  66379. getClassName(): string;
  66380. private _isReady;
  66381. /**
  66382. * Sets the new light position for light scattering effect
  66383. * @param position The new custom light position
  66384. */
  66385. setCustomMeshPosition(position: Vector3): void;
  66386. /**
  66387. * Returns the light position for light scattering effect
  66388. * @return Vector3 The custom light position
  66389. */
  66390. getCustomMeshPosition(): Vector3;
  66391. /**
  66392. * Disposes the internal assets and detaches the post-process from the camera
  66393. */
  66394. dispose(camera: Camera): void;
  66395. /**
  66396. * Returns the render target texture used by the post-process
  66397. * @return the render target texture used by the post-process
  66398. */
  66399. getPass(): RenderTargetTexture;
  66400. private _meshExcluded;
  66401. private _createPass;
  66402. private _updateMeshScreenCoordinates;
  66403. /**
  66404. * Creates a default mesh for the Volumeric Light Scattering post-process
  66405. * @param name The mesh name
  66406. * @param scene The scene where to create the mesh
  66407. * @return the default mesh
  66408. */
  66409. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66410. }
  66411. }
  66412. declare module BABYLON {
  66413. interface Scene {
  66414. /** @hidden (Backing field) */
  66415. _boundingBoxRenderer: BoundingBoxRenderer;
  66416. /** @hidden (Backing field) */
  66417. _forceShowBoundingBoxes: boolean;
  66418. /**
  66419. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66420. */
  66421. forceShowBoundingBoxes: boolean;
  66422. /**
  66423. * Gets the bounding box renderer associated with the scene
  66424. * @returns a BoundingBoxRenderer
  66425. */
  66426. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66427. }
  66428. interface AbstractMesh {
  66429. /** @hidden (Backing field) */
  66430. _showBoundingBox: boolean;
  66431. /**
  66432. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66433. */
  66434. showBoundingBox: boolean;
  66435. }
  66436. /**
  66437. * Component responsible of rendering the bounding box of the meshes in a scene.
  66438. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66439. */
  66440. export class BoundingBoxRenderer implements ISceneComponent {
  66441. /**
  66442. * The component name helpfull to identify the component in the list of scene components.
  66443. */
  66444. readonly name: string;
  66445. /**
  66446. * The scene the component belongs to.
  66447. */
  66448. scene: Scene;
  66449. /**
  66450. * Color of the bounding box lines placed in front of an object
  66451. */
  66452. frontColor: Color3;
  66453. /**
  66454. * Color of the bounding box lines placed behind an object
  66455. */
  66456. backColor: Color3;
  66457. /**
  66458. * Defines if the renderer should show the back lines or not
  66459. */
  66460. showBackLines: boolean;
  66461. /**
  66462. * @hidden
  66463. */
  66464. renderList: SmartArray<BoundingBox>;
  66465. private _colorShader;
  66466. private _vertexBuffers;
  66467. private _indexBuffer;
  66468. private _fillIndexBuffer;
  66469. private _fillIndexData;
  66470. /**
  66471. * Instantiates a new bounding box renderer in a scene.
  66472. * @param scene the scene the renderer renders in
  66473. */
  66474. constructor(scene: Scene);
  66475. /**
  66476. * Registers the component in a given scene
  66477. */
  66478. register(): void;
  66479. private _evaluateSubMesh;
  66480. private _activeMesh;
  66481. private _prepareRessources;
  66482. private _createIndexBuffer;
  66483. /**
  66484. * Rebuilds the elements related to this component in case of
  66485. * context lost for instance.
  66486. */
  66487. rebuild(): void;
  66488. /**
  66489. * @hidden
  66490. */
  66491. reset(): void;
  66492. /**
  66493. * Render the bounding boxes of a specific rendering group
  66494. * @param renderingGroupId defines the rendering group to render
  66495. */
  66496. render(renderingGroupId: number): void;
  66497. /**
  66498. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66499. * @param mesh Define the mesh to render the occlusion bounding box for
  66500. */
  66501. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66502. /**
  66503. * Dispose and release the resources attached to this renderer.
  66504. */
  66505. dispose(): void;
  66506. }
  66507. }
  66508. declare module BABYLON {
  66509. interface Scene {
  66510. /** @hidden (Backing field) */
  66511. _depthRenderer: {
  66512. [id: string]: DepthRenderer;
  66513. };
  66514. /**
  66515. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66516. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66517. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66518. * @returns the created depth renderer
  66519. */
  66520. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66521. /**
  66522. * Disables a depth renderer for a given camera
  66523. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66524. */
  66525. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66526. }
  66527. /**
  66528. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66529. * in several rendering techniques.
  66530. */
  66531. export class DepthRendererSceneComponent implements ISceneComponent {
  66532. /**
  66533. * The component name helpfull to identify the component in the list of scene components.
  66534. */
  66535. readonly name: string;
  66536. /**
  66537. * The scene the component belongs to.
  66538. */
  66539. scene: Scene;
  66540. /**
  66541. * Creates a new instance of the component for the given scene
  66542. * @param scene Defines the scene to register the component in
  66543. */
  66544. constructor(scene: Scene);
  66545. /**
  66546. * Registers the component in a given scene
  66547. */
  66548. register(): void;
  66549. /**
  66550. * Rebuilds the elements related to this component in case of
  66551. * context lost for instance.
  66552. */
  66553. rebuild(): void;
  66554. /**
  66555. * Disposes the component and the associated ressources
  66556. */
  66557. dispose(): void;
  66558. private _gatherRenderTargets;
  66559. private _gatherActiveCameraRenderTargets;
  66560. }
  66561. }
  66562. declare module BABYLON {
  66563. /** @hidden */
  66564. export var outlinePixelShader: {
  66565. name: string;
  66566. shader: string;
  66567. };
  66568. }
  66569. declare module BABYLON {
  66570. /** @hidden */
  66571. export var outlineVertexShader: {
  66572. name: string;
  66573. shader: string;
  66574. };
  66575. }
  66576. declare module BABYLON {
  66577. interface Scene {
  66578. /** @hidden */
  66579. _outlineRenderer: OutlineRenderer;
  66580. /**
  66581. * Gets the outline renderer associated with the scene
  66582. * @returns a OutlineRenderer
  66583. */
  66584. getOutlineRenderer(): OutlineRenderer;
  66585. }
  66586. interface AbstractMesh {
  66587. /** @hidden (Backing field) */
  66588. _renderOutline: boolean;
  66589. /**
  66590. * Gets or sets a boolean indicating if the outline must be rendered as well
  66591. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66592. */
  66593. renderOutline: boolean;
  66594. /** @hidden (Backing field) */
  66595. _renderOverlay: boolean;
  66596. /**
  66597. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66598. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66599. */
  66600. renderOverlay: boolean;
  66601. }
  66602. /**
  66603. * This class is responsible to draw bothe outline/overlay of meshes.
  66604. * It should not be used directly but through the available method on mesh.
  66605. */
  66606. export class OutlineRenderer implements ISceneComponent {
  66607. /**
  66608. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66609. */
  66610. private static _StencilReference;
  66611. /**
  66612. * The name of the component. Each component must have a unique name.
  66613. */
  66614. name: string;
  66615. /**
  66616. * The scene the component belongs to.
  66617. */
  66618. scene: Scene;
  66619. /**
  66620. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66621. */
  66622. zOffset: number;
  66623. private _engine;
  66624. private _effect;
  66625. private _cachedDefines;
  66626. private _savedDepthWrite;
  66627. /**
  66628. * Instantiates a new outline renderer. (There could be only one per scene).
  66629. * @param scene Defines the scene it belongs to
  66630. */
  66631. constructor(scene: Scene);
  66632. /**
  66633. * Register the component to one instance of a scene.
  66634. */
  66635. register(): void;
  66636. /**
  66637. * Rebuilds the elements related to this component in case of
  66638. * context lost for instance.
  66639. */
  66640. rebuild(): void;
  66641. /**
  66642. * Disposes the component and the associated ressources.
  66643. */
  66644. dispose(): void;
  66645. /**
  66646. * Renders the outline in the canvas.
  66647. * @param subMesh Defines the sumesh to render
  66648. * @param batch Defines the batch of meshes in case of instances
  66649. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66650. */
  66651. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66652. /**
  66653. * Returns whether or not the outline renderer is ready for a given submesh.
  66654. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66655. * @param subMesh Defines the submesh to check readyness for
  66656. * @param useInstances Defines wheter wee are trying to render instances or not
  66657. * @returns true if ready otherwise false
  66658. */
  66659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66660. private _beforeRenderingMesh;
  66661. private _afterRenderingMesh;
  66662. }
  66663. }
  66664. declare module BABYLON {
  66665. /**
  66666. * Defines the basic options interface of a Sprite Frame Source Size.
  66667. */
  66668. export interface ISpriteJSONSpriteSourceSize {
  66669. /**
  66670. * number of the original width of the Frame
  66671. */
  66672. w: number;
  66673. /**
  66674. * number of the original height of the Frame
  66675. */
  66676. h: number;
  66677. }
  66678. /**
  66679. * Defines the basic options interface of a Sprite Frame Data.
  66680. */
  66681. export interface ISpriteJSONSpriteFrameData {
  66682. /**
  66683. * number of the x offset of the Frame
  66684. */
  66685. x: number;
  66686. /**
  66687. * number of the y offset of the Frame
  66688. */
  66689. y: number;
  66690. /**
  66691. * number of the width of the Frame
  66692. */
  66693. w: number;
  66694. /**
  66695. * number of the height of the Frame
  66696. */
  66697. h: number;
  66698. }
  66699. /**
  66700. * Defines the basic options interface of a JSON Sprite.
  66701. */
  66702. export interface ISpriteJSONSprite {
  66703. /**
  66704. * string name of the Frame
  66705. */
  66706. filename: string;
  66707. /**
  66708. * ISpriteJSONSpriteFrame basic object of the frame data
  66709. */
  66710. frame: ISpriteJSONSpriteFrameData;
  66711. /**
  66712. * boolean to flag is the frame was rotated.
  66713. */
  66714. rotated: boolean;
  66715. /**
  66716. * boolean to flag is the frame was trimmed.
  66717. */
  66718. trimmed: boolean;
  66719. /**
  66720. * ISpriteJSONSpriteFrame basic object of the source data
  66721. */
  66722. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66723. /**
  66724. * ISpriteJSONSpriteFrame basic object of the source data
  66725. */
  66726. sourceSize: ISpriteJSONSpriteSourceSize;
  66727. }
  66728. /**
  66729. * Defines the basic options interface of a JSON atlas.
  66730. */
  66731. export interface ISpriteJSONAtlas {
  66732. /**
  66733. * Array of objects that contain the frame data.
  66734. */
  66735. frames: Array<ISpriteJSONSprite>;
  66736. /**
  66737. * object basic object containing the sprite meta data.
  66738. */
  66739. meta?: object;
  66740. }
  66741. }
  66742. declare module BABYLON {
  66743. /** @hidden */
  66744. export var spriteMapPixelShader: {
  66745. name: string;
  66746. shader: string;
  66747. };
  66748. }
  66749. declare module BABYLON {
  66750. /** @hidden */
  66751. export var spriteMapVertexShader: {
  66752. name: string;
  66753. shader: string;
  66754. };
  66755. }
  66756. declare module BABYLON {
  66757. /**
  66758. * Defines the basic options interface of a SpriteMap
  66759. */
  66760. export interface ISpriteMapOptions {
  66761. /**
  66762. * Vector2 of the number of cells in the grid.
  66763. */
  66764. stageSize?: Vector2;
  66765. /**
  66766. * Vector2 of the size of the output plane in World Units.
  66767. */
  66768. outputSize?: Vector2;
  66769. /**
  66770. * Vector3 of the position of the output plane in World Units.
  66771. */
  66772. outputPosition?: Vector3;
  66773. /**
  66774. * Vector3 of the rotation of the output plane.
  66775. */
  66776. outputRotation?: Vector3;
  66777. /**
  66778. * number of layers that the system will reserve in resources.
  66779. */
  66780. layerCount?: number;
  66781. /**
  66782. * number of max animation frames a single cell will reserve in resources.
  66783. */
  66784. maxAnimationFrames?: number;
  66785. /**
  66786. * number cell index of the base tile when the system compiles.
  66787. */
  66788. baseTile?: number;
  66789. /**
  66790. * boolean flip the sprite after its been repositioned by the framing data.
  66791. */
  66792. flipU?: boolean;
  66793. /**
  66794. * Vector3 scalar of the global RGB values of the SpriteMap.
  66795. */
  66796. colorMultiply?: Vector3;
  66797. }
  66798. /**
  66799. * Defines the IDisposable interface in order to be cleanable from resources.
  66800. */
  66801. export interface ISpriteMap extends IDisposable {
  66802. /**
  66803. * String name of the SpriteMap.
  66804. */
  66805. name: string;
  66806. /**
  66807. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66808. */
  66809. atlasJSON: ISpriteJSONAtlas;
  66810. /**
  66811. * Texture of the SpriteMap.
  66812. */
  66813. spriteSheet: Texture;
  66814. /**
  66815. * The parameters to initialize the SpriteMap with.
  66816. */
  66817. options: ISpriteMapOptions;
  66818. }
  66819. /**
  66820. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66821. */
  66822. export class SpriteMap implements ISpriteMap {
  66823. /** The Name of the spriteMap */
  66824. name: string;
  66825. /** The JSON file with the frame and meta data */
  66826. atlasJSON: ISpriteJSONAtlas;
  66827. /** The systems Sprite Sheet Texture */
  66828. spriteSheet: Texture;
  66829. /** Arguments passed with the Constructor */
  66830. options: ISpriteMapOptions;
  66831. /** Public Sprite Storage array, parsed from atlasJSON */
  66832. sprites: Array<ISpriteJSONSprite>;
  66833. /** Returns the Number of Sprites in the System */
  66834. get spriteCount(): number;
  66835. /** Returns the Position of Output Plane*/
  66836. get position(): Vector3;
  66837. /** Returns the Position of Output Plane*/
  66838. set position(v: Vector3);
  66839. /** Returns the Rotation of Output Plane*/
  66840. get rotation(): Vector3;
  66841. /** Returns the Rotation of Output Plane*/
  66842. set rotation(v: Vector3);
  66843. /** Sets the AnimationMap*/
  66844. get animationMap(): RawTexture;
  66845. /** Sets the AnimationMap*/
  66846. set animationMap(v: RawTexture);
  66847. /** Scene that the SpriteMap was created in */
  66848. private _scene;
  66849. /** Texture Buffer of Float32 that holds tile frame data*/
  66850. private _frameMap;
  66851. /** Texture Buffers of Float32 that holds tileMap data*/
  66852. private _tileMaps;
  66853. /** Texture Buffer of Float32 that holds Animation Data*/
  66854. private _animationMap;
  66855. /** Custom ShaderMaterial Central to the System*/
  66856. private _material;
  66857. /** Custom ShaderMaterial Central to the System*/
  66858. private _output;
  66859. /** Systems Time Ticker*/
  66860. private _time;
  66861. /**
  66862. * Creates a new SpriteMap
  66863. * @param name defines the SpriteMaps Name
  66864. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66865. * @param spriteSheet is the Texture that the Sprites are on.
  66866. * @param options a basic deployment configuration
  66867. * @param scene The Scene that the map is deployed on
  66868. */
  66869. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66870. /**
  66871. * Returns tileID location
  66872. * @returns Vector2 the cell position ID
  66873. */
  66874. getTileID(): Vector2;
  66875. /**
  66876. * Gets the UV location of the mouse over the SpriteMap.
  66877. * @returns Vector2 the UV position of the mouse interaction
  66878. */
  66879. getMousePosition(): Vector2;
  66880. /**
  66881. * Creates the "frame" texture Buffer
  66882. * -------------------------------------
  66883. * Structure of frames
  66884. * "filename": "Falling-Water-2.png",
  66885. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66886. * "rotated": true,
  66887. * "trimmed": true,
  66888. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66889. * "sourceSize": {"w":32,"h":32}
  66890. * @returns RawTexture of the frameMap
  66891. */
  66892. private _createFrameBuffer;
  66893. /**
  66894. * Creates the tileMap texture Buffer
  66895. * @param buffer normally and array of numbers, or a false to generate from scratch
  66896. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66897. * @returns RawTexture of the tileMap
  66898. */
  66899. private _createTileBuffer;
  66900. /**
  66901. * Modifies the data of the tileMaps
  66902. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66903. * @param pos is the iVector2 Coordinates of the Tile
  66904. * @param tile The SpriteIndex of the new Tile
  66905. */
  66906. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66907. /**
  66908. * Creates the animationMap texture Buffer
  66909. * @param buffer normally and array of numbers, or a false to generate from scratch
  66910. * @returns RawTexture of the animationMap
  66911. */
  66912. private _createTileAnimationBuffer;
  66913. /**
  66914. * Modifies the data of the animationMap
  66915. * @param cellID is the Index of the Sprite
  66916. * @param _frame is the target Animation frame
  66917. * @param toCell is the Target Index of the next frame of the animation
  66918. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66919. * @param speed is a global scalar of the time variable on the map.
  66920. */
  66921. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66922. /**
  66923. * Exports the .tilemaps file
  66924. */
  66925. saveTileMaps(): void;
  66926. /**
  66927. * Imports the .tilemaps file
  66928. * @param url of the .tilemaps file
  66929. */
  66930. loadTileMaps(url: string): void;
  66931. /**
  66932. * Release associated resources
  66933. */
  66934. dispose(): void;
  66935. }
  66936. }
  66937. declare module BABYLON {
  66938. /**
  66939. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66940. * @see http://doc.babylonjs.com/babylon101/sprites
  66941. */
  66942. export class SpritePackedManager extends SpriteManager {
  66943. /** defines the packed manager's name */
  66944. name: string;
  66945. /**
  66946. * Creates a new sprite manager from a packed sprite sheet
  66947. * @param name defines the manager's name
  66948. * @param imgUrl defines the sprite sheet url
  66949. * @param capacity defines the maximum allowed number of sprites
  66950. * @param scene defines the hosting scene
  66951. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66952. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66953. * @param samplingMode defines the smapling mode to use with spritesheet
  66954. * @param fromPacked set to true; do not alter
  66955. */
  66956. constructor(
  66957. /** defines the packed manager's name */
  66958. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66959. }
  66960. }
  66961. declare module BABYLON {
  66962. /**
  66963. * Defines the list of states available for a task inside a AssetsManager
  66964. */
  66965. export enum AssetTaskState {
  66966. /**
  66967. * Initialization
  66968. */
  66969. INIT = 0,
  66970. /**
  66971. * Running
  66972. */
  66973. RUNNING = 1,
  66974. /**
  66975. * Done
  66976. */
  66977. DONE = 2,
  66978. /**
  66979. * Error
  66980. */
  66981. ERROR = 3
  66982. }
  66983. /**
  66984. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66985. */
  66986. export abstract class AbstractAssetTask {
  66987. /**
  66988. * Task name
  66989. */ name: string;
  66990. /**
  66991. * Callback called when the task is successful
  66992. */
  66993. onSuccess: (task: any) => void;
  66994. /**
  66995. * Callback called when the task is not successful
  66996. */
  66997. onError: (task: any, message?: string, exception?: any) => void;
  66998. /**
  66999. * Creates a new AssetsManager
  67000. * @param name defines the name of the task
  67001. */
  67002. constructor(
  67003. /**
  67004. * Task name
  67005. */ name: string);
  67006. private _isCompleted;
  67007. private _taskState;
  67008. private _errorObject;
  67009. /**
  67010. * Get if the task is completed
  67011. */
  67012. get isCompleted(): boolean;
  67013. /**
  67014. * Gets the current state of the task
  67015. */
  67016. get taskState(): AssetTaskState;
  67017. /**
  67018. * Gets the current error object (if task is in error)
  67019. */
  67020. get errorObject(): {
  67021. message?: string;
  67022. exception?: any;
  67023. };
  67024. /**
  67025. * Internal only
  67026. * @hidden
  67027. */
  67028. _setErrorObject(message?: string, exception?: any): void;
  67029. /**
  67030. * Execute the current task
  67031. * @param scene defines the scene where you want your assets to be loaded
  67032. * @param onSuccess is a callback called when the task is successfully executed
  67033. * @param onError is a callback called if an error occurs
  67034. */
  67035. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67036. /**
  67037. * Execute the current task
  67038. * @param scene defines the scene where you want your assets to be loaded
  67039. * @param onSuccess is a callback called when the task is successfully executed
  67040. * @param onError is a callback called if an error occurs
  67041. */
  67042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67043. /**
  67044. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67045. * This can be used with failed tasks that have the reason for failure fixed.
  67046. */
  67047. reset(): void;
  67048. private onErrorCallback;
  67049. private onDoneCallback;
  67050. }
  67051. /**
  67052. * Define the interface used by progress events raised during assets loading
  67053. */
  67054. export interface IAssetsProgressEvent {
  67055. /**
  67056. * Defines the number of remaining tasks to process
  67057. */
  67058. remainingCount: number;
  67059. /**
  67060. * Defines the total number of tasks
  67061. */
  67062. totalCount: number;
  67063. /**
  67064. * Defines the task that was just processed
  67065. */
  67066. task: AbstractAssetTask;
  67067. }
  67068. /**
  67069. * Class used to share progress information about assets loading
  67070. */
  67071. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67072. /**
  67073. * Defines the number of remaining tasks to process
  67074. */
  67075. remainingCount: number;
  67076. /**
  67077. * Defines the total number of tasks
  67078. */
  67079. totalCount: number;
  67080. /**
  67081. * Defines the task that was just processed
  67082. */
  67083. task: AbstractAssetTask;
  67084. /**
  67085. * Creates a AssetsProgressEvent
  67086. * @param remainingCount defines the number of remaining tasks to process
  67087. * @param totalCount defines the total number of tasks
  67088. * @param task defines the task that was just processed
  67089. */
  67090. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67091. }
  67092. /**
  67093. * Define a task used by AssetsManager to load meshes
  67094. */
  67095. export class MeshAssetTask extends AbstractAssetTask {
  67096. /**
  67097. * Defines the name of the task
  67098. */
  67099. name: string;
  67100. /**
  67101. * Defines the list of mesh's names you want to load
  67102. */
  67103. meshesNames: any;
  67104. /**
  67105. * Defines the root url to use as a base to load your meshes and associated resources
  67106. */
  67107. rootUrl: string;
  67108. /**
  67109. * Defines the filename of the scene to load from
  67110. */
  67111. sceneFilename: string;
  67112. /**
  67113. * Gets the list of loaded meshes
  67114. */
  67115. loadedMeshes: Array<AbstractMesh>;
  67116. /**
  67117. * Gets the list of loaded particle systems
  67118. */
  67119. loadedParticleSystems: Array<IParticleSystem>;
  67120. /**
  67121. * Gets the list of loaded skeletons
  67122. */
  67123. loadedSkeletons: Array<Skeleton>;
  67124. /**
  67125. * Gets the list of loaded animation groups
  67126. */
  67127. loadedAnimationGroups: Array<AnimationGroup>;
  67128. /**
  67129. * Callback called when the task is successful
  67130. */
  67131. onSuccess: (task: MeshAssetTask) => void;
  67132. /**
  67133. * Callback called when the task is successful
  67134. */
  67135. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67136. /**
  67137. * Creates a new MeshAssetTask
  67138. * @param name defines the name of the task
  67139. * @param meshesNames defines the list of mesh's names you want to load
  67140. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67141. * @param sceneFilename defines the filename of the scene to load from
  67142. */
  67143. constructor(
  67144. /**
  67145. * Defines the name of the task
  67146. */
  67147. name: string,
  67148. /**
  67149. * Defines the list of mesh's names you want to load
  67150. */
  67151. meshesNames: any,
  67152. /**
  67153. * Defines the root url to use as a base to load your meshes and associated resources
  67154. */
  67155. rootUrl: string,
  67156. /**
  67157. * Defines the filename of the scene to load from
  67158. */
  67159. sceneFilename: string);
  67160. /**
  67161. * Execute the current task
  67162. * @param scene defines the scene where you want your assets to be loaded
  67163. * @param onSuccess is a callback called when the task is successfully executed
  67164. * @param onError is a callback called if an error occurs
  67165. */
  67166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67167. }
  67168. /**
  67169. * Define a task used by AssetsManager to load text content
  67170. */
  67171. export class TextFileAssetTask extends AbstractAssetTask {
  67172. /**
  67173. * Defines the name of the task
  67174. */
  67175. name: string;
  67176. /**
  67177. * Defines the location of the file to load
  67178. */
  67179. url: string;
  67180. /**
  67181. * Gets the loaded text string
  67182. */
  67183. text: string;
  67184. /**
  67185. * Callback called when the task is successful
  67186. */
  67187. onSuccess: (task: TextFileAssetTask) => void;
  67188. /**
  67189. * Callback called when the task is successful
  67190. */
  67191. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67192. /**
  67193. * Creates a new TextFileAssetTask object
  67194. * @param name defines the name of the task
  67195. * @param url defines the location of the file to load
  67196. */
  67197. constructor(
  67198. /**
  67199. * Defines the name of the task
  67200. */
  67201. name: string,
  67202. /**
  67203. * Defines the location of the file to load
  67204. */
  67205. url: string);
  67206. /**
  67207. * Execute the current task
  67208. * @param scene defines the scene where you want your assets to be loaded
  67209. * @param onSuccess is a callback called when the task is successfully executed
  67210. * @param onError is a callback called if an error occurs
  67211. */
  67212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67213. }
  67214. /**
  67215. * Define a task used by AssetsManager to load binary data
  67216. */
  67217. export class BinaryFileAssetTask extends AbstractAssetTask {
  67218. /**
  67219. * Defines the name of the task
  67220. */
  67221. name: string;
  67222. /**
  67223. * Defines the location of the file to load
  67224. */
  67225. url: string;
  67226. /**
  67227. * Gets the lodaded data (as an array buffer)
  67228. */
  67229. data: ArrayBuffer;
  67230. /**
  67231. * Callback called when the task is successful
  67232. */
  67233. onSuccess: (task: BinaryFileAssetTask) => void;
  67234. /**
  67235. * Callback called when the task is successful
  67236. */
  67237. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67238. /**
  67239. * Creates a new BinaryFileAssetTask object
  67240. * @param name defines the name of the new task
  67241. * @param url defines the location of the file to load
  67242. */
  67243. constructor(
  67244. /**
  67245. * Defines the name of the task
  67246. */
  67247. name: string,
  67248. /**
  67249. * Defines the location of the file to load
  67250. */
  67251. url: string);
  67252. /**
  67253. * Execute the current task
  67254. * @param scene defines the scene where you want your assets to be loaded
  67255. * @param onSuccess is a callback called when the task is successfully executed
  67256. * @param onError is a callback called if an error occurs
  67257. */
  67258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67259. }
  67260. /**
  67261. * Define a task used by AssetsManager to load images
  67262. */
  67263. export class ImageAssetTask extends AbstractAssetTask {
  67264. /**
  67265. * Defines the name of the task
  67266. */
  67267. name: string;
  67268. /**
  67269. * Defines the location of the image to load
  67270. */
  67271. url: string;
  67272. /**
  67273. * Gets the loaded images
  67274. */
  67275. image: HTMLImageElement;
  67276. /**
  67277. * Callback called when the task is successful
  67278. */
  67279. onSuccess: (task: ImageAssetTask) => void;
  67280. /**
  67281. * Callback called when the task is successful
  67282. */
  67283. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67284. /**
  67285. * Creates a new ImageAssetTask
  67286. * @param name defines the name of the task
  67287. * @param url defines the location of the image to load
  67288. */
  67289. constructor(
  67290. /**
  67291. * Defines the name of the task
  67292. */
  67293. name: string,
  67294. /**
  67295. * Defines the location of the image to load
  67296. */
  67297. url: string);
  67298. /**
  67299. * Execute the current task
  67300. * @param scene defines the scene where you want your assets to be loaded
  67301. * @param onSuccess is a callback called when the task is successfully executed
  67302. * @param onError is a callback called if an error occurs
  67303. */
  67304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67305. }
  67306. /**
  67307. * Defines the interface used by texture loading tasks
  67308. */
  67309. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67310. /**
  67311. * Gets the loaded texture
  67312. */
  67313. texture: TEX;
  67314. }
  67315. /**
  67316. * Define a task used by AssetsManager to load 2D textures
  67317. */
  67318. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67319. /**
  67320. * Defines the name of the task
  67321. */
  67322. name: string;
  67323. /**
  67324. * Defines the location of the file to load
  67325. */
  67326. url: string;
  67327. /**
  67328. * Defines if mipmap should not be generated (default is false)
  67329. */
  67330. noMipmap?: boolean | undefined;
  67331. /**
  67332. * Defines if texture must be inverted on Y axis (default is false)
  67333. */
  67334. invertY?: boolean | undefined;
  67335. /**
  67336. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67337. */
  67338. samplingMode: number;
  67339. /**
  67340. * Gets the loaded texture
  67341. */
  67342. texture: Texture;
  67343. /**
  67344. * Callback called when the task is successful
  67345. */
  67346. onSuccess: (task: TextureAssetTask) => void;
  67347. /**
  67348. * Callback called when the task is successful
  67349. */
  67350. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67351. /**
  67352. * Creates a new TextureAssetTask object
  67353. * @param name defines the name of the task
  67354. * @param url defines the location of the file to load
  67355. * @param noMipmap defines if mipmap should not be generated (default is false)
  67356. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67357. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67358. */
  67359. constructor(
  67360. /**
  67361. * Defines the name of the task
  67362. */
  67363. name: string,
  67364. /**
  67365. * Defines the location of the file to load
  67366. */
  67367. url: string,
  67368. /**
  67369. * Defines if mipmap should not be generated (default is false)
  67370. */
  67371. noMipmap?: boolean | undefined,
  67372. /**
  67373. * Defines if texture must be inverted on Y axis (default is false)
  67374. */
  67375. invertY?: boolean | undefined,
  67376. /**
  67377. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67378. */
  67379. samplingMode?: number);
  67380. /**
  67381. * Execute the current task
  67382. * @param scene defines the scene where you want your assets to be loaded
  67383. * @param onSuccess is a callback called when the task is successfully executed
  67384. * @param onError is a callback called if an error occurs
  67385. */
  67386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67387. }
  67388. /**
  67389. * Define a task used by AssetsManager to load cube textures
  67390. */
  67391. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67392. /**
  67393. * Defines the name of the task
  67394. */
  67395. name: string;
  67396. /**
  67397. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67398. */
  67399. url: string;
  67400. /**
  67401. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67402. */
  67403. extensions?: string[] | undefined;
  67404. /**
  67405. * Defines if mipmaps should not be generated (default is false)
  67406. */
  67407. noMipmap?: boolean | undefined;
  67408. /**
  67409. * Defines the explicit list of files (undefined by default)
  67410. */
  67411. files?: string[] | undefined;
  67412. /**
  67413. * Gets the loaded texture
  67414. */
  67415. texture: CubeTexture;
  67416. /**
  67417. * Callback called when the task is successful
  67418. */
  67419. onSuccess: (task: CubeTextureAssetTask) => void;
  67420. /**
  67421. * Callback called when the task is successful
  67422. */
  67423. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67424. /**
  67425. * Creates a new CubeTextureAssetTask
  67426. * @param name defines the name of the task
  67427. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67428. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67429. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67430. * @param files defines the explicit list of files (undefined by default)
  67431. */
  67432. constructor(
  67433. /**
  67434. * Defines the name of the task
  67435. */
  67436. name: string,
  67437. /**
  67438. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67439. */
  67440. url: string,
  67441. /**
  67442. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67443. */
  67444. extensions?: string[] | undefined,
  67445. /**
  67446. * Defines if mipmaps should not be generated (default is false)
  67447. */
  67448. noMipmap?: boolean | undefined,
  67449. /**
  67450. * Defines the explicit list of files (undefined by default)
  67451. */
  67452. files?: string[] | undefined);
  67453. /**
  67454. * Execute the current task
  67455. * @param scene defines the scene where you want your assets to be loaded
  67456. * @param onSuccess is a callback called when the task is successfully executed
  67457. * @param onError is a callback called if an error occurs
  67458. */
  67459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67460. }
  67461. /**
  67462. * Define a task used by AssetsManager to load HDR cube textures
  67463. */
  67464. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67465. /**
  67466. * Defines the name of the task
  67467. */
  67468. name: string;
  67469. /**
  67470. * Defines the location of the file to load
  67471. */
  67472. url: string;
  67473. /**
  67474. * Defines the desired size (the more it increases the longer the generation will be)
  67475. */
  67476. size: number;
  67477. /**
  67478. * Defines if mipmaps should not be generated (default is false)
  67479. */
  67480. noMipmap: boolean;
  67481. /**
  67482. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67483. */
  67484. generateHarmonics: boolean;
  67485. /**
  67486. * 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)
  67487. */
  67488. gammaSpace: boolean;
  67489. /**
  67490. * Internal Use Only
  67491. */
  67492. reserved: boolean;
  67493. /**
  67494. * Gets the loaded texture
  67495. */
  67496. texture: HDRCubeTexture;
  67497. /**
  67498. * Callback called when the task is successful
  67499. */
  67500. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67501. /**
  67502. * Callback called when the task is successful
  67503. */
  67504. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67505. /**
  67506. * Creates a new HDRCubeTextureAssetTask object
  67507. * @param name defines the name of the task
  67508. * @param url defines the location of the file to load
  67509. * @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.
  67510. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67511. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67512. * @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)
  67513. * @param reserved Internal use only
  67514. */
  67515. constructor(
  67516. /**
  67517. * Defines the name of the task
  67518. */
  67519. name: string,
  67520. /**
  67521. * Defines the location of the file to load
  67522. */
  67523. url: string,
  67524. /**
  67525. * Defines the desired size (the more it increases the longer the generation will be)
  67526. */
  67527. size: number,
  67528. /**
  67529. * Defines if mipmaps should not be generated (default is false)
  67530. */
  67531. noMipmap?: boolean,
  67532. /**
  67533. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67534. */
  67535. generateHarmonics?: boolean,
  67536. /**
  67537. * 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)
  67538. */
  67539. gammaSpace?: boolean,
  67540. /**
  67541. * Internal Use Only
  67542. */
  67543. reserved?: boolean);
  67544. /**
  67545. * Execute the current task
  67546. * @param scene defines the scene where you want your assets to be loaded
  67547. * @param onSuccess is a callback called when the task is successfully executed
  67548. * @param onError is a callback called if an error occurs
  67549. */
  67550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67551. }
  67552. /**
  67553. * Define a task used by AssetsManager to load Equirectangular cube textures
  67554. */
  67555. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67556. /**
  67557. * Defines the name of the task
  67558. */
  67559. name: string;
  67560. /**
  67561. * Defines the location of the file to load
  67562. */
  67563. url: string;
  67564. /**
  67565. * Defines the desired size (the more it increases the longer the generation will be)
  67566. */
  67567. size: number;
  67568. /**
  67569. * Defines if mipmaps should not be generated (default is false)
  67570. */
  67571. noMipmap: boolean;
  67572. /**
  67573. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67574. * but the standard material would require them in Gamma space) (default is true)
  67575. */
  67576. gammaSpace: boolean;
  67577. /**
  67578. * Gets the loaded texture
  67579. */
  67580. texture: EquiRectangularCubeTexture;
  67581. /**
  67582. * Callback called when the task is successful
  67583. */
  67584. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67585. /**
  67586. * Callback called when the task is successful
  67587. */
  67588. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67589. /**
  67590. * Creates a new EquiRectangularCubeTextureAssetTask object
  67591. * @param name defines the name of the task
  67592. * @param url defines the location of the file to load
  67593. * @param size defines the desired size (the more it increases the longer the generation will be)
  67594. * If the size is omitted this implies you are using a preprocessed cubemap.
  67595. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67596. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67597. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67598. * (default is true)
  67599. */
  67600. constructor(
  67601. /**
  67602. * Defines the name of the task
  67603. */
  67604. name: string,
  67605. /**
  67606. * Defines the location of the file to load
  67607. */
  67608. url: string,
  67609. /**
  67610. * Defines the desired size (the more it increases the longer the generation will be)
  67611. */
  67612. size: number,
  67613. /**
  67614. * Defines if mipmaps should not be generated (default is false)
  67615. */
  67616. noMipmap?: boolean,
  67617. /**
  67618. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67619. * but the standard material would require them in Gamma space) (default is true)
  67620. */
  67621. gammaSpace?: boolean);
  67622. /**
  67623. * Execute the current task
  67624. * @param scene defines the scene where you want your assets to be loaded
  67625. * @param onSuccess is a callback called when the task is successfully executed
  67626. * @param onError is a callback called if an error occurs
  67627. */
  67628. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67629. }
  67630. /**
  67631. * This class can be used to easily import assets into a scene
  67632. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67633. */
  67634. export class AssetsManager {
  67635. private _scene;
  67636. private _isLoading;
  67637. protected _tasks: AbstractAssetTask[];
  67638. protected _waitingTasksCount: number;
  67639. protected _totalTasksCount: number;
  67640. /**
  67641. * Callback called when all tasks are processed
  67642. */
  67643. onFinish: (tasks: AbstractAssetTask[]) => void;
  67644. /**
  67645. * Callback called when a task is successful
  67646. */
  67647. onTaskSuccess: (task: AbstractAssetTask) => void;
  67648. /**
  67649. * Callback called when a task had an error
  67650. */
  67651. onTaskError: (task: AbstractAssetTask) => void;
  67652. /**
  67653. * Callback called when a task is done (whatever the result is)
  67654. */
  67655. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67656. /**
  67657. * Observable called when all tasks are processed
  67658. */
  67659. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67660. /**
  67661. * Observable called when a task had an error
  67662. */
  67663. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67664. /**
  67665. * Observable called when all tasks were executed
  67666. */
  67667. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67668. /**
  67669. * Observable called when a task is done (whatever the result is)
  67670. */
  67671. onProgressObservable: Observable<IAssetsProgressEvent>;
  67672. /**
  67673. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67674. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67675. */
  67676. useDefaultLoadingScreen: boolean;
  67677. /**
  67678. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67679. * when all assets have been downloaded.
  67680. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67681. */
  67682. autoHideLoadingUI: boolean;
  67683. /**
  67684. * Creates a new AssetsManager
  67685. * @param scene defines the scene to work on
  67686. */
  67687. constructor(scene: Scene);
  67688. /**
  67689. * Add a MeshAssetTask to the list of active tasks
  67690. * @param taskName defines the name of the new task
  67691. * @param meshesNames defines the name of meshes to load
  67692. * @param rootUrl defines the root url to use to locate files
  67693. * @param sceneFilename defines the filename of the scene file
  67694. * @returns a new MeshAssetTask object
  67695. */
  67696. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67697. /**
  67698. * Add a TextFileAssetTask to the list of active tasks
  67699. * @param taskName defines the name of the new task
  67700. * @param url defines the url of the file to load
  67701. * @returns a new TextFileAssetTask object
  67702. */
  67703. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67704. /**
  67705. * Add a BinaryFileAssetTask to the list of active tasks
  67706. * @param taskName defines the name of the new task
  67707. * @param url defines the url of the file to load
  67708. * @returns a new BinaryFileAssetTask object
  67709. */
  67710. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67711. /**
  67712. * Add a ImageAssetTask to the list of active tasks
  67713. * @param taskName defines the name of the new task
  67714. * @param url defines the url of the file to load
  67715. * @returns a new ImageAssetTask object
  67716. */
  67717. addImageTask(taskName: string, url: string): ImageAssetTask;
  67718. /**
  67719. * Add a TextureAssetTask to the list of active tasks
  67720. * @param taskName defines the name of the new task
  67721. * @param url defines the url of the file to load
  67722. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67723. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67724. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67725. * @returns a new TextureAssetTask object
  67726. */
  67727. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67728. /**
  67729. * Add a CubeTextureAssetTask to the list of active tasks
  67730. * @param taskName defines the name of the new task
  67731. * @param url defines the url of the file to load
  67732. * @param extensions defines the extension to use to load the cube map (can be null)
  67733. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67734. * @param files defines the list of files to load (can be null)
  67735. * @returns a new CubeTextureAssetTask object
  67736. */
  67737. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67738. /**
  67739. *
  67740. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67741. * @param taskName defines the name of the new task
  67742. * @param url defines the url of the file to load
  67743. * @param size defines the size you want for the cubemap (can be null)
  67744. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67745. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67746. * @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)
  67747. * @param reserved Internal use only
  67748. * @returns a new HDRCubeTextureAssetTask object
  67749. */
  67750. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67751. /**
  67752. *
  67753. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67754. * @param taskName defines the name of the new task
  67755. * @param url defines the url of the file to load
  67756. * @param size defines the size you want for the cubemap (can be null)
  67757. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67758. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67759. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67760. * @returns a new EquiRectangularCubeTextureAssetTask object
  67761. */
  67762. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67763. /**
  67764. * Remove a task from the assets manager.
  67765. * @param task the task to remove
  67766. */
  67767. removeTask(task: AbstractAssetTask): void;
  67768. private _decreaseWaitingTasksCount;
  67769. private _runTask;
  67770. /**
  67771. * Reset the AssetsManager and remove all tasks
  67772. * @return the current instance of the AssetsManager
  67773. */
  67774. reset(): AssetsManager;
  67775. /**
  67776. * Start the loading process
  67777. * @return the current instance of the AssetsManager
  67778. */
  67779. load(): AssetsManager;
  67780. /**
  67781. * Start the loading process as an async operation
  67782. * @return a promise returning the list of failed tasks
  67783. */
  67784. loadAsync(): Promise<void>;
  67785. }
  67786. }
  67787. declare module BABYLON {
  67788. /**
  67789. * Wrapper class for promise with external resolve and reject.
  67790. */
  67791. export class Deferred<T> {
  67792. /**
  67793. * The promise associated with this deferred object.
  67794. */
  67795. readonly promise: Promise<T>;
  67796. private _resolve;
  67797. private _reject;
  67798. /**
  67799. * The resolve method of the promise associated with this deferred object.
  67800. */
  67801. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67802. /**
  67803. * The reject method of the promise associated with this deferred object.
  67804. */
  67805. get reject(): (reason?: any) => void;
  67806. /**
  67807. * Constructor for this deferred object.
  67808. */
  67809. constructor();
  67810. }
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67815. */
  67816. export class MeshExploder {
  67817. private _centerMesh;
  67818. private _meshes;
  67819. private _meshesOrigins;
  67820. private _toCenterVectors;
  67821. private _scaledDirection;
  67822. private _newPosition;
  67823. private _centerPosition;
  67824. /**
  67825. * Explodes meshes from a center mesh.
  67826. * @param meshes The meshes to explode.
  67827. * @param centerMesh The mesh to be center of explosion.
  67828. */
  67829. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67830. private _setCenterMesh;
  67831. /**
  67832. * Get class name
  67833. * @returns "MeshExploder"
  67834. */
  67835. getClassName(): string;
  67836. /**
  67837. * "Exploded meshes"
  67838. * @returns Array of meshes with the centerMesh at index 0.
  67839. */
  67840. getMeshes(): Array<Mesh>;
  67841. /**
  67842. * Explodes meshes giving a specific direction
  67843. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67844. */
  67845. explode(direction?: number): void;
  67846. }
  67847. }
  67848. declare module BABYLON {
  67849. /**
  67850. * Class used to help managing file picking and drag'n'drop
  67851. */
  67852. export class FilesInput {
  67853. /**
  67854. * List of files ready to be loaded
  67855. */
  67856. static get FilesToLoad(): {
  67857. [key: string]: File;
  67858. };
  67859. /**
  67860. * Callback called when a file is processed
  67861. */
  67862. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67863. private _engine;
  67864. private _currentScene;
  67865. private _sceneLoadedCallback;
  67866. private _progressCallback;
  67867. private _additionalRenderLoopLogicCallback;
  67868. private _textureLoadingCallback;
  67869. private _startingProcessingFilesCallback;
  67870. private _onReloadCallback;
  67871. private _errorCallback;
  67872. private _elementToMonitor;
  67873. private _sceneFileToLoad;
  67874. private _filesToLoad;
  67875. /**
  67876. * Creates a new FilesInput
  67877. * @param engine defines the rendering engine
  67878. * @param scene defines the hosting scene
  67879. * @param sceneLoadedCallback callback called when scene is loaded
  67880. * @param progressCallback callback called to track progress
  67881. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67882. * @param textureLoadingCallback callback called when a texture is loading
  67883. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67884. * @param onReloadCallback callback called when a reload is requested
  67885. * @param errorCallback callback call if an error occurs
  67886. */
  67887. 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);
  67888. private _dragEnterHandler;
  67889. private _dragOverHandler;
  67890. private _dropHandler;
  67891. /**
  67892. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67893. * @param elementToMonitor defines the DOM element to track
  67894. */
  67895. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67896. /**
  67897. * Release all associated resources
  67898. */
  67899. dispose(): void;
  67900. private renderFunction;
  67901. private drag;
  67902. private drop;
  67903. private _traverseFolder;
  67904. private _processFiles;
  67905. /**
  67906. * Load files from a drop event
  67907. * @param event defines the drop event to use as source
  67908. */
  67909. loadFiles(event: any): void;
  67910. private _processReload;
  67911. /**
  67912. * Reload the current scene from the loaded files
  67913. */
  67914. reload(): void;
  67915. }
  67916. }
  67917. declare module BABYLON {
  67918. /**
  67919. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67921. */
  67922. export class SceneOptimization {
  67923. /**
  67924. * Defines the priority of this optimization (0 by default which means first in the list)
  67925. */
  67926. priority: number;
  67927. /**
  67928. * Gets a string describing the action executed by the current optimization
  67929. * @returns description string
  67930. */
  67931. getDescription(): string;
  67932. /**
  67933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67934. * @param scene defines the current scene where to apply this optimization
  67935. * @param optimizer defines the current optimizer
  67936. * @returns true if everything that can be done was applied
  67937. */
  67938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67939. /**
  67940. * Creates the SceneOptimization object
  67941. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67942. * @param desc defines the description associated with the optimization
  67943. */
  67944. constructor(
  67945. /**
  67946. * Defines the priority of this optimization (0 by default which means first in the list)
  67947. */
  67948. priority?: number);
  67949. }
  67950. /**
  67951. * Defines an optimization used to reduce the size of render target textures
  67952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67953. */
  67954. export class TextureOptimization extends SceneOptimization {
  67955. /**
  67956. * Defines the priority of this optimization (0 by default which means first in the list)
  67957. */
  67958. priority: number;
  67959. /**
  67960. * 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
  67961. */
  67962. maximumSize: number;
  67963. /**
  67964. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67965. */
  67966. step: number;
  67967. /**
  67968. * Gets a string describing the action executed by the current optimization
  67969. * @returns description string
  67970. */
  67971. getDescription(): string;
  67972. /**
  67973. * Creates the TextureOptimization object
  67974. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67975. * @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
  67976. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67977. */
  67978. constructor(
  67979. /**
  67980. * Defines the priority of this optimization (0 by default which means first in the list)
  67981. */
  67982. priority?: number,
  67983. /**
  67984. * 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
  67985. */
  67986. maximumSize?: number,
  67987. /**
  67988. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67989. */
  67990. step?: number);
  67991. /**
  67992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67993. * @param scene defines the current scene where to apply this optimization
  67994. * @param optimizer defines the current optimizer
  67995. * @returns true if everything that can be done was applied
  67996. */
  67997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67998. }
  67999. /**
  68000. * Defines an optimization used to increase or decrease the rendering resolution
  68001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68002. */
  68003. export class HardwareScalingOptimization extends SceneOptimization {
  68004. /**
  68005. * Defines the priority of this optimization (0 by default which means first in the list)
  68006. */
  68007. priority: number;
  68008. /**
  68009. * Defines the maximum scale to use (2 by default)
  68010. */
  68011. maximumScale: number;
  68012. /**
  68013. * Defines the step to use between two passes (0.5 by default)
  68014. */
  68015. step: number;
  68016. private _currentScale;
  68017. private _directionOffset;
  68018. /**
  68019. * Gets a string describing the action executed by the current optimization
  68020. * @return description string
  68021. */
  68022. getDescription(): string;
  68023. /**
  68024. * Creates the HardwareScalingOptimization object
  68025. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68026. * @param maximumScale defines the maximum scale to use (2 by default)
  68027. * @param step defines the step to use between two passes (0.5 by default)
  68028. */
  68029. constructor(
  68030. /**
  68031. * Defines the priority of this optimization (0 by default which means first in the list)
  68032. */
  68033. priority?: number,
  68034. /**
  68035. * Defines the maximum scale to use (2 by default)
  68036. */
  68037. maximumScale?: number,
  68038. /**
  68039. * Defines the step to use between two passes (0.5 by default)
  68040. */
  68041. step?: number);
  68042. /**
  68043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68044. * @param scene defines the current scene where to apply this optimization
  68045. * @param optimizer defines the current optimizer
  68046. * @returns true if everything that can be done was applied
  68047. */
  68048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68049. }
  68050. /**
  68051. * Defines an optimization used to remove shadows
  68052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68053. */
  68054. export class ShadowsOptimization extends SceneOptimization {
  68055. /**
  68056. * Gets a string describing the action executed by the current optimization
  68057. * @return description string
  68058. */
  68059. getDescription(): string;
  68060. /**
  68061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68062. * @param scene defines the current scene where to apply this optimization
  68063. * @param optimizer defines the current optimizer
  68064. * @returns true if everything that can be done was applied
  68065. */
  68066. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68067. }
  68068. /**
  68069. * Defines an optimization used to turn post-processes off
  68070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68071. */
  68072. export class PostProcessesOptimization extends SceneOptimization {
  68073. /**
  68074. * Gets a string describing the action executed by the current optimization
  68075. * @return description string
  68076. */
  68077. getDescription(): string;
  68078. /**
  68079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68080. * @param scene defines the current scene where to apply this optimization
  68081. * @param optimizer defines the current optimizer
  68082. * @returns true if everything that can be done was applied
  68083. */
  68084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68085. }
  68086. /**
  68087. * Defines an optimization used to turn lens flares off
  68088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68089. */
  68090. export class LensFlaresOptimization extends SceneOptimization {
  68091. /**
  68092. * Gets a string describing the action executed by the current optimization
  68093. * @return description string
  68094. */
  68095. getDescription(): string;
  68096. /**
  68097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68098. * @param scene defines the current scene where to apply this optimization
  68099. * @param optimizer defines the current optimizer
  68100. * @returns true if everything that can be done was applied
  68101. */
  68102. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68103. }
  68104. /**
  68105. * Defines an optimization based on user defined callback.
  68106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68107. */
  68108. export class CustomOptimization extends SceneOptimization {
  68109. /**
  68110. * Callback called to apply the custom optimization.
  68111. */
  68112. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68113. /**
  68114. * Callback called to get custom description
  68115. */
  68116. onGetDescription: () => string;
  68117. /**
  68118. * Gets a string describing the action executed by the current optimization
  68119. * @returns description string
  68120. */
  68121. getDescription(): string;
  68122. /**
  68123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68124. * @param scene defines the current scene where to apply this optimization
  68125. * @param optimizer defines the current optimizer
  68126. * @returns true if everything that can be done was applied
  68127. */
  68128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68129. }
  68130. /**
  68131. * Defines an optimization used to turn particles off
  68132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68133. */
  68134. export class ParticlesOptimization extends SceneOptimization {
  68135. /**
  68136. * Gets a string describing the action executed by the current optimization
  68137. * @return description string
  68138. */
  68139. getDescription(): string;
  68140. /**
  68141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68142. * @param scene defines the current scene where to apply this optimization
  68143. * @param optimizer defines the current optimizer
  68144. * @returns true if everything that can be done was applied
  68145. */
  68146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68147. }
  68148. /**
  68149. * Defines an optimization used to turn render targets off
  68150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68151. */
  68152. export class RenderTargetsOptimization extends SceneOptimization {
  68153. /**
  68154. * Gets a string describing the action executed by the current optimization
  68155. * @return description string
  68156. */
  68157. getDescription(): string;
  68158. /**
  68159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68160. * @param scene defines the current scene where to apply this optimization
  68161. * @param optimizer defines the current optimizer
  68162. * @returns true if everything that can be done was applied
  68163. */
  68164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68165. }
  68166. /**
  68167. * Defines an optimization used to merge meshes with compatible materials
  68168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68169. */
  68170. export class MergeMeshesOptimization extends SceneOptimization {
  68171. private static _UpdateSelectionTree;
  68172. /**
  68173. * Gets or sets a boolean which defines if optimization octree has to be updated
  68174. */
  68175. static get UpdateSelectionTree(): boolean;
  68176. /**
  68177. * Gets or sets a boolean which defines if optimization octree has to be updated
  68178. */
  68179. static set UpdateSelectionTree(value: boolean);
  68180. /**
  68181. * Gets a string describing the action executed by the current optimization
  68182. * @return description string
  68183. */
  68184. getDescription(): string;
  68185. private _canBeMerged;
  68186. /**
  68187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68188. * @param scene defines the current scene where to apply this optimization
  68189. * @param optimizer defines the current optimizer
  68190. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68191. * @returns true if everything that can be done was applied
  68192. */
  68193. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68194. }
  68195. /**
  68196. * Defines a list of options used by SceneOptimizer
  68197. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68198. */
  68199. export class SceneOptimizerOptions {
  68200. /**
  68201. * Defines the target frame rate to reach (60 by default)
  68202. */
  68203. targetFrameRate: number;
  68204. /**
  68205. * Defines the interval between two checkes (2000ms by default)
  68206. */
  68207. trackerDuration: number;
  68208. /**
  68209. * Gets the list of optimizations to apply
  68210. */
  68211. optimizations: SceneOptimization[];
  68212. /**
  68213. * Creates a new list of options used by SceneOptimizer
  68214. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68215. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68216. */
  68217. constructor(
  68218. /**
  68219. * Defines the target frame rate to reach (60 by default)
  68220. */
  68221. targetFrameRate?: number,
  68222. /**
  68223. * Defines the interval between two checkes (2000ms by default)
  68224. */
  68225. trackerDuration?: number);
  68226. /**
  68227. * Add a new optimization
  68228. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68229. * @returns the current SceneOptimizerOptions
  68230. */
  68231. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68232. /**
  68233. * Add a new custom optimization
  68234. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68235. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68236. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68237. * @returns the current SceneOptimizerOptions
  68238. */
  68239. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68240. /**
  68241. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68242. * @param targetFrameRate defines the target frame rate (60 by default)
  68243. * @returns a SceneOptimizerOptions object
  68244. */
  68245. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68246. /**
  68247. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68248. * @param targetFrameRate defines the target frame rate (60 by default)
  68249. * @returns a SceneOptimizerOptions object
  68250. */
  68251. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68252. /**
  68253. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68254. * @param targetFrameRate defines the target frame rate (60 by default)
  68255. * @returns a SceneOptimizerOptions object
  68256. */
  68257. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68258. }
  68259. /**
  68260. * Class used to run optimizations in order to reach a target frame rate
  68261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68262. */
  68263. export class SceneOptimizer implements IDisposable {
  68264. private _isRunning;
  68265. private _options;
  68266. private _scene;
  68267. private _currentPriorityLevel;
  68268. private _targetFrameRate;
  68269. private _trackerDuration;
  68270. private _currentFrameRate;
  68271. private _sceneDisposeObserver;
  68272. private _improvementMode;
  68273. /**
  68274. * Defines an observable called when the optimizer reaches the target frame rate
  68275. */
  68276. onSuccessObservable: Observable<SceneOptimizer>;
  68277. /**
  68278. * Defines an observable called when the optimizer enables an optimization
  68279. */
  68280. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68281. /**
  68282. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68283. */
  68284. onFailureObservable: Observable<SceneOptimizer>;
  68285. /**
  68286. * Gets a boolean indicating if the optimizer is in improvement mode
  68287. */
  68288. get isInImprovementMode(): boolean;
  68289. /**
  68290. * Gets the current priority level (0 at start)
  68291. */
  68292. get currentPriorityLevel(): number;
  68293. /**
  68294. * Gets the current frame rate checked by the SceneOptimizer
  68295. */
  68296. get currentFrameRate(): number;
  68297. /**
  68298. * Gets or sets the current target frame rate (60 by default)
  68299. */
  68300. get targetFrameRate(): number;
  68301. /**
  68302. * Gets or sets the current target frame rate (60 by default)
  68303. */
  68304. set targetFrameRate(value: number);
  68305. /**
  68306. * Gets or sets the current interval between two checks (every 2000ms by default)
  68307. */
  68308. get trackerDuration(): number;
  68309. /**
  68310. * Gets or sets the current interval between two checks (every 2000ms by default)
  68311. */
  68312. set trackerDuration(value: number);
  68313. /**
  68314. * Gets the list of active optimizations
  68315. */
  68316. get optimizations(): SceneOptimization[];
  68317. /**
  68318. * Creates a new SceneOptimizer
  68319. * @param scene defines the scene to work on
  68320. * @param options defines the options to use with the SceneOptimizer
  68321. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68322. * @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)
  68323. */
  68324. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68325. /**
  68326. * Stops the current optimizer
  68327. */
  68328. stop(): void;
  68329. /**
  68330. * Reset the optimizer to initial step (current priority level = 0)
  68331. */
  68332. reset(): void;
  68333. /**
  68334. * Start the optimizer. By default it will try to reach a specific framerate
  68335. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68336. */
  68337. start(): void;
  68338. private _checkCurrentState;
  68339. /**
  68340. * Release all resources
  68341. */
  68342. dispose(): void;
  68343. /**
  68344. * Helper function to create a SceneOptimizer with one single line of code
  68345. * @param scene defines the scene to work on
  68346. * @param options defines the options to use with the SceneOptimizer
  68347. * @param onSuccess defines a callback to call on success
  68348. * @param onFailure defines a callback to call on failure
  68349. * @returns the new SceneOptimizer object
  68350. */
  68351. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /**
  68356. * Class used to serialize a scene into a string
  68357. */
  68358. export class SceneSerializer {
  68359. /**
  68360. * Clear cache used by a previous serialization
  68361. */
  68362. static ClearCache(): void;
  68363. /**
  68364. * Serialize a scene into a JSON compatible object
  68365. * @param scene defines the scene to serialize
  68366. * @returns a JSON compatible object
  68367. */
  68368. static Serialize(scene: Scene): any;
  68369. /**
  68370. * Serialize a mesh into a JSON compatible object
  68371. * @param toSerialize defines the mesh to serialize
  68372. * @param withParents defines if parents must be serialized as well
  68373. * @param withChildren defines if children must be serialized as well
  68374. * @returns a JSON compatible object
  68375. */
  68376. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68377. }
  68378. }
  68379. declare module BABYLON {
  68380. /**
  68381. * Class used to host texture specific utilities
  68382. */
  68383. export class TextureTools {
  68384. /**
  68385. * Uses the GPU to create a copy texture rescaled at a given size
  68386. * @param texture Texture to copy from
  68387. * @param width defines the desired width
  68388. * @param height defines the desired height
  68389. * @param useBilinearMode defines if bilinear mode has to be used
  68390. * @return the generated texture
  68391. */
  68392. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68393. }
  68394. }
  68395. declare module BABYLON {
  68396. /**
  68397. * This represents the different options available for the video capture.
  68398. */
  68399. export interface VideoRecorderOptions {
  68400. /** Defines the mime type of the video. */
  68401. mimeType: string;
  68402. /** Defines the FPS the video should be recorded at. */
  68403. fps: number;
  68404. /** Defines the chunk size for the recording data. */
  68405. recordChunckSize: number;
  68406. /** The audio tracks to attach to the recording. */
  68407. audioTracks?: MediaStreamTrack[];
  68408. }
  68409. /**
  68410. * This can help with recording videos from BabylonJS.
  68411. * This is based on the available WebRTC functionalities of the browser.
  68412. *
  68413. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68414. */
  68415. export class VideoRecorder {
  68416. private static readonly _defaultOptions;
  68417. /**
  68418. * Returns whether or not the VideoRecorder is available in your browser.
  68419. * @param engine Defines the Babylon Engine.
  68420. * @returns true if supported otherwise false.
  68421. */
  68422. static IsSupported(engine: Engine): boolean;
  68423. private readonly _options;
  68424. private _canvas;
  68425. private _mediaRecorder;
  68426. private _recordedChunks;
  68427. private _fileName;
  68428. private _resolve;
  68429. private _reject;
  68430. /**
  68431. * True when a recording is already in progress.
  68432. */
  68433. get isRecording(): boolean;
  68434. /**
  68435. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68436. * @param engine Defines the BabylonJS Engine you wish to record.
  68437. * @param options Defines options that can be used to customize the capture.
  68438. */
  68439. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68440. /**
  68441. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68442. */
  68443. stopRecording(): void;
  68444. /**
  68445. * Starts recording the canvas for a max duration specified in parameters.
  68446. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68447. * If null no automatic download will start and you can rely on the promise to get the data back.
  68448. * @param maxDuration Defines the maximum recording time in seconds.
  68449. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68450. * @return A promise callback at the end of the recording with the video data in Blob.
  68451. */
  68452. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68453. /**
  68454. * Releases internal resources used during the recording.
  68455. */
  68456. dispose(): void;
  68457. private _handleDataAvailable;
  68458. private _handleError;
  68459. private _handleStop;
  68460. }
  68461. }
  68462. declare module BABYLON {
  68463. /**
  68464. * Class containing a set of static utilities functions for screenshots
  68465. */
  68466. export class ScreenshotTools {
  68467. /**
  68468. * Captures a screenshot of the current rendering
  68469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68470. * @param engine defines the rendering engine
  68471. * @param camera defines the source camera
  68472. * @param size This parameter can be set to a single number or to an object with the
  68473. * following (optional) properties: precision, width, height. If a single number is passed,
  68474. * it will be used for both width and height. If an object is passed, the screenshot size
  68475. * will be derived from the parameters. The precision property is a multiplier allowing
  68476. * rendering at a higher or lower resolution
  68477. * @param successCallback defines the callback receives a single parameter which contains the
  68478. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68479. * src parameter of an <img> to display it
  68480. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68481. * Check your browser for supported MIME types
  68482. */
  68483. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68484. /**
  68485. * Captures a screenshot of the current rendering
  68486. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68487. * @param engine defines the rendering engine
  68488. * @param camera defines the source camera
  68489. * @param size This parameter can be set to a single number or to an object with the
  68490. * following (optional) properties: precision, width, height. If a single number is passed,
  68491. * it will be used for both width and height. If an object is passed, the screenshot size
  68492. * will be derived from the parameters. The precision property is a multiplier allowing
  68493. * rendering at a higher or lower resolution
  68494. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68495. * Check your browser for supported MIME types
  68496. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68497. * to the src parameter of an <img> to display it
  68498. */
  68499. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68500. /**
  68501. * Generates an image screenshot from the specified camera.
  68502. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68503. * @param engine The engine to use for rendering
  68504. * @param camera The camera to use for rendering
  68505. * @param size This parameter can be set to a single number or to an object with the
  68506. * following (optional) properties: precision, width, height. If a single number is passed,
  68507. * it will be used for both width and height. If an object is passed, the screenshot size
  68508. * will be derived from the parameters. The precision property is a multiplier allowing
  68509. * rendering at a higher or lower resolution
  68510. * @param successCallback The callback receives a single parameter which contains the
  68511. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68512. * src parameter of an <img> to display it
  68513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68514. * Check your browser for supported MIME types
  68515. * @param samples Texture samples (default: 1)
  68516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68517. * @param fileName A name for for the downloaded file.
  68518. */
  68519. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68520. /**
  68521. * Generates an image screenshot from the specified camera.
  68522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68523. * @param engine The engine to use for rendering
  68524. * @param camera The camera to use for rendering
  68525. * @param size This parameter can be set to a single number or to an object with the
  68526. * following (optional) properties: precision, width, height. If a single number is passed,
  68527. * it will be used for both width and height. If an object is passed, the screenshot size
  68528. * will be derived from the parameters. The precision property is a multiplier allowing
  68529. * rendering at a higher or lower resolution
  68530. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68531. * Check your browser for supported MIME types
  68532. * @param samples Texture samples (default: 1)
  68533. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68534. * @param fileName A name for for the downloaded file.
  68535. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68536. * to the src parameter of an <img> to display it
  68537. */
  68538. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68539. /**
  68540. * Gets height and width for screenshot size
  68541. * @private
  68542. */
  68543. private static _getScreenshotSize;
  68544. }
  68545. }
  68546. declare module BABYLON {
  68547. /**
  68548. * Interface for a data buffer
  68549. */
  68550. export interface IDataBuffer {
  68551. /**
  68552. * Reads bytes from the data buffer.
  68553. * @param byteOffset The byte offset to read
  68554. * @param byteLength The byte length to read
  68555. * @returns A promise that resolves when the bytes are read
  68556. */
  68557. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68558. /**
  68559. * The byte length of the buffer.
  68560. */
  68561. readonly byteLength: number;
  68562. }
  68563. /**
  68564. * Utility class for reading from a data buffer
  68565. */
  68566. export class DataReader {
  68567. /**
  68568. * The data buffer associated with this data reader.
  68569. */
  68570. readonly buffer: IDataBuffer;
  68571. /**
  68572. * The current byte offset from the beginning of the data buffer.
  68573. */
  68574. byteOffset: number;
  68575. private _dataView;
  68576. private _dataByteOffset;
  68577. /**
  68578. * Constructor
  68579. * @param buffer The buffer to read
  68580. */
  68581. constructor(buffer: IDataBuffer);
  68582. /**
  68583. * Loads the given byte length.
  68584. * @param byteLength The byte length to load
  68585. * @returns A promise that resolves when the load is complete
  68586. */
  68587. loadAsync(byteLength: number): Promise<void>;
  68588. /**
  68589. * Read a unsigned 32-bit integer from the currently loaded data range.
  68590. * @returns The 32-bit integer read
  68591. */
  68592. readUint32(): number;
  68593. /**
  68594. * Read a byte array from the currently loaded data range.
  68595. * @param byteLength The byte length to read
  68596. * @returns The byte array read
  68597. */
  68598. readUint8Array(byteLength: number): Uint8Array;
  68599. /**
  68600. * Read a string from the currently loaded data range.
  68601. * @param byteLength The byte length to read
  68602. * @returns The string read
  68603. */
  68604. readString(byteLength: number): string;
  68605. /**
  68606. * Skips the given byte length the currently loaded data range.
  68607. * @param byteLength The byte length to skip
  68608. */
  68609. skipBytes(byteLength: number): void;
  68610. }
  68611. }
  68612. declare module BABYLON {
  68613. /**
  68614. * A cursor which tracks a point on a path
  68615. */
  68616. export class PathCursor {
  68617. private path;
  68618. /**
  68619. * Stores path cursor callbacks for when an onchange event is triggered
  68620. */
  68621. private _onchange;
  68622. /**
  68623. * The value of the path cursor
  68624. */
  68625. value: number;
  68626. /**
  68627. * The animation array of the path cursor
  68628. */
  68629. animations: Animation[];
  68630. /**
  68631. * Initializes the path cursor
  68632. * @param path The path to track
  68633. */
  68634. constructor(path: Path2);
  68635. /**
  68636. * Gets the cursor point on the path
  68637. * @returns A point on the path cursor at the cursor location
  68638. */
  68639. getPoint(): Vector3;
  68640. /**
  68641. * Moves the cursor ahead by the step amount
  68642. * @param step The amount to move the cursor forward
  68643. * @returns This path cursor
  68644. */
  68645. moveAhead(step?: number): PathCursor;
  68646. /**
  68647. * Moves the cursor behind by the step amount
  68648. * @param step The amount to move the cursor back
  68649. * @returns This path cursor
  68650. */
  68651. moveBack(step?: number): PathCursor;
  68652. /**
  68653. * Moves the cursor by the step amount
  68654. * If the step amount is greater than one, an exception is thrown
  68655. * @param step The amount to move the cursor
  68656. * @returns This path cursor
  68657. */
  68658. move(step: number): PathCursor;
  68659. /**
  68660. * Ensures that the value is limited between zero and one
  68661. * @returns This path cursor
  68662. */
  68663. private ensureLimits;
  68664. /**
  68665. * Runs onchange callbacks on change (used by the animation engine)
  68666. * @returns This path cursor
  68667. */
  68668. private raiseOnChange;
  68669. /**
  68670. * Executes a function on change
  68671. * @param f A path cursor onchange callback
  68672. * @returns This path cursor
  68673. */
  68674. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68675. }
  68676. }
  68677. declare module BABYLON {
  68678. /** @hidden */
  68679. export var blurPixelShader: {
  68680. name: string;
  68681. shader: string;
  68682. };
  68683. }
  68684. declare module BABYLON {
  68685. /** @hidden */
  68686. export var pointCloudVertexDeclaration: {
  68687. name: string;
  68688. shader: string;
  68689. };
  68690. }
  68691. // Mixins
  68692. interface Window {
  68693. mozIndexedDB: IDBFactory;
  68694. webkitIndexedDB: IDBFactory;
  68695. msIndexedDB: IDBFactory;
  68696. webkitURL: typeof URL;
  68697. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  68698. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  68699. WebGLRenderingContext: WebGLRenderingContext;
  68700. MSGesture: MSGesture;
  68701. CANNON: any;
  68702. AudioContext: AudioContext;
  68703. webkitAudioContext: AudioContext;
  68704. PointerEvent: any;
  68705. Math: Math;
  68706. Uint8Array: Uint8ArrayConstructor;
  68707. Float32Array: Float32ArrayConstructor;
  68708. mozURL: typeof URL;
  68709. msURL: typeof URL;
  68710. VRFrameData: any; // WebVR, from specs 1.1
  68711. DracoDecoderModule: any;
  68712. setImmediate(handler: (...args: any[]) => void): number;
  68713. }
  68714. interface HTMLCanvasElement {
  68715. requestPointerLock(): void;
  68716. msRequestPointerLock?(): void;
  68717. mozRequestPointerLock?(): void;
  68718. webkitRequestPointerLock?(): void;
  68719. /** Track wether a record is in progress */
  68720. isRecording: boolean;
  68721. /** Capture Stream method defined by some browsers */
  68722. captureStream(fps?: number): MediaStream;
  68723. }
  68724. interface CanvasRenderingContext2D {
  68725. msImageSmoothingEnabled: boolean;
  68726. }
  68727. interface MouseEvent {
  68728. mozMovementX: number;
  68729. mozMovementY: number;
  68730. webkitMovementX: number;
  68731. webkitMovementY: number;
  68732. msMovementX: number;
  68733. msMovementY: number;
  68734. }
  68735. interface Navigator {
  68736. mozGetVRDevices: (any: any) => any;
  68737. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68738. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68739. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68740. webkitGetGamepads(): Gamepad[];
  68741. msGetGamepads(): Gamepad[];
  68742. webkitGamepads(): Gamepad[];
  68743. }
  68744. interface HTMLVideoElement {
  68745. mozSrcObject: any;
  68746. }
  68747. interface Math {
  68748. fround(x: number): number;
  68749. imul(a: number, b: number): number;
  68750. }
  68751. interface WebGLRenderingContext {
  68752. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  68753. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  68754. vertexAttribDivisor(index: number, divisor: number): void;
  68755. createVertexArray(): any;
  68756. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  68757. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  68758. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  68759. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  68760. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  68761. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  68762. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  68763. // Queries
  68764. createQuery(): WebGLQuery;
  68765. deleteQuery(query: WebGLQuery): void;
  68766. beginQuery(target: number, query: WebGLQuery): void;
  68767. endQuery(target: number): void;
  68768. getQueryParameter(query: WebGLQuery, pname: number): any;
  68769. getQuery(target: number, pname: number): any;
  68770. MAX_SAMPLES: number;
  68771. RGBA8: number;
  68772. READ_FRAMEBUFFER: number;
  68773. DRAW_FRAMEBUFFER: number;
  68774. UNIFORM_BUFFER: number;
  68775. HALF_FLOAT_OES: number;
  68776. RGBA16F: number;
  68777. RGBA32F: number;
  68778. R32F: number;
  68779. RG32F: number;
  68780. RGB32F: number;
  68781. R16F: number;
  68782. RG16F: number;
  68783. RGB16F: number;
  68784. RED: number;
  68785. RG: number;
  68786. R8: number;
  68787. RG8: number;
  68788. UNSIGNED_INT_24_8: number;
  68789. DEPTH24_STENCIL8: number;
  68790. MIN: number;
  68791. MAX: number;
  68792. /* Multiple Render Targets */
  68793. drawBuffers(buffers: number[]): void;
  68794. readBuffer(src: number): void;
  68795. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  68796. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  68797. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  68798. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  68799. // Occlusion Query
  68800. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  68801. ANY_SAMPLES_PASSED: number;
  68802. QUERY_RESULT_AVAILABLE: number;
  68803. QUERY_RESULT: number;
  68804. }
  68805. interface WebGLProgram {
  68806. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  68807. }
  68808. interface EXT_disjoint_timer_query {
  68809. QUERY_COUNTER_BITS_EXT: number;
  68810. TIME_ELAPSED_EXT: number;
  68811. TIMESTAMP_EXT: number;
  68812. GPU_DISJOINT_EXT: number;
  68813. QUERY_RESULT_EXT: number;
  68814. QUERY_RESULT_AVAILABLE_EXT: number;
  68815. queryCounterEXT(query: WebGLQuery, target: number): void;
  68816. createQueryEXT(): WebGLQuery;
  68817. beginQueryEXT(target: number, query: WebGLQuery): void;
  68818. endQueryEXT(target: number): void;
  68819. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  68820. deleteQueryEXT(query: WebGLQuery): void;
  68821. }
  68822. interface WebGLUniformLocation {
  68823. _currentState: any;
  68824. }
  68825. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  68826. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  68827. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  68828. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  68829. interface WebGLRenderingContext {
  68830. readonly RASTERIZER_DISCARD: number;
  68831. readonly DEPTH_COMPONENT24: number;
  68832. readonly TEXTURE_3D: number;
  68833. readonly TEXTURE_2D_ARRAY: number;
  68834. readonly TEXTURE_COMPARE_FUNC: number;
  68835. readonly TEXTURE_COMPARE_MODE: number;
  68836. readonly COMPARE_REF_TO_TEXTURE: number;
  68837. readonly TEXTURE_WRAP_R: number;
  68838. readonly HALF_FLOAT: number;
  68839. readonly RGB8: number;
  68840. readonly RED_INTEGER: number;
  68841. readonly RG_INTEGER: number;
  68842. readonly RGB_INTEGER: number;
  68843. readonly RGBA_INTEGER: number;
  68844. readonly R8_SNORM: number;
  68845. readonly RG8_SNORM: number;
  68846. readonly RGB8_SNORM: number;
  68847. readonly RGBA8_SNORM: number;
  68848. readonly R8I: number;
  68849. readonly RG8I: number;
  68850. readonly RGB8I: number;
  68851. readonly RGBA8I: number;
  68852. readonly R8UI: number;
  68853. readonly RG8UI: number;
  68854. readonly RGB8UI: number;
  68855. readonly RGBA8UI: number;
  68856. readonly R16I: number;
  68857. readonly RG16I: number;
  68858. readonly RGB16I: number;
  68859. readonly RGBA16I: number;
  68860. readonly R16UI: number;
  68861. readonly RG16UI: number;
  68862. readonly RGB16UI: number;
  68863. readonly RGBA16UI: number;
  68864. readonly R32I: number;
  68865. readonly RG32I: number;
  68866. readonly RGB32I: number;
  68867. readonly RGBA32I: number;
  68868. readonly R32UI: number;
  68869. readonly RG32UI: number;
  68870. readonly RGB32UI: number;
  68871. readonly RGBA32UI: number;
  68872. readonly RGB10_A2UI: number;
  68873. readonly R11F_G11F_B10F: number;
  68874. readonly RGB9_E5: number;
  68875. readonly RGB10_A2: number;
  68876. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  68877. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  68878. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  68879. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68880. readonly DEPTH_COMPONENT32F: number;
  68881. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  68882. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  68883. 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;
  68884. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  68885. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  68886. readonly TRANSFORM_FEEDBACK: number;
  68887. readonly INTERLEAVED_ATTRIBS: number;
  68888. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  68889. createTransformFeedback(): WebGLTransformFeedback;
  68890. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  68891. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  68892. beginTransformFeedback(primitiveMode: number): void;
  68893. endTransformFeedback(): void;
  68894. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  68895. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  68896. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  68897. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  68898. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  68899. }
  68900. interface ImageBitmap {
  68901. readonly width: number;
  68902. readonly height: number;
  68903. close(): void;
  68904. }
  68905. interface WebGLQuery extends WebGLObject {
  68906. }
  68907. declare var WebGLQuery: {
  68908. prototype: WebGLQuery;
  68909. new(): WebGLQuery;
  68910. };
  68911. interface WebGLSampler extends WebGLObject {
  68912. }
  68913. declare var WebGLSampler: {
  68914. prototype: WebGLSampler;
  68915. new(): WebGLSampler;
  68916. };
  68917. interface WebGLSync extends WebGLObject {
  68918. }
  68919. declare var WebGLSync: {
  68920. prototype: WebGLSync;
  68921. new(): WebGLSync;
  68922. };
  68923. interface WebGLTransformFeedback extends WebGLObject {
  68924. }
  68925. declare var WebGLTransformFeedback: {
  68926. prototype: WebGLTransformFeedback;
  68927. new(): WebGLTransformFeedback;
  68928. };
  68929. interface WebGLVertexArrayObject extends WebGLObject {
  68930. }
  68931. declare var WebGLVertexArrayObject: {
  68932. prototype: WebGLVertexArrayObject;
  68933. new(): WebGLVertexArrayObject;
  68934. };
  68935. // Type definitions for WebVR API
  68936. // Project: https://w3c.github.io/webvr/
  68937. // Definitions by: six a <https://github.com/lostfictions>
  68938. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  68939. interface VRDisplay extends EventTarget {
  68940. /**
  68941. * Dictionary of capabilities describing the VRDisplay.
  68942. */
  68943. readonly capabilities: VRDisplayCapabilities;
  68944. /**
  68945. * z-depth defining the far plane of the eye view frustum
  68946. * enables mapping of values in the render target depth
  68947. * attachment to scene coordinates. Initially set to 10000.0.
  68948. */
  68949. depthFar: number;
  68950. /**
  68951. * z-depth defining the near plane of the eye view frustum
  68952. * enables mapping of values in the render target depth
  68953. * attachment to scene coordinates. Initially set to 0.01.
  68954. */
  68955. depthNear: number;
  68956. /**
  68957. * An identifier for this distinct VRDisplay. Used as an
  68958. * association point in the Gamepad API.
  68959. */
  68960. readonly displayId: number;
  68961. /**
  68962. * A display name, a user-readable name identifying it.
  68963. */
  68964. readonly displayName: string;
  68965. readonly isConnected: boolean;
  68966. readonly isPresenting: boolean;
  68967. /**
  68968. * If this VRDisplay supports room-scale experiences, the optional
  68969. * stage attribute contains details on the room-scale parameters.
  68970. */
  68971. readonly stageParameters: VRStageParameters | null;
  68972. /**
  68973. * Passing the value returned by `requestAnimationFrame` to
  68974. * `cancelAnimationFrame` will unregister the callback.
  68975. * @param handle Define the hanle of the request to cancel
  68976. */
  68977. cancelAnimationFrame(handle: number): void;
  68978. /**
  68979. * Stops presenting to the VRDisplay.
  68980. * @returns a promise to know when it stopped
  68981. */
  68982. exitPresent(): Promise<void>;
  68983. /**
  68984. * Return the current VREyeParameters for the given eye.
  68985. * @param whichEye Define the eye we want the parameter for
  68986. * @returns the eye parameters
  68987. */
  68988. getEyeParameters(whichEye: string): VREyeParameters;
  68989. /**
  68990. * Populates the passed VRFrameData with the information required to render
  68991. * the current frame.
  68992. * @param frameData Define the data structure to populate
  68993. * @returns true if ok otherwise false
  68994. */
  68995. getFrameData(frameData: VRFrameData): boolean;
  68996. /**
  68997. * Get the layers currently being presented.
  68998. * @returns the list of VR layers
  68999. */
  69000. getLayers(): VRLayer[];
  69001. /**
  69002. * Return a VRPose containing the future predicted pose of the VRDisplay
  69003. * when the current frame will be presented. The value returned will not
  69004. * change until JavaScript has returned control to the browser.
  69005. *
  69006. * The VRPose will contain the position, orientation, velocity,
  69007. * and acceleration of each of these properties.
  69008. * @returns the pose object
  69009. */
  69010. getPose(): VRPose;
  69011. /**
  69012. * Return the current instantaneous pose of the VRDisplay, with no
  69013. * prediction applied.
  69014. * @returns the current instantaneous pose
  69015. */
  69016. getImmediatePose(): VRPose;
  69017. /**
  69018. * The callback passed to `requestAnimationFrame` will be called
  69019. * any time a new frame should be rendered. When the VRDisplay is
  69020. * presenting the callback will be called at the native refresh
  69021. * rate of the HMD. When not presenting this function acts
  69022. * identically to how window.requestAnimationFrame acts. Content should
  69023. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69024. * asynchronously from other displays and at differing refresh rates.
  69025. * @param callback Define the eaction to run next frame
  69026. * @returns the request handle it
  69027. */
  69028. requestAnimationFrame(callback: FrameRequestCallback): number;
  69029. /**
  69030. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69031. * Repeat calls while already presenting will update the VRLayers being displayed.
  69032. * @param layers Define the list of layer to present
  69033. * @returns a promise to know when the request has been fulfilled
  69034. */
  69035. requestPresent(layers: VRLayer[]): Promise<void>;
  69036. /**
  69037. * Reset the pose for this display, treating its current position and
  69038. * orientation as the "origin/zero" values. VRPose.position,
  69039. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69040. * updated when calling resetPose(). This should be called in only
  69041. * sitting-space experiences.
  69042. */
  69043. resetPose(): void;
  69044. /**
  69045. * The VRLayer provided to the VRDisplay will be captured and presented
  69046. * in the HMD. Calling this function has the same effect on the source
  69047. * canvas as any other operation that uses its source image, and canvases
  69048. * created without preserveDrawingBuffer set to true will be cleared.
  69049. * @param pose Define the pose to submit
  69050. */
  69051. submitFrame(pose?: VRPose): void;
  69052. }
  69053. declare var VRDisplay: {
  69054. prototype: VRDisplay;
  69055. new(): VRDisplay;
  69056. };
  69057. interface VRLayer {
  69058. leftBounds?: number[] | Float32Array | null;
  69059. rightBounds?: number[] | Float32Array | null;
  69060. source?: HTMLCanvasElement | null;
  69061. }
  69062. interface VRDisplayCapabilities {
  69063. readonly canPresent: boolean;
  69064. readonly hasExternalDisplay: boolean;
  69065. readonly hasOrientation: boolean;
  69066. readonly hasPosition: boolean;
  69067. readonly maxLayers: number;
  69068. }
  69069. interface VREyeParameters {
  69070. /** @deprecated */
  69071. readonly fieldOfView: VRFieldOfView;
  69072. readonly offset: Float32Array;
  69073. readonly renderHeight: number;
  69074. readonly renderWidth: number;
  69075. }
  69076. interface VRFieldOfView {
  69077. readonly downDegrees: number;
  69078. readonly leftDegrees: number;
  69079. readonly rightDegrees: number;
  69080. readonly upDegrees: number;
  69081. }
  69082. interface VRFrameData {
  69083. readonly leftProjectionMatrix: Float32Array;
  69084. readonly leftViewMatrix: Float32Array;
  69085. readonly pose: VRPose;
  69086. readonly rightProjectionMatrix: Float32Array;
  69087. readonly rightViewMatrix: Float32Array;
  69088. readonly timestamp: number;
  69089. }
  69090. interface VRPose {
  69091. readonly angularAcceleration: Float32Array | null;
  69092. readonly angularVelocity: Float32Array | null;
  69093. readonly linearAcceleration: Float32Array | null;
  69094. readonly linearVelocity: Float32Array | null;
  69095. readonly orientation: Float32Array | null;
  69096. readonly position: Float32Array | null;
  69097. readonly timestamp: number;
  69098. }
  69099. interface VRStageParameters {
  69100. sittingToStandingTransform?: Float32Array;
  69101. sizeX?: number;
  69102. sizeY?: number;
  69103. }
  69104. interface Navigator {
  69105. getVRDisplays(): Promise<VRDisplay[]>;
  69106. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69107. }
  69108. interface Window {
  69109. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69110. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69111. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69112. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69113. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69114. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69115. }
  69116. interface Gamepad {
  69117. readonly displayId: number;
  69118. }
  69119. type XRSessionMode =
  69120. | "inline"
  69121. | "immersive-vr"
  69122. | "immersive-ar";
  69123. type XRReferenceSpaceType =
  69124. | "viewer"
  69125. | "local"
  69126. | "local-floor"
  69127. | "bounded-floor"
  69128. | "unbounded";
  69129. type XREnvironmentBlendMode =
  69130. | "opaque"
  69131. | "additive"
  69132. | "alpha-blend";
  69133. type XRVisibilityState =
  69134. | "visible"
  69135. | "visible-blurred"
  69136. | "hidden";
  69137. type XRHandedness =
  69138. | "none"
  69139. | "left"
  69140. | "right";
  69141. type XRTargetRayMode =
  69142. | "gaze"
  69143. | "tracked-pointer"
  69144. | "screen";
  69145. type XREye =
  69146. | "none"
  69147. | "left"
  69148. | "right";
  69149. interface XRSpace extends EventTarget {
  69150. }
  69151. interface XRRenderState {
  69152. depthNear?: number;
  69153. depthFar?: number;
  69154. inlineVerticalFieldOfView?: number;
  69155. baseLayer?: XRWebGLLayer;
  69156. }
  69157. interface XRInputSource {
  69158. handedness: XRHandedness;
  69159. targetRayMode: XRTargetRayMode;
  69160. targetRaySpace: XRSpace;
  69161. gripSpace: XRSpace | undefined;
  69162. gamepad: Gamepad | undefined;
  69163. profiles: Array<string>;
  69164. }
  69165. interface XRSessionInit {
  69166. optionalFeatures?: XRReferenceSpaceType[];
  69167. requiredFeatures?: XRReferenceSpaceType[];
  69168. }
  69169. interface XRSession extends XRAnchorCreator {
  69170. addEventListener: Function;
  69171. removeEventListener: Function;
  69172. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69173. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69174. requestAnimationFrame: Function;
  69175. end(): Promise<void>;
  69176. renderState: XRRenderState;
  69177. inputSources: Array<XRInputSource>;
  69178. // AR hit test
  69179. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69180. updateWorldTrackingState(options: {
  69181. planeDetectionState?: { enabled: boolean; }
  69182. }): void;
  69183. }
  69184. interface XRReferenceSpace extends XRSpace {
  69185. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69186. onreset: any;
  69187. }
  69188. type XRPlaneSet = Set<XRPlane>;
  69189. type XRAnchorSet = Set<XRAnchor>;
  69190. interface XRFrame {
  69191. session: XRSession;
  69192. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69193. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69194. // Anchors
  69195. trackedAnchors?: XRAnchorSet;
  69196. // Planes
  69197. worldInformation: {
  69198. detectedPlanes?: XRPlaneSet;
  69199. };
  69200. }
  69201. interface XRViewerPose extends XRPose {
  69202. views: Array<XRView>;
  69203. }
  69204. interface XRPose {
  69205. transform: XRRigidTransform;
  69206. emulatedPosition: boolean;
  69207. }
  69208. interface XRWebGLLayerOptions {
  69209. antialias?: boolean;
  69210. depth?: boolean;
  69211. stencil?: boolean;
  69212. alpha?: boolean;
  69213. multiview?: boolean;
  69214. framebufferScaleFactor?: number;
  69215. }
  69216. declare var XRWebGLLayer: {
  69217. prototype: XRWebGLLayer;
  69218. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69219. };
  69220. interface XRWebGLLayer {
  69221. framebuffer: WebGLFramebuffer;
  69222. framebufferWidth: number;
  69223. framebufferHeight: number;
  69224. getViewport: Function;
  69225. }
  69226. declare class XRRigidTransform {
  69227. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69228. position: DOMPointReadOnly;
  69229. orientation: DOMPointReadOnly;
  69230. matrix: Float32Array;
  69231. inverse: XRRigidTransform;
  69232. }
  69233. interface XRView {
  69234. eye: XREye;
  69235. projectionMatrix: Float32Array;
  69236. transform: XRRigidTransform;
  69237. }
  69238. interface XRInputSourceChangeEvent {
  69239. session: XRSession;
  69240. removed: Array<XRInputSource>;
  69241. added: Array<XRInputSource>;
  69242. }
  69243. interface XRInputSourceEvent extends Event {
  69244. readonly frame: XRFrame;
  69245. readonly inputSource: XRInputSource;
  69246. }
  69247. // Experimental(er) features
  69248. declare class XRRay {
  69249. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69250. origin: DOMPointReadOnly;
  69251. direction: DOMPointReadOnly;
  69252. matrix: Float32Array;
  69253. }
  69254. interface XRHitResult {
  69255. hitMatrix: Float32Array;
  69256. }
  69257. interface XRAnchor {
  69258. // remove?
  69259. id?: string;
  69260. anchorSpace: XRSpace;
  69261. lastChangedTime: number;
  69262. detach(): void;
  69263. }
  69264. interface XRPlane extends XRAnchorCreator {
  69265. orientation: "Horizontal" | "Vertical";
  69266. planeSpace: XRSpace;
  69267. polygon: Array<DOMPointReadOnly>;
  69268. lastChangedTime: number;
  69269. }
  69270. interface XRAnchorCreator {
  69271. // AR Anchors
  69272. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69273. }
  69274. /**
  69275. * @ignore
  69276. */
  69277. declare module BABYLON.GLTF2.Exporter {
  69278. }
  69279. /**
  69280. * @ignore
  69281. */
  69282. declare module BABYLON.GLTF1 {
  69283. }
  69284. declare module BABYLON.GUI {
  69285. /**
  69286. * Class used to specific a value and its associated unit
  69287. */
  69288. export class ValueAndUnit {
  69289. /** defines the unit to store */
  69290. unit: number;
  69291. /** defines a boolean indicating if the value can be negative */
  69292. negativeValueAllowed: boolean;
  69293. private _value;
  69294. private _originalUnit;
  69295. /**
  69296. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69297. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69298. */
  69299. ignoreAdaptiveScaling: boolean;
  69300. /**
  69301. * Creates a new ValueAndUnit
  69302. * @param value defines the value to store
  69303. * @param unit defines the unit to store
  69304. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69305. */
  69306. constructor(value: number,
  69307. /** defines the unit to store */
  69308. unit?: number,
  69309. /** defines a boolean indicating if the value can be negative */
  69310. negativeValueAllowed?: boolean);
  69311. /** Gets a boolean indicating if the value is a percentage */
  69312. get isPercentage(): boolean;
  69313. /** Gets a boolean indicating if the value is store as pixel */
  69314. get isPixel(): boolean;
  69315. /** Gets direct internal value */
  69316. get internalValue(): number;
  69317. /**
  69318. * Gets value as pixel
  69319. * @param host defines the root host
  69320. * @param refValue defines the reference value for percentages
  69321. * @returns the value as pixel
  69322. */
  69323. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  69324. /**
  69325. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  69326. * @param value defines the value to store
  69327. * @param unit defines the unit to store
  69328. * @returns the current ValueAndUnit
  69329. */
  69330. updateInPlace(value: number, unit?: number): ValueAndUnit;
  69331. /**
  69332. * Gets the value accordingly to its unit
  69333. * @param host defines the root host
  69334. * @returns the value
  69335. */
  69336. getValue(host: AdvancedDynamicTexture): number;
  69337. /**
  69338. * Gets a string representation of the value
  69339. * @param host defines the root host
  69340. * @param decimals defines an optional number of decimals to display
  69341. * @returns a string
  69342. */
  69343. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  69344. /**
  69345. * Store a value parsed from a string
  69346. * @param source defines the source string
  69347. * @returns true if the value was successfully parsed
  69348. */
  69349. fromString(source: string | number): boolean;
  69350. private static _Regex;
  69351. private static _UNITMODE_PERCENTAGE;
  69352. private static _UNITMODE_PIXEL;
  69353. /** UNITMODE_PERCENTAGE */
  69354. static get UNITMODE_PERCENTAGE(): number;
  69355. /** UNITMODE_PIXEL */
  69356. static get UNITMODE_PIXEL(): number;
  69357. }
  69358. }
  69359. declare module BABYLON.GUI {
  69360. /**
  69361. * Define a style used by control to automatically setup properties based on a template.
  69362. * Only support font related properties so far
  69363. */
  69364. export class Style implements BABYLON.IDisposable {
  69365. private _fontFamily;
  69366. private _fontStyle;
  69367. private _fontWeight;
  69368. /** @hidden */
  69369. _host: AdvancedDynamicTexture;
  69370. /** @hidden */
  69371. _fontSize: ValueAndUnit;
  69372. /**
  69373. * BABYLON.Observable raised when the style values are changed
  69374. */
  69375. onChangedObservable: BABYLON.Observable<Style>;
  69376. /**
  69377. * Creates a new style object
  69378. * @param host defines the AdvancedDynamicTexture which hosts this style
  69379. */
  69380. constructor(host: AdvancedDynamicTexture);
  69381. /**
  69382. * Gets or sets the font size
  69383. */
  69384. get fontSize(): string | number;
  69385. set fontSize(value: string | number);
  69386. /**
  69387. * Gets or sets the font family
  69388. */
  69389. get fontFamily(): string;
  69390. set fontFamily(value: string);
  69391. /**
  69392. * Gets or sets the font style
  69393. */
  69394. get fontStyle(): string;
  69395. set fontStyle(value: string);
  69396. /** Gets or sets font weight */
  69397. get fontWeight(): string;
  69398. set fontWeight(value: string);
  69399. /** Dispose all associated resources */
  69400. dispose(): void;
  69401. }
  69402. }
  69403. declare module BABYLON.GUI {
  69404. /**
  69405. * Class used to transport BABYLON.Vector2 information for pointer events
  69406. */
  69407. export class Vector2WithInfo extends BABYLON.Vector2 {
  69408. /** defines the current mouse button index */
  69409. buttonIndex: number;
  69410. /**
  69411. * Creates a new Vector2WithInfo
  69412. * @param source defines the vector2 data to transport
  69413. * @param buttonIndex defines the current mouse button index
  69414. */
  69415. constructor(source: BABYLON.Vector2,
  69416. /** defines the current mouse button index */
  69417. buttonIndex?: number);
  69418. }
  69419. /** Class used to provide 2D matrix features */
  69420. export class Matrix2D {
  69421. /** Gets the internal array of 6 floats used to store matrix data */
  69422. m: Float32Array;
  69423. /**
  69424. * Creates a new matrix
  69425. * @param m00 defines value for (0, 0)
  69426. * @param m01 defines value for (0, 1)
  69427. * @param m10 defines value for (1, 0)
  69428. * @param m11 defines value for (1, 1)
  69429. * @param m20 defines value for (2, 0)
  69430. * @param m21 defines value for (2, 1)
  69431. */
  69432. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  69433. /**
  69434. * Fills the matrix from direct values
  69435. * @param m00 defines value for (0, 0)
  69436. * @param m01 defines value for (0, 1)
  69437. * @param m10 defines value for (1, 0)
  69438. * @param m11 defines value for (1, 1)
  69439. * @param m20 defines value for (2, 0)
  69440. * @param m21 defines value for (2, 1)
  69441. * @returns the current modified matrix
  69442. */
  69443. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  69444. /**
  69445. * Gets matrix determinant
  69446. * @returns the determinant
  69447. */
  69448. determinant(): number;
  69449. /**
  69450. * Inverses the matrix and stores it in a target matrix
  69451. * @param result defines the target matrix
  69452. * @returns the current matrix
  69453. */
  69454. invertToRef(result: Matrix2D): Matrix2D;
  69455. /**
  69456. * Multiplies the current matrix with another one
  69457. * @param other defines the second operand
  69458. * @param result defines the target matrix
  69459. * @returns the current matrix
  69460. */
  69461. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  69462. /**
  69463. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  69464. * @param x defines the x coordinate to transform
  69465. * @param y defines the x coordinate to transform
  69466. * @param result defines the target vector2
  69467. * @returns the current matrix
  69468. */
  69469. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  69470. /**
  69471. * Creates an identity matrix
  69472. * @returns a new matrix
  69473. */
  69474. static Identity(): Matrix2D;
  69475. /**
  69476. * Creates a translation matrix and stores it in a target matrix
  69477. * @param x defines the x coordinate of the translation
  69478. * @param y defines the y coordinate of the translation
  69479. * @param result defines the target matrix
  69480. */
  69481. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  69482. /**
  69483. * Creates a scaling matrix and stores it in a target matrix
  69484. * @param x defines the x coordinate of the scaling
  69485. * @param y defines the y coordinate of the scaling
  69486. * @param result defines the target matrix
  69487. */
  69488. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  69489. /**
  69490. * Creates a rotation matrix and stores it in a target matrix
  69491. * @param angle defines the rotation angle
  69492. * @param result defines the target matrix
  69493. */
  69494. static RotationToRef(angle: number, result: Matrix2D): void;
  69495. private static _TempPreTranslationMatrix;
  69496. private static _TempPostTranslationMatrix;
  69497. private static _TempRotationMatrix;
  69498. private static _TempScalingMatrix;
  69499. private static _TempCompose0;
  69500. private static _TempCompose1;
  69501. private static _TempCompose2;
  69502. /**
  69503. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  69504. * @param tx defines the x coordinate of the translation
  69505. * @param ty defines the y coordinate of the translation
  69506. * @param angle defines the rotation angle
  69507. * @param scaleX defines the x coordinate of the scaling
  69508. * @param scaleY defines the y coordinate of the scaling
  69509. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  69510. * @param result defines the target matrix
  69511. */
  69512. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  69513. }
  69514. }
  69515. declare module BABYLON.GUI {
  69516. /**
  69517. * Class used to store 2D control sizes
  69518. */
  69519. export class Measure {
  69520. /** defines left coordinate */
  69521. left: number;
  69522. /** defines top coordinate */
  69523. top: number;
  69524. /** defines width dimension */
  69525. width: number;
  69526. /** defines height dimension */
  69527. height: number;
  69528. /**
  69529. * Creates a new measure
  69530. * @param left defines left coordinate
  69531. * @param top defines top coordinate
  69532. * @param width defines width dimension
  69533. * @param height defines height dimension
  69534. */
  69535. constructor(
  69536. /** defines left coordinate */
  69537. left: number,
  69538. /** defines top coordinate */
  69539. top: number,
  69540. /** defines width dimension */
  69541. width: number,
  69542. /** defines height dimension */
  69543. height: number);
  69544. /**
  69545. * Copy from another measure
  69546. * @param other defines the other measure to copy from
  69547. */
  69548. copyFrom(other: Measure): void;
  69549. /**
  69550. * Copy from a group of 4 floats
  69551. * @param left defines left coordinate
  69552. * @param top defines top coordinate
  69553. * @param width defines width dimension
  69554. * @param height defines height dimension
  69555. */
  69556. copyFromFloats(left: number, top: number, width: number, height: number): void;
  69557. /**
  69558. * Computes the axis aligned bounding box measure for two given measures
  69559. * @param a Input measure
  69560. * @param b Input measure
  69561. * @param result the resulting bounding measure
  69562. */
  69563. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  69564. /**
  69565. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  69566. * @param transform the matrix to transform the measure before computing the AABB
  69567. * @param result the resulting AABB
  69568. */
  69569. transformToRef(transform: Matrix2D, result: Measure): void;
  69570. /**
  69571. * Check equality between this measure and another one
  69572. * @param other defines the other measures
  69573. * @returns true if both measures are equals
  69574. */
  69575. isEqualsTo(other: Measure): boolean;
  69576. /**
  69577. * Creates an empty measure
  69578. * @returns a new measure
  69579. */
  69580. static Empty(): Measure;
  69581. }
  69582. }
  69583. declare module BABYLON.GUI {
  69584. /**
  69585. * Interface used to define a control that can receive focus
  69586. */
  69587. export interface IFocusableControl {
  69588. /**
  69589. * Function called when the control receives the focus
  69590. */
  69591. onFocus(): void;
  69592. /**
  69593. * Function called when the control loses the focus
  69594. */
  69595. onBlur(): void;
  69596. /**
  69597. * Function called to let the control handle keyboard events
  69598. * @param evt defines the current keyboard event
  69599. */
  69600. processKeyboard(evt: KeyboardEvent): void;
  69601. /**
  69602. * Function called to get the list of controls that should not steal the focus from this control
  69603. * @returns an array of controls
  69604. */
  69605. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69606. }
  69607. /**
  69608. * Class used to create texture to support 2D GUI elements
  69609. * @see http://doc.babylonjs.com/how_to/gui
  69610. */
  69611. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  69612. private _isDirty;
  69613. private _renderObserver;
  69614. private _resizeObserver;
  69615. private _preKeyboardObserver;
  69616. private _pointerMoveObserver;
  69617. private _pointerObserver;
  69618. private _canvasPointerOutObserver;
  69619. private _background;
  69620. /** @hidden */
  69621. _rootContainer: Container;
  69622. /** @hidden */
  69623. _lastPickedControl: Control;
  69624. /** @hidden */
  69625. _lastControlOver: {
  69626. [pointerId: number]: Control;
  69627. };
  69628. /** @hidden */
  69629. _lastControlDown: {
  69630. [pointerId: number]: Control;
  69631. };
  69632. /** @hidden */
  69633. _capturingControl: {
  69634. [pointerId: number]: Control;
  69635. };
  69636. /** @hidden */
  69637. _shouldBlockPointer: boolean;
  69638. /** @hidden */
  69639. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  69640. /** @hidden */
  69641. _linkedControls: Control[];
  69642. private _isFullscreen;
  69643. private _fullscreenViewport;
  69644. private _idealWidth;
  69645. private _idealHeight;
  69646. private _useSmallestIdeal;
  69647. private _renderAtIdealSize;
  69648. private _focusedControl;
  69649. private _blockNextFocusCheck;
  69650. private _renderScale;
  69651. private _rootElement;
  69652. private _cursorChanged;
  69653. /**
  69654. * Define type to string to ensure compatibility across browsers
  69655. * Safari doesn't support DataTransfer constructor
  69656. */
  69657. private _clipboardData;
  69658. /**
  69659. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  69660. */
  69661. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  69662. /**
  69663. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  69664. */
  69665. onControlPickedObservable: BABYLON.Observable<Control>;
  69666. /**
  69667. * BABYLON.Observable event triggered before layout is evaluated
  69668. */
  69669. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69670. /**
  69671. * BABYLON.Observable event triggered after the layout was evaluated
  69672. */
  69673. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69674. /**
  69675. * BABYLON.Observable event triggered before the texture is rendered
  69676. */
  69677. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69678. /**
  69679. * BABYLON.Observable event triggered after the texture was rendered
  69680. */
  69681. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69682. /**
  69683. * Gets or sets a boolean defining if alpha is stored as premultiplied
  69684. */
  69685. premulAlpha: boolean;
  69686. /**
  69687. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  69688. * Useful when you want more antialiasing
  69689. */
  69690. get renderScale(): number;
  69691. set renderScale(value: number);
  69692. /** Gets or sets the background color */
  69693. get background(): string;
  69694. set background(value: string);
  69695. /**
  69696. * Gets or sets the ideal width used to design controls.
  69697. * The GUI will then rescale everything accordingly
  69698. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69699. */
  69700. get idealWidth(): number;
  69701. set idealWidth(value: number);
  69702. /**
  69703. * Gets or sets the ideal height used to design controls.
  69704. * The GUI will then rescale everything accordingly
  69705. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69706. */
  69707. get idealHeight(): number;
  69708. set idealHeight(value: number);
  69709. /**
  69710. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  69711. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69712. */
  69713. get useSmallestIdeal(): boolean;
  69714. set useSmallestIdeal(value: boolean);
  69715. /**
  69716. * Gets or sets a boolean indicating if adaptive scaling must be used
  69717. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69718. */
  69719. get renderAtIdealSize(): boolean;
  69720. set renderAtIdealSize(value: boolean);
  69721. /**
  69722. * Gets the underlying layer used to render the texture when in fullscreen mode
  69723. */
  69724. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  69725. /**
  69726. * Gets the root container control
  69727. */
  69728. get rootContainer(): Container;
  69729. /**
  69730. * Returns an array containing the root container.
  69731. * This is mostly used to let the Inspector introspects the ADT
  69732. * @returns an array containing the rootContainer
  69733. */
  69734. getChildren(): Array<Container>;
  69735. /**
  69736. * Will return all controls that are inside this texture
  69737. * @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
  69738. * @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
  69739. * @return all child controls
  69740. */
  69741. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  69742. /**
  69743. * Gets or sets the current focused control
  69744. */
  69745. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  69746. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  69747. /**
  69748. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  69749. */
  69750. get isForeground(): boolean;
  69751. set isForeground(value: boolean);
  69752. /**
  69753. * Gets or set information about clipboardData
  69754. */
  69755. get clipboardData(): string;
  69756. set clipboardData(value: string);
  69757. /**
  69758. * Creates a new AdvancedDynamicTexture
  69759. * @param name defines the name of the texture
  69760. * @param width defines the width of the texture
  69761. * @param height defines the height of the texture
  69762. * @param scene defines the hosting scene
  69763. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  69764. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  69765. */
  69766. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  69767. /**
  69768. * Get the current class name of the texture useful for serialization or dynamic coding.
  69769. * @returns "AdvancedDynamicTexture"
  69770. */
  69771. getClassName(): string;
  69772. /**
  69773. * Function used to execute a function on all controls
  69774. * @param func defines the function to execute
  69775. * @param container defines the container where controls belong. If null the root container will be used
  69776. */
  69777. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  69778. private _useInvalidateRectOptimization;
  69779. /**
  69780. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  69781. */
  69782. get useInvalidateRectOptimization(): boolean;
  69783. set useInvalidateRectOptimization(value: boolean);
  69784. private _invalidatedRectangle;
  69785. /**
  69786. * Invalidates a rectangle area on the gui texture
  69787. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  69788. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  69789. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  69790. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  69791. */
  69792. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  69793. /**
  69794. * Marks the texture as dirty forcing a complete update
  69795. */
  69796. markAsDirty(): void;
  69797. /**
  69798. * Helper function used to create a new style
  69799. * @returns a new style
  69800. * @see http://doc.babylonjs.com/how_to/gui#styles
  69801. */
  69802. createStyle(): Style;
  69803. /**
  69804. * Adds a new control to the root container
  69805. * @param control defines the control to add
  69806. * @returns the current texture
  69807. */
  69808. addControl(control: Control): AdvancedDynamicTexture;
  69809. /**
  69810. * Removes a control from the root container
  69811. * @param control defines the control to remove
  69812. * @returns the current texture
  69813. */
  69814. removeControl(control: Control): AdvancedDynamicTexture;
  69815. /**
  69816. * Release all resources
  69817. */
  69818. dispose(): void;
  69819. private _onResize;
  69820. /** @hidden */
  69821. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  69822. /**
  69823. * Get screen coordinates for a vector3
  69824. * @param position defines the position to project
  69825. * @param worldMatrix defines the world matrix to use
  69826. * @returns the projected position
  69827. */
  69828. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  69829. private _checkUpdate;
  69830. private _clearMeasure;
  69831. private _render;
  69832. /** @hidden */
  69833. _changeCursor(cursor: string): void;
  69834. /** @hidden */
  69835. _registerLastControlDown(control: Control, pointerId: number): void;
  69836. private _doPicking;
  69837. /** @hidden */
  69838. _cleanControlAfterRemovalFromList(list: {
  69839. [pointerId: number]: Control;
  69840. }, control: Control): void;
  69841. /** @hidden */
  69842. _cleanControlAfterRemoval(control: Control): void;
  69843. /** Attach to all scene events required to support pointer events */
  69844. attach(): void;
  69845. /** @hidden */
  69846. private onClipboardCopy;
  69847. /** @hidden */
  69848. private onClipboardCut;
  69849. /** @hidden */
  69850. private onClipboardPaste;
  69851. /**
  69852. * Register the clipboard Events onto the canvas
  69853. */
  69854. registerClipboardEvents(): void;
  69855. /**
  69856. * Unregister the clipboard Events from the canvas
  69857. */
  69858. unRegisterClipboardEvents(): void;
  69859. /**
  69860. * Connect the texture to a hosting mesh to enable interactions
  69861. * @param mesh defines the mesh to attach to
  69862. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  69863. */
  69864. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  69865. /**
  69866. * Move the focus to a specific control
  69867. * @param control defines the control which will receive the focus
  69868. */
  69869. moveFocusToControl(control: IFocusableControl): void;
  69870. private _manageFocus;
  69871. private _attachToOnPointerOut;
  69872. /**
  69873. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  69874. * @param mesh defines the mesh which will receive the texture
  69875. * @param width defines the texture width (1024 by default)
  69876. * @param height defines the texture height (1024 by default)
  69877. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  69878. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  69879. * @returns a new AdvancedDynamicTexture
  69880. */
  69881. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  69882. /**
  69883. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  69884. * In this mode the texture will rely on a layer for its rendering.
  69885. * This allows it to be treated like any other layer.
  69886. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  69887. * LayerMask is set through advancedTexture.layer.layerMask
  69888. * @param name defines name for the texture
  69889. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  69890. * @param scene defines the hsoting scene
  69891. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  69892. * @returns a new AdvancedDynamicTexture
  69893. */
  69894. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  69895. }
  69896. }
  69897. declare module BABYLON.GUI {
  69898. /**
  69899. * Root class used for all 2D controls
  69900. * @see http://doc.babylonjs.com/how_to/gui#controls
  69901. */
  69902. export class Control {
  69903. /** defines the name of the control */
  69904. name?: string | undefined;
  69905. /**
  69906. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  69907. */
  69908. static AllowAlphaInheritance: boolean;
  69909. private _alpha;
  69910. private _alphaSet;
  69911. private _zIndex;
  69912. /** @hidden */
  69913. _host: AdvancedDynamicTexture;
  69914. /** Gets or sets the control parent */
  69915. parent: BABYLON.Nullable<Container>;
  69916. /** @hidden */
  69917. _currentMeasure: Measure;
  69918. private _fontFamily;
  69919. private _fontStyle;
  69920. private _fontWeight;
  69921. private _fontSize;
  69922. private _font;
  69923. /** @hidden */
  69924. _width: ValueAndUnit;
  69925. /** @hidden */
  69926. _height: ValueAndUnit;
  69927. /** @hidden */
  69928. protected _fontOffset: {
  69929. ascent: number;
  69930. height: number;
  69931. descent: number;
  69932. };
  69933. private _color;
  69934. private _style;
  69935. private _styleObserver;
  69936. /** @hidden */
  69937. protected _horizontalAlignment: number;
  69938. /** @hidden */
  69939. protected _verticalAlignment: number;
  69940. /** @hidden */
  69941. protected _isDirty: boolean;
  69942. /** @hidden */
  69943. protected _wasDirty: boolean;
  69944. /** @hidden */
  69945. _tempParentMeasure: Measure;
  69946. /** @hidden */
  69947. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  69948. /** @hidden */
  69949. protected _cachedParentMeasure: Measure;
  69950. private _paddingLeft;
  69951. private _paddingRight;
  69952. private _paddingTop;
  69953. private _paddingBottom;
  69954. /** @hidden */
  69955. _left: ValueAndUnit;
  69956. /** @hidden */
  69957. _top: ValueAndUnit;
  69958. private _scaleX;
  69959. private _scaleY;
  69960. private _rotation;
  69961. private _transformCenterX;
  69962. private _transformCenterY;
  69963. /** @hidden */
  69964. _transformMatrix: Matrix2D;
  69965. /** @hidden */
  69966. protected _invertTransformMatrix: Matrix2D;
  69967. /** @hidden */
  69968. protected _transformedPosition: BABYLON.Vector2;
  69969. private _isMatrixDirty;
  69970. private _cachedOffsetX;
  69971. private _cachedOffsetY;
  69972. private _isVisible;
  69973. private _isHighlighted;
  69974. /** @hidden */
  69975. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69976. private _fontSet;
  69977. private _dummyVector2;
  69978. private _downCount;
  69979. private _enterCount;
  69980. private _doNotRender;
  69981. private _downPointerIds;
  69982. protected _isEnabled: boolean;
  69983. protected _disabledColor: string;
  69984. /** @hidden */
  69985. protected _rebuildLayout: boolean;
  69986. /** @hidden */
  69987. _isClipped: boolean;
  69988. /** @hidden */
  69989. _automaticSize: boolean;
  69990. /** @hidden */
  69991. _tag: any;
  69992. /**
  69993. * 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
  69994. */
  69995. uniqueId: number;
  69996. /**
  69997. * Gets or sets an object used to store user defined information for the node
  69998. */
  69999. metadata: any;
  70000. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70001. isHitTestVisible: boolean;
  70002. /** Gets or sets a boolean indicating if the control can block pointer events */
  70003. isPointerBlocker: boolean;
  70004. /** Gets or sets a boolean indicating if the control can be focusable */
  70005. isFocusInvisible: boolean;
  70006. /**
  70007. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70008. * 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
  70009. */
  70010. clipChildren: boolean;
  70011. /**
  70012. * Gets or sets a boolean indicating that control content must be clipped
  70013. * 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
  70014. */
  70015. clipContent: boolean;
  70016. /**
  70017. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70018. */
  70019. useBitmapCache: boolean;
  70020. private _cacheData;
  70021. private _shadowOffsetX;
  70022. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70023. get shadowOffsetX(): number;
  70024. set shadowOffsetX(value: number);
  70025. private _shadowOffsetY;
  70026. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70027. get shadowOffsetY(): number;
  70028. set shadowOffsetY(value: number);
  70029. private _shadowBlur;
  70030. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70031. get shadowBlur(): number;
  70032. set shadowBlur(value: number);
  70033. private _shadowColor;
  70034. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70035. get shadowColor(): string;
  70036. set shadowColor(value: string);
  70037. /** Gets or sets the cursor to use when the control is hovered */
  70038. hoverCursor: string;
  70039. /** @hidden */
  70040. protected _linkOffsetX: ValueAndUnit;
  70041. /** @hidden */
  70042. protected _linkOffsetY: ValueAndUnit;
  70043. /** Gets the control type name */
  70044. get typeName(): string;
  70045. /**
  70046. * Get the current class name of the control.
  70047. * @returns current class name
  70048. */
  70049. getClassName(): string;
  70050. /**
  70051. * An event triggered when the pointer move over the control.
  70052. */
  70053. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70054. /**
  70055. * An event triggered when the pointer move out of the control.
  70056. */
  70057. onPointerOutObservable: BABYLON.Observable<Control>;
  70058. /**
  70059. * An event triggered when the pointer taps the control
  70060. */
  70061. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70062. /**
  70063. * An event triggered when pointer up
  70064. */
  70065. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70066. /**
  70067. * An event triggered when a control is clicked on
  70068. */
  70069. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70070. /**
  70071. * An event triggered when pointer enters the control
  70072. */
  70073. onPointerEnterObservable: BABYLON.Observable<Control>;
  70074. /**
  70075. * An event triggered when the control is marked as dirty
  70076. */
  70077. onDirtyObservable: BABYLON.Observable<Control>;
  70078. /**
  70079. * An event triggered before drawing the control
  70080. */
  70081. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70082. /**
  70083. * An event triggered after the control was drawn
  70084. */
  70085. onAfterDrawObservable: BABYLON.Observable<Control>;
  70086. /**
  70087. * Get the hosting AdvancedDynamicTexture
  70088. */
  70089. get host(): AdvancedDynamicTexture;
  70090. /** Gets or set information about font offsets (used to render and align text) */
  70091. get fontOffset(): {
  70092. ascent: number;
  70093. height: number;
  70094. descent: number;
  70095. };
  70096. set fontOffset(offset: {
  70097. ascent: number;
  70098. height: number;
  70099. descent: number;
  70100. });
  70101. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70102. get alpha(): number;
  70103. set alpha(value: number);
  70104. /**
  70105. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70106. */
  70107. get isHighlighted(): boolean;
  70108. set isHighlighted(value: boolean);
  70109. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70110. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70111. */
  70112. get scaleX(): number;
  70113. set scaleX(value: number);
  70114. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70115. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70116. */
  70117. get scaleY(): number;
  70118. set scaleY(value: number);
  70119. /** Gets or sets the rotation angle (0 by default)
  70120. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70121. */
  70122. get rotation(): number;
  70123. set rotation(value: number);
  70124. /** Gets or sets the transformation center on Y axis (0 by default)
  70125. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70126. */
  70127. get transformCenterY(): number;
  70128. set transformCenterY(value: number);
  70129. /** Gets or sets the transformation center on X axis (0 by default)
  70130. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70131. */
  70132. get transformCenterX(): number;
  70133. set transformCenterX(value: number);
  70134. /**
  70135. * Gets or sets the horizontal alignment
  70136. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70137. */
  70138. get horizontalAlignment(): number;
  70139. set horizontalAlignment(value: number);
  70140. /**
  70141. * Gets or sets the vertical alignment
  70142. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70143. */
  70144. get verticalAlignment(): number;
  70145. set verticalAlignment(value: number);
  70146. /**
  70147. * Gets or sets control width
  70148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70149. */
  70150. get width(): string | number;
  70151. set width(value: string | number);
  70152. /**
  70153. * Gets or sets the control width in pixel
  70154. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70155. */
  70156. get widthInPixels(): number;
  70157. set widthInPixels(value: number);
  70158. /**
  70159. * Gets or sets control height
  70160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70161. */
  70162. get height(): string | number;
  70163. set height(value: string | number);
  70164. /**
  70165. * Gets or sets control height in pixel
  70166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70167. */
  70168. get heightInPixels(): number;
  70169. set heightInPixels(value: number);
  70170. /** Gets or set font family */
  70171. get fontFamily(): string;
  70172. set fontFamily(value: string);
  70173. /** Gets or sets font style */
  70174. get fontStyle(): string;
  70175. set fontStyle(value: string);
  70176. /** Gets or sets font weight */
  70177. get fontWeight(): string;
  70178. set fontWeight(value: string);
  70179. /**
  70180. * Gets or sets style
  70181. * @see http://doc.babylonjs.com/how_to/gui#styles
  70182. */
  70183. get style(): BABYLON.Nullable<Style>;
  70184. set style(value: BABYLON.Nullable<Style>);
  70185. /** @hidden */
  70186. get _isFontSizeInPercentage(): boolean;
  70187. /** Gets or sets font size in pixels */
  70188. get fontSizeInPixels(): number;
  70189. set fontSizeInPixels(value: number);
  70190. /** Gets or sets font size */
  70191. get fontSize(): string | number;
  70192. set fontSize(value: string | number);
  70193. /** Gets or sets foreground color */
  70194. get color(): string;
  70195. set color(value: string);
  70196. /** Gets or sets z index which is used to reorder controls on the z axis */
  70197. get zIndex(): number;
  70198. set zIndex(value: number);
  70199. /** Gets or sets a boolean indicating if the control can be rendered */
  70200. get notRenderable(): boolean;
  70201. set notRenderable(value: boolean);
  70202. /** Gets or sets a boolean indicating if the control is visible */
  70203. get isVisible(): boolean;
  70204. set isVisible(value: boolean);
  70205. /** Gets a boolean indicating that the control needs to update its rendering */
  70206. get isDirty(): boolean;
  70207. /**
  70208. * Gets the current linked mesh (or null if none)
  70209. */
  70210. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70211. /**
  70212. * Gets or sets a value indicating the padding to use on the left of the control
  70213. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70214. */
  70215. get paddingLeft(): string | number;
  70216. set paddingLeft(value: string | number);
  70217. /**
  70218. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70219. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70220. */
  70221. get paddingLeftInPixels(): number;
  70222. set paddingLeftInPixels(value: number);
  70223. /**
  70224. * Gets or sets a value indicating the padding to use on the right of the control
  70225. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70226. */
  70227. get paddingRight(): string | number;
  70228. set paddingRight(value: string | number);
  70229. /**
  70230. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70232. */
  70233. get paddingRightInPixels(): number;
  70234. set paddingRightInPixels(value: number);
  70235. /**
  70236. * Gets or sets a value indicating the padding to use on the top of the control
  70237. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70238. */
  70239. get paddingTop(): string | number;
  70240. set paddingTop(value: string | number);
  70241. /**
  70242. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70243. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70244. */
  70245. get paddingTopInPixels(): number;
  70246. set paddingTopInPixels(value: number);
  70247. /**
  70248. * Gets or sets a value indicating the padding to use on the bottom of the control
  70249. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70250. */
  70251. get paddingBottom(): string | number;
  70252. set paddingBottom(value: string | number);
  70253. /**
  70254. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70255. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70256. */
  70257. get paddingBottomInPixels(): number;
  70258. set paddingBottomInPixels(value: number);
  70259. /**
  70260. * Gets or sets a value indicating the left coordinate of the control
  70261. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70262. */
  70263. get left(): string | number;
  70264. set left(value: string | number);
  70265. /**
  70266. * Gets or sets a value indicating the left coordinate in pixels of the control
  70267. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70268. */
  70269. get leftInPixels(): number;
  70270. set leftInPixels(value: number);
  70271. /**
  70272. * Gets or sets a value indicating the top coordinate of the control
  70273. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70274. */
  70275. get top(): string | number;
  70276. set top(value: string | number);
  70277. /**
  70278. * Gets or sets a value indicating the top coordinate in pixels of the control
  70279. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70280. */
  70281. get topInPixels(): number;
  70282. set topInPixels(value: number);
  70283. /**
  70284. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70285. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70286. */
  70287. get linkOffsetX(): string | number;
  70288. set linkOffsetX(value: string | number);
  70289. /**
  70290. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70291. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70292. */
  70293. get linkOffsetXInPixels(): number;
  70294. set linkOffsetXInPixels(value: number);
  70295. /**
  70296. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70297. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70298. */
  70299. get linkOffsetY(): string | number;
  70300. set linkOffsetY(value: string | number);
  70301. /**
  70302. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70303. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70304. */
  70305. get linkOffsetYInPixels(): number;
  70306. set linkOffsetYInPixels(value: number);
  70307. /** Gets the center coordinate on X axis */
  70308. get centerX(): number;
  70309. /** Gets the center coordinate on Y axis */
  70310. get centerY(): number;
  70311. /** Gets or sets if control is Enabled*/
  70312. get isEnabled(): boolean;
  70313. set isEnabled(value: boolean);
  70314. /** Gets or sets background color of control if it's disabled*/
  70315. get disabledColor(): string;
  70316. set disabledColor(value: string);
  70317. /**
  70318. * Creates a new control
  70319. * @param name defines the name of the control
  70320. */
  70321. constructor(
  70322. /** defines the name of the control */
  70323. name?: string | undefined);
  70324. /** @hidden */
  70325. protected _getTypeName(): string;
  70326. /**
  70327. * Gets the first ascendant in the hierarchy of the given type
  70328. * @param className defines the required type
  70329. * @returns the ascendant or null if not found
  70330. */
  70331. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  70332. /** @hidden */
  70333. _resetFontCache(): void;
  70334. /**
  70335. * Determines if a container is an ascendant of the current control
  70336. * @param container defines the container to look for
  70337. * @returns true if the container is one of the ascendant of the control
  70338. */
  70339. isAscendant(container: Control): boolean;
  70340. /**
  70341. * Gets coordinates in local control space
  70342. * @param globalCoordinates defines the coordinates to transform
  70343. * @returns the new coordinates in local space
  70344. */
  70345. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70346. /**
  70347. * Gets coordinates in local control space
  70348. * @param globalCoordinates defines the coordinates to transform
  70349. * @param result defines the target vector2 where to store the result
  70350. * @returns the current control
  70351. */
  70352. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  70353. /**
  70354. * Gets coordinates in parent local control space
  70355. * @param globalCoordinates defines the coordinates to transform
  70356. * @returns the new coordinates in parent local space
  70357. */
  70358. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70359. /**
  70360. * Move the current control to a vector3 position projected onto the screen.
  70361. * @param position defines the target position
  70362. * @param scene defines the hosting scene
  70363. */
  70364. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  70365. /**
  70366. * Will store all controls that have this control as ascendant in a given array
  70367. * @param results defines the array where to store the descendants
  70368. * @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
  70369. * @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
  70370. */
  70371. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70372. /**
  70373. * Will return all controls that have this control as ascendant
  70374. * @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
  70375. * @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
  70376. * @return all child controls
  70377. */
  70378. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70379. /**
  70380. * Link current control with a target mesh
  70381. * @param mesh defines the mesh to link with
  70382. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70383. */
  70384. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  70385. /** @hidden */
  70386. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  70387. /** @hidden */
  70388. _offsetLeft(offset: number): void;
  70389. /** @hidden */
  70390. _offsetTop(offset: number): void;
  70391. /** @hidden */
  70392. _markMatrixAsDirty(): void;
  70393. /** @hidden */
  70394. _flagDescendantsAsMatrixDirty(): void;
  70395. /** @hidden */
  70396. _intersectsRect(rect: Measure): boolean;
  70397. /** @hidden */
  70398. protected invalidateRect(): void;
  70399. /** @hidden */
  70400. _markAsDirty(force?: boolean): void;
  70401. /** @hidden */
  70402. _markAllAsDirty(): void;
  70403. /** @hidden */
  70404. _link(host: AdvancedDynamicTexture): void;
  70405. /** @hidden */
  70406. protected _transform(context?: CanvasRenderingContext2D): void;
  70407. /** @hidden */
  70408. _renderHighlight(context: CanvasRenderingContext2D): void;
  70409. /** @hidden */
  70410. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70411. /** @hidden */
  70412. protected _applyStates(context: CanvasRenderingContext2D): void;
  70413. /** @hidden */
  70414. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70415. /** @hidden */
  70416. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70417. protected _evaluateClippingState(parentMeasure: Measure): void;
  70418. /** @hidden */
  70419. _measure(): void;
  70420. /** @hidden */
  70421. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70422. /** @hidden */
  70423. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70424. /** @hidden */
  70425. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70426. /** @hidden */
  70427. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70428. private static _ClipMeasure;
  70429. private _tmpMeasureA;
  70430. private _clip;
  70431. /** @hidden */
  70432. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  70433. /** @hidden */
  70434. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70435. /**
  70436. * Tests if a given coordinates belong to the current control
  70437. * @param x defines x coordinate to test
  70438. * @param y defines y coordinate to test
  70439. * @returns true if the coordinates are inside the control
  70440. */
  70441. contains(x: number, y: number): boolean;
  70442. /** @hidden */
  70443. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70444. /** @hidden */
  70445. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70446. /** @hidden */
  70447. _onPointerEnter(target: Control): boolean;
  70448. /** @hidden */
  70449. _onPointerOut(target: Control, force?: boolean): void;
  70450. /** @hidden */
  70451. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70452. /** @hidden */
  70453. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70454. /** @hidden */
  70455. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70456. /** @hidden */
  70457. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  70458. private _prepareFont;
  70459. /** Releases associated resources */
  70460. dispose(): void;
  70461. private static _HORIZONTAL_ALIGNMENT_LEFT;
  70462. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  70463. private static _HORIZONTAL_ALIGNMENT_CENTER;
  70464. private static _VERTICAL_ALIGNMENT_TOP;
  70465. private static _VERTICAL_ALIGNMENT_BOTTOM;
  70466. private static _VERTICAL_ALIGNMENT_CENTER;
  70467. /** HORIZONTAL_ALIGNMENT_LEFT */
  70468. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  70469. /** HORIZONTAL_ALIGNMENT_RIGHT */
  70470. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  70471. /** HORIZONTAL_ALIGNMENT_CENTER */
  70472. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  70473. /** VERTICAL_ALIGNMENT_TOP */
  70474. static get VERTICAL_ALIGNMENT_TOP(): number;
  70475. /** VERTICAL_ALIGNMENT_BOTTOM */
  70476. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  70477. /** VERTICAL_ALIGNMENT_CENTER */
  70478. static get VERTICAL_ALIGNMENT_CENTER(): number;
  70479. private static _FontHeightSizes;
  70480. /** @hidden */
  70481. static _GetFontOffset(font: string): {
  70482. ascent: number;
  70483. height: number;
  70484. descent: number;
  70485. };
  70486. /**
  70487. * Creates a stack panel that can be used to render headers
  70488. * @param control defines the control to associate with the header
  70489. * @param text defines the text of the header
  70490. * @param size defines the size of the header
  70491. * @param options defines options used to configure the header
  70492. * @returns a new StackPanel
  70493. * @ignore
  70494. * @hidden
  70495. */
  70496. static AddHeader: (control: Control, text: string, size: string | number, options: {
  70497. isHorizontal: boolean;
  70498. controlFirst: boolean;
  70499. }) => any;
  70500. /** @hidden */
  70501. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  70502. }
  70503. }
  70504. declare module BABYLON.GUI {
  70505. /**
  70506. * Root class for 2D containers
  70507. * @see http://doc.babylonjs.com/how_to/gui#containers
  70508. */
  70509. export class Container extends Control {
  70510. name?: string | undefined;
  70511. /** @hidden */
  70512. protected _children: Control[];
  70513. /** @hidden */
  70514. protected _measureForChildren: Measure;
  70515. /** @hidden */
  70516. protected _background: string;
  70517. /** @hidden */
  70518. protected _adaptWidthToChildren: boolean;
  70519. /** @hidden */
  70520. protected _adaptHeightToChildren: boolean;
  70521. /**
  70522. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  70523. */
  70524. logLayoutCycleErrors: boolean;
  70525. /**
  70526. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  70527. */
  70528. maxLayoutCycle: number;
  70529. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  70530. get adaptHeightToChildren(): boolean;
  70531. set adaptHeightToChildren(value: boolean);
  70532. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  70533. get adaptWidthToChildren(): boolean;
  70534. set adaptWidthToChildren(value: boolean);
  70535. /** Gets or sets background color */
  70536. get background(): string;
  70537. set background(value: string);
  70538. /** Gets the list of children */
  70539. get children(): Control[];
  70540. /**
  70541. * Creates a new Container
  70542. * @param name defines the name of the container
  70543. */
  70544. constructor(name?: string | undefined);
  70545. protected _getTypeName(): string;
  70546. _flagDescendantsAsMatrixDirty(): void;
  70547. /**
  70548. * Gets a child using its name
  70549. * @param name defines the child name to look for
  70550. * @returns the child control if found
  70551. */
  70552. getChildByName(name: string): BABYLON.Nullable<Control>;
  70553. /**
  70554. * Gets a child using its type and its name
  70555. * @param name defines the child name to look for
  70556. * @param type defines the child type to look for
  70557. * @returns the child control if found
  70558. */
  70559. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  70560. /**
  70561. * Search for a specific control in children
  70562. * @param control defines the control to look for
  70563. * @returns true if the control is in child list
  70564. */
  70565. containsControl(control: Control): boolean;
  70566. /**
  70567. * Adds a new control to the current container
  70568. * @param control defines the control to add
  70569. * @returns the current container
  70570. */
  70571. addControl(control: BABYLON.Nullable<Control>): Container;
  70572. /**
  70573. * Removes all controls from the current container
  70574. * @returns the current container
  70575. */
  70576. clearControls(): Container;
  70577. /**
  70578. * Removes a control from the current container
  70579. * @param control defines the control to remove
  70580. * @returns the current container
  70581. */
  70582. removeControl(control: Control): Container;
  70583. /** @hidden */
  70584. _reOrderControl(control: Control): void;
  70585. /** @hidden */
  70586. _offsetLeft(offset: number): void;
  70587. /** @hidden */
  70588. _offsetTop(offset: number): void;
  70589. /** @hidden */
  70590. _markAllAsDirty(): void;
  70591. /** @hidden */
  70592. protected _localDraw(context: CanvasRenderingContext2D): void;
  70593. /** @hidden */
  70594. _link(host: AdvancedDynamicTexture): void;
  70595. /** @hidden */
  70596. protected _beforeLayout(): void;
  70597. /** @hidden */
  70598. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70599. /** @hidden */
  70600. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70601. protected _postMeasure(): void;
  70602. /** @hidden */
  70603. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  70604. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70605. /** @hidden */
  70606. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70607. /** @hidden */
  70608. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70609. /** Releases associated resources */
  70610. dispose(): void;
  70611. }
  70612. }
  70613. declare module BABYLON.GUI {
  70614. /** Class used to create rectangle container */
  70615. export class Rectangle extends Container {
  70616. name?: string | undefined;
  70617. private _thickness;
  70618. private _cornerRadius;
  70619. /** Gets or sets border thickness */
  70620. get thickness(): number;
  70621. set thickness(value: number);
  70622. /** Gets or sets the corner radius angle */
  70623. get cornerRadius(): number;
  70624. set cornerRadius(value: number);
  70625. /**
  70626. * Creates a new Rectangle
  70627. * @param name defines the control name
  70628. */
  70629. constructor(name?: string | undefined);
  70630. protected _getTypeName(): string;
  70631. protected _localDraw(context: CanvasRenderingContext2D): void;
  70632. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70633. private _drawRoundedRect;
  70634. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70635. }
  70636. }
  70637. declare module BABYLON.GUI {
  70638. /**
  70639. * Enum that determines the text-wrapping mode to use.
  70640. */
  70641. export enum TextWrapping {
  70642. /**
  70643. * Clip the text when it's larger than Control.width; this is the default mode.
  70644. */
  70645. Clip = 0,
  70646. /**
  70647. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  70648. */
  70649. WordWrap = 1,
  70650. /**
  70651. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  70652. */
  70653. Ellipsis = 2
  70654. }
  70655. /**
  70656. * Class used to create text block control
  70657. */
  70658. export class TextBlock extends Control {
  70659. /**
  70660. * Defines the name of the control
  70661. */
  70662. name?: string | undefined;
  70663. private _text;
  70664. private _textWrapping;
  70665. private _textHorizontalAlignment;
  70666. private _textVerticalAlignment;
  70667. private _lines;
  70668. private _resizeToFit;
  70669. private _lineSpacing;
  70670. private _outlineWidth;
  70671. private _outlineColor;
  70672. /**
  70673. * An event triggered after the text is changed
  70674. */
  70675. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  70676. /**
  70677. * An event triggered after the text was broken up into lines
  70678. */
  70679. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  70680. /**
  70681. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  70682. */
  70683. get lines(): any[];
  70684. /**
  70685. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70686. */
  70687. get resizeToFit(): boolean;
  70688. /**
  70689. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70690. */
  70691. set resizeToFit(value: boolean);
  70692. /**
  70693. * Gets or sets a boolean indicating if text must be wrapped
  70694. */
  70695. get textWrapping(): TextWrapping | boolean;
  70696. /**
  70697. * Gets or sets a boolean indicating if text must be wrapped
  70698. */
  70699. set textWrapping(value: TextWrapping | boolean);
  70700. /**
  70701. * Gets or sets text to display
  70702. */
  70703. get text(): string;
  70704. /**
  70705. * Gets or sets text to display
  70706. */
  70707. set text(value: string);
  70708. /**
  70709. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70710. */
  70711. get textHorizontalAlignment(): number;
  70712. /**
  70713. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70714. */
  70715. set textHorizontalAlignment(value: number);
  70716. /**
  70717. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70718. */
  70719. get textVerticalAlignment(): number;
  70720. /**
  70721. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70722. */
  70723. set textVerticalAlignment(value: number);
  70724. /**
  70725. * Gets or sets line spacing value
  70726. */
  70727. set lineSpacing(value: string | number);
  70728. /**
  70729. * Gets or sets line spacing value
  70730. */
  70731. get lineSpacing(): string | number;
  70732. /**
  70733. * Gets or sets outlineWidth of the text to display
  70734. */
  70735. get outlineWidth(): number;
  70736. /**
  70737. * Gets or sets outlineWidth of the text to display
  70738. */
  70739. set outlineWidth(value: number);
  70740. /**
  70741. * Gets or sets outlineColor of the text to display
  70742. */
  70743. get outlineColor(): string;
  70744. /**
  70745. * Gets or sets outlineColor of the text to display
  70746. */
  70747. set outlineColor(value: string);
  70748. /**
  70749. * Creates a new TextBlock object
  70750. * @param name defines the name of the control
  70751. * @param text defines the text to display (emptry string by default)
  70752. */
  70753. constructor(
  70754. /**
  70755. * Defines the name of the control
  70756. */
  70757. name?: string | undefined, text?: string);
  70758. protected _getTypeName(): string;
  70759. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70760. private _drawText;
  70761. /** @hidden */
  70762. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70763. protected _applyStates(context: CanvasRenderingContext2D): void;
  70764. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  70765. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  70766. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  70767. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  70768. protected _renderLines(context: CanvasRenderingContext2D): void;
  70769. /**
  70770. * Given a width constraint applied on the text block, find the expected height
  70771. * @returns expected height
  70772. */
  70773. computeExpectedHeight(): number;
  70774. dispose(): void;
  70775. }
  70776. }
  70777. declare module BABYLON.GUI {
  70778. /**
  70779. * Class used to create 2D images
  70780. */
  70781. export class Image extends Control {
  70782. name?: string | undefined;
  70783. private _workingCanvas;
  70784. private _domImage;
  70785. private _imageWidth;
  70786. private _imageHeight;
  70787. private _loaded;
  70788. private _stretch;
  70789. private _source;
  70790. private _autoScale;
  70791. private _sourceLeft;
  70792. private _sourceTop;
  70793. private _sourceWidth;
  70794. private _sourceHeight;
  70795. private _cellWidth;
  70796. private _cellHeight;
  70797. private _cellId;
  70798. private _populateNinePatchSlicesFromImage;
  70799. private _sliceLeft;
  70800. private _sliceRight;
  70801. private _sliceTop;
  70802. private _sliceBottom;
  70803. private _detectPointerOnOpaqueOnly;
  70804. /**
  70805. * BABYLON.Observable notified when the content is loaded
  70806. */
  70807. onImageLoadedObservable: BABYLON.Observable<Image>;
  70808. /**
  70809. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  70810. */
  70811. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  70812. /**
  70813. * Gets a boolean indicating that the content is loaded
  70814. */
  70815. get isLoaded(): boolean;
  70816. /**
  70817. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  70818. */
  70819. get populateNinePatchSlicesFromImage(): boolean;
  70820. set populateNinePatchSlicesFromImage(value: boolean);
  70821. /**
  70822. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  70823. * Beware using this as this will comsume more memory as the image has to be stored twice
  70824. */
  70825. get detectPointerOnOpaqueOnly(): boolean;
  70826. set detectPointerOnOpaqueOnly(value: boolean);
  70827. /**
  70828. * Gets or sets the left value for slicing (9-patch)
  70829. */
  70830. get sliceLeft(): number;
  70831. set sliceLeft(value: number);
  70832. /**
  70833. * Gets or sets the right value for slicing (9-patch)
  70834. */
  70835. get sliceRight(): number;
  70836. set sliceRight(value: number);
  70837. /**
  70838. * Gets or sets the top value for slicing (9-patch)
  70839. */
  70840. get sliceTop(): number;
  70841. set sliceTop(value: number);
  70842. /**
  70843. * Gets or sets the bottom value for slicing (9-patch)
  70844. */
  70845. get sliceBottom(): number;
  70846. set sliceBottom(value: number);
  70847. /**
  70848. * Gets or sets the left coordinate in the source image
  70849. */
  70850. get sourceLeft(): number;
  70851. set sourceLeft(value: number);
  70852. /**
  70853. * Gets or sets the top coordinate in the source image
  70854. */
  70855. get sourceTop(): number;
  70856. set sourceTop(value: number);
  70857. /**
  70858. * Gets or sets the width to capture in the source image
  70859. */
  70860. get sourceWidth(): number;
  70861. set sourceWidth(value: number);
  70862. /**
  70863. * Gets or sets the height to capture in the source image
  70864. */
  70865. get sourceHeight(): number;
  70866. set sourceHeight(value: number);
  70867. /**
  70868. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  70869. * @see http://doc.babylonjs.com/how_to/gui#image
  70870. */
  70871. get autoScale(): boolean;
  70872. set autoScale(value: boolean);
  70873. /** Gets or sets the streching mode used by the image */
  70874. get stretch(): number;
  70875. set stretch(value: number);
  70876. /** @hidden */
  70877. _rotate90(n: number): Image;
  70878. /**
  70879. * Gets or sets the internal DOM image used to render the control
  70880. */
  70881. set domImage(value: HTMLImageElement);
  70882. get domImage(): HTMLImageElement;
  70883. private _onImageLoaded;
  70884. private _extractNinePatchSliceDataFromImage;
  70885. /**
  70886. * Gets or sets image source url
  70887. */
  70888. set source(value: BABYLON.Nullable<string>);
  70889. /**
  70890. * Checks for svg document with icon id present
  70891. */
  70892. private _svgCheck;
  70893. /**
  70894. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  70895. * given external svg file and icon id
  70896. */
  70897. private _getSVGAttribs;
  70898. /**
  70899. * Gets or sets the cell width to use when animation sheet is enabled
  70900. * @see http://doc.babylonjs.com/how_to/gui#image
  70901. */
  70902. get cellWidth(): number;
  70903. set cellWidth(value: number);
  70904. /**
  70905. * Gets or sets the cell height to use when animation sheet is enabled
  70906. * @see http://doc.babylonjs.com/how_to/gui#image
  70907. */
  70908. get cellHeight(): number;
  70909. set cellHeight(value: number);
  70910. /**
  70911. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  70912. * @see http://doc.babylonjs.com/how_to/gui#image
  70913. */
  70914. get cellId(): number;
  70915. set cellId(value: number);
  70916. /**
  70917. * Creates a new Image
  70918. * @param name defines the control name
  70919. * @param url defines the image url
  70920. */
  70921. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  70922. /**
  70923. * Tests if a given coordinates belong to the current control
  70924. * @param x defines x coordinate to test
  70925. * @param y defines y coordinate to test
  70926. * @returns true if the coordinates are inside the control
  70927. */
  70928. contains(x: number, y: number): boolean;
  70929. protected _getTypeName(): string;
  70930. /** Force the control to synchronize with its content */
  70931. synchronizeSizeWithContent(): void;
  70932. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70933. private _prepareWorkingCanvasForOpaqueDetection;
  70934. private _drawImage;
  70935. _draw(context: CanvasRenderingContext2D): void;
  70936. private _renderCornerPatch;
  70937. private _renderNinePatch;
  70938. dispose(): void;
  70939. /** STRETCH_NONE */
  70940. static readonly STRETCH_NONE: number;
  70941. /** STRETCH_FILL */
  70942. static readonly STRETCH_FILL: number;
  70943. /** STRETCH_UNIFORM */
  70944. static readonly STRETCH_UNIFORM: number;
  70945. /** STRETCH_EXTEND */
  70946. static readonly STRETCH_EXTEND: number;
  70947. /** NINE_PATCH */
  70948. static readonly STRETCH_NINE_PATCH: number;
  70949. }
  70950. }
  70951. declare module BABYLON.GUI {
  70952. /**
  70953. * Class used to create 2D buttons
  70954. */
  70955. export class Button extends Rectangle {
  70956. name?: string | undefined;
  70957. /**
  70958. * Function called to generate a pointer enter animation
  70959. */
  70960. pointerEnterAnimation: () => void;
  70961. /**
  70962. * Function called to generate a pointer out animation
  70963. */
  70964. pointerOutAnimation: () => void;
  70965. /**
  70966. * Function called to generate a pointer down animation
  70967. */
  70968. pointerDownAnimation: () => void;
  70969. /**
  70970. * Function called to generate a pointer up animation
  70971. */
  70972. pointerUpAnimation: () => void;
  70973. /**
  70974. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  70975. */
  70976. delegatePickingToChildren: boolean;
  70977. private _image;
  70978. /**
  70979. * Returns the image part of the button (if any)
  70980. */
  70981. get image(): BABYLON.Nullable<Image>;
  70982. private _textBlock;
  70983. /**
  70984. * Returns the image part of the button (if any)
  70985. */
  70986. get textBlock(): BABYLON.Nullable<TextBlock>;
  70987. /**
  70988. * Creates a new Button
  70989. * @param name defines the name of the button
  70990. */
  70991. constructor(name?: string | undefined);
  70992. protected _getTypeName(): string;
  70993. /** @hidden */
  70994. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70995. /** @hidden */
  70996. _onPointerEnter(target: Control): boolean;
  70997. /** @hidden */
  70998. _onPointerOut(target: Control, force?: boolean): void;
  70999. /** @hidden */
  71000. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71001. /** @hidden */
  71002. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71003. /**
  71004. * Creates a new button made with an image and a text
  71005. * @param name defines the name of the button
  71006. * @param text defines the text of the button
  71007. * @param imageUrl defines the url of the image
  71008. * @returns a new Button
  71009. */
  71010. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71011. /**
  71012. * Creates a new button made with an image
  71013. * @param name defines the name of the button
  71014. * @param imageUrl defines the url of the image
  71015. * @returns a new Button
  71016. */
  71017. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71018. /**
  71019. * Creates a new button made with a text
  71020. * @param name defines the name of the button
  71021. * @param text defines the text of the button
  71022. * @returns a new Button
  71023. */
  71024. static CreateSimpleButton(name: string, text: string): Button;
  71025. /**
  71026. * Creates a new button made with an image and a centered text
  71027. * @param name defines the name of the button
  71028. * @param text defines the text of the button
  71029. * @param imageUrl defines the url of the image
  71030. * @returns a new Button
  71031. */
  71032. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71033. }
  71034. }
  71035. declare module BABYLON.GUI {
  71036. /**
  71037. * Class used to create a 2D stack panel container
  71038. */
  71039. export class StackPanel extends Container {
  71040. name?: string | undefined;
  71041. private _isVertical;
  71042. private _manualWidth;
  71043. private _manualHeight;
  71044. private _doNotTrackManualChanges;
  71045. /**
  71046. * Gets or sets a boolean indicating that layou warnings should be ignored
  71047. */
  71048. ignoreLayoutWarnings: boolean;
  71049. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71050. get isVertical(): boolean;
  71051. set isVertical(value: boolean);
  71052. /**
  71053. * Gets or sets panel width.
  71054. * This value should not be set when in horizontal mode as it will be computed automatically
  71055. */
  71056. set width(value: string | number);
  71057. get width(): string | number;
  71058. /**
  71059. * Gets or sets panel height.
  71060. * This value should not be set when in vertical mode as it will be computed automatically
  71061. */
  71062. set height(value: string | number);
  71063. get height(): string | number;
  71064. /**
  71065. * Creates a new StackPanel
  71066. * @param name defines control name
  71067. */
  71068. constructor(name?: string | undefined);
  71069. protected _getTypeName(): string;
  71070. /** @hidden */
  71071. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71072. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71073. protected _postMeasure(): void;
  71074. }
  71075. }
  71076. declare module BABYLON.GUI {
  71077. /**
  71078. * Class used to represent a 2D checkbox
  71079. */
  71080. export class Checkbox extends Control {
  71081. name?: string | undefined;
  71082. private _isChecked;
  71083. private _background;
  71084. private _checkSizeRatio;
  71085. private _thickness;
  71086. /** Gets or sets border thickness */
  71087. get thickness(): number;
  71088. set thickness(value: number);
  71089. /**
  71090. * BABYLON.Observable raised when isChecked property changes
  71091. */
  71092. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71093. /** Gets or sets a value indicating the ratio between overall size and check size */
  71094. get checkSizeRatio(): number;
  71095. set checkSizeRatio(value: number);
  71096. /** Gets or sets background color */
  71097. get background(): string;
  71098. set background(value: string);
  71099. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71100. get isChecked(): boolean;
  71101. set isChecked(value: boolean);
  71102. /**
  71103. * Creates a new CheckBox
  71104. * @param name defines the control name
  71105. */
  71106. constructor(name?: string | undefined);
  71107. protected _getTypeName(): string;
  71108. /** @hidden */
  71109. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71110. /** @hidden */
  71111. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71112. /**
  71113. * Utility function to easily create a checkbox with a header
  71114. * @param title defines the label to use for the header
  71115. * @param onValueChanged defines the callback to call when value changes
  71116. * @returns a StackPanel containing the checkbox and a textBlock
  71117. */
  71118. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71119. }
  71120. }
  71121. declare module BABYLON.GUI {
  71122. /**
  71123. * Class used to store key control properties
  71124. */
  71125. export class KeyPropertySet {
  71126. /** Width */
  71127. width?: string;
  71128. /** Height */
  71129. height?: string;
  71130. /** Left padding */
  71131. paddingLeft?: string;
  71132. /** Right padding */
  71133. paddingRight?: string;
  71134. /** Top padding */
  71135. paddingTop?: string;
  71136. /** Bottom padding */
  71137. paddingBottom?: string;
  71138. /** Foreground color */
  71139. color?: string;
  71140. /** Background color */
  71141. background?: string;
  71142. }
  71143. /**
  71144. * Class used to create virtual keyboard
  71145. */
  71146. export class VirtualKeyboard extends StackPanel {
  71147. /** BABYLON.Observable raised when a key is pressed */
  71148. onKeyPressObservable: BABYLON.Observable<string>;
  71149. /** Gets or sets default key button width */
  71150. defaultButtonWidth: string;
  71151. /** Gets or sets default key button height */
  71152. defaultButtonHeight: string;
  71153. /** Gets or sets default key button left padding */
  71154. defaultButtonPaddingLeft: string;
  71155. /** Gets or sets default key button right padding */
  71156. defaultButtonPaddingRight: string;
  71157. /** Gets or sets default key button top padding */
  71158. defaultButtonPaddingTop: string;
  71159. /** Gets or sets default key button bottom padding */
  71160. defaultButtonPaddingBottom: string;
  71161. /** Gets or sets default key button foreground color */
  71162. defaultButtonColor: string;
  71163. /** Gets or sets default key button background color */
  71164. defaultButtonBackground: string;
  71165. /** Gets or sets shift button foreground color */
  71166. shiftButtonColor: string;
  71167. /** Gets or sets shift button thickness*/
  71168. selectedShiftThickness: number;
  71169. /** Gets shift key state */
  71170. shiftState: number;
  71171. protected _getTypeName(): string;
  71172. private _createKey;
  71173. /**
  71174. * Adds a new row of keys
  71175. * @param keys defines the list of keys to add
  71176. * @param propertySets defines the associated property sets
  71177. */
  71178. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71179. /**
  71180. * Set the shift key to a specific state
  71181. * @param shiftState defines the new shift state
  71182. */
  71183. applyShiftState(shiftState: number): void;
  71184. private _currentlyConnectedInputText;
  71185. private _connectedInputTexts;
  71186. private _onKeyPressObserver;
  71187. /** Gets the input text control currently attached to the keyboard */
  71188. get connectedInputText(): BABYLON.Nullable<InputText>;
  71189. /**
  71190. * Connects the keyboard with an input text control
  71191. *
  71192. * @param input defines the target control
  71193. */
  71194. connect(input: InputText): void;
  71195. /**
  71196. * Disconnects the keyboard from connected InputText controls
  71197. *
  71198. * @param input optionally defines a target control, otherwise all are disconnected
  71199. */
  71200. disconnect(input?: InputText): void;
  71201. private _removeConnectedInputObservables;
  71202. /**
  71203. * Release all resources
  71204. */
  71205. dispose(): void;
  71206. /**
  71207. * Creates a new keyboard using a default layout
  71208. *
  71209. * @param name defines control name
  71210. * @returns a new VirtualKeyboard
  71211. */
  71212. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71213. }
  71214. }
  71215. declare module BABYLON.GUI {
  71216. /**
  71217. * Class used to create input text control
  71218. */
  71219. export class InputText extends Control implements IFocusableControl {
  71220. name?: string | undefined;
  71221. private _text;
  71222. private _placeholderText;
  71223. private _background;
  71224. private _focusedBackground;
  71225. private _focusedColor;
  71226. private _placeholderColor;
  71227. private _thickness;
  71228. private _margin;
  71229. private _autoStretchWidth;
  71230. private _maxWidth;
  71231. private _isFocused;
  71232. private _blinkTimeout;
  71233. private _blinkIsEven;
  71234. private _cursorOffset;
  71235. private _scrollLeft;
  71236. private _textWidth;
  71237. private _clickedCoordinate;
  71238. private _deadKey;
  71239. private _addKey;
  71240. private _currentKey;
  71241. private _isTextHighlightOn;
  71242. private _textHighlightColor;
  71243. private _highligherOpacity;
  71244. private _highlightedText;
  71245. private _startHighlightIndex;
  71246. private _endHighlightIndex;
  71247. private _cursorIndex;
  71248. private _onFocusSelectAll;
  71249. private _isPointerDown;
  71250. private _onClipboardObserver;
  71251. private _onPointerDblTapObserver;
  71252. /** @hidden */
  71253. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71254. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71255. promptMessage: string;
  71256. /** Force disable prompt on mobile device */
  71257. disableMobilePrompt: boolean;
  71258. /** BABYLON.Observable raised when the text changes */
  71259. onTextChangedObservable: BABYLON.Observable<InputText>;
  71260. /** BABYLON.Observable raised just before an entered character is to be added */
  71261. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71262. /** BABYLON.Observable raised when the control gets the focus */
  71263. onFocusObservable: BABYLON.Observable<InputText>;
  71264. /** BABYLON.Observable raised when the control loses the focus */
  71265. onBlurObservable: BABYLON.Observable<InputText>;
  71266. /**Observable raised when the text is highlighted */
  71267. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71268. /**Observable raised when copy event is triggered */
  71269. onTextCopyObservable: BABYLON.Observable<InputText>;
  71270. /** BABYLON.Observable raised when cut event is triggered */
  71271. onTextCutObservable: BABYLON.Observable<InputText>;
  71272. /** BABYLON.Observable raised when paste event is triggered */
  71273. onTextPasteObservable: BABYLON.Observable<InputText>;
  71274. /** BABYLON.Observable raised when a key event was processed */
  71275. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71276. /** Gets or sets the maximum width allowed by the control */
  71277. get maxWidth(): string | number;
  71278. /** Gets the maximum width allowed by the control in pixels */
  71279. get maxWidthInPixels(): number;
  71280. set maxWidth(value: string | number);
  71281. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71282. get highligherOpacity(): number;
  71283. set highligherOpacity(value: number);
  71284. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71285. get onFocusSelectAll(): boolean;
  71286. set onFocusSelectAll(value: boolean);
  71287. /** Gets or sets the text hightlight color */
  71288. get textHighlightColor(): string;
  71289. set textHighlightColor(value: string);
  71290. /** Gets or sets control margin */
  71291. get margin(): string;
  71292. /** Gets control margin in pixels */
  71293. get marginInPixels(): number;
  71294. set margin(value: string);
  71295. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71296. get autoStretchWidth(): boolean;
  71297. set autoStretchWidth(value: boolean);
  71298. /** Gets or sets border thickness */
  71299. get thickness(): number;
  71300. set thickness(value: number);
  71301. /** Gets or sets the background color when focused */
  71302. get focusedBackground(): string;
  71303. set focusedBackground(value: string);
  71304. /** Gets or sets the background color when focused */
  71305. get focusedColor(): string;
  71306. set focusedColor(value: string);
  71307. /** Gets or sets the background color */
  71308. get background(): string;
  71309. set background(value: string);
  71310. /** Gets or sets the placeholder color */
  71311. get placeholderColor(): string;
  71312. set placeholderColor(value: string);
  71313. /** Gets or sets the text displayed when the control is empty */
  71314. get placeholderText(): string;
  71315. set placeholderText(value: string);
  71316. /** Gets or sets the dead key flag */
  71317. get deadKey(): boolean;
  71318. set deadKey(flag: boolean);
  71319. /** Gets or sets the highlight text */
  71320. get highlightedText(): string;
  71321. set highlightedText(text: string);
  71322. /** Gets or sets if the current key should be added */
  71323. get addKey(): boolean;
  71324. set addKey(flag: boolean);
  71325. /** Gets or sets the value of the current key being entered */
  71326. get currentKey(): string;
  71327. set currentKey(key: string);
  71328. /** Gets or sets the text displayed in the control */
  71329. get text(): string;
  71330. set text(value: string);
  71331. /** Gets or sets control width */
  71332. get width(): string | number;
  71333. set width(value: string | number);
  71334. /**
  71335. * Creates a new InputText
  71336. * @param name defines the control name
  71337. * @param text defines the text of the control
  71338. */
  71339. constructor(name?: string | undefined, text?: string);
  71340. /** @hidden */
  71341. onBlur(): void;
  71342. /** @hidden */
  71343. onFocus(): void;
  71344. protected _getTypeName(): string;
  71345. /**
  71346. * Function called to get the list of controls that should not steal the focus from this control
  71347. * @returns an array of controls
  71348. */
  71349. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71350. /** @hidden */
  71351. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  71352. /** @hidden */
  71353. private _updateValueFromCursorIndex;
  71354. /** @hidden */
  71355. private _processDblClick;
  71356. /** @hidden */
  71357. private _selectAllText;
  71358. /**
  71359. * Handles the keyboard event
  71360. * @param evt Defines the KeyboardEvent
  71361. */
  71362. processKeyboard(evt: KeyboardEvent): void;
  71363. /** @hidden */
  71364. private _onCopyText;
  71365. /** @hidden */
  71366. private _onCutText;
  71367. /** @hidden */
  71368. private _onPasteText;
  71369. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71370. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71371. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71372. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71373. protected _beforeRenderText(text: string): string;
  71374. dispose(): void;
  71375. }
  71376. }
  71377. declare module BABYLON.GUI {
  71378. /**
  71379. * Class used to create a 2D grid container
  71380. */
  71381. export class Grid extends Container {
  71382. name?: string | undefined;
  71383. private _rowDefinitions;
  71384. private _columnDefinitions;
  71385. private _cells;
  71386. private _childControls;
  71387. /**
  71388. * Gets the number of columns
  71389. */
  71390. get columnCount(): number;
  71391. /**
  71392. * Gets the number of rows
  71393. */
  71394. get rowCount(): number;
  71395. /** Gets the list of children */
  71396. get children(): Control[];
  71397. /** Gets the list of cells (e.g. the containers) */
  71398. get cells(): {
  71399. [key: string]: Container;
  71400. };
  71401. /**
  71402. * Gets the definition of a specific row
  71403. * @param index defines the index of the row
  71404. * @returns the row definition
  71405. */
  71406. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71407. /**
  71408. * Gets the definition of a specific column
  71409. * @param index defines the index of the column
  71410. * @returns the column definition
  71411. */
  71412. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71413. /**
  71414. * Adds a new row to the grid
  71415. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71416. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  71417. * @returns the current grid
  71418. */
  71419. addRowDefinition(height: number, isPixel?: boolean): Grid;
  71420. /**
  71421. * Adds a new column to the grid
  71422. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71423. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71424. * @returns the current grid
  71425. */
  71426. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  71427. /**
  71428. * Update a row definition
  71429. * @param index defines the index of the row to update
  71430. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71431. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  71432. * @returns the current grid
  71433. */
  71434. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  71435. /**
  71436. * Update a column definition
  71437. * @param index defines the index of the column to update
  71438. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71439. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71440. * @returns the current grid
  71441. */
  71442. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  71443. /**
  71444. * Gets the list of children stored in a specific cell
  71445. * @param row defines the row to check
  71446. * @param column defines the column to check
  71447. * @returns the list of controls
  71448. */
  71449. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  71450. /**
  71451. * Gets a string representing the child cell info (row x column)
  71452. * @param child defines the control to get info from
  71453. * @returns a string containing the child cell info (row x column)
  71454. */
  71455. getChildCellInfo(child: Control): string;
  71456. private _removeCell;
  71457. private _offsetCell;
  71458. /**
  71459. * Remove a column definition at specified index
  71460. * @param index defines the index of the column to remove
  71461. * @returns the current grid
  71462. */
  71463. removeColumnDefinition(index: number): Grid;
  71464. /**
  71465. * Remove a row definition at specified index
  71466. * @param index defines the index of the row to remove
  71467. * @returns the current grid
  71468. */
  71469. removeRowDefinition(index: number): Grid;
  71470. /**
  71471. * Adds a new control to the current grid
  71472. * @param control defines the control to add
  71473. * @param row defines the row where to add the control (0 by default)
  71474. * @param column defines the column where to add the control (0 by default)
  71475. * @returns the current grid
  71476. */
  71477. addControl(control: Control, row?: number, column?: number): Grid;
  71478. /**
  71479. * Removes a control from the current container
  71480. * @param control defines the control to remove
  71481. * @returns the current container
  71482. */
  71483. removeControl(control: Control): Container;
  71484. /**
  71485. * Creates a new Grid
  71486. * @param name defines control name
  71487. */
  71488. constructor(name?: string | undefined);
  71489. protected _getTypeName(): string;
  71490. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  71491. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71492. _flagDescendantsAsMatrixDirty(): void;
  71493. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71494. /** Releases associated resources */
  71495. dispose(): void;
  71496. }
  71497. }
  71498. declare module BABYLON.GUI {
  71499. /** Class used to create color pickers */
  71500. export class ColorPicker extends Control {
  71501. name?: string | undefined;
  71502. private static _Epsilon;
  71503. private _colorWheelCanvas;
  71504. private _value;
  71505. private _tmpColor;
  71506. private _pointerStartedOnSquare;
  71507. private _pointerStartedOnWheel;
  71508. private _squareLeft;
  71509. private _squareTop;
  71510. private _squareSize;
  71511. private _h;
  71512. private _s;
  71513. private _v;
  71514. private _lastPointerDownID;
  71515. /**
  71516. * BABYLON.Observable raised when the value changes
  71517. */
  71518. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  71519. /** Gets or sets the color of the color picker */
  71520. get value(): BABYLON.Color3;
  71521. set value(value: BABYLON.Color3);
  71522. /**
  71523. * Gets or sets control width
  71524. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71525. */
  71526. get width(): string | number;
  71527. set width(value: string | number);
  71528. /**
  71529. * Gets or sets control height
  71530. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71531. */
  71532. get height(): string | number;
  71533. /** Gets or sets control height */
  71534. set height(value: string | number);
  71535. /** Gets or sets control size */
  71536. get size(): string | number;
  71537. set size(value: string | number);
  71538. /**
  71539. * Creates a new ColorPicker
  71540. * @param name defines the control name
  71541. */
  71542. constructor(name?: string | undefined);
  71543. protected _getTypeName(): string;
  71544. /** @hidden */
  71545. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71546. private _updateSquareProps;
  71547. private _drawGradientSquare;
  71548. private _drawCircle;
  71549. private _createColorWheelCanvas;
  71550. /** @hidden */
  71551. _draw(context: CanvasRenderingContext2D): void;
  71552. private _pointerIsDown;
  71553. private _updateValueFromPointer;
  71554. private _isPointOnSquare;
  71555. private _isPointOnWheel;
  71556. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71557. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71558. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71559. /**
  71560. * This function expands the color picker by creating a color picker dialog with manual
  71561. * color value input and the ability to save colors into an array to be used later in
  71562. * subsequent launches of the dialogue.
  71563. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  71564. * @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.
  71565. * @returns picked color as a hex string and the saved colors array as hex strings.
  71566. */
  71567. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  71568. pickerWidth?: string;
  71569. pickerHeight?: string;
  71570. headerHeight?: string;
  71571. lastColor?: string;
  71572. swatchLimit?: number;
  71573. numSwatchesPerLine?: number;
  71574. savedColors?: Array<string>;
  71575. }): Promise<{
  71576. savedColors?: string[];
  71577. pickedColor: string;
  71578. }>;
  71579. }
  71580. }
  71581. declare module BABYLON.GUI {
  71582. /** Class used to create 2D ellipse containers */
  71583. export class Ellipse extends Container {
  71584. name?: string | undefined;
  71585. private _thickness;
  71586. /** Gets or sets border thickness */
  71587. get thickness(): number;
  71588. set thickness(value: number);
  71589. /**
  71590. * Creates a new Ellipse
  71591. * @param name defines the control name
  71592. */
  71593. constructor(name?: string | undefined);
  71594. protected _getTypeName(): string;
  71595. protected _localDraw(context: CanvasRenderingContext2D): void;
  71596. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71597. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71598. }
  71599. }
  71600. declare module BABYLON.GUI {
  71601. /**
  71602. * Class used to create a password control
  71603. */
  71604. export class InputPassword extends InputText {
  71605. protected _beforeRenderText(text: string): string;
  71606. }
  71607. }
  71608. declare module BABYLON.GUI {
  71609. /** Class used to render 2D lines */
  71610. export class Line extends Control {
  71611. name?: string | undefined;
  71612. private _lineWidth;
  71613. private _x1;
  71614. private _y1;
  71615. private _x2;
  71616. private _y2;
  71617. private _dash;
  71618. private _connectedControl;
  71619. private _connectedControlDirtyObserver;
  71620. /** Gets or sets the dash pattern */
  71621. get dash(): Array<number>;
  71622. set dash(value: Array<number>);
  71623. /** Gets or sets the control connected with the line end */
  71624. get connectedControl(): Control;
  71625. set connectedControl(value: Control);
  71626. /** Gets or sets start coordinates on X axis */
  71627. get x1(): string | number;
  71628. set x1(value: string | number);
  71629. /** Gets or sets start coordinates on Y axis */
  71630. get y1(): string | number;
  71631. set y1(value: string | number);
  71632. /** Gets or sets end coordinates on X axis */
  71633. get x2(): string | number;
  71634. set x2(value: string | number);
  71635. /** Gets or sets end coordinates on Y axis */
  71636. get y2(): string | number;
  71637. set y2(value: string | number);
  71638. /** Gets or sets line width */
  71639. get lineWidth(): number;
  71640. set lineWidth(value: number);
  71641. /** Gets or sets horizontal alignment */
  71642. set horizontalAlignment(value: number);
  71643. /** Gets or sets vertical alignment */
  71644. set verticalAlignment(value: number);
  71645. private get _effectiveX2();
  71646. private get _effectiveY2();
  71647. /**
  71648. * Creates a new Line
  71649. * @param name defines the control name
  71650. */
  71651. constructor(name?: string | undefined);
  71652. protected _getTypeName(): string;
  71653. _draw(context: CanvasRenderingContext2D): void;
  71654. _measure(): void;
  71655. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71656. /**
  71657. * Move one end of the line given 3D cartesian coordinates.
  71658. * @param position Targeted world position
  71659. * @param scene BABYLON.Scene
  71660. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71661. */
  71662. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  71663. /**
  71664. * Move one end of the line to a position in screen absolute space.
  71665. * @param projectedPosition Position in screen absolute space (X, Y)
  71666. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71667. */
  71668. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  71669. }
  71670. }
  71671. declare module BABYLON.GUI {
  71672. /**
  71673. * Class used to store a point for a MultiLine object.
  71674. * The point can be pure 2D coordinates, a mesh or a control
  71675. */
  71676. export class MultiLinePoint {
  71677. private _multiLine;
  71678. private _x;
  71679. private _y;
  71680. private _control;
  71681. private _mesh;
  71682. private _controlObserver;
  71683. private _meshObserver;
  71684. /** @hidden */
  71685. _point: BABYLON.Vector2;
  71686. /**
  71687. * Creates a new MultiLinePoint
  71688. * @param multiLine defines the source MultiLine object
  71689. */
  71690. constructor(multiLine: MultiLine);
  71691. /** Gets or sets x coordinate */
  71692. get x(): string | number;
  71693. set x(value: string | number);
  71694. /** Gets or sets y coordinate */
  71695. get y(): string | number;
  71696. set y(value: string | number);
  71697. /** Gets or sets the control associated with this point */
  71698. get control(): BABYLON.Nullable<Control>;
  71699. set control(value: BABYLON.Nullable<Control>);
  71700. /** Gets or sets the mesh associated with this point */
  71701. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71702. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  71703. /** Resets links */
  71704. resetLinks(): void;
  71705. /**
  71706. * Gets a translation vector
  71707. * @returns the translation vector
  71708. */
  71709. translate(): BABYLON.Vector2;
  71710. private _translatePoint;
  71711. /** Release associated resources */
  71712. dispose(): void;
  71713. }
  71714. }
  71715. declare module BABYLON.GUI {
  71716. /**
  71717. * Class used to create multi line control
  71718. */
  71719. export class MultiLine extends Control {
  71720. name?: string | undefined;
  71721. private _lineWidth;
  71722. private _dash;
  71723. private _points;
  71724. private _minX;
  71725. private _minY;
  71726. private _maxX;
  71727. private _maxY;
  71728. /**
  71729. * Creates a new MultiLine
  71730. * @param name defines the control name
  71731. */
  71732. constructor(name?: string | undefined);
  71733. /** Gets or sets dash pattern */
  71734. get dash(): Array<number>;
  71735. set dash(value: Array<number>);
  71736. /**
  71737. * Gets point stored at specified index
  71738. * @param index defines the index to look for
  71739. * @returns the requested point if found
  71740. */
  71741. getAt(index: number): MultiLinePoint;
  71742. /** Function called when a point is updated */
  71743. onPointUpdate: () => void;
  71744. /**
  71745. * Adds new points to the point collection
  71746. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  71747. * @returns the list of created MultiLinePoint
  71748. */
  71749. add(...items: (AbstractMesh | Control | {
  71750. x: string | number;
  71751. y: string | number;
  71752. })[]): MultiLinePoint[];
  71753. /**
  71754. * Adds a new point to the point collection
  71755. * @param item defines the item (mesh, control or 2d coordiantes) to add
  71756. * @returns the created MultiLinePoint
  71757. */
  71758. push(item?: (AbstractMesh | Control | {
  71759. x: string | number;
  71760. y: string | number;
  71761. })): MultiLinePoint;
  71762. /**
  71763. * Remove a specific value or point from the active point collection
  71764. * @param value defines the value or point to remove
  71765. */
  71766. remove(value: number | MultiLinePoint): void;
  71767. /**
  71768. * Resets this object to initial state (no point)
  71769. */
  71770. reset(): void;
  71771. /**
  71772. * Resets all links
  71773. */
  71774. resetLinks(): void;
  71775. /** Gets or sets line width */
  71776. get lineWidth(): number;
  71777. set lineWidth(value: number);
  71778. set horizontalAlignment(value: number);
  71779. set verticalAlignment(value: number);
  71780. protected _getTypeName(): string;
  71781. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71782. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71783. _measure(): void;
  71784. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71785. dispose(): void;
  71786. }
  71787. }
  71788. declare module BABYLON.GUI {
  71789. /**
  71790. * Class used to create radio button controls
  71791. */
  71792. export class RadioButton extends Control {
  71793. name?: string | undefined;
  71794. private _isChecked;
  71795. private _background;
  71796. private _checkSizeRatio;
  71797. private _thickness;
  71798. /** Gets or sets border thickness */
  71799. get thickness(): number;
  71800. set thickness(value: number);
  71801. /** Gets or sets group name */
  71802. group: string;
  71803. /** BABYLON.Observable raised when isChecked is changed */
  71804. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71805. /** Gets or sets a value indicating the ratio between overall size and check size */
  71806. get checkSizeRatio(): number;
  71807. set checkSizeRatio(value: number);
  71808. /** Gets or sets background color */
  71809. get background(): string;
  71810. set background(value: string);
  71811. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71812. get isChecked(): boolean;
  71813. set isChecked(value: boolean);
  71814. /**
  71815. * Creates a new RadioButton
  71816. * @param name defines the control name
  71817. */
  71818. constructor(name?: string | undefined);
  71819. protected _getTypeName(): string;
  71820. _draw(context: CanvasRenderingContext2D): void;
  71821. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71822. /**
  71823. * Utility function to easily create a radio button with a header
  71824. * @param title defines the label to use for the header
  71825. * @param group defines the group to use for the radio button
  71826. * @param isChecked defines the initial state of the radio button
  71827. * @param onValueChanged defines the callback to call when value changes
  71828. * @returns a StackPanel containing the radio button and a textBlock
  71829. */
  71830. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  71831. }
  71832. }
  71833. declare module BABYLON.GUI {
  71834. /**
  71835. * Class used to create slider controls
  71836. */
  71837. export class BaseSlider extends Control {
  71838. name?: string | undefined;
  71839. protected _thumbWidth: ValueAndUnit;
  71840. private _minimum;
  71841. private _maximum;
  71842. private _value;
  71843. private _isVertical;
  71844. protected _barOffset: ValueAndUnit;
  71845. private _isThumbClamped;
  71846. protected _displayThumb: boolean;
  71847. private _step;
  71848. private _lastPointerDownID;
  71849. protected _effectiveBarOffset: number;
  71850. protected _renderLeft: number;
  71851. protected _renderTop: number;
  71852. protected _renderWidth: number;
  71853. protected _renderHeight: number;
  71854. protected _backgroundBoxLength: number;
  71855. protected _backgroundBoxThickness: number;
  71856. protected _effectiveThumbThickness: number;
  71857. /** BABYLON.Observable raised when the sldier value changes */
  71858. onValueChangedObservable: BABYLON.Observable<number>;
  71859. /** Gets or sets a boolean indicating if the thumb must be rendered */
  71860. get displayThumb(): boolean;
  71861. set displayThumb(value: boolean);
  71862. /** Gets or sets a step to apply to values (0 by default) */
  71863. get step(): number;
  71864. set step(value: number);
  71865. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  71866. get barOffset(): string | number;
  71867. /** Gets main bar offset in pixels*/
  71868. get barOffsetInPixels(): number;
  71869. set barOffset(value: string | number);
  71870. /** Gets or sets thumb width */
  71871. get thumbWidth(): string | number;
  71872. /** Gets thumb width in pixels */
  71873. get thumbWidthInPixels(): number;
  71874. set thumbWidth(value: string | number);
  71875. /** Gets or sets minimum value */
  71876. get minimum(): number;
  71877. set minimum(value: number);
  71878. /** Gets or sets maximum value */
  71879. get maximum(): number;
  71880. set maximum(value: number);
  71881. /** Gets or sets current value */
  71882. get value(): number;
  71883. set value(value: number);
  71884. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  71885. get isVertical(): boolean;
  71886. set isVertical(value: boolean);
  71887. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  71888. get isThumbClamped(): boolean;
  71889. set isThumbClamped(value: boolean);
  71890. /**
  71891. * Creates a new BaseSlider
  71892. * @param name defines the control name
  71893. */
  71894. constructor(name?: string | undefined);
  71895. protected _getTypeName(): string;
  71896. protected _getThumbPosition(): number;
  71897. protected _getThumbThickness(type: string): number;
  71898. protected _prepareRenderingData(type: string): void;
  71899. private _pointerIsDown;
  71900. /** @hidden */
  71901. protected _updateValueFromPointer(x: number, y: number): void;
  71902. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71903. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71904. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71905. }
  71906. }
  71907. declare module BABYLON.GUI {
  71908. /**
  71909. * Class used to create slider controls
  71910. */
  71911. export class Slider extends BaseSlider {
  71912. name?: string | undefined;
  71913. private _background;
  71914. private _borderColor;
  71915. private _isThumbCircle;
  71916. protected _displayValueBar: boolean;
  71917. /** Gets or sets a boolean indicating if the value bar must be rendered */
  71918. get displayValueBar(): boolean;
  71919. set displayValueBar(value: boolean);
  71920. /** Gets or sets border color */
  71921. get borderColor(): string;
  71922. set borderColor(value: string);
  71923. /** Gets or sets background color */
  71924. get background(): string;
  71925. set background(value: string);
  71926. /** Gets or sets a boolean indicating if the thumb should be round or square */
  71927. get isThumbCircle(): boolean;
  71928. set isThumbCircle(value: boolean);
  71929. /**
  71930. * Creates a new Slider
  71931. * @param name defines the control name
  71932. */
  71933. constructor(name?: string | undefined);
  71934. protected _getTypeName(): string;
  71935. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71936. }
  71937. }
  71938. declare module BABYLON.GUI {
  71939. /** Class used to create a RadioGroup
  71940. * which contains groups of radio buttons
  71941. */
  71942. export class SelectorGroup {
  71943. /** name of SelectorGroup */
  71944. name: string;
  71945. private _groupPanel;
  71946. private _selectors;
  71947. private _groupHeader;
  71948. /**
  71949. * Creates a new SelectorGroup
  71950. * @param name of group, used as a group heading
  71951. */
  71952. constructor(
  71953. /** name of SelectorGroup */
  71954. name: string);
  71955. /** Gets the groupPanel of the SelectorGroup */
  71956. get groupPanel(): StackPanel;
  71957. /** Gets the selectors array */
  71958. get selectors(): StackPanel[];
  71959. /** Gets and sets the group header */
  71960. get header(): string;
  71961. set header(label: string);
  71962. /** @hidden */
  71963. private _addGroupHeader;
  71964. /** @hidden*/
  71965. _getSelector(selectorNb: number): StackPanel | undefined;
  71966. /** Removes the selector at the given position
  71967. * @param selectorNb the position of the selector within the group
  71968. */
  71969. removeSelector(selectorNb: number): void;
  71970. }
  71971. /** Class used to create a CheckboxGroup
  71972. * which contains groups of checkbox buttons
  71973. */
  71974. export class CheckboxGroup extends SelectorGroup {
  71975. /** Adds a checkbox as a control
  71976. * @param text is the label for the selector
  71977. * @param func is the function called when the Selector is checked
  71978. * @param checked is true when Selector is checked
  71979. */
  71980. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  71981. /** @hidden */
  71982. _setSelectorLabel(selectorNb: number, label: string): void;
  71983. /** @hidden */
  71984. _setSelectorLabelColor(selectorNb: number, color: string): void;
  71985. /** @hidden */
  71986. _setSelectorButtonColor(selectorNb: number, color: string): void;
  71987. /** @hidden */
  71988. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  71989. }
  71990. /** Class used to create a RadioGroup
  71991. * which contains groups of radio buttons
  71992. */
  71993. export class RadioGroup extends SelectorGroup {
  71994. private _selectNb;
  71995. /** Adds a radio button as a control
  71996. * @param label is the label for the selector
  71997. * @param func is the function called when the Selector is checked
  71998. * @param checked is true when Selector is checked
  71999. */
  72000. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72001. /** @hidden */
  72002. _setSelectorLabel(selectorNb: number, label: string): void;
  72003. /** @hidden */
  72004. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72005. /** @hidden */
  72006. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72007. /** @hidden */
  72008. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72009. }
  72010. /** Class used to create a SliderGroup
  72011. * which contains groups of slider buttons
  72012. */
  72013. export class SliderGroup extends SelectorGroup {
  72014. /**
  72015. * Adds a slider to the SelectorGroup
  72016. * @param label is the label for the SliderBar
  72017. * @param func is the function called when the Slider moves
  72018. * @param unit is a string describing the units used, eg degrees or metres
  72019. * @param min is the minimum value for the Slider
  72020. * @param max is the maximum value for the Slider
  72021. * @param value is the start value for the Slider between min and max
  72022. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72023. */
  72024. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72025. /** @hidden */
  72026. _setSelectorLabel(selectorNb: number, label: string): void;
  72027. /** @hidden */
  72028. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72029. /** @hidden */
  72030. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72031. /** @hidden */
  72032. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72033. }
  72034. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72035. * @see http://doc.babylonjs.com/how_to/selector
  72036. */
  72037. export class SelectionPanel extends Rectangle {
  72038. /** name of SelectionPanel */
  72039. name: string;
  72040. /** an array of SelectionGroups */
  72041. groups: SelectorGroup[];
  72042. private _panel;
  72043. private _buttonColor;
  72044. private _buttonBackground;
  72045. private _headerColor;
  72046. private _barColor;
  72047. private _barHeight;
  72048. private _spacerHeight;
  72049. private _labelColor;
  72050. private _groups;
  72051. private _bars;
  72052. /**
  72053. * Creates a new SelectionPanel
  72054. * @param name of SelectionPanel
  72055. * @param groups is an array of SelectionGroups
  72056. */
  72057. constructor(
  72058. /** name of SelectionPanel */
  72059. name: string,
  72060. /** an array of SelectionGroups */
  72061. groups?: SelectorGroup[]);
  72062. protected _getTypeName(): string;
  72063. /** Gets or sets the headerColor */
  72064. get headerColor(): string;
  72065. set headerColor(color: string);
  72066. private _setHeaderColor;
  72067. /** Gets or sets the button color */
  72068. get buttonColor(): string;
  72069. set buttonColor(color: string);
  72070. private _setbuttonColor;
  72071. /** Gets or sets the label color */
  72072. get labelColor(): string;
  72073. set labelColor(color: string);
  72074. private _setLabelColor;
  72075. /** Gets or sets the button background */
  72076. get buttonBackground(): string;
  72077. set buttonBackground(color: string);
  72078. private _setButtonBackground;
  72079. /** Gets or sets the color of separator bar */
  72080. get barColor(): string;
  72081. set barColor(color: string);
  72082. private _setBarColor;
  72083. /** Gets or sets the height of separator bar */
  72084. get barHeight(): string;
  72085. set barHeight(value: string);
  72086. private _setBarHeight;
  72087. /** Gets or sets the height of spacers*/
  72088. get spacerHeight(): string;
  72089. set spacerHeight(value: string);
  72090. private _setSpacerHeight;
  72091. /** Adds a bar between groups */
  72092. private _addSpacer;
  72093. /** Add a group to the selection panel
  72094. * @param group is the selector group to add
  72095. */
  72096. addGroup(group: SelectorGroup): void;
  72097. /** Remove the group from the given position
  72098. * @param groupNb is the position of the group in the list
  72099. */
  72100. removeGroup(groupNb: number): void;
  72101. /** Change a group header label
  72102. * @param label is the new group header label
  72103. * @param groupNb is the number of the group to relabel
  72104. * */
  72105. setHeaderName(label: string, groupNb: number): void;
  72106. /** Change selector label to the one given
  72107. * @param label is the new selector label
  72108. * @param groupNb is the number of the groupcontaining the selector
  72109. * @param selectorNb is the number of the selector within a group to relabel
  72110. * */
  72111. relabel(label: string, groupNb: number, selectorNb: number): void;
  72112. /** For a given group position remove the selector at the given position
  72113. * @param groupNb is the number of the group to remove the selector from
  72114. * @param selectorNb is the number of the selector within the group
  72115. */
  72116. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72117. /** For a given group position of correct type add a checkbox button
  72118. * @param groupNb is the number of the group to remove the selector from
  72119. * @param label is the label for the selector
  72120. * @param func is the function called when the Selector is checked
  72121. * @param checked is true when Selector is checked
  72122. */
  72123. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72124. /** For a given group position of correct type add a radio button
  72125. * @param groupNb is the number of the group to remove the selector from
  72126. * @param label is the label for the selector
  72127. * @param func is the function called when the Selector is checked
  72128. * @param checked is true when Selector is checked
  72129. */
  72130. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72131. /**
  72132. * For a given slider group add a slider
  72133. * @param groupNb is the number of the group to add the slider to
  72134. * @param label is the label for the Slider
  72135. * @param func is the function called when the Slider moves
  72136. * @param unit is a string describing the units used, eg degrees or metres
  72137. * @param min is the minimum value for the Slider
  72138. * @param max is the maximum value for the Slider
  72139. * @param value is the start value for the Slider between min and max
  72140. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72141. */
  72142. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72143. }
  72144. }
  72145. declare module BABYLON.GUI {
  72146. /**
  72147. * Class used to hold a the container for ScrollViewer
  72148. * @hidden
  72149. */
  72150. export class _ScrollViewerWindow extends Container {
  72151. parentClientWidth: number;
  72152. parentClientHeight: number;
  72153. /**
  72154. * Creates a new ScrollViewerWindow
  72155. * @param name of ScrollViewerWindow
  72156. */
  72157. constructor(name?: string);
  72158. protected _getTypeName(): string;
  72159. /** @hidden */
  72160. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72161. protected _postMeasure(): void;
  72162. }
  72163. }
  72164. declare module BABYLON.GUI {
  72165. /**
  72166. * Class used to create slider controls
  72167. */
  72168. export class ScrollBar extends BaseSlider {
  72169. name?: string | undefined;
  72170. private _background;
  72171. private _borderColor;
  72172. private _tempMeasure;
  72173. /** Gets or sets border color */
  72174. get borderColor(): string;
  72175. set borderColor(value: string);
  72176. /** Gets or sets background color */
  72177. get background(): string;
  72178. set background(value: string);
  72179. /**
  72180. * Creates a new Slider
  72181. * @param name defines the control name
  72182. */
  72183. constructor(name?: string | undefined);
  72184. protected _getTypeName(): string;
  72185. protected _getThumbThickness(): number;
  72186. _draw(context: CanvasRenderingContext2D): void;
  72187. private _first;
  72188. private _originX;
  72189. private _originY;
  72190. /** @hidden */
  72191. protected _updateValueFromPointer(x: number, y: number): void;
  72192. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72193. }
  72194. }
  72195. declare module BABYLON.GUI {
  72196. /**
  72197. * Class used to create slider controls
  72198. */
  72199. export class ImageScrollBar extends BaseSlider {
  72200. name?: string | undefined;
  72201. private _backgroundBaseImage;
  72202. private _backgroundImage;
  72203. private _thumbImage;
  72204. private _thumbBaseImage;
  72205. private _thumbLength;
  72206. private _thumbHeight;
  72207. private _barImageHeight;
  72208. private _tempMeasure;
  72209. /**
  72210. * Gets or sets the image used to render the background for horizontal bar
  72211. */
  72212. get backgroundImage(): Image;
  72213. set backgroundImage(value: Image);
  72214. /**
  72215. * Gets or sets the image used to render the thumb
  72216. */
  72217. get thumbImage(): Image;
  72218. set thumbImage(value: Image);
  72219. /**
  72220. * Gets or sets the length of the thumb
  72221. */
  72222. get thumbLength(): number;
  72223. set thumbLength(value: number);
  72224. /**
  72225. * Gets or sets the height of the thumb
  72226. */
  72227. get thumbHeight(): number;
  72228. set thumbHeight(value: number);
  72229. /**
  72230. * Gets or sets the height of the bar image
  72231. */
  72232. get barImageHeight(): number;
  72233. set barImageHeight(value: number);
  72234. /**
  72235. * Creates a new ImageScrollBar
  72236. * @param name defines the control name
  72237. */
  72238. constructor(name?: string | undefined);
  72239. protected _getTypeName(): string;
  72240. protected _getThumbThickness(): number;
  72241. _draw(context: CanvasRenderingContext2D): void;
  72242. private _first;
  72243. private _originX;
  72244. private _originY;
  72245. /** @hidden */
  72246. protected _updateValueFromPointer(x: number, y: number): void;
  72247. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72248. }
  72249. }
  72250. declare module BABYLON.GUI {
  72251. /**
  72252. * Class used to hold a viewer window and sliders in a grid
  72253. */
  72254. export class ScrollViewer extends Rectangle {
  72255. private _grid;
  72256. private _horizontalBarSpace;
  72257. private _verticalBarSpace;
  72258. private _dragSpace;
  72259. private _horizontalBar;
  72260. private _verticalBar;
  72261. private _barColor;
  72262. private _barBackground;
  72263. private _barImage;
  72264. private _barBackgroundImage;
  72265. private _barSize;
  72266. private _endLeft;
  72267. private _endTop;
  72268. private _window;
  72269. private _pointerIsOver;
  72270. private _wheelPrecision;
  72271. private _onPointerObserver;
  72272. private _clientWidth;
  72273. private _clientHeight;
  72274. private _useImageBar;
  72275. private _thumbLength;
  72276. private _thumbHeight;
  72277. private _barImageHeight;
  72278. /**
  72279. * Gets the horizontal scrollbar
  72280. */
  72281. get horizontalBar(): ScrollBar | ImageScrollBar;
  72282. /**
  72283. * Gets the vertical scrollbar
  72284. */
  72285. get verticalBar(): ScrollBar | ImageScrollBar;
  72286. /**
  72287. * Adds a new control to the current container
  72288. * @param control defines the control to add
  72289. * @returns the current container
  72290. */
  72291. addControl(control: BABYLON.Nullable<Control>): Container;
  72292. /**
  72293. * Removes a control from the current container
  72294. * @param control defines the control to remove
  72295. * @returns the current container
  72296. */
  72297. removeControl(control: Control): Container;
  72298. /** Gets the list of children */
  72299. get children(): Control[];
  72300. _flagDescendantsAsMatrixDirty(): void;
  72301. /**
  72302. * Creates a new ScrollViewer
  72303. * @param name of ScrollViewer
  72304. */
  72305. constructor(name?: string, isImageBased?: boolean);
  72306. /** Reset the scroll viewer window to initial size */
  72307. resetWindow(): void;
  72308. protected _getTypeName(): string;
  72309. private _buildClientSizes;
  72310. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72311. protected _postMeasure(): void;
  72312. /**
  72313. * Gets or sets the mouse wheel precision
  72314. * from 0 to 1 with a default value of 0.05
  72315. * */
  72316. get wheelPrecision(): number;
  72317. set wheelPrecision(value: number);
  72318. /** Gets or sets the scroll bar container background color */
  72319. get scrollBackground(): string;
  72320. set scrollBackground(color: string);
  72321. /** Gets or sets the bar color */
  72322. get barColor(): string;
  72323. set barColor(color: string);
  72324. /** Gets or sets the bar image */
  72325. get thumbImage(): Image;
  72326. set thumbImage(value: Image);
  72327. /** Gets or sets the size of the bar */
  72328. get barSize(): number;
  72329. set barSize(value: number);
  72330. /** Gets or sets the length of the thumb */
  72331. get thumbLength(): number;
  72332. set thumbLength(value: number);
  72333. /** Gets or sets the height of the thumb */
  72334. get thumbHeight(): number;
  72335. set thumbHeight(value: number);
  72336. /** Gets or sets the height of the bar image */
  72337. get barImageHeight(): number;
  72338. set barImageHeight(value: number);
  72339. /** Gets or sets the bar background */
  72340. get barBackground(): string;
  72341. set barBackground(color: string);
  72342. /** Gets or sets the bar background image */
  72343. get barImage(): Image;
  72344. set barImage(value: Image);
  72345. /** @hidden */
  72346. private _updateScroller;
  72347. _link(host: AdvancedDynamicTexture): void;
  72348. /** @hidden */
  72349. private _addBar;
  72350. /** @hidden */
  72351. private _attachWheel;
  72352. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72353. /** Releases associated resources */
  72354. dispose(): void;
  72355. }
  72356. }
  72357. declare module BABYLON.GUI {
  72358. /** Class used to render a grid */
  72359. export class DisplayGrid extends Control {
  72360. name?: string | undefined;
  72361. private _cellWidth;
  72362. private _cellHeight;
  72363. private _minorLineTickness;
  72364. private _minorLineColor;
  72365. private _majorLineTickness;
  72366. private _majorLineColor;
  72367. private _majorLineFrequency;
  72368. private _background;
  72369. private _displayMajorLines;
  72370. private _displayMinorLines;
  72371. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  72372. get displayMinorLines(): boolean;
  72373. set displayMinorLines(value: boolean);
  72374. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  72375. get displayMajorLines(): boolean;
  72376. set displayMajorLines(value: boolean);
  72377. /** Gets or sets background color (Black by default) */
  72378. get background(): string;
  72379. set background(value: string);
  72380. /** Gets or sets the width of each cell (20 by default) */
  72381. get cellWidth(): number;
  72382. set cellWidth(value: number);
  72383. /** Gets or sets the height of each cell (20 by default) */
  72384. get cellHeight(): number;
  72385. set cellHeight(value: number);
  72386. /** Gets or sets the tickness of minor lines (1 by default) */
  72387. get minorLineTickness(): number;
  72388. set minorLineTickness(value: number);
  72389. /** Gets or sets the color of minor lines (DarkGray by default) */
  72390. get minorLineColor(): string;
  72391. set minorLineColor(value: string);
  72392. /** Gets or sets the tickness of major lines (2 by default) */
  72393. get majorLineTickness(): number;
  72394. set majorLineTickness(value: number);
  72395. /** Gets or sets the color of major lines (White by default) */
  72396. get majorLineColor(): string;
  72397. set majorLineColor(value: string);
  72398. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  72399. get majorLineFrequency(): number;
  72400. set majorLineFrequency(value: number);
  72401. /**
  72402. * Creates a new GridDisplayRectangle
  72403. * @param name defines the control name
  72404. */
  72405. constructor(name?: string | undefined);
  72406. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72407. protected _getTypeName(): string;
  72408. }
  72409. }
  72410. declare module BABYLON.GUI {
  72411. /**
  72412. * Class used to create slider controls based on images
  72413. */
  72414. export class ImageBasedSlider extends BaseSlider {
  72415. name?: string | undefined;
  72416. private _backgroundImage;
  72417. private _thumbImage;
  72418. private _valueBarImage;
  72419. private _tempMeasure;
  72420. get displayThumb(): boolean;
  72421. set displayThumb(value: boolean);
  72422. /**
  72423. * Gets or sets the image used to render the background
  72424. */
  72425. get backgroundImage(): Image;
  72426. set backgroundImage(value: Image);
  72427. /**
  72428. * Gets or sets the image used to render the value bar
  72429. */
  72430. get valueBarImage(): Image;
  72431. set valueBarImage(value: Image);
  72432. /**
  72433. * Gets or sets the image used to render the thumb
  72434. */
  72435. get thumbImage(): Image;
  72436. set thumbImage(value: Image);
  72437. /**
  72438. * Creates a new ImageBasedSlider
  72439. * @param name defines the control name
  72440. */
  72441. constructor(name?: string | undefined);
  72442. protected _getTypeName(): string;
  72443. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72444. }
  72445. }
  72446. declare module BABYLON.GUI {
  72447. /**
  72448. * Forcing an export so that this code will execute
  72449. * @hidden
  72450. */
  72451. const name = "Statics";
  72452. }
  72453. declare module BABYLON.GUI {
  72454. /**
  72455. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  72456. */
  72457. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  72458. /**
  72459. * Define the instrumented AdvancedDynamicTexture.
  72460. */
  72461. texture: AdvancedDynamicTexture;
  72462. private _captureRenderTime;
  72463. private _renderTime;
  72464. private _captureLayoutTime;
  72465. private _layoutTime;
  72466. private _onBeginRenderObserver;
  72467. private _onEndRenderObserver;
  72468. private _onBeginLayoutObserver;
  72469. private _onEndLayoutObserver;
  72470. /**
  72471. * Gets the perf counter used to capture render time
  72472. */
  72473. get renderTimeCounter(): BABYLON.PerfCounter;
  72474. /**
  72475. * Gets the perf counter used to capture layout time
  72476. */
  72477. get layoutTimeCounter(): BABYLON.PerfCounter;
  72478. /**
  72479. * Enable or disable the render time capture
  72480. */
  72481. get captureRenderTime(): boolean;
  72482. set captureRenderTime(value: boolean);
  72483. /**
  72484. * Enable or disable the layout time capture
  72485. */
  72486. get captureLayoutTime(): boolean;
  72487. set captureLayoutTime(value: boolean);
  72488. /**
  72489. * Instantiates a new advanced dynamic texture instrumentation.
  72490. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  72491. * @param texture Defines the AdvancedDynamicTexture to instrument
  72492. */
  72493. constructor(
  72494. /**
  72495. * Define the instrumented AdvancedDynamicTexture.
  72496. */
  72497. texture: AdvancedDynamicTexture);
  72498. /**
  72499. * Dispose and release associated resources.
  72500. */
  72501. dispose(): void;
  72502. }
  72503. }
  72504. declare module BABYLON.GUI {
  72505. /**
  72506. * Class used to load GUI via XML.
  72507. */
  72508. export class XmlLoader {
  72509. private _nodes;
  72510. private _nodeTypes;
  72511. private _isLoaded;
  72512. private _objectAttributes;
  72513. private _parentClass;
  72514. /**
  72515. * Create a new xml loader
  72516. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  72517. */
  72518. constructor(parentClass?: null);
  72519. private _getChainElement;
  72520. private _getClassAttribute;
  72521. private _createGuiElement;
  72522. private _parseGrid;
  72523. private _parseElement;
  72524. private _prepareSourceElement;
  72525. private _parseElementsFromSource;
  72526. private _parseXml;
  72527. /**
  72528. * Gets if the loading has finished.
  72529. * @returns whether the loading has finished or not
  72530. */
  72531. isLoaded(): boolean;
  72532. /**
  72533. * Gets a loaded node / control by id.
  72534. * @param id the Controls id set in the xml
  72535. * @returns element of type Control
  72536. */
  72537. getNodeById(id: string): any;
  72538. /**
  72539. * Gets all loaded nodes / controls
  72540. * @returns Array of controls
  72541. */
  72542. getNodes(): any;
  72543. /**
  72544. * Initiates the xml layout loading
  72545. * @param xmlFile defines the xml layout to load
  72546. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  72547. * @param callback defines the callback called on layout load.
  72548. */
  72549. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  72550. }
  72551. }
  72552. declare module BABYLON.GUI {
  72553. /**
  72554. * Class used to create containers for controls
  72555. */
  72556. export class Container3D extends Control3D {
  72557. private _blockLayout;
  72558. /**
  72559. * Gets the list of child controls
  72560. */
  72561. protected _children: Control3D[];
  72562. /**
  72563. * Gets the list of child controls
  72564. */
  72565. get children(): Array<Control3D>;
  72566. /**
  72567. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  72568. * This is helpful to optimize layout operation when adding multiple children in a row
  72569. */
  72570. get blockLayout(): boolean;
  72571. set blockLayout(value: boolean);
  72572. /**
  72573. * Creates a new container
  72574. * @param name defines the container name
  72575. */
  72576. constructor(name?: string);
  72577. /**
  72578. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  72579. * @returns the current container
  72580. */
  72581. updateLayout(): Container3D;
  72582. /**
  72583. * Gets a boolean indicating if the given control is in the children of this control
  72584. * @param control defines the control to check
  72585. * @returns true if the control is in the child list
  72586. */
  72587. containsControl(control: Control3D): boolean;
  72588. /**
  72589. * Adds a control to the children of this control
  72590. * @param control defines the control to add
  72591. * @returns the current container
  72592. */
  72593. addControl(control: Control3D): Container3D;
  72594. /**
  72595. * This function will be called everytime a new control is added
  72596. */
  72597. protected _arrangeChildren(): void;
  72598. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72599. /**
  72600. * Removes a control from the children of this control
  72601. * @param control defines the control to remove
  72602. * @returns the current container
  72603. */
  72604. removeControl(control: Control3D): Container3D;
  72605. protected _getTypeName(): string;
  72606. /**
  72607. * Releases all associated resources
  72608. */
  72609. dispose(): void;
  72610. /** Control rotation will remain unchanged */
  72611. static readonly UNSET_ORIENTATION: number;
  72612. /** Control will rotate to make it look at sphere central axis */
  72613. static readonly FACEORIGIN_ORIENTATION: number;
  72614. /** Control will rotate to make it look back at sphere central axis */
  72615. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  72616. /** Control will rotate to look at z axis (0, 0, 1) */
  72617. static readonly FACEFORWARD_ORIENTATION: number;
  72618. /** Control will rotate to look at negative z axis (0, 0, -1) */
  72619. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  72620. }
  72621. }
  72622. declare module BABYLON.GUI {
  72623. /**
  72624. * Class used to manage 3D user interface
  72625. * @see http://doc.babylonjs.com/how_to/gui3d
  72626. */
  72627. export class GUI3DManager implements BABYLON.IDisposable {
  72628. private _scene;
  72629. private _sceneDisposeObserver;
  72630. private _utilityLayer;
  72631. private _rootContainer;
  72632. private _pointerObserver;
  72633. private _pointerOutObserver;
  72634. /** @hidden */
  72635. _lastPickedControl: Control3D;
  72636. /** @hidden */
  72637. _lastControlOver: {
  72638. [pointerId: number]: Control3D;
  72639. };
  72640. /** @hidden */
  72641. _lastControlDown: {
  72642. [pointerId: number]: Control3D;
  72643. };
  72644. /**
  72645. * BABYLON.Observable raised when the point picked by the pointer events changed
  72646. */
  72647. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  72648. /** @hidden */
  72649. _sharedMaterials: {
  72650. [key: string]: BABYLON.Material;
  72651. };
  72652. /** Gets the hosting scene */
  72653. get scene(): BABYLON.Scene;
  72654. /** Gets associated utility layer */
  72655. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  72656. /**
  72657. * Creates a new GUI3DManager
  72658. * @param scene
  72659. */
  72660. constructor(scene?: BABYLON.Scene);
  72661. private _handlePointerOut;
  72662. private _doPicking;
  72663. /**
  72664. * Gets the root container
  72665. */
  72666. get rootContainer(): Container3D;
  72667. /**
  72668. * Gets a boolean indicating if the given control is in the root child list
  72669. * @param control defines the control to check
  72670. * @returns true if the control is in the root child list
  72671. */
  72672. containsControl(control: Control3D): boolean;
  72673. /**
  72674. * Adds a control to the root child list
  72675. * @param control defines the control to add
  72676. * @returns the current manager
  72677. */
  72678. addControl(control: Control3D): GUI3DManager;
  72679. /**
  72680. * Removes a control from the root child list
  72681. * @param control defines the control to remove
  72682. * @returns the current container
  72683. */
  72684. removeControl(control: Control3D): GUI3DManager;
  72685. /**
  72686. * Releases all associated resources
  72687. */
  72688. dispose(): void;
  72689. }
  72690. }
  72691. declare module BABYLON.GUI {
  72692. /**
  72693. * Class used to transport BABYLON.Vector3 information for pointer events
  72694. */
  72695. export class Vector3WithInfo extends BABYLON.Vector3 {
  72696. /** defines the current mouse button index */
  72697. buttonIndex: number;
  72698. /**
  72699. * Creates a new Vector3WithInfo
  72700. * @param source defines the vector3 data to transport
  72701. * @param buttonIndex defines the current mouse button index
  72702. */
  72703. constructor(source: BABYLON.Vector3,
  72704. /** defines the current mouse button index */
  72705. buttonIndex?: number);
  72706. }
  72707. }
  72708. declare module BABYLON.GUI {
  72709. /**
  72710. * Class used as base class for controls
  72711. */
  72712. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  72713. /** Defines the control name */
  72714. name?: string | undefined;
  72715. /** @hidden */
  72716. _host: GUI3DManager;
  72717. private _node;
  72718. private _downCount;
  72719. private _enterCount;
  72720. private _downPointerIds;
  72721. private _isVisible;
  72722. /** Gets or sets the control position in world space */
  72723. get position(): BABYLON.Vector3;
  72724. set position(value: BABYLON.Vector3);
  72725. /** Gets or sets the control scaling in world space */
  72726. get scaling(): BABYLON.Vector3;
  72727. set scaling(value: BABYLON.Vector3);
  72728. /** Callback used to start pointer enter animation */
  72729. pointerEnterAnimation: () => void;
  72730. /** Callback used to start pointer out animation */
  72731. pointerOutAnimation: () => void;
  72732. /** Callback used to start pointer down animation */
  72733. pointerDownAnimation: () => void;
  72734. /** Callback used to start pointer up animation */
  72735. pointerUpAnimation: () => void;
  72736. /**
  72737. * An event triggered when the pointer move over the control
  72738. */
  72739. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  72740. /**
  72741. * An event triggered when the pointer move out of the control
  72742. */
  72743. onPointerOutObservable: BABYLON.Observable<Control3D>;
  72744. /**
  72745. * An event triggered when the pointer taps the control
  72746. */
  72747. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  72748. /**
  72749. * An event triggered when pointer is up
  72750. */
  72751. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  72752. /**
  72753. * An event triggered when a control is clicked on (with a mouse)
  72754. */
  72755. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  72756. /**
  72757. * An event triggered when pointer enters the control
  72758. */
  72759. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  72760. /**
  72761. * Gets or sets the parent container
  72762. */
  72763. parent: BABYLON.Nullable<Container3D>;
  72764. private _behaviors;
  72765. /**
  72766. * Gets the list of attached behaviors
  72767. * @see http://doc.babylonjs.com/features/behaviour
  72768. */
  72769. get behaviors(): BABYLON.Behavior<Control3D>[];
  72770. /**
  72771. * Attach a behavior to the control
  72772. * @see http://doc.babylonjs.com/features/behaviour
  72773. * @param behavior defines the behavior to attach
  72774. * @returns the current control
  72775. */
  72776. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72777. /**
  72778. * Remove an attached behavior
  72779. * @see http://doc.babylonjs.com/features/behaviour
  72780. * @param behavior defines the behavior to attach
  72781. * @returns the current control
  72782. */
  72783. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72784. /**
  72785. * Gets an attached behavior by name
  72786. * @param name defines the name of the behavior to look for
  72787. * @see http://doc.babylonjs.com/features/behaviour
  72788. * @returns null if behavior was not found else the requested behavior
  72789. */
  72790. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  72791. /** Gets or sets a boolean indicating if the control is visible */
  72792. get isVisible(): boolean;
  72793. set isVisible(value: boolean);
  72794. /**
  72795. * Creates a new control
  72796. * @param name defines the control name
  72797. */
  72798. constructor(
  72799. /** Defines the control name */
  72800. name?: string | undefined);
  72801. /**
  72802. * Gets a string representing the class name
  72803. */
  72804. get typeName(): string;
  72805. /**
  72806. * Get the current class name of the control.
  72807. * @returns current class name
  72808. */
  72809. getClassName(): string;
  72810. protected _getTypeName(): string;
  72811. /**
  72812. * Gets the transform node used by this control
  72813. */
  72814. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  72815. /**
  72816. * Gets the mesh used to render this control
  72817. */
  72818. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72819. /**
  72820. * Link the control as child of the given node
  72821. * @param node defines the node to link to. Use null to unlink the control
  72822. * @returns the current control
  72823. */
  72824. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  72825. /** @hidden **/
  72826. _prepareNode(scene: BABYLON.Scene): void;
  72827. /**
  72828. * Node creation.
  72829. * Can be overriden by children
  72830. * @param scene defines the scene where the node must be attached
  72831. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  72832. */
  72833. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72834. /**
  72835. * Affect a material to the given mesh
  72836. * @param mesh defines the mesh which will represent the control
  72837. */
  72838. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  72839. /** @hidden */
  72840. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  72841. /** @hidden */
  72842. _onPointerEnter(target: Control3D): boolean;
  72843. /** @hidden */
  72844. _onPointerOut(target: Control3D): void;
  72845. /** @hidden */
  72846. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  72847. /** @hidden */
  72848. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72849. /** @hidden */
  72850. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72851. /** @hidden */
  72852. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  72853. /** @hidden */
  72854. _disposeNode(): void;
  72855. /**
  72856. * Releases all associated resources
  72857. */
  72858. dispose(): void;
  72859. }
  72860. }
  72861. declare module BABYLON.GUI {
  72862. /**
  72863. * Class used as a root to all buttons
  72864. */
  72865. export class AbstractButton3D extends Control3D {
  72866. /**
  72867. * Creates a new button
  72868. * @param name defines the control name
  72869. */
  72870. constructor(name?: string);
  72871. protected _getTypeName(): string;
  72872. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  72873. }
  72874. }
  72875. declare module BABYLON.GUI {
  72876. /**
  72877. * Class used to create a button in 3D
  72878. */
  72879. export class Button3D extends AbstractButton3D {
  72880. /** @hidden */
  72881. protected _currentMaterial: BABYLON.Material;
  72882. private _facadeTexture;
  72883. private _content;
  72884. private _contentResolution;
  72885. private _contentScaleRatio;
  72886. /**
  72887. * Gets or sets the texture resolution used to render content (512 by default)
  72888. */
  72889. get contentResolution(): BABYLON.int;
  72890. set contentResolution(value: BABYLON.int);
  72891. /**
  72892. * Gets or sets the texture scale ratio used to render content (2 by default)
  72893. */
  72894. get contentScaleRatio(): number;
  72895. set contentScaleRatio(value: number);
  72896. protected _disposeFacadeTexture(): void;
  72897. protected _resetContent(): void;
  72898. /**
  72899. * Creates a new button
  72900. * @param name defines the control name
  72901. */
  72902. constructor(name?: string);
  72903. /**
  72904. * Gets or sets the GUI 2D content used to display the button's facade
  72905. */
  72906. get content(): Control;
  72907. set content(value: Control);
  72908. /**
  72909. * Apply the facade texture (created from the content property).
  72910. * This function can be overloaded by child classes
  72911. * @param facadeTexture defines the AdvancedDynamicTexture to use
  72912. */
  72913. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  72914. protected _getTypeName(): string;
  72915. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  72916. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  72917. /**
  72918. * Releases all associated resources
  72919. */
  72920. dispose(): void;
  72921. }
  72922. }
  72923. declare module BABYLON.GUI {
  72924. /**
  72925. * Abstract class used to create a container panel deployed on the surface of a volume
  72926. */
  72927. export abstract class VolumeBasedPanel extends Container3D {
  72928. private _columns;
  72929. private _rows;
  72930. private _rowThenColum;
  72931. private _orientation;
  72932. protected _cellWidth: number;
  72933. protected _cellHeight: number;
  72934. /**
  72935. * Gets or sets the distance between elements
  72936. */
  72937. margin: number;
  72938. /**
  72939. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  72940. * | Value | Type | Description |
  72941. * | ----- | ----------------------------------- | ----------- |
  72942. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  72943. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  72944. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  72945. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  72946. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  72947. */
  72948. get orientation(): number;
  72949. set orientation(value: number);
  72950. /**
  72951. * Gets or sets the number of columns requested (10 by default).
  72952. * The panel will automatically compute the number of rows based on number of child controls.
  72953. */
  72954. get columns(): BABYLON.int;
  72955. set columns(value: BABYLON.int);
  72956. /**
  72957. * Gets or sets a the number of rows requested.
  72958. * The panel will automatically compute the number of columns based on number of child controls.
  72959. */
  72960. get rows(): BABYLON.int;
  72961. set rows(value: BABYLON.int);
  72962. /**
  72963. * Creates new VolumeBasedPanel
  72964. */
  72965. constructor();
  72966. protected _arrangeChildren(): void;
  72967. /** Child classes must implement this function to provide correct control positioning */
  72968. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72969. /** Child classes can implement this function to provide additional processing */
  72970. protected _finalProcessing(): void;
  72971. }
  72972. }
  72973. declare module BABYLON.GUI {
  72974. /**
  72975. * Class used to create a container panel deployed on the surface of a cylinder
  72976. */
  72977. export class CylinderPanel extends VolumeBasedPanel {
  72978. private _radius;
  72979. /**
  72980. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  72981. */
  72982. get radius(): BABYLON.float;
  72983. set radius(value: BABYLON.float);
  72984. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72985. private _cylindricalMapping;
  72986. }
  72987. }
  72988. declare module BABYLON.GUI {
  72989. /** @hidden */
  72990. export var fluentVertexShader: {
  72991. name: string;
  72992. shader: string;
  72993. };
  72994. }
  72995. declare module BABYLON.GUI {
  72996. /** @hidden */
  72997. export var fluentPixelShader: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module BABYLON.GUI {
  73003. /** @hidden */
  73004. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73005. INNERGLOW: boolean;
  73006. BORDER: boolean;
  73007. HOVERLIGHT: boolean;
  73008. TEXTURE: boolean;
  73009. constructor();
  73010. }
  73011. /**
  73012. * Class used to render controls with fluent desgin
  73013. */
  73014. export class FluentMaterial extends BABYLON.PushMaterial {
  73015. /**
  73016. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73017. */
  73018. innerGlowColorIntensity: number;
  73019. /**
  73020. * Gets or sets the inner glow color (white by default)
  73021. */
  73022. innerGlowColor: BABYLON.Color3;
  73023. /**
  73024. * Gets or sets alpha value (default is 1.0)
  73025. */
  73026. alpha: number;
  73027. /**
  73028. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73029. */
  73030. albedoColor: BABYLON.Color3;
  73031. /**
  73032. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73033. */
  73034. renderBorders: boolean;
  73035. /**
  73036. * Gets or sets border width (default is 0.5)
  73037. */
  73038. borderWidth: number;
  73039. /**
  73040. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73041. */
  73042. edgeSmoothingValue: number;
  73043. /**
  73044. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73045. */
  73046. borderMinValue: number;
  73047. /**
  73048. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73049. */
  73050. renderHoverLight: boolean;
  73051. /**
  73052. * Gets or sets the radius used to render the hover light (default is 1.0)
  73053. */
  73054. hoverRadius: number;
  73055. /**
  73056. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73057. */
  73058. hoverColor: BABYLON.Color4;
  73059. /**
  73060. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73061. */
  73062. hoverPosition: BABYLON.Vector3;
  73063. private _albedoTexture;
  73064. /** Gets or sets the texture to use for albedo color */
  73065. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73066. /**
  73067. * Creates a new Fluent material
  73068. * @param name defines the name of the material
  73069. * @param scene defines the hosting scene
  73070. */
  73071. constructor(name: string, scene: BABYLON.Scene);
  73072. needAlphaBlending(): boolean;
  73073. needAlphaTesting(): boolean;
  73074. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73075. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73076. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73077. getActiveTextures(): BABYLON.BaseTexture[];
  73078. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73079. dispose(forceDisposeEffect?: boolean): void;
  73080. clone(name: string): FluentMaterial;
  73081. serialize(): any;
  73082. getClassName(): string;
  73083. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73084. }
  73085. }
  73086. declare module BABYLON.GUI {
  73087. /**
  73088. * Class used to create a holographic button in 3D
  73089. */
  73090. export class HolographicButton extends Button3D {
  73091. private _backPlate;
  73092. private _textPlate;
  73093. private _frontPlate;
  73094. private _text;
  73095. private _imageUrl;
  73096. private _shareMaterials;
  73097. private _frontMaterial;
  73098. private _backMaterial;
  73099. private _plateMaterial;
  73100. private _pickedPointObserver;
  73101. private _tooltipFade;
  73102. private _tooltipTextBlock;
  73103. private _tooltipTexture;
  73104. private _tooltipMesh;
  73105. private _tooltipHoverObserver;
  73106. private _tooltipOutObserver;
  73107. private _disposeTooltip;
  73108. /**
  73109. * Rendering ground id of all the mesh in the button
  73110. */
  73111. set renderingGroupId(id: number);
  73112. get renderingGroupId(): number;
  73113. /**
  73114. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73115. */
  73116. set tooltipText(text: BABYLON.Nullable<string>);
  73117. get tooltipText(): BABYLON.Nullable<string>;
  73118. /**
  73119. * Gets or sets text for the button
  73120. */
  73121. get text(): string;
  73122. set text(value: string);
  73123. /**
  73124. * Gets or sets the image url for the button
  73125. */
  73126. get imageUrl(): string;
  73127. set imageUrl(value: string);
  73128. /**
  73129. * Gets the back material used by this button
  73130. */
  73131. get backMaterial(): FluentMaterial;
  73132. /**
  73133. * Gets the front material used by this button
  73134. */
  73135. get frontMaterial(): FluentMaterial;
  73136. /**
  73137. * Gets the plate material used by this button
  73138. */
  73139. get plateMaterial(): BABYLON.StandardMaterial;
  73140. /**
  73141. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73142. */
  73143. get shareMaterials(): boolean;
  73144. /**
  73145. * Creates a new button
  73146. * @param name defines the control name
  73147. */
  73148. constructor(name?: string, shareMaterials?: boolean);
  73149. protected _getTypeName(): string;
  73150. private _rebuildContent;
  73151. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73152. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73153. private _createBackMaterial;
  73154. private _createFrontMaterial;
  73155. private _createPlateMaterial;
  73156. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73157. /**
  73158. * Releases all associated resources
  73159. */
  73160. dispose(): void;
  73161. }
  73162. }
  73163. declare module BABYLON.GUI {
  73164. /**
  73165. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73166. */
  73167. export class MeshButton3D extends Button3D {
  73168. /** @hidden */
  73169. protected _currentMesh: BABYLON.Mesh;
  73170. /**
  73171. * Creates a new 3D button based on a mesh
  73172. * @param mesh mesh to become a 3D button
  73173. * @param name defines the control name
  73174. */
  73175. constructor(mesh: BABYLON.Mesh, name?: string);
  73176. protected _getTypeName(): string;
  73177. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73178. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73179. }
  73180. }
  73181. declare module BABYLON.GUI {
  73182. /**
  73183. * Class used to create a container panel deployed on the surface of a plane
  73184. */
  73185. export class PlanePanel extends VolumeBasedPanel {
  73186. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73187. }
  73188. }
  73189. declare module BABYLON.GUI {
  73190. /**
  73191. * Class used to create a container panel where items get randomized planar mapping
  73192. */
  73193. export class ScatterPanel extends VolumeBasedPanel {
  73194. private _iteration;
  73195. /**
  73196. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73197. */
  73198. get iteration(): BABYLON.float;
  73199. set iteration(value: BABYLON.float);
  73200. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73201. private _scatterMapping;
  73202. protected _finalProcessing(): void;
  73203. }
  73204. }
  73205. declare module BABYLON.GUI {
  73206. /**
  73207. * Class used to create a container panel deployed on the surface of a sphere
  73208. */
  73209. export class SpherePanel extends VolumeBasedPanel {
  73210. private _radius;
  73211. /**
  73212. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73213. */
  73214. get radius(): BABYLON.float;
  73215. set radius(value: BABYLON.float);
  73216. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73217. private _sphericalMapping;
  73218. }
  73219. }
  73220. declare module BABYLON.GUI {
  73221. /**
  73222. * Class used to create a stack panel in 3D on XY plane
  73223. */
  73224. export class StackPanel3D extends Container3D {
  73225. private _isVertical;
  73226. /**
  73227. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  73228. */
  73229. get isVertical(): boolean;
  73230. set isVertical(value: boolean);
  73231. /**
  73232. * Gets or sets the distance between elements
  73233. */
  73234. margin: number;
  73235. /**
  73236. * Creates new StackPanel
  73237. * @param isVertical
  73238. */
  73239. constructor(isVertical?: boolean);
  73240. protected _arrangeChildren(): void;
  73241. }
  73242. }
  73243. declare module BABYLON {
  73244. /**
  73245. * Configuration for glTF validation
  73246. */
  73247. export interface IGLTFValidationConfiguration {
  73248. /**
  73249. * The url of the glTF validator.
  73250. */
  73251. url: string;
  73252. }
  73253. /**
  73254. * glTF validation
  73255. */
  73256. export class GLTFValidation {
  73257. /**
  73258. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  73259. */
  73260. static Configuration: IGLTFValidationConfiguration;
  73261. private static _LoadScriptPromise;
  73262. /**
  73263. * Validate a glTF asset using the glTF-Validator.
  73264. * @param data The JSON of a glTF or the array buffer of a binary glTF
  73265. * @param rootUrl The root url for the glTF
  73266. * @param fileName The file name for the glTF
  73267. * @param getExternalResource The callback to get external resources for the glTF validator
  73268. * @returns A promise that resolves with the glTF validation results once complete
  73269. */
  73270. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  73271. }
  73272. }
  73273. declare module BABYLON {
  73274. /**
  73275. * Mode that determines the coordinate system to use.
  73276. */
  73277. export enum GLTFLoaderCoordinateSystemMode {
  73278. /**
  73279. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  73280. */
  73281. AUTO = 0,
  73282. /**
  73283. * Sets the useRightHandedSystem flag on the scene.
  73284. */
  73285. FORCE_RIGHT_HANDED = 1
  73286. }
  73287. /**
  73288. * Mode that determines what animations will start.
  73289. */
  73290. export enum GLTFLoaderAnimationStartMode {
  73291. /**
  73292. * No animation will start.
  73293. */
  73294. NONE = 0,
  73295. /**
  73296. * The first animation will start.
  73297. */
  73298. FIRST = 1,
  73299. /**
  73300. * All animations will start.
  73301. */
  73302. ALL = 2
  73303. }
  73304. /**
  73305. * Interface that contains the data for the glTF asset.
  73306. */
  73307. export interface IGLTFLoaderData {
  73308. /**
  73309. * The object that represents the glTF JSON.
  73310. */
  73311. json: Object;
  73312. /**
  73313. * The BIN chunk of a binary glTF.
  73314. */
  73315. bin: Nullable<IDataBuffer>;
  73316. }
  73317. /**
  73318. * Interface for extending the loader.
  73319. */
  73320. export interface IGLTFLoaderExtension {
  73321. /**
  73322. * The name of this extension.
  73323. */
  73324. readonly name: string;
  73325. /**
  73326. * Defines whether this extension is enabled.
  73327. */
  73328. enabled: boolean;
  73329. /**
  73330. * Defines the order of this extension.
  73331. * The loader sorts the extensions using these values when loading.
  73332. */
  73333. order?: number;
  73334. }
  73335. /**
  73336. * Loader state.
  73337. */
  73338. export enum GLTFLoaderState {
  73339. /**
  73340. * The asset is loading.
  73341. */
  73342. LOADING = 0,
  73343. /**
  73344. * The asset is ready for rendering.
  73345. */
  73346. READY = 1,
  73347. /**
  73348. * The asset is completely loaded.
  73349. */
  73350. COMPLETE = 2
  73351. }
  73352. /** @hidden */
  73353. export interface IGLTFLoader extends IDisposable {
  73354. readonly state: Nullable<GLTFLoaderState>;
  73355. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  73356. meshes: AbstractMesh[];
  73357. particleSystems: IParticleSystem[];
  73358. skeletons: Skeleton[];
  73359. animationGroups: AnimationGroup[];
  73360. }>;
  73361. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  73362. }
  73363. /**
  73364. * File loader for loading glTF files into a scene.
  73365. */
  73366. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73367. /** @hidden */
  73368. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73369. /** @hidden */
  73370. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73371. /**
  73372. * Raised when the asset has been parsed
  73373. */
  73374. onParsedObservable: Observable<IGLTFLoaderData>;
  73375. private _onParsedObserver;
  73376. /**
  73377. * Raised when the asset has been parsed
  73378. */
  73379. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  73380. /**
  73381. * 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.
  73382. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  73383. * Defaults to true.
  73384. * @hidden
  73385. */
  73386. static IncrementalLoading: boolean;
  73387. /**
  73388. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  73389. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  73390. * @hidden
  73391. */
  73392. static HomogeneousCoordinates: boolean;
  73393. /**
  73394. * The coordinate system mode. Defaults to AUTO.
  73395. */
  73396. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  73397. /**
  73398. * The animation start mode. Defaults to FIRST.
  73399. */
  73400. animationStartMode: GLTFLoaderAnimationStartMode;
  73401. /**
  73402. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  73403. */
  73404. compileMaterials: boolean;
  73405. /**
  73406. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  73407. */
  73408. useClipPlane: boolean;
  73409. /**
  73410. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  73411. */
  73412. compileShadowGenerators: boolean;
  73413. /**
  73414. * Defines if the Alpha blended materials are only applied as coverage.
  73415. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  73416. * If true, no extra effects are applied to transparent pixels.
  73417. */
  73418. transparencyAsCoverage: boolean;
  73419. /**
  73420. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  73421. * Enabling will disable offline support and glTF validator.
  73422. * Defaults to false.
  73423. */
  73424. useRangeRequests: boolean;
  73425. /**
  73426. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  73427. */
  73428. createInstances: boolean;
  73429. /**
  73430. * Function called before loading a url referenced by the asset.
  73431. */
  73432. preprocessUrlAsync: (url: string) => Promise<string>;
  73433. /**
  73434. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73435. */
  73436. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  73437. private _onMeshLoadedObserver;
  73438. /**
  73439. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73440. */
  73441. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  73442. /**
  73443. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  73444. */
  73445. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  73446. private _onTextureLoadedObserver;
  73447. /**
  73448. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  73449. */
  73450. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  73451. /**
  73452. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  73453. */
  73454. readonly onMaterialLoadedObservable: Observable<Material>;
  73455. private _onMaterialLoadedObserver;
  73456. /**
  73457. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  73458. */
  73459. set onMaterialLoaded(callback: (material: Material) => void);
  73460. /**
  73461. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  73462. */
  73463. readonly onCameraLoadedObservable: Observable<Camera>;
  73464. private _onCameraLoadedObserver;
  73465. /**
  73466. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  73467. */
  73468. set onCameraLoaded(callback: (camera: Camera) => void);
  73469. /**
  73470. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  73471. * For assets with LODs, raised when all of the LODs are complete.
  73472. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73473. */
  73474. readonly onCompleteObservable: Observable<void>;
  73475. private _onCompleteObserver;
  73476. /**
  73477. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  73478. * For assets with LODs, raised when all of the LODs are complete.
  73479. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73480. */
  73481. set onComplete(callback: () => void);
  73482. /**
  73483. * Observable raised when an error occurs.
  73484. */
  73485. readonly onErrorObservable: Observable<any>;
  73486. private _onErrorObserver;
  73487. /**
  73488. * Callback raised when an error occurs.
  73489. */
  73490. set onError(callback: (reason: any) => void);
  73491. /**
  73492. * Observable raised after the loader is disposed.
  73493. */
  73494. readonly onDisposeObservable: Observable<void>;
  73495. private _onDisposeObserver;
  73496. /**
  73497. * Callback raised after the loader is disposed.
  73498. */
  73499. set onDispose(callback: () => void);
  73500. /**
  73501. * Observable raised after a loader extension is created.
  73502. * Set additional options for a loader extension in this event.
  73503. */
  73504. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  73505. private _onExtensionLoadedObserver;
  73506. /**
  73507. * Callback raised after a loader extension is created.
  73508. */
  73509. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  73510. /**
  73511. * Defines if the loader logging is enabled.
  73512. */
  73513. get loggingEnabled(): boolean;
  73514. set loggingEnabled(value: boolean);
  73515. /**
  73516. * Defines if the loader should capture performance counters.
  73517. */
  73518. get capturePerformanceCounters(): boolean;
  73519. set capturePerformanceCounters(value: boolean);
  73520. /**
  73521. * Defines if the loader should validate the asset.
  73522. */
  73523. validate: boolean;
  73524. /**
  73525. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  73526. */
  73527. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  73528. private _onValidatedObserver;
  73529. /**
  73530. * Callback raised after a loader extension is created.
  73531. */
  73532. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  73533. private _loader;
  73534. /**
  73535. * Name of the loader ("gltf")
  73536. */
  73537. name: string;
  73538. /** @hidden */
  73539. extensions: ISceneLoaderPluginExtensions;
  73540. /**
  73541. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  73542. */
  73543. dispose(): void;
  73544. /** @hidden */
  73545. _clear(): void;
  73546. /** @hidden */
  73547. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73548. /** @hidden */
  73549. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73550. /** @hidden */
  73551. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73552. meshes: AbstractMesh[];
  73553. particleSystems: IParticleSystem[];
  73554. skeletons: Skeleton[];
  73555. animationGroups: AnimationGroup[];
  73556. }>;
  73557. /** @hidden */
  73558. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73559. /** @hidden */
  73560. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73561. /** @hidden */
  73562. canDirectLoad(data: string): boolean;
  73563. /** @hidden */
  73564. directLoad(scene: Scene, data: string): any;
  73565. /**
  73566. * The callback that allows custom handling of the root url based on the response url.
  73567. * @param rootUrl the original root url
  73568. * @param responseURL the response url if available
  73569. * @returns the new root url
  73570. */
  73571. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  73572. /** @hidden */
  73573. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  73574. /**
  73575. * The loader state or null if the loader is not active.
  73576. */
  73577. get loaderState(): Nullable<GLTFLoaderState>;
  73578. /**
  73579. * Returns a promise that resolves when the asset is completely loaded.
  73580. * @returns a promise that resolves when the asset is completely loaded.
  73581. */
  73582. whenCompleteAsync(): Promise<void>;
  73583. private _validate;
  73584. private _getLoader;
  73585. private _parseJson;
  73586. private _unpackBinaryAsync;
  73587. private _unpackBinaryV1Async;
  73588. private _unpackBinaryV2Async;
  73589. private static _parseVersion;
  73590. private static _compareVersion;
  73591. private static readonly _logSpaces;
  73592. private _logIndentLevel;
  73593. private _loggingEnabled;
  73594. /** @hidden */
  73595. _log: (message: string) => void;
  73596. /** @hidden */
  73597. _logOpen(message: string): void;
  73598. /** @hidden */
  73599. _logClose(): void;
  73600. private _logEnabled;
  73601. private _logDisabled;
  73602. private _capturePerformanceCounters;
  73603. /** @hidden */
  73604. _startPerformanceCounter: (counterName: string) => void;
  73605. /** @hidden */
  73606. _endPerformanceCounter: (counterName: string) => void;
  73607. private _startPerformanceCounterEnabled;
  73608. private _startPerformanceCounterDisabled;
  73609. private _endPerformanceCounterEnabled;
  73610. private _endPerformanceCounterDisabled;
  73611. }
  73612. }
  73613. declare module BABYLON.GLTF1 {
  73614. /**
  73615. * Enums
  73616. * @hidden
  73617. */
  73618. export enum EComponentType {
  73619. BYTE = 5120,
  73620. UNSIGNED_BYTE = 5121,
  73621. SHORT = 5122,
  73622. UNSIGNED_SHORT = 5123,
  73623. FLOAT = 5126
  73624. }
  73625. /** @hidden */
  73626. export enum EShaderType {
  73627. FRAGMENT = 35632,
  73628. VERTEX = 35633
  73629. }
  73630. /** @hidden */
  73631. export enum EParameterType {
  73632. BYTE = 5120,
  73633. UNSIGNED_BYTE = 5121,
  73634. SHORT = 5122,
  73635. UNSIGNED_SHORT = 5123,
  73636. INT = 5124,
  73637. UNSIGNED_INT = 5125,
  73638. FLOAT = 5126,
  73639. FLOAT_VEC2 = 35664,
  73640. FLOAT_VEC3 = 35665,
  73641. FLOAT_VEC4 = 35666,
  73642. INT_VEC2 = 35667,
  73643. INT_VEC3 = 35668,
  73644. INT_VEC4 = 35669,
  73645. BOOL = 35670,
  73646. BOOL_VEC2 = 35671,
  73647. BOOL_VEC3 = 35672,
  73648. BOOL_VEC4 = 35673,
  73649. FLOAT_MAT2 = 35674,
  73650. FLOAT_MAT3 = 35675,
  73651. FLOAT_MAT4 = 35676,
  73652. SAMPLER_2D = 35678
  73653. }
  73654. /** @hidden */
  73655. export enum ETextureWrapMode {
  73656. CLAMP_TO_EDGE = 33071,
  73657. MIRRORED_REPEAT = 33648,
  73658. REPEAT = 10497
  73659. }
  73660. /** @hidden */
  73661. export enum ETextureFilterType {
  73662. NEAREST = 9728,
  73663. LINEAR = 9728,
  73664. NEAREST_MIPMAP_NEAREST = 9984,
  73665. LINEAR_MIPMAP_NEAREST = 9985,
  73666. NEAREST_MIPMAP_LINEAR = 9986,
  73667. LINEAR_MIPMAP_LINEAR = 9987
  73668. }
  73669. /** @hidden */
  73670. export enum ETextureFormat {
  73671. ALPHA = 6406,
  73672. RGB = 6407,
  73673. RGBA = 6408,
  73674. LUMINANCE = 6409,
  73675. LUMINANCE_ALPHA = 6410
  73676. }
  73677. /** @hidden */
  73678. export enum ECullingType {
  73679. FRONT = 1028,
  73680. BACK = 1029,
  73681. FRONT_AND_BACK = 1032
  73682. }
  73683. /** @hidden */
  73684. export enum EBlendingFunction {
  73685. ZERO = 0,
  73686. ONE = 1,
  73687. SRC_COLOR = 768,
  73688. ONE_MINUS_SRC_COLOR = 769,
  73689. DST_COLOR = 774,
  73690. ONE_MINUS_DST_COLOR = 775,
  73691. SRC_ALPHA = 770,
  73692. ONE_MINUS_SRC_ALPHA = 771,
  73693. DST_ALPHA = 772,
  73694. ONE_MINUS_DST_ALPHA = 773,
  73695. CONSTANT_COLOR = 32769,
  73696. ONE_MINUS_CONSTANT_COLOR = 32770,
  73697. CONSTANT_ALPHA = 32771,
  73698. ONE_MINUS_CONSTANT_ALPHA = 32772,
  73699. SRC_ALPHA_SATURATE = 776
  73700. }
  73701. /** @hidden */
  73702. export interface IGLTFProperty {
  73703. extensions?: {
  73704. [key: string]: any;
  73705. };
  73706. extras?: Object;
  73707. }
  73708. /** @hidden */
  73709. export interface IGLTFChildRootProperty extends IGLTFProperty {
  73710. name?: string;
  73711. }
  73712. /** @hidden */
  73713. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  73714. bufferView: string;
  73715. byteOffset: number;
  73716. byteStride: number;
  73717. count: number;
  73718. type: string;
  73719. componentType: EComponentType;
  73720. max?: number[];
  73721. min?: number[];
  73722. name?: string;
  73723. }
  73724. /** @hidden */
  73725. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  73726. buffer: string;
  73727. byteOffset: number;
  73728. byteLength: number;
  73729. byteStride: number;
  73730. target?: number;
  73731. }
  73732. /** @hidden */
  73733. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  73734. uri: string;
  73735. byteLength?: number;
  73736. type?: string;
  73737. }
  73738. /** @hidden */
  73739. export interface IGLTFShader extends IGLTFChildRootProperty {
  73740. uri: string;
  73741. type: EShaderType;
  73742. }
  73743. /** @hidden */
  73744. export interface IGLTFProgram extends IGLTFChildRootProperty {
  73745. attributes: string[];
  73746. fragmentShader: string;
  73747. vertexShader: string;
  73748. }
  73749. /** @hidden */
  73750. export interface IGLTFTechniqueParameter {
  73751. type: number;
  73752. count?: number;
  73753. semantic?: string;
  73754. node?: string;
  73755. value?: number | boolean | string | Array<any>;
  73756. source?: string;
  73757. babylonValue?: any;
  73758. }
  73759. /** @hidden */
  73760. export interface IGLTFTechniqueCommonProfile {
  73761. lightingModel: string;
  73762. texcoordBindings: Object;
  73763. parameters?: Array<any>;
  73764. }
  73765. /** @hidden */
  73766. export interface IGLTFTechniqueStatesFunctions {
  73767. blendColor?: number[];
  73768. blendEquationSeparate?: number[];
  73769. blendFuncSeparate?: number[];
  73770. colorMask: boolean[];
  73771. cullFace: number[];
  73772. }
  73773. /** @hidden */
  73774. export interface IGLTFTechniqueStates {
  73775. enable: number[];
  73776. functions: IGLTFTechniqueStatesFunctions;
  73777. }
  73778. /** @hidden */
  73779. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  73780. parameters: {
  73781. [key: string]: IGLTFTechniqueParameter;
  73782. };
  73783. program: string;
  73784. attributes: {
  73785. [key: string]: string;
  73786. };
  73787. uniforms: {
  73788. [key: string]: string;
  73789. };
  73790. states: IGLTFTechniqueStates;
  73791. }
  73792. /** @hidden */
  73793. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  73794. technique?: string;
  73795. values: string[];
  73796. }
  73797. /** @hidden */
  73798. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  73799. attributes: {
  73800. [key: string]: string;
  73801. };
  73802. indices: string;
  73803. material: string;
  73804. mode?: number;
  73805. }
  73806. /** @hidden */
  73807. export interface IGLTFMesh extends IGLTFChildRootProperty {
  73808. primitives: IGLTFMeshPrimitive[];
  73809. }
  73810. /** @hidden */
  73811. export interface IGLTFImage extends IGLTFChildRootProperty {
  73812. uri: string;
  73813. }
  73814. /** @hidden */
  73815. export interface IGLTFSampler extends IGLTFChildRootProperty {
  73816. magFilter?: number;
  73817. minFilter?: number;
  73818. wrapS?: number;
  73819. wrapT?: number;
  73820. }
  73821. /** @hidden */
  73822. export interface IGLTFTexture extends IGLTFChildRootProperty {
  73823. sampler: string;
  73824. source: string;
  73825. format?: ETextureFormat;
  73826. internalFormat?: ETextureFormat;
  73827. target?: number;
  73828. type?: number;
  73829. babylonTexture?: Texture;
  73830. }
  73831. /** @hidden */
  73832. export interface IGLTFAmbienLight {
  73833. color?: number[];
  73834. }
  73835. /** @hidden */
  73836. export interface IGLTFDirectionalLight {
  73837. color?: number[];
  73838. }
  73839. /** @hidden */
  73840. export interface IGLTFPointLight {
  73841. color?: number[];
  73842. constantAttenuation?: number;
  73843. linearAttenuation?: number;
  73844. quadraticAttenuation?: number;
  73845. }
  73846. /** @hidden */
  73847. export interface IGLTFSpotLight {
  73848. color?: number[];
  73849. constantAttenuation?: number;
  73850. fallOfAngle?: number;
  73851. fallOffExponent?: number;
  73852. linearAttenuation?: number;
  73853. quadraticAttenuation?: number;
  73854. }
  73855. /** @hidden */
  73856. export interface IGLTFLight extends IGLTFChildRootProperty {
  73857. type: string;
  73858. }
  73859. /** @hidden */
  73860. export interface IGLTFCameraOrthographic {
  73861. xmag: number;
  73862. ymag: number;
  73863. zfar: number;
  73864. znear: number;
  73865. }
  73866. /** @hidden */
  73867. export interface IGLTFCameraPerspective {
  73868. aspectRatio: number;
  73869. yfov: number;
  73870. zfar: number;
  73871. znear: number;
  73872. }
  73873. /** @hidden */
  73874. export interface IGLTFCamera extends IGLTFChildRootProperty {
  73875. type: string;
  73876. }
  73877. /** @hidden */
  73878. export interface IGLTFAnimationChannelTarget {
  73879. id: string;
  73880. path: string;
  73881. }
  73882. /** @hidden */
  73883. export interface IGLTFAnimationChannel {
  73884. sampler: string;
  73885. target: IGLTFAnimationChannelTarget;
  73886. }
  73887. /** @hidden */
  73888. export interface IGLTFAnimationSampler {
  73889. input: string;
  73890. output: string;
  73891. interpolation?: string;
  73892. }
  73893. /** @hidden */
  73894. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  73895. channels?: IGLTFAnimationChannel[];
  73896. parameters?: {
  73897. [key: string]: string;
  73898. };
  73899. samplers?: {
  73900. [key: string]: IGLTFAnimationSampler;
  73901. };
  73902. }
  73903. /** @hidden */
  73904. export interface IGLTFNodeInstanceSkin {
  73905. skeletons: string[];
  73906. skin: string;
  73907. meshes: string[];
  73908. }
  73909. /** @hidden */
  73910. export interface IGLTFSkins extends IGLTFChildRootProperty {
  73911. bindShapeMatrix: number[];
  73912. inverseBindMatrices: string;
  73913. jointNames: string[];
  73914. babylonSkeleton?: Skeleton;
  73915. }
  73916. /** @hidden */
  73917. export interface IGLTFNode extends IGLTFChildRootProperty {
  73918. camera?: string;
  73919. children: string[];
  73920. skin?: string;
  73921. jointName?: string;
  73922. light?: string;
  73923. matrix: number[];
  73924. mesh?: string;
  73925. meshes?: string[];
  73926. rotation?: number[];
  73927. scale?: number[];
  73928. translation?: number[];
  73929. babylonNode?: Node;
  73930. }
  73931. /** @hidden */
  73932. export interface IGLTFScene extends IGLTFChildRootProperty {
  73933. nodes: string[];
  73934. }
  73935. /** @hidden */
  73936. export interface IGLTFRuntime {
  73937. extensions: {
  73938. [key: string]: any;
  73939. };
  73940. accessors: {
  73941. [key: string]: IGLTFAccessor;
  73942. };
  73943. buffers: {
  73944. [key: string]: IGLTFBuffer;
  73945. };
  73946. bufferViews: {
  73947. [key: string]: IGLTFBufferView;
  73948. };
  73949. meshes: {
  73950. [key: string]: IGLTFMesh;
  73951. };
  73952. lights: {
  73953. [key: string]: IGLTFLight;
  73954. };
  73955. cameras: {
  73956. [key: string]: IGLTFCamera;
  73957. };
  73958. nodes: {
  73959. [key: string]: IGLTFNode;
  73960. };
  73961. images: {
  73962. [key: string]: IGLTFImage;
  73963. };
  73964. textures: {
  73965. [key: string]: IGLTFTexture;
  73966. };
  73967. shaders: {
  73968. [key: string]: IGLTFShader;
  73969. };
  73970. programs: {
  73971. [key: string]: IGLTFProgram;
  73972. };
  73973. samplers: {
  73974. [key: string]: IGLTFSampler;
  73975. };
  73976. techniques: {
  73977. [key: string]: IGLTFTechnique;
  73978. };
  73979. materials: {
  73980. [key: string]: IGLTFMaterial;
  73981. };
  73982. animations: {
  73983. [key: string]: IGLTFAnimation;
  73984. };
  73985. skins: {
  73986. [key: string]: IGLTFSkins;
  73987. };
  73988. currentScene?: Object;
  73989. scenes: {
  73990. [key: string]: IGLTFScene;
  73991. };
  73992. extensionsUsed: string[];
  73993. extensionsRequired?: string[];
  73994. buffersCount: number;
  73995. shaderscount: number;
  73996. scene: Scene;
  73997. rootUrl: string;
  73998. loadedBufferCount: number;
  73999. loadedBufferViews: {
  74000. [name: string]: ArrayBufferView;
  74001. };
  74002. loadedShaderCount: number;
  74003. importOnlyMeshes: boolean;
  74004. importMeshesNames?: string[];
  74005. dummyNodes: Node[];
  74006. }
  74007. /** @hidden */
  74008. export interface INodeToRoot {
  74009. bone: Bone;
  74010. node: IGLTFNode;
  74011. id: string;
  74012. }
  74013. /** @hidden */
  74014. export interface IJointNode {
  74015. node: IGLTFNode;
  74016. id: string;
  74017. }
  74018. }
  74019. declare module BABYLON.GLTF1 {
  74020. /**
  74021. * Utils functions for GLTF
  74022. * @hidden
  74023. */
  74024. export class GLTFUtils {
  74025. /**
  74026. * Sets the given "parameter" matrix
  74027. * @param scene: the Scene object
  74028. * @param source: the source node where to pick the matrix
  74029. * @param parameter: the GLTF technique parameter
  74030. * @param uniformName: the name of the shader's uniform
  74031. * @param shaderMaterial: the shader material
  74032. */
  74033. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74034. /**
  74035. * Sets the given "parameter" matrix
  74036. * @param shaderMaterial: the shader material
  74037. * @param uniform: the name of the shader's uniform
  74038. * @param value: the value of the uniform
  74039. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74040. */
  74041. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74042. /**
  74043. * Returns the wrap mode of the texture
  74044. * @param mode: the mode value
  74045. */
  74046. static GetWrapMode(mode: number): number;
  74047. /**
  74048. * Returns the byte stride giving an accessor
  74049. * @param accessor: the GLTF accessor objet
  74050. */
  74051. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74052. /**
  74053. * Returns the texture filter mode giving a mode value
  74054. * @param mode: the filter mode value
  74055. */
  74056. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74057. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74058. /**
  74059. * Returns a buffer from its accessor
  74060. * @param gltfRuntime: the GLTF runtime
  74061. * @param accessor: the GLTF accessor
  74062. */
  74063. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74064. /**
  74065. * Decodes a buffer view into a string
  74066. * @param view: the buffer view
  74067. */
  74068. static DecodeBufferToText(view: ArrayBufferView): string;
  74069. /**
  74070. * Returns the default material of gltf. Related to
  74071. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74072. * @param scene: the Babylon.js scene
  74073. */
  74074. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74075. private static _DefaultMaterial;
  74076. }
  74077. }
  74078. declare module BABYLON.GLTF1 {
  74079. /**
  74080. * Implementation of the base glTF spec
  74081. * @hidden
  74082. */
  74083. export class GLTFLoaderBase {
  74084. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74085. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74086. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74087. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74088. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74089. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74090. }
  74091. /**
  74092. * glTF V1 Loader
  74093. * @hidden
  74094. */
  74095. export class GLTFLoader implements IGLTFLoader {
  74096. static Extensions: {
  74097. [name: string]: GLTFLoaderExtension;
  74098. };
  74099. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74100. state: Nullable<GLTFLoaderState>;
  74101. dispose(): void;
  74102. private _importMeshAsync;
  74103. /**
  74104. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74105. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74106. * @param scene the scene the meshes should be added to
  74107. * @param data gltf data containing information of the meshes in a loaded file
  74108. * @param rootUrl root url to load from
  74109. * @param onProgress event that fires when loading progress has occured
  74110. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74111. */
  74112. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74113. meshes: AbstractMesh[];
  74114. particleSystems: IParticleSystem[];
  74115. skeletons: Skeleton[];
  74116. animationGroups: AnimationGroup[];
  74117. }>;
  74118. private _loadAsync;
  74119. /**
  74120. * Imports all objects from a loaded gltf file and adds them to the scene
  74121. * @param scene the scene the objects should be added to
  74122. * @param data gltf data containing information of the meshes in a loaded file
  74123. * @param rootUrl root url to load from
  74124. * @param onProgress event that fires when loading progress has occured
  74125. * @returns a promise which completes when objects have been loaded to the scene
  74126. */
  74127. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74128. private _loadShadersAsync;
  74129. private _loadBuffersAsync;
  74130. private _createNodes;
  74131. }
  74132. /** @hidden */
  74133. export abstract class GLTFLoaderExtension {
  74134. private _name;
  74135. constructor(name: string);
  74136. get name(): string;
  74137. /**
  74138. * Defines an override for loading the runtime
  74139. * Return true to stop further extensions from loading the runtime
  74140. */
  74141. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74142. /**
  74143. * Defines an onverride for creating gltf runtime
  74144. * Return true to stop further extensions from creating the runtime
  74145. */
  74146. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74147. /**
  74148. * Defines an override for loading buffers
  74149. * Return true to stop further extensions from loading this buffer
  74150. */
  74151. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74152. /**
  74153. * Defines an override for loading texture buffers
  74154. * Return true to stop further extensions from loading this texture data
  74155. */
  74156. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74157. /**
  74158. * Defines an override for creating textures
  74159. * Return true to stop further extensions from loading this texture
  74160. */
  74161. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74162. /**
  74163. * Defines an override for loading shader strings
  74164. * Return true to stop further extensions from loading this shader data
  74165. */
  74166. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74167. /**
  74168. * Defines an override for loading materials
  74169. * Return true to stop further extensions from loading this material
  74170. */
  74171. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74172. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74173. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74174. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74175. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74176. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74177. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74178. private static LoadTextureBufferAsync;
  74179. private static CreateTextureAsync;
  74180. private static ApplyExtensions;
  74181. }
  74182. }
  74183. declare module BABYLON.GLTF1 {
  74184. /** @hidden */
  74185. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74186. private _bin;
  74187. constructor();
  74188. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74189. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74190. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74191. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74192. }
  74193. }
  74194. declare module BABYLON.GLTF1 {
  74195. /** @hidden */
  74196. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74197. constructor();
  74198. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74199. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74200. private _loadTexture;
  74201. }
  74202. }
  74203. declare module BABYLON.GLTF2.Loader {
  74204. /**
  74205. * Loader interface with an index field.
  74206. */
  74207. export interface IArrayItem {
  74208. /**
  74209. * The index of this item in the array.
  74210. */
  74211. index: number;
  74212. }
  74213. /**
  74214. * Loader interface with additional members.
  74215. */
  74216. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  74217. /** @hidden */
  74218. _data?: Promise<ArrayBufferView>;
  74219. /** @hidden */
  74220. _babylonVertexBuffer?: Promise<VertexBuffer>;
  74221. }
  74222. /**
  74223. * Loader interface with additional members.
  74224. */
  74225. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  74226. }
  74227. /** @hidden */
  74228. export interface _IAnimationSamplerData {
  74229. input: Float32Array;
  74230. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  74231. output: Float32Array;
  74232. }
  74233. /**
  74234. * Loader interface with additional members.
  74235. */
  74236. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  74237. /** @hidden */
  74238. _data?: Promise<_IAnimationSamplerData>;
  74239. }
  74240. /**
  74241. * Loader interface with additional members.
  74242. */
  74243. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  74244. channels: IAnimationChannel[];
  74245. samplers: IAnimationSampler[];
  74246. /** @hidden */
  74247. _babylonAnimationGroup?: AnimationGroup;
  74248. }
  74249. /**
  74250. * Loader interface with additional members.
  74251. */
  74252. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  74253. /** @hidden */
  74254. _data?: Promise<ArrayBufferView>;
  74255. }
  74256. /**
  74257. * Loader interface with additional members.
  74258. */
  74259. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  74260. /** @hidden */
  74261. _data?: Promise<ArrayBufferView>;
  74262. /** @hidden */
  74263. _babylonBuffer?: Promise<Buffer>;
  74264. }
  74265. /**
  74266. * Loader interface with additional members.
  74267. */
  74268. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  74269. }
  74270. /**
  74271. * Loader interface with additional members.
  74272. */
  74273. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  74274. /** @hidden */
  74275. _data?: Promise<ArrayBufferView>;
  74276. }
  74277. /**
  74278. * Loader interface with additional members.
  74279. */
  74280. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  74281. }
  74282. /**
  74283. * Loader interface with additional members.
  74284. */
  74285. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  74286. }
  74287. /**
  74288. * Loader interface with additional members.
  74289. */
  74290. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  74291. baseColorTexture?: ITextureInfo;
  74292. metallicRoughnessTexture?: ITextureInfo;
  74293. }
  74294. /**
  74295. * Loader interface with additional members.
  74296. */
  74297. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  74298. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74299. normalTexture?: IMaterialNormalTextureInfo;
  74300. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74301. emissiveTexture?: ITextureInfo;
  74302. /** @hidden */
  74303. _data?: {
  74304. [babylonDrawMode: number]: {
  74305. babylonMaterial: Material;
  74306. babylonMeshes: AbstractMesh[];
  74307. promise: Promise<void>;
  74308. };
  74309. };
  74310. }
  74311. /**
  74312. * Loader interface with additional members.
  74313. */
  74314. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  74315. primitives: IMeshPrimitive[];
  74316. }
  74317. /**
  74318. * Loader interface with additional members.
  74319. */
  74320. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  74321. /** @hidden */
  74322. _instanceData?: {
  74323. babylonSourceMesh: Mesh;
  74324. promise: Promise<any>;
  74325. };
  74326. }
  74327. /**
  74328. * Loader interface with additional members.
  74329. */
  74330. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  74331. /**
  74332. * The parent glTF node.
  74333. */
  74334. parent?: INode;
  74335. /** @hidden */
  74336. _babylonTransformNode?: TransformNode;
  74337. /** @hidden */
  74338. _primitiveBabylonMeshes?: AbstractMesh[];
  74339. /** @hidden */
  74340. _babylonBones?: Bone[];
  74341. /** @hidden */
  74342. _numMorphTargets?: number;
  74343. }
  74344. /** @hidden */
  74345. export interface _ISamplerData {
  74346. noMipMaps: boolean;
  74347. samplingMode: number;
  74348. wrapU: number;
  74349. wrapV: number;
  74350. }
  74351. /**
  74352. * Loader interface with additional members.
  74353. */
  74354. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  74355. /** @hidden */
  74356. _data?: _ISamplerData;
  74357. }
  74358. /**
  74359. * Loader interface with additional members.
  74360. */
  74361. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  74362. }
  74363. /**
  74364. * Loader interface with additional members.
  74365. */
  74366. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  74367. /** @hidden */
  74368. _data?: {
  74369. babylonSkeleton: Skeleton;
  74370. promise: Promise<void>;
  74371. };
  74372. }
  74373. /**
  74374. * Loader interface with additional members.
  74375. */
  74376. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  74377. }
  74378. /**
  74379. * Loader interface with additional members.
  74380. */
  74381. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  74382. }
  74383. /**
  74384. * Loader interface with additional members.
  74385. */
  74386. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  74387. accessors?: IAccessor[];
  74388. animations?: IAnimation[];
  74389. buffers?: IBuffer[];
  74390. bufferViews?: IBufferView[];
  74391. cameras?: ICamera[];
  74392. images?: IImage[];
  74393. materials?: IMaterial[];
  74394. meshes?: IMesh[];
  74395. nodes?: INode[];
  74396. samplers?: ISampler[];
  74397. scenes?: IScene[];
  74398. skins?: ISkin[];
  74399. textures?: ITexture[];
  74400. }
  74401. }
  74402. declare module BABYLON.GLTF2 {
  74403. /**
  74404. * Interface for a glTF loader extension.
  74405. */
  74406. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  74407. /**
  74408. * Called after the loader state changes to LOADING.
  74409. */
  74410. onLoading?(): void;
  74411. /**
  74412. * Called after the loader state changes to READY.
  74413. */
  74414. onReady?(): void;
  74415. /**
  74416. * Define this method to modify the default behavior when loading scenes.
  74417. * @param context The context when loading the asset
  74418. * @param scene The glTF scene property
  74419. * @returns A promise that resolves when the load is complete or null if not handled
  74420. */
  74421. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  74422. /**
  74423. * Define this method to modify the default behavior when loading nodes.
  74424. * @param context The context when loading the asset
  74425. * @param node The glTF node property
  74426. * @param assign A function called synchronously after parsing the glTF properties
  74427. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  74428. */
  74429. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74430. /**
  74431. * Define this method to modify the default behavior when loading cameras.
  74432. * @param context The context when loading the asset
  74433. * @param camera The glTF camera property
  74434. * @param assign A function called synchronously after parsing the glTF properties
  74435. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  74436. */
  74437. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74438. /**
  74439. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  74440. * @param context The context when loading the asset
  74441. * @param primitive The glTF mesh primitive property
  74442. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  74443. */
  74444. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74445. /**
  74446. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74447. * @param context The context when loading the asset
  74448. * @param name The mesh name when loading the asset
  74449. * @param node The glTF node when loading the asset
  74450. * @param mesh The glTF mesh when loading the asset
  74451. * @param primitive The glTF mesh primitive property
  74452. * @param assign A function called synchronously after parsing the glTF properties
  74453. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74454. */
  74455. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74456. /**
  74457. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  74458. * @param context The context when loading the asset
  74459. * @param material The glTF material property
  74460. * @param assign A function called synchronously after parsing the glTF properties
  74461. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  74462. */
  74463. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74464. /**
  74465. * Define this method to modify the default behavior when creating materials.
  74466. * @param context The context when loading the asset
  74467. * @param material The glTF material property
  74468. * @param babylonDrawMode The draw mode for the Babylon material
  74469. * @returns The Babylon material or null if not handled
  74470. */
  74471. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74472. /**
  74473. * Define this method to modify the default behavior when loading material properties.
  74474. * @param context The context when loading the asset
  74475. * @param material The glTF material property
  74476. * @param babylonMaterial The Babylon material
  74477. * @returns A promise that resolves when the load is complete or null if not handled
  74478. */
  74479. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74480. /**
  74481. * Define this method to modify the default behavior when loading texture infos.
  74482. * @param context The context when loading the asset
  74483. * @param textureInfo The glTF texture info property
  74484. * @param assign A function called synchronously after parsing the glTF properties
  74485. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  74486. */
  74487. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  74488. /**
  74489. * Define this method to modify the default behavior when loading animations.
  74490. * @param context The context when loading the asset
  74491. * @param animation The glTF animation property
  74492. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  74493. */
  74494. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  74495. /**
  74496. * @hidden Define this method to modify the default behavior when loading skins.
  74497. * @param context The context when loading the asset
  74498. * @param node The glTF node property
  74499. * @param skin The glTF skin property
  74500. * @returns A promise that resolves when the load is complete or null if not handled
  74501. */
  74502. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  74503. /**
  74504. * @hidden Define this method to modify the default behavior when loading uris.
  74505. * @param context The context when loading the asset
  74506. * @param property The glTF property associated with the uri
  74507. * @param uri The uri to load
  74508. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74509. */
  74510. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  74511. /**
  74512. * Define this method to modify the default behavior when loading buffer views.
  74513. * @param context The context when loading the asset
  74514. * @param bufferView The glTF buffer view property
  74515. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74516. */
  74517. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  74518. /**
  74519. * Define this method to modify the default behavior when loading buffers.
  74520. * @param context The context when loading the asset
  74521. * @param buffer The glTF buffer property
  74522. * @param byteOffset The byte offset to load
  74523. * @param byteLength The byte length to load
  74524. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74525. */
  74526. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  74527. }
  74528. }
  74529. declare module BABYLON.GLTF2 {
  74530. /**
  74531. * Helper class for working with arrays when loading the glTF asset
  74532. */
  74533. export class ArrayItem {
  74534. /**
  74535. * Gets an item from the given array.
  74536. * @param context The context when loading the asset
  74537. * @param array The array to get the item from
  74538. * @param index The index to the array
  74539. * @returns The array item
  74540. */
  74541. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  74542. /**
  74543. * Assign an `index` field to each item of the given array.
  74544. * @param array The array of items
  74545. */
  74546. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  74547. }
  74548. /**
  74549. * The glTF 2.0 loader
  74550. */
  74551. export class GLTFLoader implements IGLTFLoader {
  74552. /** @hidden */
  74553. _completePromises: Promise<any>[];
  74554. private _disposed;
  74555. private _parent;
  74556. private _state;
  74557. private _extensions;
  74558. private _rootUrl;
  74559. private _fileName;
  74560. private _uniqueRootUrl;
  74561. private _gltf;
  74562. private _bin;
  74563. private _babylonScene;
  74564. private _rootBabylonMesh;
  74565. private _defaultBabylonMaterialData;
  74566. private _progressCallback?;
  74567. private _requests;
  74568. private static readonly _DefaultSampler;
  74569. private static _RegisteredExtensions;
  74570. /**
  74571. * Registers a loader extension.
  74572. * @param name The name of the loader extension.
  74573. * @param factory The factory function that creates the loader extension.
  74574. */
  74575. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  74576. /**
  74577. * Unregisters a loader extension.
  74578. * @param name The name of the loader extension.
  74579. * @returns A boolean indicating whether the extension has been unregistered
  74580. */
  74581. static UnregisterExtension(name: string): boolean;
  74582. /**
  74583. * Gets the loader state.
  74584. */
  74585. get state(): Nullable<GLTFLoaderState>;
  74586. /**
  74587. * The object that represents the glTF JSON.
  74588. */
  74589. get gltf(): IGLTF;
  74590. /**
  74591. * The BIN chunk of a binary glTF.
  74592. */
  74593. get bin(): Nullable<IDataBuffer>;
  74594. /**
  74595. * The parent file loader.
  74596. */
  74597. get parent(): GLTFFileLoader;
  74598. /**
  74599. * The Babylon scene when loading the asset.
  74600. */
  74601. get babylonScene(): Scene;
  74602. /**
  74603. * The root Babylon mesh when loading the asset.
  74604. */
  74605. get rootBabylonMesh(): Mesh;
  74606. /** @hidden */
  74607. constructor(parent: GLTFFileLoader);
  74608. /** @hidden */
  74609. dispose(): void;
  74610. /** @hidden */
  74611. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74612. meshes: AbstractMesh[];
  74613. particleSystems: IParticleSystem[];
  74614. skeletons: Skeleton[];
  74615. animationGroups: AnimationGroup[];
  74616. }>;
  74617. /** @hidden */
  74618. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74619. private _loadAsync;
  74620. private _loadData;
  74621. private _setupData;
  74622. private _loadExtensions;
  74623. private _checkExtensions;
  74624. private _setState;
  74625. private _createRootNode;
  74626. /**
  74627. * Loads a glTF scene.
  74628. * @param context The context when loading the asset
  74629. * @param scene The glTF scene property
  74630. * @returns A promise that resolves when the load is complete
  74631. */
  74632. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  74633. private _forEachPrimitive;
  74634. private _getMeshes;
  74635. private _getSkeletons;
  74636. private _getAnimationGroups;
  74637. private _startAnimations;
  74638. /**
  74639. * Loads a glTF node.
  74640. * @param context The context when loading the asset
  74641. * @param node The glTF node property
  74642. * @param assign A function called synchronously after parsing the glTF properties
  74643. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  74644. */
  74645. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  74646. private _loadMeshAsync;
  74647. /**
  74648. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74649. * @param context The context when loading the asset
  74650. * @param name The mesh name when loading the asset
  74651. * @param node The glTF node when loading the asset
  74652. * @param mesh The glTF mesh when loading the asset
  74653. * @param primitive The glTF mesh primitive property
  74654. * @param assign A function called synchronously after parsing the glTF properties
  74655. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74656. */
  74657. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74658. private _loadVertexDataAsync;
  74659. private _createMorphTargets;
  74660. private _loadMorphTargetsAsync;
  74661. private _loadMorphTargetVertexDataAsync;
  74662. private static _LoadTransform;
  74663. private _loadSkinAsync;
  74664. private _loadBones;
  74665. private _loadBone;
  74666. private _loadSkinInverseBindMatricesDataAsync;
  74667. private _updateBoneMatrices;
  74668. private _getNodeMatrix;
  74669. /**
  74670. * Loads a glTF camera.
  74671. * @param context The context when loading the asset
  74672. * @param camera The glTF camera property
  74673. * @param assign A function called synchronously after parsing the glTF properties
  74674. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  74675. */
  74676. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  74677. private _loadAnimationsAsync;
  74678. /**
  74679. * Loads a glTF animation.
  74680. * @param context The context when loading the asset
  74681. * @param animation The glTF animation property
  74682. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  74683. */
  74684. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  74685. /**
  74686. * @hidden Loads a glTF animation channel.
  74687. * @param context The context when loading the asset
  74688. * @param animationContext The context of the animation when loading the asset
  74689. * @param animation The glTF animation property
  74690. * @param channel The glTF animation channel property
  74691. * @param babylonAnimationGroup The babylon animation group property
  74692. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  74693. * @returns A void promise when the channel load is complete
  74694. */
  74695. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  74696. private _loadAnimationSamplerAsync;
  74697. private _loadBufferAsync;
  74698. /**
  74699. * Loads a glTF buffer view.
  74700. * @param context The context when loading the asset
  74701. * @param bufferView The glTF buffer view property
  74702. * @returns A promise that resolves with the loaded data when the load is complete
  74703. */
  74704. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  74705. private _loadAccessorAsync;
  74706. private _loadFloatAccessorAsync;
  74707. private _loadIndicesAccessorAsync;
  74708. private _loadVertexBufferViewAsync;
  74709. private _loadVertexAccessorAsync;
  74710. private _loadMaterialMetallicRoughnessPropertiesAsync;
  74711. /** @hidden */
  74712. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  74713. private _createDefaultMaterial;
  74714. /**
  74715. * Creates a Babylon material from a glTF material.
  74716. * @param context The context when loading the asset
  74717. * @param material The glTF material property
  74718. * @param babylonDrawMode The draw mode for the Babylon material
  74719. * @returns The Babylon material
  74720. */
  74721. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  74722. /**
  74723. * Loads properties from a glTF material into a Babylon material.
  74724. * @param context The context when loading the asset
  74725. * @param material The glTF material property
  74726. * @param babylonMaterial The Babylon material
  74727. * @returns A promise that resolves when the load is complete
  74728. */
  74729. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74730. /**
  74731. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  74732. * @param context The context when loading the asset
  74733. * @param material The glTF material property
  74734. * @param babylonMaterial The Babylon material
  74735. * @returns A promise that resolves when the load is complete
  74736. */
  74737. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74738. /**
  74739. * Loads the alpha properties from a glTF material into a Babylon material.
  74740. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  74741. * @param context The context when loading the asset
  74742. * @param material The glTF material property
  74743. * @param babylonMaterial The Babylon material
  74744. */
  74745. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  74746. /**
  74747. * Loads a glTF texture info.
  74748. * @param context The context when loading the asset
  74749. * @param textureInfo The glTF texture info property
  74750. * @param assign A function called synchronously after parsing the glTF properties
  74751. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  74752. */
  74753. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  74754. private _loadTextureAsync;
  74755. private _loadSampler;
  74756. /**
  74757. * Loads a glTF image.
  74758. * @param context The context when loading the asset
  74759. * @param image The glTF image property
  74760. * @returns A promise that resolves with the loaded data when the load is complete
  74761. */
  74762. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  74763. /**
  74764. * Loads a glTF uri.
  74765. * @param context The context when loading the asset
  74766. * @param property The glTF property associated with the uri
  74767. * @param uri The base64 or relative uri
  74768. * @returns A promise that resolves with the loaded data when the load is complete
  74769. */
  74770. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  74771. private _onProgress;
  74772. /**
  74773. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  74774. * @param babylonObject the Babylon object with metadata
  74775. * @param pointer the JSON pointer
  74776. */
  74777. static AddPointerMetadata(babylonObject: {
  74778. metadata: any;
  74779. }, pointer: string): void;
  74780. private static _GetTextureWrapMode;
  74781. private static _GetTextureSamplingMode;
  74782. private static _GetTypedArrayConstructor;
  74783. private static _GetTypedArray;
  74784. private static _GetNumComponents;
  74785. private static _ValidateUri;
  74786. private static _GetDrawMode;
  74787. private _compileMaterialsAsync;
  74788. private _compileShadowGeneratorsAsync;
  74789. private _forEachExtensions;
  74790. private _applyExtensions;
  74791. private _extensionsOnLoading;
  74792. private _extensionsOnReady;
  74793. private _extensionsLoadSceneAsync;
  74794. private _extensionsLoadNodeAsync;
  74795. private _extensionsLoadCameraAsync;
  74796. private _extensionsLoadVertexDataAsync;
  74797. private _extensionsLoadMeshPrimitiveAsync;
  74798. private _extensionsLoadMaterialAsync;
  74799. private _extensionsCreateMaterial;
  74800. private _extensionsLoadMaterialPropertiesAsync;
  74801. private _extensionsLoadTextureInfoAsync;
  74802. private _extensionsLoadAnimationAsync;
  74803. private _extensionsLoadSkinAsync;
  74804. private _extensionsLoadUriAsync;
  74805. private _extensionsLoadBufferViewAsync;
  74806. private _extensionsLoadBufferAsync;
  74807. /**
  74808. * Helper method called by a loader extension to load an glTF extension.
  74809. * @param context The context when loading the asset
  74810. * @param property The glTF property to load the extension from
  74811. * @param extensionName The name of the extension to load
  74812. * @param actionAsync The action to run
  74813. * @returns The promise returned by actionAsync or null if the extension does not exist
  74814. */
  74815. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74816. /**
  74817. * Helper method called by a loader extension to load a glTF extra.
  74818. * @param context The context when loading the asset
  74819. * @param property The glTF property to load the extra from
  74820. * @param extensionName The name of the extension to load
  74821. * @param actionAsync The action to run
  74822. * @returns The promise returned by actionAsync or null if the extra does not exist
  74823. */
  74824. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74825. /**
  74826. * Checks for presence of an extension.
  74827. * @param name The name of the extension to check
  74828. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  74829. */
  74830. isExtensionUsed(name: string): boolean;
  74831. /**
  74832. * Increments the indentation level and logs a message.
  74833. * @param message The message to log
  74834. */
  74835. logOpen(message: string): void;
  74836. /**
  74837. * Decrements the indentation level.
  74838. */
  74839. logClose(): void;
  74840. /**
  74841. * Logs a message
  74842. * @param message The message to log
  74843. */
  74844. log(message: string): void;
  74845. /**
  74846. * Starts a performance counter.
  74847. * @param counterName The name of the performance counter
  74848. */
  74849. startPerformanceCounter(counterName: string): void;
  74850. /**
  74851. * Ends a performance counter.
  74852. * @param counterName The name of the performance counter
  74853. */
  74854. endPerformanceCounter(counterName: string): void;
  74855. }
  74856. }
  74857. declare module BABYLON.GLTF2.Loader.Extensions {
  74858. /**
  74859. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  74860. */
  74861. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  74862. /**
  74863. * The name of this extension.
  74864. */
  74865. readonly name: string;
  74866. /**
  74867. * Defines whether this extension is enabled.
  74868. */
  74869. enabled: boolean;
  74870. private _loader;
  74871. private _lights?;
  74872. /** @hidden */
  74873. constructor(loader: GLTFLoader);
  74874. /** @hidden */
  74875. dispose(): void;
  74876. /** @hidden */
  74877. onLoading(): void;
  74878. /** @hidden */
  74879. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  74880. private _loadLightAsync;
  74881. }
  74882. }
  74883. declare module BABYLON.GLTF2.Loader.Extensions {
  74884. /**
  74885. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  74886. */
  74887. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  74888. /**
  74889. * The name of this extension.
  74890. */
  74891. readonly name: string;
  74892. /**
  74893. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  74894. */
  74895. dracoCompression?: DracoCompression;
  74896. /**
  74897. * Defines whether this extension is enabled.
  74898. */
  74899. enabled: boolean;
  74900. private _loader;
  74901. /** @hidden */
  74902. constructor(loader: GLTFLoader);
  74903. /** @hidden */
  74904. dispose(): void;
  74905. /** @hidden */
  74906. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74907. }
  74908. }
  74909. declare module BABYLON.GLTF2.Loader.Extensions {
  74910. /**
  74911. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74912. */
  74913. export class KHR_lights implements IGLTFLoaderExtension {
  74914. /**
  74915. * The name of this extension.
  74916. */
  74917. readonly name: string;
  74918. /**
  74919. * Defines whether this extension is enabled.
  74920. */
  74921. enabled: boolean;
  74922. private _loader;
  74923. private _lights?;
  74924. /** @hidden */
  74925. constructor(loader: GLTFLoader);
  74926. /** @hidden */
  74927. dispose(): void;
  74928. /** @hidden */
  74929. onLoading(): void;
  74930. /** @hidden */
  74931. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74932. }
  74933. }
  74934. declare module BABYLON.GLTF2.Loader.Extensions {
  74935. /**
  74936. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  74937. */
  74938. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  74939. /**
  74940. * The name of this extension.
  74941. */
  74942. readonly name: string;
  74943. /**
  74944. * Defines whether this extension is enabled.
  74945. */
  74946. enabled: boolean;
  74947. /**
  74948. * Defines a number that determines the order the extensions are applied.
  74949. */
  74950. order: number;
  74951. private _loader;
  74952. /** @hidden */
  74953. constructor(loader: GLTFLoader);
  74954. /** @hidden */
  74955. dispose(): void;
  74956. /** @hidden */
  74957. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74958. private _loadSpecularGlossinessPropertiesAsync;
  74959. }
  74960. }
  74961. declare module BABYLON.GLTF2.Loader.Extensions {
  74962. /**
  74963. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  74964. */
  74965. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  74966. /**
  74967. * The name of this extension.
  74968. */
  74969. readonly name: string;
  74970. /**
  74971. * Defines whether this extension is enabled.
  74972. */
  74973. enabled: boolean;
  74974. /**
  74975. * Defines a number that determines the order the extensions are applied.
  74976. */
  74977. order: number;
  74978. private _loader;
  74979. /** @hidden */
  74980. constructor(loader: GLTFLoader);
  74981. /** @hidden */
  74982. dispose(): void;
  74983. /** @hidden */
  74984. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74985. private _loadUnlitPropertiesAsync;
  74986. }
  74987. }
  74988. declare module BABYLON.GLTF2.Loader.Extensions {
  74989. /**
  74990. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  74991. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  74992. * !!! Experimental Extension Subject to Changes !!!
  74993. */
  74994. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  74995. /**
  74996. * The name of this extension.
  74997. */
  74998. readonly name: string;
  74999. /**
  75000. * Defines whether this extension is enabled.
  75001. */
  75002. enabled: boolean;
  75003. /**
  75004. * Defines a number that determines the order the extensions are applied.
  75005. */
  75006. order: number;
  75007. private _loader;
  75008. /** @hidden */
  75009. constructor(loader: GLTFLoader);
  75010. /** @hidden */
  75011. dispose(): void;
  75012. /** @hidden */
  75013. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75014. private _loadClearCoatPropertiesAsync;
  75015. }
  75016. }
  75017. declare module BABYLON.GLTF2.Loader.Extensions {
  75018. /**
  75019. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75020. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75021. * !!! Experimental Extension Subject to Changes !!!
  75022. */
  75023. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75024. /**
  75025. * The name of this extension.
  75026. */
  75027. readonly name: string;
  75028. /**
  75029. * Defines whether this extension is enabled.
  75030. */
  75031. enabled: boolean;
  75032. /**
  75033. * Defines a number that determines the order the extensions are applied.
  75034. */
  75035. order: number;
  75036. private _loader;
  75037. /** @hidden */
  75038. constructor(loader: GLTFLoader);
  75039. /** @hidden */
  75040. dispose(): void;
  75041. /** @hidden */
  75042. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75043. private _loadSheenPropertiesAsync;
  75044. }
  75045. }
  75046. declare module BABYLON.GLTF2.Loader.Extensions {
  75047. /**
  75048. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75049. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75050. * !!! Experimental Extension Subject to Changes !!!
  75051. */
  75052. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75053. /**
  75054. * The name of this extension.
  75055. */
  75056. readonly name: string;
  75057. /**
  75058. * Defines whether this extension is enabled.
  75059. */
  75060. enabled: boolean;
  75061. /**
  75062. * Defines a number that determines the order the extensions are applied.
  75063. */
  75064. order: number;
  75065. private _loader;
  75066. /** @hidden */
  75067. constructor(loader: GLTFLoader);
  75068. /** @hidden */
  75069. dispose(): void;
  75070. /** @hidden */
  75071. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75072. private _loadSpecularPropertiesAsync;
  75073. }
  75074. }
  75075. declare module BABYLON.GLTF2.Loader.Extensions {
  75076. /**
  75077. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75078. */
  75079. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75080. /**
  75081. * The name of this extension.
  75082. */
  75083. readonly name: string;
  75084. /**
  75085. * Defines whether this extension is enabled.
  75086. */
  75087. enabled: boolean;
  75088. /** @hidden */
  75089. constructor(loader: GLTFLoader);
  75090. /** @hidden */
  75091. dispose(): void;
  75092. }
  75093. }
  75094. declare module BABYLON.GLTF2.Loader.Extensions {
  75095. /**
  75096. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75097. */
  75098. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75099. /**
  75100. * The name of this extension.
  75101. */
  75102. readonly name: string;
  75103. /**
  75104. * Defines whether this extension is enabled.
  75105. */
  75106. enabled: boolean;
  75107. private _loader;
  75108. /** @hidden */
  75109. constructor(loader: GLTFLoader);
  75110. /** @hidden */
  75111. dispose(): void;
  75112. /** @hidden */
  75113. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75114. }
  75115. }
  75116. declare module BABYLON.GLTF2.Loader.Extensions {
  75117. /**
  75118. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75119. */
  75120. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75121. /**
  75122. * The name of this extension.
  75123. */
  75124. readonly name: string;
  75125. /**
  75126. * Defines whether this extension is enabled.
  75127. */
  75128. enabled: boolean;
  75129. private _loader;
  75130. private _clips;
  75131. private _emitters;
  75132. /** @hidden */
  75133. constructor(loader: GLTFLoader);
  75134. /** @hidden */
  75135. dispose(): void;
  75136. /** @hidden */
  75137. onLoading(): void;
  75138. /** @hidden */
  75139. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75140. /** @hidden */
  75141. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75142. /** @hidden */
  75143. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75144. private _loadClipAsync;
  75145. private _loadEmitterAsync;
  75146. private _getEventAction;
  75147. private _loadAnimationEventAsync;
  75148. }
  75149. }
  75150. declare module BABYLON.GLTF2.Loader.Extensions {
  75151. /**
  75152. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75153. */
  75154. export class MSFT_lod implements IGLTFLoaderExtension {
  75155. /**
  75156. * The name of this extension.
  75157. */
  75158. readonly name: string;
  75159. /**
  75160. * Defines whether this extension is enabled.
  75161. */
  75162. enabled: boolean;
  75163. /**
  75164. * Defines a number that determines the order the extensions are applied.
  75165. */
  75166. order: number;
  75167. /**
  75168. * Maximum number of LODs to load, starting from the lowest LOD.
  75169. */
  75170. maxLODsToLoad: number;
  75171. /**
  75172. * Observable raised when all node LODs of one level are loaded.
  75173. * The event data is the index of the loaded LOD starting from zero.
  75174. * Dispose the loader to cancel the loading of the next level of LODs.
  75175. */
  75176. onNodeLODsLoadedObservable: Observable<number>;
  75177. /**
  75178. * Observable raised when all material LODs of one level are loaded.
  75179. * The event data is the index of the loaded LOD starting from zero.
  75180. * Dispose the loader to cancel the loading of the next level of LODs.
  75181. */
  75182. onMaterialLODsLoadedObservable: Observable<number>;
  75183. private _loader;
  75184. private _nodeIndexLOD;
  75185. private _nodeSignalLODs;
  75186. private _nodePromiseLODs;
  75187. private _materialIndexLOD;
  75188. private _materialSignalLODs;
  75189. private _materialPromiseLODs;
  75190. private _indexLOD;
  75191. private _bufferLODs;
  75192. /** @hidden */
  75193. constructor(loader: GLTFLoader);
  75194. /** @hidden */
  75195. dispose(): void;
  75196. /** @hidden */
  75197. onReady(): void;
  75198. /** @hidden */
  75199. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75200. /** @hidden */
  75201. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75202. /** @hidden */
  75203. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75204. /** @hidden */
  75205. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75206. private _loadBufferLOD;
  75207. /**
  75208. * Gets an array of LOD properties from lowest to highest.
  75209. */
  75210. private _getLODs;
  75211. private _disposeUnusedMaterials;
  75212. }
  75213. }
  75214. declare module BABYLON.GLTF2.Loader.Extensions {
  75215. /** @hidden */
  75216. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  75217. readonly name: string;
  75218. enabled: boolean;
  75219. private _loader;
  75220. constructor(loader: GLTFLoader);
  75221. dispose(): void;
  75222. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75223. }
  75224. }
  75225. declare module BABYLON.GLTF2.Loader.Extensions {
  75226. /** @hidden */
  75227. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  75228. readonly name: string;
  75229. enabled: boolean;
  75230. private _loader;
  75231. constructor(loader: GLTFLoader);
  75232. dispose(): void;
  75233. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75234. }
  75235. }
  75236. declare module BABYLON.GLTF2.Loader.Extensions {
  75237. /**
  75238. * Store glTF extras (if present) in BJS objects' metadata
  75239. */
  75240. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  75241. /**
  75242. * The name of this extension.
  75243. */
  75244. readonly name: string;
  75245. /**
  75246. * Defines whether this extension is enabled.
  75247. */
  75248. enabled: boolean;
  75249. private _loader;
  75250. private _assignExtras;
  75251. /** @hidden */
  75252. constructor(loader: GLTFLoader);
  75253. /** @hidden */
  75254. dispose(): void;
  75255. /** @hidden */
  75256. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75257. /** @hidden */
  75258. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75259. /** @hidden */
  75260. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75261. }
  75262. }
  75263. declare module BABYLON {
  75264. /**
  75265. * Class reading and parsing the MTL file bundled with the obj file.
  75266. */
  75267. export class MTLFileLoader {
  75268. /**
  75269. * Invert Y-Axis of referenced textures on load
  75270. */
  75271. static INVERT_TEXTURE_Y: boolean;
  75272. /**
  75273. * All material loaded from the mtl will be set here
  75274. */
  75275. materials: StandardMaterial[];
  75276. /**
  75277. * This function will read the mtl file and create each material described inside
  75278. * This function could be improve by adding :
  75279. * -some component missing (Ni, Tf...)
  75280. * -including the specific options available
  75281. *
  75282. * @param scene defines the scene the material will be created in
  75283. * @param data defines the mtl data to parse
  75284. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  75285. */
  75286. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  75287. /**
  75288. * Gets the texture for the material.
  75289. *
  75290. * If the material is imported from input file,
  75291. * We sanitize the url to ensure it takes the textre from aside the material.
  75292. *
  75293. * @param rootUrl The root url to load from
  75294. * @param value The value stored in the mtl
  75295. * @return The Texture
  75296. */
  75297. private static _getTexture;
  75298. }
  75299. }
  75300. declare module BABYLON {
  75301. /**
  75302. * Options for loading OBJ/MTL files
  75303. */
  75304. type MeshLoadOptions = {
  75305. /**
  75306. * Defines if UVs are optimized by default during load.
  75307. */
  75308. OptimizeWithUV: boolean;
  75309. /**
  75310. * Defines custom scaling of UV coordinates of loaded meshes.
  75311. */
  75312. UVScaling: Vector2;
  75313. /**
  75314. * Invert model on y-axis (does a model scaling inversion)
  75315. */
  75316. InvertY: boolean;
  75317. /**
  75318. * Invert Y-Axis of referenced textures on load
  75319. */
  75320. InvertTextureY: boolean;
  75321. /**
  75322. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75323. */
  75324. ImportVertexColors: boolean;
  75325. /**
  75326. * Compute the normals for the model, even if normals are present in the file.
  75327. */
  75328. ComputeNormals: boolean;
  75329. /**
  75330. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75331. */
  75332. SkipMaterials: boolean;
  75333. /**
  75334. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75335. */
  75336. MaterialLoadingFailsSilently: boolean;
  75337. };
  75338. /**
  75339. * OBJ file type loader.
  75340. * This is a babylon scene loader plugin.
  75341. */
  75342. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75343. /**
  75344. * Defines if UVs are optimized by default during load.
  75345. */
  75346. static OPTIMIZE_WITH_UV: boolean;
  75347. /**
  75348. * Invert model on y-axis (does a model scaling inversion)
  75349. */
  75350. static INVERT_Y: boolean;
  75351. /**
  75352. * Invert Y-Axis of referenced textures on load
  75353. */
  75354. static get INVERT_TEXTURE_Y(): boolean;
  75355. static set INVERT_TEXTURE_Y(value: boolean);
  75356. /**
  75357. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75358. */
  75359. static IMPORT_VERTEX_COLORS: boolean;
  75360. /**
  75361. * Compute the normals for the model, even if normals are present in the file.
  75362. */
  75363. static COMPUTE_NORMALS: boolean;
  75364. /**
  75365. * Defines custom scaling of UV coordinates of loaded meshes.
  75366. */
  75367. static UV_SCALING: Vector2;
  75368. /**
  75369. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75370. */
  75371. static SKIP_MATERIALS: boolean;
  75372. /**
  75373. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75374. *
  75375. * Defaults to true for backwards compatibility.
  75376. */
  75377. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  75378. /**
  75379. * Defines the name of the plugin.
  75380. */
  75381. name: string;
  75382. /**
  75383. * Defines the extension the plugin is able to load.
  75384. */
  75385. extensions: string;
  75386. /** @hidden */
  75387. obj: RegExp;
  75388. /** @hidden */
  75389. group: RegExp;
  75390. /** @hidden */
  75391. mtllib: RegExp;
  75392. /** @hidden */
  75393. usemtl: RegExp;
  75394. /** @hidden */
  75395. smooth: RegExp;
  75396. /** @hidden */
  75397. vertexPattern: RegExp;
  75398. /** @hidden */
  75399. normalPattern: RegExp;
  75400. /** @hidden */
  75401. uvPattern: RegExp;
  75402. /** @hidden */
  75403. facePattern1: RegExp;
  75404. /** @hidden */
  75405. facePattern2: RegExp;
  75406. /** @hidden */
  75407. facePattern3: RegExp;
  75408. /** @hidden */
  75409. facePattern4: RegExp;
  75410. /** @hidden */
  75411. facePattern5: RegExp;
  75412. private _meshLoadOptions;
  75413. /**
  75414. * Creates loader for .OBJ files
  75415. *
  75416. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  75417. */
  75418. constructor(meshLoadOptions?: MeshLoadOptions);
  75419. private static get currentMeshLoadOptions();
  75420. /**
  75421. * Calls synchronously the MTL file attached to this obj.
  75422. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  75423. * Without this function materials are not displayed in the first frame (but displayed after).
  75424. * In consequence it is impossible to get material information in your HTML file
  75425. *
  75426. * @param url The URL of the MTL file
  75427. * @param rootUrl
  75428. * @param onSuccess Callback function to be called when the MTL file is loaded
  75429. * @private
  75430. */
  75431. private _loadMTL;
  75432. /**
  75433. * Instantiates a OBJ file loader plugin.
  75434. * @returns the created plugin
  75435. */
  75436. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  75437. /**
  75438. * If the data string can be loaded directly.
  75439. *
  75440. * @param data string containing the file data
  75441. * @returns if the data can be loaded directly
  75442. */
  75443. canDirectLoad(data: string): boolean;
  75444. /**
  75445. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  75446. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75447. * @param scene the scene the meshes should be added to
  75448. * @param data the OBJ data to load
  75449. * @param rootUrl root url to load from
  75450. * @param onProgress event that fires when loading progress has occured
  75451. * @param fileName Defines the name of the file to load
  75452. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75453. */
  75454. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75455. meshes: AbstractMesh[];
  75456. particleSystems: IParticleSystem[];
  75457. skeletons: Skeleton[];
  75458. animationGroups: AnimationGroup[];
  75459. }>;
  75460. /**
  75461. * Imports all objects from the loaded OBJ data and adds them to the scene
  75462. * @param scene the scene the objects should be added to
  75463. * @param data the OBJ data to load
  75464. * @param rootUrl root url to load from
  75465. * @param onProgress event that fires when loading progress has occured
  75466. * @param fileName Defines the name of the file to load
  75467. * @returns a promise which completes when objects have been loaded to the scene
  75468. */
  75469. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75470. /**
  75471. * Load into an asset container.
  75472. * @param scene The scene to load into
  75473. * @param data The data to import
  75474. * @param rootUrl The root url for scene and resources
  75475. * @param onProgress The callback when the load progresses
  75476. * @param fileName Defines the name of the file to load
  75477. * @returns The loaded asset container
  75478. */
  75479. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75480. /**
  75481. * Read the OBJ file and create an Array of meshes.
  75482. * Each mesh contains all information given by the OBJ and the MTL file.
  75483. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  75484. *
  75485. * @param meshesNames
  75486. * @param scene Scene The scene where are displayed the data
  75487. * @param data String The content of the obj file
  75488. * @param rootUrl String The path to the folder
  75489. * @returns Array<AbstractMesh>
  75490. * @private
  75491. */
  75492. private _parseSolid;
  75493. }
  75494. }
  75495. declare module BABYLON {
  75496. /**
  75497. * STL file type loader.
  75498. * This is a babylon scene loader plugin.
  75499. */
  75500. export class STLFileLoader implements ISceneLoaderPlugin {
  75501. /** @hidden */
  75502. solidPattern: RegExp;
  75503. /** @hidden */
  75504. facetsPattern: RegExp;
  75505. /** @hidden */
  75506. normalPattern: RegExp;
  75507. /** @hidden */
  75508. vertexPattern: RegExp;
  75509. /**
  75510. * Defines the name of the plugin.
  75511. */
  75512. name: string;
  75513. /**
  75514. * Defines the extensions the stl loader is able to load.
  75515. * force data to come in as an ArrayBuffer
  75516. * we'll convert to string if it looks like it's an ASCII .stl
  75517. */
  75518. extensions: ISceneLoaderPluginExtensions;
  75519. /**
  75520. * Import meshes into a scene.
  75521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  75522. * @param scene The scene to import into
  75523. * @param data The data to import
  75524. * @param rootUrl The root url for scene and resources
  75525. * @param meshes The meshes array to import into
  75526. * @param particleSystems The particle systems array to import into
  75527. * @param skeletons The skeletons array to import into
  75528. * @param onError The callback when import fails
  75529. * @returns True if successful or false otherwise
  75530. */
  75531. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  75532. /**
  75533. * Load into a scene.
  75534. * @param scene The scene to load into
  75535. * @param data The data to import
  75536. * @param rootUrl The root url for scene and resources
  75537. * @param onError The callback when import fails
  75538. * @returns true if successful or false otherwise
  75539. */
  75540. load(scene: Scene, data: any, rootUrl: string): boolean;
  75541. /**
  75542. * Load into an asset container.
  75543. * @param scene The scene to load into
  75544. * @param data The data to import
  75545. * @param rootUrl The root url for scene and resources
  75546. * @param onError The callback when import fails
  75547. * @returns The loaded asset container
  75548. */
  75549. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  75550. private _isBinary;
  75551. private _parseBinary;
  75552. private _parseASCII;
  75553. }
  75554. }
  75555. declare module BABYLON {
  75556. /**
  75557. * Class for generating OBJ data from a Babylon scene.
  75558. */
  75559. export class OBJExport {
  75560. /**
  75561. * Exports the geometry of a Mesh array in .OBJ file format (text)
  75562. * @param mesh defines the list of meshes to serialize
  75563. * @param materials defines if materials should be exported
  75564. * @param matlibname defines the name of the associated mtl file
  75565. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  75566. * @returns the OBJ content
  75567. */
  75568. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  75569. /**
  75570. * Exports the material(s) of a mesh in .MTL file format (text)
  75571. * @param mesh defines the mesh to extract the material from
  75572. * @returns the mtl content
  75573. */
  75574. static MTL(mesh: Mesh): string;
  75575. }
  75576. }
  75577. declare module BABYLON {
  75578. /** @hidden */
  75579. export var __IGLTFExporterExtension: number;
  75580. /**
  75581. * Interface for extending the exporter
  75582. * @hidden
  75583. */
  75584. export interface IGLTFExporterExtension {
  75585. /**
  75586. * The name of this extension
  75587. */
  75588. readonly name: string;
  75589. /**
  75590. * Defines whether this extension is enabled
  75591. */
  75592. enabled: boolean;
  75593. /**
  75594. * Defines whether this extension is required
  75595. */
  75596. required: boolean;
  75597. }
  75598. }
  75599. declare module BABYLON.GLTF2.Exporter {
  75600. /** @hidden */
  75601. export var __IGLTFExporterExtensionV2: number;
  75602. /**
  75603. * Interface for a glTF exporter extension
  75604. * @hidden
  75605. */
  75606. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  75607. /**
  75608. * Define this method to modify the default behavior before exporting a texture
  75609. * @param context The context when loading the asset
  75610. * @param babylonTexture The Babylon.js texture
  75611. * @param mimeType The mime-type of the generated image
  75612. * @returns A promise that resolves with the exported texture
  75613. */
  75614. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  75615. /**
  75616. * Define this method to get notified when a texture info is created
  75617. * @param context The context when loading the asset
  75618. * @param textureInfo The glTF texture info
  75619. * @param babylonTexture The Babylon.js texture
  75620. */
  75621. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  75622. /**
  75623. * Define this method to modify the default behavior when exporting texture info
  75624. * @param context The context when loading the asset
  75625. * @param meshPrimitive glTF mesh primitive
  75626. * @param babylonSubMesh Babylon submesh
  75627. * @param binaryWriter glTF serializer binary writer instance
  75628. * @returns nullable IMeshPrimitive promise
  75629. */
  75630. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  75631. /**
  75632. * Define this method to modify the default behavior when exporting a node
  75633. * @param context The context when exporting the node
  75634. * @param node glTF node
  75635. * @param babylonNode BabylonJS node
  75636. * @returns nullable INode promise
  75637. */
  75638. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  75639. /**
  75640. * Define this method to modify the default behavior when exporting a material
  75641. * @param material glTF material
  75642. * @param babylonMaterial BabylonJS material
  75643. * @returns nullable IMaterial promise
  75644. */
  75645. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  75646. /**
  75647. * Define this method to return additional textures to export from a material
  75648. * @param material glTF material
  75649. * @param babylonMaterial BabylonJS material
  75650. * @returns List of textures
  75651. */
  75652. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  75653. /** Gets a boolean indicating that this extension was used */
  75654. wasUsed: boolean;
  75655. /** Gets a boolean indicating that this extension is required for the file to work */
  75656. required: boolean;
  75657. /**
  75658. * Called after the exporter state changes to EXPORTING
  75659. */
  75660. onExporting?(): void;
  75661. }
  75662. }
  75663. declare module BABYLON.GLTF2.Exporter {
  75664. /**
  75665. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  75666. * @hidden
  75667. */
  75668. export class _GLTFMaterialExporter {
  75669. /**
  75670. * Represents the dielectric specular values for R, G and B
  75671. */
  75672. private static readonly _DielectricSpecular;
  75673. /**
  75674. * Allows the maximum specular power to be defined for material calculations
  75675. */
  75676. private static readonly _MaxSpecularPower;
  75677. /**
  75678. * Mapping to store textures
  75679. */
  75680. private _textureMap;
  75681. /**
  75682. * Numeric tolerance value
  75683. */
  75684. private static readonly _Epsilon;
  75685. /**
  75686. * Reference to the glTF Exporter
  75687. */
  75688. private _exporter;
  75689. constructor(exporter: _Exporter);
  75690. /**
  75691. * Specifies if two colors are approximately equal in value
  75692. * @param color1 first color to compare to
  75693. * @param color2 second color to compare to
  75694. * @param epsilon threshold value
  75695. */
  75696. private static FuzzyEquals;
  75697. /**
  75698. * Gets the materials from a Babylon scene and converts them to glTF materials
  75699. * @param scene babylonjs scene
  75700. * @param mimeType texture mime type
  75701. * @param images array of images
  75702. * @param textures array of textures
  75703. * @param materials array of materials
  75704. * @param imageData mapping of texture names to base64 textures
  75705. * @param hasTextureCoords specifies if texture coordinates are present on the material
  75706. */
  75707. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  75708. /**
  75709. * Makes a copy of the glTF material without the texture parameters
  75710. * @param originalMaterial original glTF material
  75711. * @returns glTF material without texture parameters
  75712. */
  75713. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  75714. /**
  75715. * Specifies if the material has any texture parameters present
  75716. * @param material glTF Material
  75717. * @returns boolean specifying if texture parameters are present
  75718. */
  75719. _hasTexturesPresent(material: IMaterial): boolean;
  75720. /**
  75721. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  75722. * @param babylonStandardMaterial
  75723. * @returns glTF Metallic Roughness Material representation
  75724. */
  75725. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  75726. /**
  75727. * Computes the metallic factor
  75728. * @param diffuse diffused value
  75729. * @param specular specular value
  75730. * @param oneMinusSpecularStrength one minus the specular strength
  75731. * @returns metallic value
  75732. */
  75733. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  75734. /**
  75735. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  75736. * @param glTFMaterial glTF material
  75737. * @param babylonMaterial Babylon material
  75738. */
  75739. private static _SetAlphaMode;
  75740. /**
  75741. * Converts a Babylon Standard Material to a glTF Material
  75742. * @param babylonStandardMaterial BJS Standard Material
  75743. * @param mimeType mime type to use for the textures
  75744. * @param images array of glTF image interfaces
  75745. * @param textures array of glTF texture interfaces
  75746. * @param materials array of glTF material interfaces
  75747. * @param imageData map of image file name to data
  75748. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75749. */
  75750. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75751. private _finishMaterial;
  75752. /**
  75753. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75754. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  75755. * @param mimeType mime type to use for the textures
  75756. * @param images array of glTF image interfaces
  75757. * @param textures array of glTF texture interfaces
  75758. * @param materials array of glTF material interfaces
  75759. * @param imageData map of image file name to data
  75760. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75761. */
  75762. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75763. /**
  75764. * Converts an image typed array buffer to a base64 image
  75765. * @param buffer typed array buffer
  75766. * @param width width of the image
  75767. * @param height height of the image
  75768. * @param mimeType mimetype of the image
  75769. * @returns base64 image string
  75770. */
  75771. private _createBase64FromCanvasAsync;
  75772. /**
  75773. * Generates a white texture based on the specified width and height
  75774. * @param width width of the texture in pixels
  75775. * @param height height of the texture in pixels
  75776. * @param scene babylonjs scene
  75777. * @returns white texture
  75778. */
  75779. private _createWhiteTexture;
  75780. /**
  75781. * 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
  75782. * @param texture1 first texture to resize
  75783. * @param texture2 second texture to resize
  75784. * @param scene babylonjs scene
  75785. * @returns resized textures or null
  75786. */
  75787. private _resizeTexturesToSameDimensions;
  75788. /**
  75789. * Converts an array of pixels to a Float32Array
  75790. * Throws an error if the pixel format is not supported
  75791. * @param pixels - array buffer containing pixel values
  75792. * @returns Float32 of pixels
  75793. */
  75794. private _convertPixelArrayToFloat32;
  75795. /**
  75796. * Convert Specular Glossiness Textures to Metallic Roughness
  75797. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  75798. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  75799. * @param diffuseTexture texture used to store diffuse information
  75800. * @param specularGlossinessTexture texture used to store specular and glossiness information
  75801. * @param factors specular glossiness material factors
  75802. * @param mimeType the mime type to use for the texture
  75803. * @returns pbr metallic roughness interface or null
  75804. */
  75805. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  75806. /**
  75807. * Converts specular glossiness material properties to metallic roughness
  75808. * @param specularGlossiness interface with specular glossiness material properties
  75809. * @returns interface with metallic roughness material properties
  75810. */
  75811. private _convertSpecularGlossinessToMetallicRoughness;
  75812. /**
  75813. * Calculates the surface reflectance, independent of lighting conditions
  75814. * @param color Color source to calculate brightness from
  75815. * @returns number representing the perceived brightness, or zero if color is undefined
  75816. */
  75817. private _getPerceivedBrightness;
  75818. /**
  75819. * Returns the maximum color component value
  75820. * @param color
  75821. * @returns maximum color component value, or zero if color is null or undefined
  75822. */
  75823. private _getMaxComponent;
  75824. /**
  75825. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  75826. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75827. * @param mimeType mime type to use for the textures
  75828. * @param images array of glTF image interfaces
  75829. * @param textures array of glTF texture interfaces
  75830. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  75831. * @param imageData map of image file name to data
  75832. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75833. * @returns glTF PBR Metallic Roughness factors
  75834. */
  75835. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  75836. private _getGLTFTextureSampler;
  75837. private _getGLTFTextureWrapMode;
  75838. private _getGLTFTextureWrapModesSampler;
  75839. /**
  75840. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  75841. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75842. * @param mimeType mime type to use for the textures
  75843. * @param images array of glTF image interfaces
  75844. * @param textures array of glTF texture interfaces
  75845. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  75846. * @param imageData map of image file name to data
  75847. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75848. * @returns glTF PBR Metallic Roughness factors
  75849. */
  75850. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  75851. /**
  75852. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75853. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75854. * @param mimeType mime type to use for the textures
  75855. * @param images array of glTF image interfaces
  75856. * @param textures array of glTF texture interfaces
  75857. * @param materials array of glTF material interfaces
  75858. * @param imageData map of image file name to data
  75859. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75860. */
  75861. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75862. private setMetallicRoughnessPbrMaterial;
  75863. private getPixelsFromTexture;
  75864. /**
  75865. * Extracts a texture from a Babylon texture into file data and glTF data
  75866. * @param babylonTexture Babylon texture to extract
  75867. * @param mimeType Mime Type of the babylonTexture
  75868. * @return glTF texture info, or null if the texture format is not supported
  75869. */
  75870. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  75871. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  75872. /**
  75873. * Builds a texture from base64 string
  75874. * @param base64Texture base64 texture string
  75875. * @param baseTextureName Name to use for the texture
  75876. * @param mimeType image mime type for the texture
  75877. * @param images array of images
  75878. * @param textures array of textures
  75879. * @param imageData map of image data
  75880. * @returns glTF texture info, or null if the texture format is not supported
  75881. */
  75882. private _getTextureInfoFromBase64;
  75883. }
  75884. }
  75885. declare module BABYLON {
  75886. /**
  75887. * Class for holding and downloading glTF file data
  75888. */
  75889. export class GLTFData {
  75890. /**
  75891. * Object which contains the file name as the key and its data as the value
  75892. */
  75893. glTFFiles: {
  75894. [fileName: string]: string | Blob;
  75895. };
  75896. /**
  75897. * Initializes the glTF file object
  75898. */
  75899. constructor();
  75900. /**
  75901. * Downloads the glTF data as files based on their names and data
  75902. */
  75903. downloadFiles(): void;
  75904. }
  75905. }
  75906. declare module BABYLON {
  75907. /**
  75908. * Holds a collection of exporter options and parameters
  75909. */
  75910. export interface IExportOptions {
  75911. /**
  75912. * Function which indicates whether a babylon node should be exported or not
  75913. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  75914. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  75915. */
  75916. shouldExportNode?(node: Node): boolean;
  75917. /**
  75918. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  75919. * @param metadata source metadata to read from
  75920. * @returns the data to store to glTF node extras
  75921. */
  75922. metadataSelector?(metadata: any): any;
  75923. /**
  75924. * The sample rate to bake animation curves
  75925. */
  75926. animationSampleRate?: number;
  75927. /**
  75928. * Begin serialization without waiting for the scene to be ready
  75929. */
  75930. exportWithoutWaitingForScene?: boolean;
  75931. }
  75932. /**
  75933. * Class for generating glTF data from a Babylon scene.
  75934. */
  75935. export class GLTF2Export {
  75936. /**
  75937. * Exports the geometry of the scene to .gltf file format asynchronously
  75938. * @param scene Babylon scene with scene hierarchy information
  75939. * @param filePrefix File prefix to use when generating the glTF file
  75940. * @param options Exporter options
  75941. * @returns Returns an object with a .gltf file and associates texture names
  75942. * as keys and their data and paths as values
  75943. */
  75944. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  75945. private static _PreExportAsync;
  75946. private static _PostExportAsync;
  75947. /**
  75948. * Exports the geometry of the scene to .glb file format asychronously
  75949. * @param scene Babylon scene with scene hierarchy information
  75950. * @param filePrefix File prefix to use when generating glb file
  75951. * @param options Exporter options
  75952. * @returns Returns an object with a .glb filename as key and data as value
  75953. */
  75954. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  75955. }
  75956. }
  75957. declare module BABYLON.GLTF2.Exporter {
  75958. /**
  75959. * @hidden
  75960. */
  75961. export class _GLTFUtilities {
  75962. /**
  75963. * Creates a buffer view based on the supplied arguments
  75964. * @param bufferIndex index value of the specified buffer
  75965. * @param byteOffset byte offset value
  75966. * @param byteLength byte length of the bufferView
  75967. * @param byteStride byte distance between conequential elements
  75968. * @param name name of the buffer view
  75969. * @returns bufferView for glTF
  75970. */
  75971. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  75972. /**
  75973. * Creates an accessor based on the supplied arguments
  75974. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  75975. * @param name The name of the accessor
  75976. * @param type The type of the accessor
  75977. * @param componentType The datatype of components in the attribute
  75978. * @param count The number of attributes referenced by this accessor
  75979. * @param byteOffset The offset relative to the start of the bufferView in bytes
  75980. * @param min Minimum value of each component in this attribute
  75981. * @param max Maximum value of each component in this attribute
  75982. * @returns accessor for glTF
  75983. */
  75984. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  75985. /**
  75986. * Calculates the minimum and maximum values of an array of position floats
  75987. * @param positions Positions array of a mesh
  75988. * @param vertexStart Starting vertex offset to calculate min and max values
  75989. * @param vertexCount Number of vertices to check for min and max values
  75990. * @returns min number array and max number array
  75991. */
  75992. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  75993. min: number[];
  75994. max: number[];
  75995. };
  75996. /**
  75997. * Converts a new right-handed Vector3
  75998. * @param vector vector3 array
  75999. * @returns right-handed Vector3
  76000. */
  76001. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76002. /**
  76003. * Converts a Vector3 to right-handed
  76004. * @param vector Vector3 to convert to right-handed
  76005. */
  76006. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76007. /**
  76008. * Converts a three element number array to right-handed
  76009. * @param vector number array to convert to right-handed
  76010. */
  76011. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76012. /**
  76013. * Converts a new right-handed Vector3
  76014. * @param vector vector3 array
  76015. * @returns right-handed Vector3
  76016. */
  76017. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76018. /**
  76019. * Converts a Vector3 to right-handed
  76020. * @param vector Vector3 to convert to right-handed
  76021. */
  76022. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76023. /**
  76024. * Converts a three element number array to right-handed
  76025. * @param vector number array to convert to right-handed
  76026. */
  76027. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76028. /**
  76029. * Converts a Vector4 to right-handed
  76030. * @param vector Vector4 to convert to right-handed
  76031. */
  76032. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76033. /**
  76034. * Converts a Vector4 to right-handed
  76035. * @param vector Vector4 to convert to right-handed
  76036. */
  76037. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76038. /**
  76039. * Converts a Quaternion to right-handed
  76040. * @param quaternion Source quaternion to convert to right-handed
  76041. */
  76042. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76043. /**
  76044. * Converts a Quaternion to right-handed
  76045. * @param quaternion Source quaternion to convert to right-handed
  76046. */
  76047. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76048. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76049. }
  76050. }
  76051. declare module BABYLON.GLTF2.Exporter {
  76052. /**
  76053. * Converts Babylon Scene into glTF 2.0.
  76054. * @hidden
  76055. */
  76056. export class _Exporter {
  76057. /**
  76058. * Stores the glTF to export
  76059. */
  76060. _glTF: IGLTF;
  76061. /**
  76062. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76063. */
  76064. _bufferViews: IBufferView[];
  76065. /**
  76066. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76067. */
  76068. _accessors: IAccessor[];
  76069. /**
  76070. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76071. */
  76072. private _nodes;
  76073. /**
  76074. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76075. */
  76076. private _scenes;
  76077. /**
  76078. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76079. */
  76080. private _meshes;
  76081. /**
  76082. * Stores all the generated material information, which represents the appearance of each primitive
  76083. */
  76084. _materials: IMaterial[];
  76085. _materialMap: {
  76086. [materialID: number]: number;
  76087. };
  76088. /**
  76089. * Stores all the generated texture information, which is referenced by glTF materials
  76090. */
  76091. _textures: ITexture[];
  76092. /**
  76093. * Stores all the generated image information, which is referenced by glTF textures
  76094. */
  76095. _images: IImage[];
  76096. /**
  76097. * Stores all the texture samplers
  76098. */
  76099. _samplers: ISampler[];
  76100. /**
  76101. * Stores all the generated animation samplers, which is referenced by glTF animations
  76102. */
  76103. /**
  76104. * Stores the animations for glTF models
  76105. */
  76106. private _animations;
  76107. /**
  76108. * Stores the total amount of bytes stored in the glTF buffer
  76109. */
  76110. private _totalByteLength;
  76111. /**
  76112. * Stores a reference to the Babylon scene containing the source geometry and material information
  76113. */
  76114. _babylonScene: Scene;
  76115. /**
  76116. * Stores a map of the image data, where the key is the file name and the value
  76117. * is the image data
  76118. */
  76119. _imageData: {
  76120. [fileName: string]: {
  76121. data: Uint8Array;
  76122. mimeType: ImageMimeType;
  76123. };
  76124. };
  76125. /**
  76126. * Stores a map of the unique id of a node to its index in the node array
  76127. */
  76128. private _nodeMap;
  76129. /**
  76130. * Specifies if the Babylon scene should be converted to right-handed on export
  76131. */
  76132. _convertToRightHandedSystem: boolean;
  76133. /**
  76134. * Baked animation sample rate
  76135. */
  76136. private _animationSampleRate;
  76137. private _options;
  76138. private _localEngine;
  76139. _glTFMaterialExporter: _GLTFMaterialExporter;
  76140. private _extensions;
  76141. private static _ExtensionNames;
  76142. private static _ExtensionFactories;
  76143. private _applyExtension;
  76144. private _applyExtensions;
  76145. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76146. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76147. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76148. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76149. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76150. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76151. private _forEachExtensions;
  76152. private _extensionsOnExporting;
  76153. /**
  76154. * Load glTF serializer extensions
  76155. */
  76156. private _loadExtensions;
  76157. /**
  76158. * Creates a glTF Exporter instance, which can accept optional exporter options
  76159. * @param babylonScene Babylon scene object
  76160. * @param options Options to modify the behavior of the exporter
  76161. */
  76162. constructor(babylonScene: Scene, options?: IExportOptions);
  76163. dispose(): void;
  76164. /**
  76165. * Registers a glTF exporter extension
  76166. * @param name Name of the extension to export
  76167. * @param factory The factory function that creates the exporter extension
  76168. */
  76169. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76170. /**
  76171. * Un-registers an exporter extension
  76172. * @param name The name fo the exporter extension
  76173. * @returns A boolean indicating whether the extension has been un-registered
  76174. */
  76175. static UnregisterExtension(name: string): boolean;
  76176. /**
  76177. * Lazy load a local engine
  76178. */
  76179. _getLocalEngine(): Engine;
  76180. private reorderIndicesBasedOnPrimitiveMode;
  76181. /**
  76182. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76183. * clock-wise during export to glTF
  76184. * @param submesh BabylonJS submesh
  76185. * @param primitiveMode Primitive mode of the mesh
  76186. * @param sideOrientation the winding order of the submesh
  76187. * @param vertexBufferKind The type of vertex attribute
  76188. * @param meshAttributeArray The vertex attribute data
  76189. * @param byteOffset The offset to the binary data
  76190. * @param binaryWriter The binary data for the glTF file
  76191. */
  76192. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76193. /**
  76194. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76195. * clock-wise during export to glTF
  76196. * @param submesh BabylonJS submesh
  76197. * @param primitiveMode Primitive mode of the mesh
  76198. * @param sideOrientation the winding order of the submesh
  76199. * @param vertexBufferKind The type of vertex attribute
  76200. * @param meshAttributeArray The vertex attribute data
  76201. * @param byteOffset The offset to the binary data
  76202. * @param binaryWriter The binary data for the glTF file
  76203. */
  76204. private reorderTriangleFillMode;
  76205. /**
  76206. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76207. * clock-wise during export to glTF
  76208. * @param submesh BabylonJS submesh
  76209. * @param primitiveMode Primitive mode of the mesh
  76210. * @param sideOrientation the winding order of the submesh
  76211. * @param vertexBufferKind The type of vertex attribute
  76212. * @param meshAttributeArray The vertex attribute data
  76213. * @param byteOffset The offset to the binary data
  76214. * @param binaryWriter The binary data for the glTF file
  76215. */
  76216. private reorderTriangleStripDrawMode;
  76217. /**
  76218. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  76219. * clock-wise during export to glTF
  76220. * @param submesh BabylonJS submesh
  76221. * @param primitiveMode Primitive mode of the mesh
  76222. * @param sideOrientation the winding order of the submesh
  76223. * @param vertexBufferKind The type of vertex attribute
  76224. * @param meshAttributeArray The vertex attribute data
  76225. * @param byteOffset The offset to the binary data
  76226. * @param binaryWriter The binary data for the glTF file
  76227. */
  76228. private reorderTriangleFanMode;
  76229. /**
  76230. * Writes the vertex attribute data to binary
  76231. * @param vertices The vertices to write to the binary writer
  76232. * @param byteOffset The offset into the binary writer to overwrite binary data
  76233. * @param vertexAttributeKind The vertex attribute type
  76234. * @param meshAttributeArray The vertex attribute data
  76235. * @param binaryWriter The writer containing the binary data
  76236. */
  76237. private writeVertexAttributeData;
  76238. /**
  76239. * Writes mesh attribute data to a data buffer
  76240. * Returns the bytelength of the data
  76241. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  76242. * @param meshAttributeArray Array containing the attribute data
  76243. * @param binaryWriter The buffer to write the binary data to
  76244. * @param indices Used to specify the order of the vertex data
  76245. */
  76246. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  76247. /**
  76248. * Generates glTF json data
  76249. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  76250. * @param glTFPrefix Text to use when prefixing a glTF file
  76251. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  76252. * @returns json data as string
  76253. */
  76254. private generateJSON;
  76255. /**
  76256. * Generates data for .gltf and .bin files based on the glTF prefix string
  76257. * @param glTFPrefix Text to use when prefixing a glTF file
  76258. * @param dispose Dispose the exporter
  76259. * @returns GLTFData with glTF file data
  76260. */
  76261. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76262. /**
  76263. * Creates a binary buffer for glTF
  76264. * @returns array buffer for binary data
  76265. */
  76266. private _generateBinaryAsync;
  76267. /**
  76268. * Pads the number to a multiple of 4
  76269. * @param num number to pad
  76270. * @returns padded number
  76271. */
  76272. private _getPadding;
  76273. /**
  76274. * @hidden
  76275. */
  76276. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76277. /**
  76278. * Sets the TRS for each node
  76279. * @param node glTF Node for storing the transformation data
  76280. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  76281. */
  76282. private setNodeTransformation;
  76283. private getVertexBufferFromMesh;
  76284. /**
  76285. * Creates a bufferview based on the vertices type for the Babylon mesh
  76286. * @param kind Indicates the type of vertices data
  76287. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  76288. * @param binaryWriter The buffer to write the bufferview data to
  76289. */
  76290. private createBufferViewKind;
  76291. /**
  76292. * The primitive mode of the Babylon mesh
  76293. * @param babylonMesh The BabylonJS mesh
  76294. */
  76295. private getMeshPrimitiveMode;
  76296. /**
  76297. * Sets the primitive mode of the glTF mesh primitive
  76298. * @param meshPrimitive glTF mesh primitive
  76299. * @param primitiveMode The primitive mode
  76300. */
  76301. private setPrimitiveMode;
  76302. /**
  76303. * Sets the vertex attribute accessor based of the glTF mesh primitive
  76304. * @param meshPrimitive glTF mesh primitive
  76305. * @param attributeKind vertex attribute
  76306. * @returns boolean specifying if uv coordinates are present
  76307. */
  76308. private setAttributeKind;
  76309. /**
  76310. * Sets data for the primitive attributes of each submesh
  76311. * @param mesh glTF Mesh object to store the primitive attribute information
  76312. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  76313. * @param binaryWriter Buffer to write the attribute data to
  76314. */
  76315. private setPrimitiveAttributesAsync;
  76316. /**
  76317. * Creates a glTF scene based on the array of meshes
  76318. * Returns the the total byte offset
  76319. * @param babylonScene Babylon scene to get the mesh data from
  76320. * @param binaryWriter Buffer to write binary data to
  76321. */
  76322. private createSceneAsync;
  76323. /**
  76324. * Creates a mapping of Node unique id to node index and handles animations
  76325. * @param babylonScene Babylon Scene
  76326. * @param nodes Babylon transform nodes
  76327. * @param binaryWriter Buffer to write binary data to
  76328. * @returns Node mapping of unique id to index
  76329. */
  76330. private createNodeMapAndAnimationsAsync;
  76331. /**
  76332. * Creates a glTF node from a Babylon mesh
  76333. * @param babylonMesh Source Babylon mesh
  76334. * @param binaryWriter Buffer for storing geometry data
  76335. * @returns glTF node
  76336. */
  76337. private createNodeAsync;
  76338. }
  76339. /**
  76340. * @hidden
  76341. *
  76342. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  76343. */
  76344. export class _BinaryWriter {
  76345. /**
  76346. * Array buffer which stores all binary data
  76347. */
  76348. private _arrayBuffer;
  76349. /**
  76350. * View of the array buffer
  76351. */
  76352. private _dataView;
  76353. /**
  76354. * byte offset of data in array buffer
  76355. */
  76356. private _byteOffset;
  76357. /**
  76358. * Initialize binary writer with an initial byte length
  76359. * @param byteLength Initial byte length of the array buffer
  76360. */
  76361. constructor(byteLength: number);
  76362. /**
  76363. * Resize the array buffer to the specified byte length
  76364. * @param byteLength
  76365. */
  76366. private resizeBuffer;
  76367. /**
  76368. * Get an array buffer with the length of the byte offset
  76369. * @returns ArrayBuffer resized to the byte offset
  76370. */
  76371. getArrayBuffer(): ArrayBuffer;
  76372. /**
  76373. * Get the byte offset of the array buffer
  76374. * @returns byte offset
  76375. */
  76376. getByteOffset(): number;
  76377. /**
  76378. * Stores an UInt8 in the array buffer
  76379. * @param entry
  76380. * @param byteOffset If defined, specifies where to set the value as an offset.
  76381. */
  76382. setUInt8(entry: number, byteOffset?: number): void;
  76383. /**
  76384. * Gets an UInt32 in the array buffer
  76385. * @param entry
  76386. * @param byteOffset If defined, specifies where to set the value as an offset.
  76387. */
  76388. getUInt32(byteOffset: number): number;
  76389. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76390. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76391. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76392. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76393. /**
  76394. * Stores a Float32 in the array buffer
  76395. * @param entry
  76396. */
  76397. setFloat32(entry: number, byteOffset?: number): void;
  76398. /**
  76399. * Stores an UInt32 in the array buffer
  76400. * @param entry
  76401. * @param byteOffset If defined, specifies where to set the value as an offset.
  76402. */
  76403. setUInt32(entry: number, byteOffset?: number): void;
  76404. }
  76405. }
  76406. declare module BABYLON.GLTF2.Exporter {
  76407. /**
  76408. * @hidden
  76409. * Interface to store animation data.
  76410. */
  76411. export interface _IAnimationData {
  76412. /**
  76413. * Keyframe data.
  76414. */
  76415. inputs: number[];
  76416. /**
  76417. * Value data.
  76418. */
  76419. outputs: number[][];
  76420. /**
  76421. * Animation interpolation data.
  76422. */
  76423. samplerInterpolation: AnimationSamplerInterpolation;
  76424. /**
  76425. * Minimum keyframe value.
  76426. */
  76427. inputsMin: number;
  76428. /**
  76429. * Maximum keyframe value.
  76430. */
  76431. inputsMax: number;
  76432. }
  76433. /**
  76434. * @hidden
  76435. */
  76436. export interface _IAnimationInfo {
  76437. /**
  76438. * The target channel for the animation
  76439. */
  76440. animationChannelTargetPath: AnimationChannelTargetPath;
  76441. /**
  76442. * The glTF accessor type for the data.
  76443. */
  76444. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  76445. /**
  76446. * Specifies if quaternions should be used.
  76447. */
  76448. useQuaternion: boolean;
  76449. }
  76450. /**
  76451. * @hidden
  76452. * Utility class for generating glTF animation data from BabylonJS.
  76453. */
  76454. export class _GLTFAnimation {
  76455. /**
  76456. * @ignore
  76457. *
  76458. * Creates glTF channel animation from BabylonJS animation.
  76459. * @param babylonTransformNode - BabylonJS mesh.
  76460. * @param animation - animation.
  76461. * @param animationChannelTargetPath - The target animation channel.
  76462. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  76463. * @param useQuaternion - Specifies if quaternions are used.
  76464. * @returns nullable IAnimationData
  76465. */
  76466. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  76467. private static _DeduceAnimationInfo;
  76468. /**
  76469. * @ignore
  76470. * Create node animations from the transform node animations
  76471. * @param babylonNode
  76472. * @param runtimeGLTFAnimation
  76473. * @param idleGLTFAnimations
  76474. * @param nodeMap
  76475. * @param nodes
  76476. * @param binaryWriter
  76477. * @param bufferViews
  76478. * @param accessors
  76479. * @param convertToRightHandedSystem
  76480. */
  76481. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  76482. [key: number]: number;
  76483. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76484. /**
  76485. * @ignore
  76486. * Create node animations from the animation groups
  76487. * @param babylonScene
  76488. * @param glTFAnimations
  76489. * @param nodeMap
  76490. * @param nodes
  76491. * @param binaryWriter
  76492. * @param bufferViews
  76493. * @param accessors
  76494. * @param convertToRightHandedSystem
  76495. */
  76496. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  76497. [key: number]: number;
  76498. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76499. private static AddAnimation;
  76500. /**
  76501. * Create a baked animation
  76502. * @param babylonTransformNode BabylonJS mesh
  76503. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  76504. * @param animationChannelTargetPath animation target channel
  76505. * @param minFrame minimum animation frame
  76506. * @param maxFrame maximum animation frame
  76507. * @param fps frames per second of the animation
  76508. * @param inputs input key frames of the animation
  76509. * @param outputs output key frame data of the animation
  76510. * @param convertToRightHandedSystem converts the values to right-handed
  76511. * @param useQuaternion specifies if quaternions should be used
  76512. */
  76513. private static _CreateBakedAnimation;
  76514. private static _ConvertFactorToVector3OrQuaternion;
  76515. private static _SetInterpolatedValue;
  76516. /**
  76517. * Creates linear animation from the animation key frames
  76518. * @param babylonTransformNode BabylonJS mesh
  76519. * @param animation BabylonJS animation
  76520. * @param animationChannelTargetPath The target animation channel
  76521. * @param frameDelta The difference between the last and first frame of the animation
  76522. * @param inputs Array to store the key frame times
  76523. * @param outputs Array to store the key frame data
  76524. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76525. * @param useQuaternion Specifies if quaternions are used in the animation
  76526. */
  76527. private static _CreateLinearOrStepAnimation;
  76528. /**
  76529. * Creates cubic spline animation from the animation key frames
  76530. * @param babylonTransformNode BabylonJS mesh
  76531. * @param animation BabylonJS animation
  76532. * @param animationChannelTargetPath The target animation channel
  76533. * @param frameDelta The difference between the last and first frame of the animation
  76534. * @param inputs Array to store the key frame times
  76535. * @param outputs Array to store the key frame data
  76536. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76537. * @param useQuaternion Specifies if quaternions are used in the animation
  76538. */
  76539. private static _CreateCubicSplineAnimation;
  76540. private static _GetBasePositionRotationOrScale;
  76541. /**
  76542. * Adds a key frame value
  76543. * @param keyFrame
  76544. * @param animation
  76545. * @param outputs
  76546. * @param animationChannelTargetPath
  76547. * @param basePositionRotationOrScale
  76548. * @param convertToRightHandedSystem
  76549. * @param useQuaternion
  76550. */
  76551. private static _AddKeyframeValue;
  76552. /**
  76553. * Determine the interpolation based on the key frames
  76554. * @param keyFrames
  76555. * @param animationChannelTargetPath
  76556. * @param useQuaternion
  76557. */
  76558. private static _DeduceInterpolation;
  76559. /**
  76560. * Adds an input tangent or output tangent to the output data
  76561. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  76562. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  76563. * @param outputs The animation data by keyframe
  76564. * @param animationChannelTargetPath The target animation channel
  76565. * @param interpolation The interpolation type
  76566. * @param keyFrame The key frame with the animation data
  76567. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  76568. * @param useQuaternion Specifies if quaternions are used
  76569. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  76570. */
  76571. private static AddSplineTangent;
  76572. /**
  76573. * Get the minimum and maximum key frames' frame values
  76574. * @param keyFrames animation key frames
  76575. * @returns the minimum and maximum key frame value
  76576. */
  76577. private static calculateMinMaxKeyFrames;
  76578. }
  76579. }
  76580. declare module BABYLON.GLTF2.Exporter {
  76581. /** @hidden */
  76582. export var textureTransformPixelShader: {
  76583. name: string;
  76584. shader: string;
  76585. };
  76586. }
  76587. declare module BABYLON.GLTF2.Exporter.Extensions {
  76588. /**
  76589. * @hidden
  76590. */
  76591. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  76592. private _recordedTextures;
  76593. /** Name of this extension */
  76594. readonly name: string;
  76595. /** Defines whether this extension is enabled */
  76596. enabled: boolean;
  76597. /** Defines whether this extension is required */
  76598. required: boolean;
  76599. /** Reference to the glTF exporter */
  76600. private _wasUsed;
  76601. constructor(exporter: _Exporter);
  76602. dispose(): void;
  76603. /** @hidden */
  76604. get wasUsed(): boolean;
  76605. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76606. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76607. /**
  76608. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  76609. * @param babylonTexture
  76610. * @param offset
  76611. * @param rotation
  76612. * @param scale
  76613. * @param scene
  76614. */
  76615. private _textureTransformTextureAsync;
  76616. }
  76617. }
  76618. declare module BABYLON.GLTF2.Exporter.Extensions {
  76619. /**
  76620. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  76621. */
  76622. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  76623. /** The name of this extension. */
  76624. readonly name: string;
  76625. /** Defines whether this extension is enabled. */
  76626. enabled: boolean;
  76627. /** Defines whether this extension is required */
  76628. required: boolean;
  76629. /** Reference to the glTF exporter */
  76630. private _exporter;
  76631. private _lights;
  76632. /** @hidden */
  76633. constructor(exporter: _Exporter);
  76634. /** @hidden */
  76635. dispose(): void;
  76636. /** @hidden */
  76637. get wasUsed(): boolean;
  76638. /** @hidden */
  76639. onExporting(): void;
  76640. /**
  76641. * Define this method to modify the default behavior when exporting a node
  76642. * @param context The context when exporting the node
  76643. * @param node glTF node
  76644. * @param babylonNode BabylonJS node
  76645. * @returns nullable INode promise
  76646. */
  76647. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76648. }
  76649. }
  76650. declare module BABYLON.GLTF2.Exporter.Extensions {
  76651. /**
  76652. * @hidden
  76653. */
  76654. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  76655. /** Name of this extension */
  76656. readonly name: string;
  76657. /** Defines whether this extension is enabled */
  76658. enabled: boolean;
  76659. /** Defines whether this extension is required */
  76660. required: boolean;
  76661. /** Reference to the glTF exporter */
  76662. private _textureInfos;
  76663. private _exportedTextures;
  76664. private _wasUsed;
  76665. constructor(exporter: _Exporter);
  76666. dispose(): void;
  76667. /** @hidden */
  76668. get wasUsed(): boolean;
  76669. private _getTextureIndex;
  76670. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76671. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76672. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76673. }
  76674. }
  76675. declare module BABYLON {
  76676. /**
  76677. * Class for generating STL data from a Babylon scene.
  76678. */
  76679. export class STLExport {
  76680. /**
  76681. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  76682. * @param meshes list defines the mesh to serialize
  76683. * @param download triggers the automatic download of the file.
  76684. * @param fileName changes the downloads fileName.
  76685. * @param binary changes the STL to a binary type.
  76686. * @param isLittleEndian toggle for binary type exporter.
  76687. * @returns the STL as UTF8 string
  76688. */
  76689. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  76690. }
  76691. }
  76692. declare module "babylonjs-gltf2interface" {
  76693. export = BABYLON.GLTF2;
  76694. }
  76695. /**
  76696. * Module for glTF 2.0 Interface
  76697. */
  76698. declare module BABYLON.GLTF2 {
  76699. /**
  76700. * The datatype of the components in the attribute
  76701. */
  76702. const enum AccessorComponentType {
  76703. /**
  76704. * Byte
  76705. */
  76706. BYTE = 5120,
  76707. /**
  76708. * Unsigned Byte
  76709. */
  76710. UNSIGNED_BYTE = 5121,
  76711. /**
  76712. * Short
  76713. */
  76714. SHORT = 5122,
  76715. /**
  76716. * Unsigned Short
  76717. */
  76718. UNSIGNED_SHORT = 5123,
  76719. /**
  76720. * Unsigned Int
  76721. */
  76722. UNSIGNED_INT = 5125,
  76723. /**
  76724. * Float
  76725. */
  76726. FLOAT = 5126,
  76727. }
  76728. /**
  76729. * Specifies if the attirbute is a scalar, vector, or matrix
  76730. */
  76731. const enum AccessorType {
  76732. /**
  76733. * Scalar
  76734. */
  76735. SCALAR = "SCALAR",
  76736. /**
  76737. * Vector2
  76738. */
  76739. VEC2 = "VEC2",
  76740. /**
  76741. * Vector3
  76742. */
  76743. VEC3 = "VEC3",
  76744. /**
  76745. * Vector4
  76746. */
  76747. VEC4 = "VEC4",
  76748. /**
  76749. * Matrix2x2
  76750. */
  76751. MAT2 = "MAT2",
  76752. /**
  76753. * Matrix3x3
  76754. */
  76755. MAT3 = "MAT3",
  76756. /**
  76757. * Matrix4x4
  76758. */
  76759. MAT4 = "MAT4",
  76760. }
  76761. /**
  76762. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  76763. */
  76764. const enum AnimationChannelTargetPath {
  76765. /**
  76766. * Translation
  76767. */
  76768. TRANSLATION = "translation",
  76769. /**
  76770. * Rotation
  76771. */
  76772. ROTATION = "rotation",
  76773. /**
  76774. * Scale
  76775. */
  76776. SCALE = "scale",
  76777. /**
  76778. * Weights
  76779. */
  76780. WEIGHTS = "weights",
  76781. }
  76782. /**
  76783. * Interpolation algorithm
  76784. */
  76785. const enum AnimationSamplerInterpolation {
  76786. /**
  76787. * The animated values are linearly interpolated between keyframes
  76788. */
  76789. LINEAR = "LINEAR",
  76790. /**
  76791. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  76792. */
  76793. STEP = "STEP",
  76794. /**
  76795. * The animation's interpolation is computed using a cubic spline with specified tangents
  76796. */
  76797. CUBICSPLINE = "CUBICSPLINE",
  76798. }
  76799. /**
  76800. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  76801. */
  76802. const enum CameraType {
  76803. /**
  76804. * A perspective camera containing properties to create a perspective projection matrix
  76805. */
  76806. PERSPECTIVE = "perspective",
  76807. /**
  76808. * An orthographic camera containing properties to create an orthographic projection matrix
  76809. */
  76810. ORTHOGRAPHIC = "orthographic",
  76811. }
  76812. /**
  76813. * The mime-type of the image
  76814. */
  76815. const enum ImageMimeType {
  76816. /**
  76817. * JPEG Mime-type
  76818. */
  76819. JPEG = "image/jpeg",
  76820. /**
  76821. * PNG Mime-type
  76822. */
  76823. PNG = "image/png",
  76824. }
  76825. /**
  76826. * The alpha rendering mode of the material
  76827. */
  76828. const enum MaterialAlphaMode {
  76829. /**
  76830. * The alpha value is ignored and the rendered output is fully opaque
  76831. */
  76832. OPAQUE = "OPAQUE",
  76833. /**
  76834. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  76835. */
  76836. MASK = "MASK",
  76837. /**
  76838. * 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)
  76839. */
  76840. BLEND = "BLEND",
  76841. }
  76842. /**
  76843. * The type of the primitives to render
  76844. */
  76845. const enum MeshPrimitiveMode {
  76846. /**
  76847. * Points
  76848. */
  76849. POINTS = 0,
  76850. /**
  76851. * Lines
  76852. */
  76853. LINES = 1,
  76854. /**
  76855. * Line Loop
  76856. */
  76857. LINE_LOOP = 2,
  76858. /**
  76859. * Line Strip
  76860. */
  76861. LINE_STRIP = 3,
  76862. /**
  76863. * Triangles
  76864. */
  76865. TRIANGLES = 4,
  76866. /**
  76867. * Triangle Strip
  76868. */
  76869. TRIANGLE_STRIP = 5,
  76870. /**
  76871. * Triangle Fan
  76872. */
  76873. TRIANGLE_FAN = 6,
  76874. }
  76875. /**
  76876. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  76877. */
  76878. const enum TextureMagFilter {
  76879. /**
  76880. * Nearest
  76881. */
  76882. NEAREST = 9728,
  76883. /**
  76884. * Linear
  76885. */
  76886. LINEAR = 9729,
  76887. }
  76888. /**
  76889. * Minification filter. All valid values correspond to WebGL enums
  76890. */
  76891. const enum TextureMinFilter {
  76892. /**
  76893. * Nearest
  76894. */
  76895. NEAREST = 9728,
  76896. /**
  76897. * Linear
  76898. */
  76899. LINEAR = 9729,
  76900. /**
  76901. * Nearest Mip-Map Nearest
  76902. */
  76903. NEAREST_MIPMAP_NEAREST = 9984,
  76904. /**
  76905. * Linear Mipmap Nearest
  76906. */
  76907. LINEAR_MIPMAP_NEAREST = 9985,
  76908. /**
  76909. * Nearest Mipmap Linear
  76910. */
  76911. NEAREST_MIPMAP_LINEAR = 9986,
  76912. /**
  76913. * Linear Mipmap Linear
  76914. */
  76915. LINEAR_MIPMAP_LINEAR = 9987,
  76916. }
  76917. /**
  76918. * S (U) wrapping mode. All valid values correspond to WebGL enums
  76919. */
  76920. const enum TextureWrapMode {
  76921. /**
  76922. * Clamp to Edge
  76923. */
  76924. CLAMP_TO_EDGE = 33071,
  76925. /**
  76926. * Mirrored Repeat
  76927. */
  76928. MIRRORED_REPEAT = 33648,
  76929. /**
  76930. * Repeat
  76931. */
  76932. REPEAT = 10497,
  76933. }
  76934. /**
  76935. * glTF Property
  76936. */
  76937. interface IProperty {
  76938. /**
  76939. * Dictionary object with extension-specific objects
  76940. */
  76941. extensions?: {
  76942. [key: string]: any;
  76943. };
  76944. /**
  76945. * Application-Specific data
  76946. */
  76947. extras?: any;
  76948. }
  76949. /**
  76950. * glTF Child of Root Property
  76951. */
  76952. interface IChildRootProperty extends IProperty {
  76953. /**
  76954. * The user-defined name of this object
  76955. */
  76956. name?: string;
  76957. }
  76958. /**
  76959. * Indices of those attributes that deviate from their initialization value
  76960. */
  76961. interface IAccessorSparseIndices extends IProperty {
  76962. /**
  76963. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  76964. */
  76965. bufferView: number;
  76966. /**
  76967. * The offset relative to the start of the bufferView in bytes. Must be aligned
  76968. */
  76969. byteOffset?: number;
  76970. /**
  76971. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  76972. */
  76973. componentType: AccessorComponentType;
  76974. }
  76975. /**
  76976. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  76977. */
  76978. interface IAccessorSparseValues extends IProperty {
  76979. /**
  76980. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  76981. */
  76982. bufferView: number;
  76983. /**
  76984. * The offset relative to the start of the bufferView in bytes. Must be aligned
  76985. */
  76986. byteOffset?: number;
  76987. }
  76988. /**
  76989. * Sparse storage of attributes that deviate from their initialization value
  76990. */
  76991. interface IAccessorSparse extends IProperty {
  76992. /**
  76993. * The number of attributes encoded in this sparse accessor
  76994. */
  76995. count: number;
  76996. /**
  76997. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  76998. */
  76999. indices: IAccessorSparseIndices;
  77000. /**
  77001. * 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
  77002. */
  77003. values: IAccessorSparseValues;
  77004. }
  77005. /**
  77006. * 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
  77007. */
  77008. interface IAccessor extends IChildRootProperty {
  77009. /**
  77010. * The index of the bufferview
  77011. */
  77012. bufferView?: number;
  77013. /**
  77014. * The offset relative to the start of the bufferView in bytes
  77015. */
  77016. byteOffset?: number;
  77017. /**
  77018. * The datatype of components in the attribute
  77019. */
  77020. componentType: AccessorComponentType;
  77021. /**
  77022. * Specifies whether integer data values should be normalized
  77023. */
  77024. normalized?: boolean;
  77025. /**
  77026. * The number of attributes referenced by this accessor
  77027. */
  77028. count: number;
  77029. /**
  77030. * Specifies if the attribute is a scalar, vector, or matrix
  77031. */
  77032. type: AccessorType;
  77033. /**
  77034. * Maximum value of each component in this attribute
  77035. */
  77036. max?: number[];
  77037. /**
  77038. * Minimum value of each component in this attribute
  77039. */
  77040. min?: number[];
  77041. /**
  77042. * Sparse storage of attributes that deviate from their initialization value
  77043. */
  77044. sparse?: IAccessorSparse;
  77045. }
  77046. /**
  77047. * Targets an animation's sampler at a node's property
  77048. */
  77049. interface IAnimationChannel extends IProperty {
  77050. /**
  77051. * The index of a sampler in this animation used to compute the value for the target
  77052. */
  77053. sampler: number;
  77054. /**
  77055. * The index of the node and TRS property to target
  77056. */
  77057. target: IAnimationChannelTarget;
  77058. }
  77059. /**
  77060. * The index of the node and TRS property that an animation channel targets
  77061. */
  77062. interface IAnimationChannelTarget extends IProperty {
  77063. /**
  77064. * The index of the node to target
  77065. */
  77066. node: number;
  77067. /**
  77068. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77069. */
  77070. path: AnimationChannelTargetPath;
  77071. }
  77072. /**
  77073. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77074. */
  77075. interface IAnimationSampler extends IProperty {
  77076. /**
  77077. * The index of an accessor containing keyframe input values, e.g., time
  77078. */
  77079. input: number;
  77080. /**
  77081. * Interpolation algorithm
  77082. */
  77083. interpolation?: AnimationSamplerInterpolation;
  77084. /**
  77085. * The index of an accessor, containing keyframe output values
  77086. */
  77087. output: number;
  77088. }
  77089. /**
  77090. * A keyframe animation
  77091. */
  77092. interface IAnimation extends IChildRootProperty {
  77093. /**
  77094. * An array of channels, each of which targets an animation's sampler at a node's property
  77095. */
  77096. channels: IAnimationChannel[];
  77097. /**
  77098. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77099. */
  77100. samplers: IAnimationSampler[];
  77101. }
  77102. /**
  77103. * Metadata about the glTF asset
  77104. */
  77105. interface IAsset extends IChildRootProperty {
  77106. /**
  77107. * A copyright message suitable for display to credit the content creator
  77108. */
  77109. copyright?: string;
  77110. /**
  77111. * Tool that generated this glTF model. Useful for debugging
  77112. */
  77113. generator?: string;
  77114. /**
  77115. * The glTF version that this asset targets
  77116. */
  77117. version: string;
  77118. /**
  77119. * The minimum glTF version that this asset targets
  77120. */
  77121. minVersion?: string;
  77122. }
  77123. /**
  77124. * A buffer points to binary geometry, animation, or skins
  77125. */
  77126. interface IBuffer extends IChildRootProperty {
  77127. /**
  77128. * 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
  77129. */
  77130. uri?: string;
  77131. /**
  77132. * The length of the buffer in bytes
  77133. */
  77134. byteLength: number;
  77135. }
  77136. /**
  77137. * A view into a buffer generally representing a subset of the buffer
  77138. */
  77139. interface IBufferView extends IChildRootProperty {
  77140. /**
  77141. * The index of the buffer
  77142. */
  77143. buffer: number;
  77144. /**
  77145. * The offset into the buffer in bytes
  77146. */
  77147. byteOffset?: number;
  77148. /**
  77149. * The lenth of the bufferView in bytes
  77150. */
  77151. byteLength: number;
  77152. /**
  77153. * The stride, in bytes
  77154. */
  77155. byteStride?: number;
  77156. }
  77157. /**
  77158. * An orthographic camera containing properties to create an orthographic projection matrix
  77159. */
  77160. interface ICameraOrthographic extends IProperty {
  77161. /**
  77162. * The floating-point horizontal magnification of the view. Must not be zero
  77163. */
  77164. xmag: number;
  77165. /**
  77166. * The floating-point vertical magnification of the view. Must not be zero
  77167. */
  77168. ymag: number;
  77169. /**
  77170. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77171. */
  77172. zfar: number;
  77173. /**
  77174. * The floating-point distance to the near clipping plane
  77175. */
  77176. znear: number;
  77177. }
  77178. /**
  77179. * A perspective camera containing properties to create a perspective projection matrix
  77180. */
  77181. interface ICameraPerspective extends IProperty {
  77182. /**
  77183. * The floating-point aspect ratio of the field of view
  77184. */
  77185. aspectRatio?: number;
  77186. /**
  77187. * The floating-point vertical field of view in radians
  77188. */
  77189. yfov: number;
  77190. /**
  77191. * The floating-point distance to the far clipping plane
  77192. */
  77193. zfar?: number;
  77194. /**
  77195. * The floating-point distance to the near clipping plane
  77196. */
  77197. znear: number;
  77198. }
  77199. /**
  77200. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77201. */
  77202. interface ICamera extends IChildRootProperty {
  77203. /**
  77204. * An orthographic camera containing properties to create an orthographic projection matrix
  77205. */
  77206. orthographic?: ICameraOrthographic;
  77207. /**
  77208. * A perspective camera containing properties to create a perspective projection matrix
  77209. */
  77210. perspective?: ICameraPerspective;
  77211. /**
  77212. * Specifies if the camera uses a perspective or orthographic projection
  77213. */
  77214. type: CameraType;
  77215. }
  77216. /**
  77217. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  77218. */
  77219. interface IImage extends IChildRootProperty {
  77220. /**
  77221. * 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
  77222. */
  77223. uri?: string;
  77224. /**
  77225. * The image's MIME type
  77226. */
  77227. mimeType?: ImageMimeType;
  77228. /**
  77229. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  77230. */
  77231. bufferView?: number;
  77232. }
  77233. /**
  77234. * Material Normal Texture Info
  77235. */
  77236. interface IMaterialNormalTextureInfo extends ITextureInfo {
  77237. /**
  77238. * The scalar multiplier applied to each normal vector of the normal texture
  77239. */
  77240. scale?: number;
  77241. }
  77242. /**
  77243. * Material Occlusion Texture Info
  77244. */
  77245. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  77246. /**
  77247. * A scalar multiplier controlling the amount of occlusion applied
  77248. */
  77249. strength?: number;
  77250. }
  77251. /**
  77252. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  77253. */
  77254. interface IMaterialPbrMetallicRoughness {
  77255. /**
  77256. * The material's base color factor
  77257. */
  77258. baseColorFactor?: number[];
  77259. /**
  77260. * The base color texture
  77261. */
  77262. baseColorTexture?: ITextureInfo;
  77263. /**
  77264. * The metalness of the material
  77265. */
  77266. metallicFactor?: number;
  77267. /**
  77268. * The roughness of the material
  77269. */
  77270. roughnessFactor?: number;
  77271. /**
  77272. * The metallic-roughness texture
  77273. */
  77274. metallicRoughnessTexture?: ITextureInfo;
  77275. }
  77276. /**
  77277. * The material appearance of a primitive
  77278. */
  77279. interface IMaterial extends IChildRootProperty {
  77280. /**
  77281. * 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
  77282. */
  77283. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77284. /**
  77285. * The normal map texture
  77286. */
  77287. normalTexture?: IMaterialNormalTextureInfo;
  77288. /**
  77289. * The occlusion map texture
  77290. */
  77291. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77292. /**
  77293. * The emissive map texture
  77294. */
  77295. emissiveTexture?: ITextureInfo;
  77296. /**
  77297. * 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
  77298. */
  77299. emissiveFactor?: number[];
  77300. /**
  77301. * The alpha rendering mode of the material
  77302. */
  77303. alphaMode?: MaterialAlphaMode;
  77304. /**
  77305. * The alpha cutoff value of the material
  77306. */
  77307. alphaCutoff?: number;
  77308. /**
  77309. * Specifies whether the material is double sided
  77310. */
  77311. doubleSided?: boolean;
  77312. }
  77313. /**
  77314. * Geometry to be rendered with the given material
  77315. */
  77316. interface IMeshPrimitive extends IProperty {
  77317. /**
  77318. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  77319. */
  77320. attributes: {
  77321. [name: string]: number;
  77322. };
  77323. /**
  77324. * The index of the accessor that contains the indices
  77325. */
  77326. indices?: number;
  77327. /**
  77328. * The index of the material to apply to this primitive when rendering
  77329. */
  77330. material?: number;
  77331. /**
  77332. * The type of primitives to render. All valid values correspond to WebGL enums
  77333. */
  77334. mode?: MeshPrimitiveMode;
  77335. /**
  77336. * 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
  77337. */
  77338. targets?: {
  77339. [name: string]: number;
  77340. }[];
  77341. }
  77342. /**
  77343. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  77344. */
  77345. interface IMesh extends IChildRootProperty {
  77346. /**
  77347. * An array of primitives, each defining geometry to be rendered with a material
  77348. */
  77349. primitives: IMeshPrimitive[];
  77350. /**
  77351. * Array of weights to be applied to the Morph Targets
  77352. */
  77353. weights?: number[];
  77354. }
  77355. /**
  77356. * A node in the node hierarchy
  77357. */
  77358. interface INode extends IChildRootProperty {
  77359. /**
  77360. * The index of the camera referenced by this node
  77361. */
  77362. camera?: number;
  77363. /**
  77364. * The indices of this node's children
  77365. */
  77366. children?: number[];
  77367. /**
  77368. * The index of the skin referenced by this node
  77369. */
  77370. skin?: number;
  77371. /**
  77372. * A floating-point 4x4 transformation matrix stored in column-major order
  77373. */
  77374. matrix?: number[];
  77375. /**
  77376. * The index of the mesh in this node
  77377. */
  77378. mesh?: number;
  77379. /**
  77380. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  77381. */
  77382. rotation?: number[];
  77383. /**
  77384. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  77385. */
  77386. scale?: number[];
  77387. /**
  77388. * The node's translation along the x, y, and z axes
  77389. */
  77390. translation?: number[];
  77391. /**
  77392. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  77393. */
  77394. weights?: number[];
  77395. }
  77396. /**
  77397. * Texture sampler properties for filtering and wrapping modes
  77398. */
  77399. interface ISampler extends IChildRootProperty {
  77400. /**
  77401. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77402. */
  77403. magFilter?: TextureMagFilter;
  77404. /**
  77405. * Minification filter. All valid values correspond to WebGL enums
  77406. */
  77407. minFilter?: TextureMinFilter;
  77408. /**
  77409. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77410. */
  77411. wrapS?: TextureWrapMode;
  77412. /**
  77413. * T (V) wrapping mode. All valid values correspond to WebGL enums
  77414. */
  77415. wrapT?: TextureWrapMode;
  77416. }
  77417. /**
  77418. * The root nodes of a scene
  77419. */
  77420. interface IScene extends IChildRootProperty {
  77421. /**
  77422. * The indices of each root node
  77423. */
  77424. nodes: number[];
  77425. }
  77426. /**
  77427. * Joints and matrices defining a skin
  77428. */
  77429. interface ISkin extends IChildRootProperty {
  77430. /**
  77431. * 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
  77432. */
  77433. inverseBindMatrices?: number;
  77434. /**
  77435. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  77436. */
  77437. skeleton?: number;
  77438. /**
  77439. * 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)
  77440. */
  77441. joints: number[];
  77442. }
  77443. /**
  77444. * A texture and its sampler
  77445. */
  77446. interface ITexture extends IChildRootProperty {
  77447. /**
  77448. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  77449. */
  77450. sampler?: number;
  77451. /**
  77452. * The index of the image used by this texture
  77453. */
  77454. source: number;
  77455. }
  77456. /**
  77457. * Reference to a texture
  77458. */
  77459. interface ITextureInfo extends IProperty {
  77460. /**
  77461. * The index of the texture
  77462. */
  77463. index: number;
  77464. /**
  77465. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  77466. */
  77467. texCoord?: number;
  77468. }
  77469. /**
  77470. * The root object for a glTF asset
  77471. */
  77472. interface IGLTF extends IProperty {
  77473. /**
  77474. * An array of accessors. An accessor is a typed view into a bufferView
  77475. */
  77476. accessors?: IAccessor[];
  77477. /**
  77478. * An array of keyframe animations
  77479. */
  77480. animations?: IAnimation[];
  77481. /**
  77482. * Metadata about the glTF asset
  77483. */
  77484. asset: IAsset;
  77485. /**
  77486. * An array of buffers. A buffer points to binary geometry, animation, or skins
  77487. */
  77488. buffers?: IBuffer[];
  77489. /**
  77490. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  77491. */
  77492. bufferViews?: IBufferView[];
  77493. /**
  77494. * An array of cameras
  77495. */
  77496. cameras?: ICamera[];
  77497. /**
  77498. * Names of glTF extensions used somewhere in this asset
  77499. */
  77500. extensionsUsed?: string[];
  77501. /**
  77502. * Names of glTF extensions required to properly load this asset
  77503. */
  77504. extensionsRequired?: string[];
  77505. /**
  77506. * An array of images. An image defines data used to create a texture
  77507. */
  77508. images?: IImage[];
  77509. /**
  77510. * An array of materials. A material defines the appearance of a primitive
  77511. */
  77512. materials?: IMaterial[];
  77513. /**
  77514. * An array of meshes. A mesh is a set of primitives to be rendered
  77515. */
  77516. meshes?: IMesh[];
  77517. /**
  77518. * An array of nodes
  77519. */
  77520. nodes?: INode[];
  77521. /**
  77522. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  77523. */
  77524. samplers?: ISampler[];
  77525. /**
  77526. * The index of the default scene
  77527. */
  77528. scene?: number;
  77529. /**
  77530. * An array of scenes
  77531. */
  77532. scenes?: IScene[];
  77533. /**
  77534. * An array of skins. A skin is defined by joints and matrices
  77535. */
  77536. skins?: ISkin[];
  77537. /**
  77538. * An array of textures
  77539. */
  77540. textures?: ITexture[];
  77541. }
  77542. /**
  77543. * The glTF validation results
  77544. * @ignore
  77545. */
  77546. interface IGLTFValidationResults {
  77547. info: {
  77548. generator: string;
  77549. hasAnimations: boolean;
  77550. hasDefaultScene: boolean;
  77551. hasMaterials: boolean;
  77552. hasMorphTargets: boolean;
  77553. hasSkins: boolean;
  77554. hasTextures: boolean;
  77555. maxAttributesUsed: number;
  77556. primitivesCount: number
  77557. };
  77558. issues: {
  77559. messages: Array<string>;
  77560. numErrors: number;
  77561. numHints: number;
  77562. numInfos: number;
  77563. numWarnings: number;
  77564. truncated: boolean
  77565. };
  77566. mimeType: string;
  77567. uri: string;
  77568. validatedAt: string;
  77569. validatorVersion: string;
  77570. }
  77571. /**
  77572. * The glTF validation options
  77573. */
  77574. interface IGLTFValidationOptions {
  77575. /** Uri to use */
  77576. uri?: string;
  77577. /** Function used to load external resources */
  77578. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  77579. /** Boolean indicating that we need to validate accessor data */
  77580. validateAccessorData?: boolean;
  77581. /** max number of issues allowed */
  77582. maxIssues?: number;
  77583. /** Ignored issues */
  77584. ignoredIssues?: Array<string>;
  77585. /** Value to override severy settings */
  77586. severityOverrides?: Object;
  77587. }
  77588. /**
  77589. * The glTF validator object
  77590. * @ignore
  77591. */
  77592. interface IGLTFValidator {
  77593. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77594. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77595. }
  77596. }
  77597. declare module BABYLON {
  77598. /** @hidden */
  77599. export var cellPixelShader: {
  77600. name: string;
  77601. shader: string;
  77602. };
  77603. }
  77604. declare module BABYLON {
  77605. /** @hidden */
  77606. export var cellVertexShader: {
  77607. name: string;
  77608. shader: string;
  77609. };
  77610. }
  77611. declare module BABYLON {
  77612. export class CellMaterial extends BABYLON.PushMaterial {
  77613. private _diffuseTexture;
  77614. diffuseTexture: BABYLON.BaseTexture;
  77615. diffuseColor: BABYLON.Color3;
  77616. _computeHighLevel: boolean;
  77617. computeHighLevel: boolean;
  77618. private _disableLighting;
  77619. disableLighting: boolean;
  77620. private _maxSimultaneousLights;
  77621. maxSimultaneousLights: number;
  77622. private _renderId;
  77623. constructor(name: string, scene: BABYLON.Scene);
  77624. needAlphaBlending(): boolean;
  77625. needAlphaTesting(): boolean;
  77626. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77627. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77628. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77629. getAnimatables(): BABYLON.IAnimatable[];
  77630. getActiveTextures(): BABYLON.BaseTexture[];
  77631. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77632. dispose(forceDisposeEffect?: boolean): void;
  77633. getClassName(): string;
  77634. clone(name: string): CellMaterial;
  77635. serialize(): any;
  77636. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  77637. }
  77638. }
  77639. declare module BABYLON {
  77640. export class CustomShaderStructure {
  77641. FragmentStore: string;
  77642. VertexStore: string;
  77643. constructor();
  77644. }
  77645. export class ShaderSpecialParts {
  77646. constructor();
  77647. Fragment_Begin: string;
  77648. Fragment_Definitions: string;
  77649. Fragment_MainBegin: string;
  77650. Fragment_Custom_Diffuse: string;
  77651. Fragment_Before_Lights: string;
  77652. Fragment_Before_Fog: string;
  77653. Fragment_Custom_Alpha: string;
  77654. Fragment_Before_FragColor: string;
  77655. Vertex_Begin: string;
  77656. Vertex_Definitions: string;
  77657. Vertex_MainBegin: string;
  77658. Vertex_Before_PositionUpdated: string;
  77659. Vertex_Before_NormalUpdated: string;
  77660. Vertex_MainEnd: string;
  77661. }
  77662. export class CustomMaterial extends BABYLON.StandardMaterial {
  77663. static ShaderIndexer: number;
  77664. CustomParts: ShaderSpecialParts;
  77665. _isCreatedShader: boolean;
  77666. _createdShaderName: string;
  77667. _customUniform: string[];
  77668. _newUniforms: string[];
  77669. _newUniformInstances: any[];
  77670. _newSamplerInstances: BABYLON.Texture[];
  77671. FragmentShader: string;
  77672. VertexShader: string;
  77673. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77674. ReviewUniform(name: string, arr: string[]): string[];
  77675. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  77676. constructor(name: string, scene: BABYLON.Scene);
  77677. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  77678. Fragment_Begin(shaderPart: string): CustomMaterial;
  77679. Fragment_Definitions(shaderPart: string): CustomMaterial;
  77680. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  77681. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  77682. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  77683. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  77684. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  77685. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  77686. Vertex_Begin(shaderPart: string): CustomMaterial;
  77687. Vertex_Definitions(shaderPart: string): CustomMaterial;
  77688. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  77689. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  77690. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  77691. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  77692. }
  77693. }
  77694. declare module BABYLON {
  77695. export class ShaderAlebdoParts {
  77696. constructor();
  77697. Fragment_Begin: string;
  77698. Fragment_Definitions: string;
  77699. Fragment_MainBegin: string;
  77700. Fragment_Custom_Albedo: string;
  77701. Fragment_Before_Lights: string;
  77702. Fragment_Custom_MetallicRoughness: string;
  77703. Fragment_Custom_MicroSurface: string;
  77704. Fragment_Before_Fog: string;
  77705. Fragment_Custom_Alpha: string;
  77706. Fragment_Before_FragColor: string;
  77707. Vertex_Begin: string;
  77708. Vertex_Definitions: string;
  77709. Vertex_MainBegin: string;
  77710. Vertex_Before_PositionUpdated: string;
  77711. Vertex_Before_NormalUpdated: string;
  77712. Vertex_MainEnd: string;
  77713. }
  77714. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  77715. static ShaderIndexer: number;
  77716. CustomParts: ShaderAlebdoParts;
  77717. _isCreatedShader: boolean;
  77718. _createdShaderName: string;
  77719. _customUniform: string[];
  77720. _newUniforms: string[];
  77721. _newUniformInstances: any[];
  77722. _newSamplerInstances: BABYLON.Texture[];
  77723. FragmentShader: string;
  77724. VertexShader: string;
  77725. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77726. ReviewUniform(name: string, arr: string[]): string[];
  77727. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  77728. constructor(name: string, scene: BABYLON.Scene);
  77729. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  77730. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  77731. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  77732. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  77733. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  77734. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  77735. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  77736. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  77737. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  77738. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  77739. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  77740. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  77741. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  77742. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  77743. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  77744. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  77745. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  77746. }
  77747. }
  77748. declare module BABYLON {
  77749. /** @hidden */
  77750. export var firePixelShader: {
  77751. name: string;
  77752. shader: string;
  77753. };
  77754. }
  77755. declare module BABYLON {
  77756. /** @hidden */
  77757. export var fireVertexShader: {
  77758. name: string;
  77759. shader: string;
  77760. };
  77761. }
  77762. declare module BABYLON {
  77763. export class FireMaterial extends BABYLON.PushMaterial {
  77764. private _diffuseTexture;
  77765. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77766. private _distortionTexture;
  77767. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77768. private _opacityTexture;
  77769. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77770. diffuseColor: BABYLON.Color3;
  77771. speed: number;
  77772. private _scaledDiffuse;
  77773. private _renderId;
  77774. private _lastTime;
  77775. constructor(name: string, scene: BABYLON.Scene);
  77776. needAlphaBlending(): boolean;
  77777. needAlphaTesting(): boolean;
  77778. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77779. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77780. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77781. getAnimatables(): BABYLON.IAnimatable[];
  77782. getActiveTextures(): BABYLON.BaseTexture[];
  77783. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77784. getClassName(): string;
  77785. dispose(forceDisposeEffect?: boolean): void;
  77786. clone(name: string): FireMaterial;
  77787. serialize(): any;
  77788. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  77789. }
  77790. }
  77791. declare module BABYLON {
  77792. /** @hidden */
  77793. export var furPixelShader: {
  77794. name: string;
  77795. shader: string;
  77796. };
  77797. }
  77798. declare module BABYLON {
  77799. /** @hidden */
  77800. export var furVertexShader: {
  77801. name: string;
  77802. shader: string;
  77803. };
  77804. }
  77805. declare module BABYLON {
  77806. export class FurMaterial extends BABYLON.PushMaterial {
  77807. private _diffuseTexture;
  77808. diffuseTexture: BABYLON.BaseTexture;
  77809. private _heightTexture;
  77810. heightTexture: BABYLON.BaseTexture;
  77811. diffuseColor: BABYLON.Color3;
  77812. furLength: number;
  77813. furAngle: number;
  77814. furColor: BABYLON.Color3;
  77815. furOffset: number;
  77816. furSpacing: number;
  77817. furGravity: BABYLON.Vector3;
  77818. furSpeed: number;
  77819. furDensity: number;
  77820. furOcclusion: number;
  77821. furTexture: BABYLON.DynamicTexture;
  77822. private _disableLighting;
  77823. disableLighting: boolean;
  77824. private _maxSimultaneousLights;
  77825. maxSimultaneousLights: number;
  77826. highLevelFur: boolean;
  77827. _meshes: BABYLON.AbstractMesh[];
  77828. private _renderId;
  77829. private _furTime;
  77830. constructor(name: string, scene: BABYLON.Scene);
  77831. get furTime(): number;
  77832. set furTime(furTime: number);
  77833. needAlphaBlending(): boolean;
  77834. needAlphaTesting(): boolean;
  77835. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77836. updateFur(): void;
  77837. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77838. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77839. getAnimatables(): BABYLON.IAnimatable[];
  77840. getActiveTextures(): BABYLON.BaseTexture[];
  77841. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77842. dispose(forceDisposeEffect?: boolean): void;
  77843. clone(name: string): FurMaterial;
  77844. serialize(): any;
  77845. getClassName(): string;
  77846. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  77847. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  77848. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  77849. }
  77850. }
  77851. declare module BABYLON {
  77852. /** @hidden */
  77853. export var gradientPixelShader: {
  77854. name: string;
  77855. shader: string;
  77856. };
  77857. }
  77858. declare module BABYLON {
  77859. /** @hidden */
  77860. export var gradientVertexShader: {
  77861. name: string;
  77862. shader: string;
  77863. };
  77864. }
  77865. declare module BABYLON {
  77866. export class GradientMaterial extends BABYLON.PushMaterial {
  77867. private _maxSimultaneousLights;
  77868. maxSimultaneousLights: number;
  77869. topColor: BABYLON.Color3;
  77870. topColorAlpha: number;
  77871. bottomColor: BABYLON.Color3;
  77872. bottomColorAlpha: number;
  77873. offset: number;
  77874. scale: number;
  77875. smoothness: number;
  77876. private _disableLighting;
  77877. disableLighting: boolean;
  77878. private _renderId;
  77879. constructor(name: string, scene: BABYLON.Scene);
  77880. needAlphaBlending(): boolean;
  77881. needAlphaTesting(): boolean;
  77882. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77883. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77884. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77885. getAnimatables(): BABYLON.IAnimatable[];
  77886. dispose(forceDisposeEffect?: boolean): void;
  77887. clone(name: string): GradientMaterial;
  77888. serialize(): any;
  77889. getClassName(): string;
  77890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  77891. }
  77892. }
  77893. declare module BABYLON {
  77894. /** @hidden */
  77895. export var gridPixelShader: {
  77896. name: string;
  77897. shader: string;
  77898. };
  77899. }
  77900. declare module BABYLON {
  77901. /** @hidden */
  77902. export var gridVertexShader: {
  77903. name: string;
  77904. shader: string;
  77905. };
  77906. }
  77907. declare module BABYLON {
  77908. /**
  77909. * The grid materials allows you to wrap any shape with a grid.
  77910. * Colors are customizable.
  77911. */
  77912. export class GridMaterial extends BABYLON.PushMaterial {
  77913. /**
  77914. * Main color of the grid (e.g. between lines)
  77915. */
  77916. mainColor: BABYLON.Color3;
  77917. /**
  77918. * Color of the grid lines.
  77919. */
  77920. lineColor: BABYLON.Color3;
  77921. /**
  77922. * The scale of the grid compared to unit.
  77923. */
  77924. gridRatio: number;
  77925. /**
  77926. * Allows setting an offset for the grid lines.
  77927. */
  77928. gridOffset: BABYLON.Vector3;
  77929. /**
  77930. * The frequency of thicker lines.
  77931. */
  77932. majorUnitFrequency: number;
  77933. /**
  77934. * The visibility of minor units in the grid.
  77935. */
  77936. minorUnitVisibility: number;
  77937. /**
  77938. * The grid opacity outside of the lines.
  77939. */
  77940. opacity: number;
  77941. /**
  77942. * Determine RBG output is premultiplied by alpha value.
  77943. */
  77944. preMultiplyAlpha: boolean;
  77945. private _opacityTexture;
  77946. opacityTexture: BABYLON.BaseTexture;
  77947. private _gridControl;
  77948. private _renderId;
  77949. /**
  77950. * constructor
  77951. * @param name The name given to the material in order to identify it afterwards.
  77952. * @param scene The scene the material is used in.
  77953. */
  77954. constructor(name: string, scene: BABYLON.Scene);
  77955. /**
  77956. * Returns wehter or not the grid requires alpha blending.
  77957. */
  77958. needAlphaBlending(): boolean;
  77959. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  77960. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77961. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77962. /**
  77963. * Dispose the material and its associated resources.
  77964. * @param forceDisposeEffect will also dispose the used effect when true
  77965. */
  77966. dispose(forceDisposeEffect?: boolean): void;
  77967. clone(name: string): GridMaterial;
  77968. serialize(): any;
  77969. getClassName(): string;
  77970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  77971. }
  77972. }
  77973. declare module BABYLON {
  77974. /** @hidden */
  77975. export var lavaPixelShader: {
  77976. name: string;
  77977. shader: string;
  77978. };
  77979. }
  77980. declare module BABYLON {
  77981. /** @hidden */
  77982. export var lavaVertexShader: {
  77983. name: string;
  77984. shader: string;
  77985. };
  77986. }
  77987. declare module BABYLON {
  77988. export class LavaMaterial extends BABYLON.PushMaterial {
  77989. private _diffuseTexture;
  77990. diffuseTexture: BABYLON.BaseTexture;
  77991. noiseTexture: BABYLON.BaseTexture;
  77992. fogColor: BABYLON.Color3;
  77993. speed: number;
  77994. movingSpeed: number;
  77995. lowFrequencySpeed: number;
  77996. fogDensity: number;
  77997. private _lastTime;
  77998. diffuseColor: BABYLON.Color3;
  77999. private _disableLighting;
  78000. disableLighting: boolean;
  78001. private _unlit;
  78002. unlit: boolean;
  78003. private _maxSimultaneousLights;
  78004. maxSimultaneousLights: number;
  78005. private _scaledDiffuse;
  78006. private _renderId;
  78007. constructor(name: string, scene: BABYLON.Scene);
  78008. needAlphaBlending(): boolean;
  78009. needAlphaTesting(): boolean;
  78010. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78011. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78012. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78013. getAnimatables(): BABYLON.IAnimatable[];
  78014. getActiveTextures(): BABYLON.BaseTexture[];
  78015. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78016. dispose(forceDisposeEffect?: boolean): void;
  78017. clone(name: string): LavaMaterial;
  78018. serialize(): any;
  78019. getClassName(): string;
  78020. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78021. }
  78022. }
  78023. declare module BABYLON {
  78024. /** @hidden */
  78025. export var mixPixelShader: {
  78026. name: string;
  78027. shader: string;
  78028. };
  78029. }
  78030. declare module BABYLON {
  78031. /** @hidden */
  78032. export var mixVertexShader: {
  78033. name: string;
  78034. shader: string;
  78035. };
  78036. }
  78037. declare module BABYLON {
  78038. export class MixMaterial extends BABYLON.PushMaterial {
  78039. /**
  78040. * Mix textures
  78041. */
  78042. private _mixTexture1;
  78043. mixTexture1: BABYLON.BaseTexture;
  78044. private _mixTexture2;
  78045. mixTexture2: BABYLON.BaseTexture;
  78046. /**
  78047. * Diffuse textures
  78048. */
  78049. private _diffuseTexture1;
  78050. diffuseTexture1: BABYLON.Texture;
  78051. private _diffuseTexture2;
  78052. diffuseTexture2: BABYLON.Texture;
  78053. private _diffuseTexture3;
  78054. diffuseTexture3: BABYLON.Texture;
  78055. private _diffuseTexture4;
  78056. diffuseTexture4: BABYLON.Texture;
  78057. private _diffuseTexture5;
  78058. diffuseTexture5: BABYLON.Texture;
  78059. private _diffuseTexture6;
  78060. diffuseTexture6: BABYLON.Texture;
  78061. private _diffuseTexture7;
  78062. diffuseTexture7: BABYLON.Texture;
  78063. private _diffuseTexture8;
  78064. diffuseTexture8: BABYLON.Texture;
  78065. /**
  78066. * Uniforms
  78067. */
  78068. diffuseColor: BABYLON.Color3;
  78069. specularColor: BABYLON.Color3;
  78070. specularPower: number;
  78071. private _disableLighting;
  78072. disableLighting: boolean;
  78073. private _maxSimultaneousLights;
  78074. maxSimultaneousLights: number;
  78075. private _renderId;
  78076. constructor(name: string, scene: BABYLON.Scene);
  78077. needAlphaBlending(): boolean;
  78078. needAlphaTesting(): boolean;
  78079. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78080. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78081. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78082. getAnimatables(): BABYLON.IAnimatable[];
  78083. getActiveTextures(): BABYLON.BaseTexture[];
  78084. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78085. dispose(forceDisposeEffect?: boolean): void;
  78086. clone(name: string): MixMaterial;
  78087. serialize(): any;
  78088. getClassName(): string;
  78089. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78090. }
  78091. }
  78092. declare module BABYLON {
  78093. /** @hidden */
  78094. export var normalPixelShader: {
  78095. name: string;
  78096. shader: string;
  78097. };
  78098. }
  78099. declare module BABYLON {
  78100. /** @hidden */
  78101. export var normalVertexShader: {
  78102. name: string;
  78103. shader: string;
  78104. };
  78105. }
  78106. declare module BABYLON {
  78107. export class NormalMaterial extends BABYLON.PushMaterial {
  78108. private _diffuseTexture;
  78109. diffuseTexture: BABYLON.BaseTexture;
  78110. diffuseColor: BABYLON.Color3;
  78111. private _disableLighting;
  78112. disableLighting: boolean;
  78113. private _maxSimultaneousLights;
  78114. maxSimultaneousLights: number;
  78115. private _renderId;
  78116. constructor(name: string, scene: BABYLON.Scene);
  78117. needAlphaBlending(): boolean;
  78118. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78119. needAlphaTesting(): boolean;
  78120. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78121. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78122. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78123. getAnimatables(): BABYLON.IAnimatable[];
  78124. getActiveTextures(): BABYLON.BaseTexture[];
  78125. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78126. dispose(forceDisposeEffect?: boolean): void;
  78127. clone(name: string): NormalMaterial;
  78128. serialize(): any;
  78129. getClassName(): string;
  78130. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78131. }
  78132. }
  78133. declare module BABYLON {
  78134. /** @hidden */
  78135. export var shadowOnlyPixelShader: {
  78136. name: string;
  78137. shader: string;
  78138. };
  78139. }
  78140. declare module BABYLON {
  78141. /** @hidden */
  78142. export var shadowOnlyVertexShader: {
  78143. name: string;
  78144. shader: string;
  78145. };
  78146. }
  78147. declare module BABYLON {
  78148. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78149. private _renderId;
  78150. private _activeLight;
  78151. constructor(name: string, scene: BABYLON.Scene);
  78152. shadowColor: BABYLON.Color3;
  78153. needAlphaBlending(): boolean;
  78154. needAlphaTesting(): boolean;
  78155. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78156. get activeLight(): BABYLON.IShadowLight;
  78157. set activeLight(light: BABYLON.IShadowLight);
  78158. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78159. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78160. clone(name: string): ShadowOnlyMaterial;
  78161. serialize(): any;
  78162. getClassName(): string;
  78163. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78164. }
  78165. }
  78166. declare module BABYLON {
  78167. /** @hidden */
  78168. export var simplePixelShader: {
  78169. name: string;
  78170. shader: string;
  78171. };
  78172. }
  78173. declare module BABYLON {
  78174. /** @hidden */
  78175. export var simpleVertexShader: {
  78176. name: string;
  78177. shader: string;
  78178. };
  78179. }
  78180. declare module BABYLON {
  78181. export class SimpleMaterial extends BABYLON.PushMaterial {
  78182. private _diffuseTexture;
  78183. diffuseTexture: BABYLON.BaseTexture;
  78184. diffuseColor: BABYLON.Color3;
  78185. private _disableLighting;
  78186. disableLighting: boolean;
  78187. private _maxSimultaneousLights;
  78188. maxSimultaneousLights: number;
  78189. private _renderId;
  78190. constructor(name: string, scene: BABYLON.Scene);
  78191. needAlphaBlending(): boolean;
  78192. needAlphaTesting(): boolean;
  78193. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78194. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78195. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78196. getAnimatables(): BABYLON.IAnimatable[];
  78197. getActiveTextures(): BABYLON.BaseTexture[];
  78198. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78199. dispose(forceDisposeEffect?: boolean): void;
  78200. clone(name: string): SimpleMaterial;
  78201. serialize(): any;
  78202. getClassName(): string;
  78203. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78204. }
  78205. }
  78206. declare module BABYLON {
  78207. /** @hidden */
  78208. export var skyPixelShader: {
  78209. name: string;
  78210. shader: string;
  78211. };
  78212. }
  78213. declare module BABYLON {
  78214. /** @hidden */
  78215. export var skyVertexShader: {
  78216. name: string;
  78217. shader: string;
  78218. };
  78219. }
  78220. declare module BABYLON {
  78221. /**
  78222. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  78223. * @see https://doc.babylonjs.com/extensions/sky
  78224. */
  78225. export class SkyMaterial extends BABYLON.PushMaterial {
  78226. /**
  78227. * Defines the overall luminance of sky in interval ]0, 1[.
  78228. */
  78229. luminance: number;
  78230. /**
  78231. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  78232. */
  78233. turbidity: number;
  78234. /**
  78235. * Defines the sky appearance (light intensity).
  78236. */
  78237. rayleigh: number;
  78238. /**
  78239. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  78240. */
  78241. mieCoefficient: number;
  78242. /**
  78243. * Defines the amount of haze particles following the Mie scattering theory.
  78244. */
  78245. mieDirectionalG: number;
  78246. /**
  78247. * Defines the distance of the sun according to the active scene camera.
  78248. */
  78249. distance: number;
  78250. /**
  78251. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  78252. * "inclined".
  78253. */
  78254. inclination: number;
  78255. /**
  78256. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  78257. * an object direction and a reference direction.
  78258. */
  78259. azimuth: number;
  78260. /**
  78261. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  78262. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  78263. */
  78264. sunPosition: BABYLON.Vector3;
  78265. /**
  78266. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  78267. * .sunPosition property.
  78268. */
  78269. useSunPosition: boolean;
  78270. /**
  78271. * Defines an offset vector used to get a horizon offset.
  78272. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  78273. */
  78274. cameraOffset: BABYLON.Vector3;
  78275. private _cameraPosition;
  78276. private _renderId;
  78277. /**
  78278. * Instantiates a new sky material.
  78279. * This material allows to create dynamic and texture free
  78280. * effects for skyboxes by taking care of the atmosphere state.
  78281. * @see https://doc.babylonjs.com/extensions/sky
  78282. * @param name Define the name of the material in the scene
  78283. * @param scene Define the scene the material belong to
  78284. */
  78285. constructor(name: string, scene: BABYLON.Scene);
  78286. /**
  78287. * Specifies if the material will require alpha blending
  78288. * @returns a boolean specifying if alpha blending is needed
  78289. */
  78290. needAlphaBlending(): boolean;
  78291. /**
  78292. * Specifies if this material should be rendered in alpha test mode
  78293. * @returns false as the sky material doesn't need alpha testing.
  78294. */
  78295. needAlphaTesting(): boolean;
  78296. /**
  78297. * Get the texture used for alpha test purpose.
  78298. * @returns null as the sky material has no texture.
  78299. */
  78300. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78301. /**
  78302. * Get if the submesh is ready to be used and all its information available.
  78303. * Child classes can use it to update shaders
  78304. * @param mesh defines the mesh to check
  78305. * @param subMesh defines which submesh to check
  78306. * @param useInstances specifies that instances should be used
  78307. * @returns a boolean indicating that the submesh is ready or not
  78308. */
  78309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78310. /**
  78311. * Binds the submesh to this material by preparing the effect and shader to draw
  78312. * @param world defines the world transformation matrix
  78313. * @param mesh defines the mesh containing the submesh
  78314. * @param subMesh defines the submesh to bind the material to
  78315. */
  78316. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78317. /**
  78318. * Get the list of animatables in the material.
  78319. * @returns the list of animatables object used in the material
  78320. */
  78321. getAnimatables(): BABYLON.IAnimatable[];
  78322. /**
  78323. * Disposes the material
  78324. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78325. */
  78326. dispose(forceDisposeEffect?: boolean): void;
  78327. /**
  78328. * Makes a duplicate of the material, and gives it a new name
  78329. * @param name defines the new name for the duplicated material
  78330. * @returns the cloned material
  78331. */
  78332. clone(name: string): SkyMaterial;
  78333. /**
  78334. * Serializes this material in a JSON representation
  78335. * @returns the serialized material object
  78336. */
  78337. serialize(): any;
  78338. /**
  78339. * Gets the current class name of the material e.g. "SkyMaterial"
  78340. * Mainly use in serialization.
  78341. * @returns the class name
  78342. */
  78343. getClassName(): string;
  78344. /**
  78345. * Creates a sky material from parsed material data
  78346. * @param source defines the JSON representation of the material
  78347. * @param scene defines the hosting scene
  78348. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  78349. * @returns a new sky material
  78350. */
  78351. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  78352. }
  78353. }
  78354. declare module BABYLON {
  78355. /** @hidden */
  78356. export var terrainPixelShader: {
  78357. name: string;
  78358. shader: string;
  78359. };
  78360. }
  78361. declare module BABYLON {
  78362. /** @hidden */
  78363. export var terrainVertexShader: {
  78364. name: string;
  78365. shader: string;
  78366. };
  78367. }
  78368. declare module BABYLON {
  78369. export class TerrainMaterial extends BABYLON.PushMaterial {
  78370. private _mixTexture;
  78371. mixTexture: BABYLON.BaseTexture;
  78372. private _diffuseTexture1;
  78373. diffuseTexture1: BABYLON.Texture;
  78374. private _diffuseTexture2;
  78375. diffuseTexture2: BABYLON.Texture;
  78376. private _diffuseTexture3;
  78377. diffuseTexture3: BABYLON.Texture;
  78378. private _bumpTexture1;
  78379. bumpTexture1: BABYLON.Texture;
  78380. private _bumpTexture2;
  78381. bumpTexture2: BABYLON.Texture;
  78382. private _bumpTexture3;
  78383. bumpTexture3: BABYLON.Texture;
  78384. diffuseColor: BABYLON.Color3;
  78385. specularColor: BABYLON.Color3;
  78386. specularPower: number;
  78387. private _disableLighting;
  78388. disableLighting: boolean;
  78389. private _maxSimultaneousLights;
  78390. maxSimultaneousLights: number;
  78391. private _renderId;
  78392. constructor(name: string, scene: BABYLON.Scene);
  78393. needAlphaBlending(): boolean;
  78394. needAlphaTesting(): boolean;
  78395. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78396. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78397. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78398. getAnimatables(): BABYLON.IAnimatable[];
  78399. getActiveTextures(): BABYLON.BaseTexture[];
  78400. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78401. dispose(forceDisposeEffect?: boolean): void;
  78402. clone(name: string): TerrainMaterial;
  78403. serialize(): any;
  78404. getClassName(): string;
  78405. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  78406. }
  78407. }
  78408. declare module BABYLON {
  78409. /** @hidden */
  78410. export var triplanarPixelShader: {
  78411. name: string;
  78412. shader: string;
  78413. };
  78414. }
  78415. declare module BABYLON {
  78416. /** @hidden */
  78417. export var triplanarVertexShader: {
  78418. name: string;
  78419. shader: string;
  78420. };
  78421. }
  78422. declare module BABYLON {
  78423. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  78424. mixTexture: BABYLON.BaseTexture;
  78425. private _diffuseTextureX;
  78426. diffuseTextureX: BABYLON.BaseTexture;
  78427. private _diffuseTextureY;
  78428. diffuseTextureY: BABYLON.BaseTexture;
  78429. private _diffuseTextureZ;
  78430. diffuseTextureZ: BABYLON.BaseTexture;
  78431. private _normalTextureX;
  78432. normalTextureX: BABYLON.BaseTexture;
  78433. private _normalTextureY;
  78434. normalTextureY: BABYLON.BaseTexture;
  78435. private _normalTextureZ;
  78436. normalTextureZ: BABYLON.BaseTexture;
  78437. tileSize: number;
  78438. diffuseColor: BABYLON.Color3;
  78439. specularColor: BABYLON.Color3;
  78440. specularPower: number;
  78441. private _disableLighting;
  78442. disableLighting: boolean;
  78443. private _maxSimultaneousLights;
  78444. maxSimultaneousLights: number;
  78445. private _renderId;
  78446. constructor(name: string, scene: BABYLON.Scene);
  78447. needAlphaBlending(): boolean;
  78448. needAlphaTesting(): boolean;
  78449. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78450. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78451. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78452. getAnimatables(): BABYLON.IAnimatable[];
  78453. getActiveTextures(): BABYLON.BaseTexture[];
  78454. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78455. dispose(forceDisposeEffect?: boolean): void;
  78456. clone(name: string): TriPlanarMaterial;
  78457. serialize(): any;
  78458. getClassName(): string;
  78459. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  78460. }
  78461. }
  78462. declare module BABYLON {
  78463. /** @hidden */
  78464. export var waterPixelShader: {
  78465. name: string;
  78466. shader: string;
  78467. };
  78468. }
  78469. declare module BABYLON {
  78470. /** @hidden */
  78471. export var waterVertexShader: {
  78472. name: string;
  78473. shader: string;
  78474. };
  78475. }
  78476. declare module BABYLON {
  78477. export class WaterMaterial extends BABYLON.PushMaterial {
  78478. renderTargetSize: BABYLON.Vector2;
  78479. private _bumpTexture;
  78480. bumpTexture: BABYLON.BaseTexture;
  78481. diffuseColor: BABYLON.Color3;
  78482. specularColor: BABYLON.Color3;
  78483. specularPower: number;
  78484. private _disableLighting;
  78485. disableLighting: boolean;
  78486. private _maxSimultaneousLights;
  78487. maxSimultaneousLights: number;
  78488. /**
  78489. * @param {number}: Represents the wind force
  78490. */
  78491. windForce: number;
  78492. /**
  78493. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  78494. */
  78495. windDirection: BABYLON.Vector2;
  78496. /**
  78497. * @param {number}: Wave height, represents the height of the waves
  78498. */
  78499. waveHeight: number;
  78500. /**
  78501. * @param {number}: Bump height, represents the bump height related to the bump map
  78502. */
  78503. bumpHeight: number;
  78504. /**
  78505. * @param {boolean}: Add a smaller moving bump to less steady waves.
  78506. */
  78507. private _bumpSuperimpose;
  78508. bumpSuperimpose: boolean;
  78509. /**
  78510. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  78511. */
  78512. private _fresnelSeparate;
  78513. fresnelSeparate: boolean;
  78514. /**
  78515. * @param {boolean}: bump Waves modify the reflection.
  78516. */
  78517. private _bumpAffectsReflection;
  78518. bumpAffectsReflection: boolean;
  78519. /**
  78520. * @param {number}: The water color blended with the refraction (near)
  78521. */
  78522. waterColor: BABYLON.Color3;
  78523. /**
  78524. * @param {number}: The blend factor related to the water color
  78525. */
  78526. colorBlendFactor: number;
  78527. /**
  78528. * @param {number}: The water color blended with the reflection (far)
  78529. */
  78530. waterColor2: BABYLON.Color3;
  78531. /**
  78532. * @param {number}: The blend factor related to the water color (reflection, far)
  78533. */
  78534. colorBlendFactor2: number;
  78535. /**
  78536. * @param {number}: Represents the maximum length of a wave
  78537. */
  78538. waveLength: number;
  78539. /**
  78540. * @param {number}: Defines the waves speed
  78541. */
  78542. waveSpeed: number;
  78543. /**
  78544. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  78545. * will avoid calculating useless pixels in the pixel shader of the water material.
  78546. */
  78547. disableClipPlane: boolean;
  78548. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  78549. private _mesh;
  78550. private _refractionRTT;
  78551. private _reflectionRTT;
  78552. private _reflectionTransform;
  78553. private _lastTime;
  78554. private _lastDeltaTime;
  78555. private _renderId;
  78556. private _useLogarithmicDepth;
  78557. private _waitingRenderList;
  78558. private _imageProcessingConfiguration;
  78559. private _imageProcessingObserver;
  78560. /**
  78561. * Gets a boolean indicating that current material needs to register RTT
  78562. */
  78563. get hasRenderTargetTextures(): boolean;
  78564. /**
  78565. * Constructor
  78566. */
  78567. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  78568. get useLogarithmicDepth(): boolean;
  78569. set useLogarithmicDepth(value: boolean);
  78570. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78571. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78572. addToRenderList(node: any): void;
  78573. enableRenderTargets(enable: boolean): void;
  78574. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  78575. get renderTargetsEnabled(): boolean;
  78576. needAlphaBlending(): boolean;
  78577. needAlphaTesting(): boolean;
  78578. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78579. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78580. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78581. private _createRenderTargets;
  78582. getAnimatables(): BABYLON.IAnimatable[];
  78583. getActiveTextures(): BABYLON.BaseTexture[];
  78584. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78585. dispose(forceDisposeEffect?: boolean): void;
  78586. clone(name: string): WaterMaterial;
  78587. serialize(): any;
  78588. getClassName(): string;
  78589. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  78590. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  78591. }
  78592. }
  78593. declare module BABYLON {
  78594. /** @hidden */
  78595. export var asciiartPixelShader: {
  78596. name: string;
  78597. shader: string;
  78598. };
  78599. }
  78600. declare module BABYLON {
  78601. /**
  78602. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  78603. *
  78604. * It basically takes care rendering the font front the given font size to a texture.
  78605. * This is used later on in the postprocess.
  78606. */
  78607. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  78608. private _font;
  78609. private _text;
  78610. private _charSize;
  78611. /**
  78612. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78613. */
  78614. get charSize(): number;
  78615. /**
  78616. * Create a new instance of the Ascii Art FontTexture class
  78617. * @param name the name of the texture
  78618. * @param font the font to use, use the W3C CSS notation
  78619. * @param text the caracter set to use in the rendering.
  78620. * @param scene the scene that owns the texture
  78621. */
  78622. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78623. /**
  78624. * Gets the max char width of a font.
  78625. * @param font the font to use, use the W3C CSS notation
  78626. * @return the max char width
  78627. */
  78628. private getFontWidth;
  78629. /**
  78630. * Gets the max char height of a font.
  78631. * @param font the font to use, use the W3C CSS notation
  78632. * @return the max char height
  78633. */
  78634. private getFontHeight;
  78635. /**
  78636. * Clones the current AsciiArtTexture.
  78637. * @return the clone of the texture.
  78638. */
  78639. clone(): AsciiArtFontTexture;
  78640. /**
  78641. * Parses a json object representing the texture and returns an instance of it.
  78642. * @param source the source JSON representation
  78643. * @param scene the scene to create the texture for
  78644. * @return the parsed texture
  78645. */
  78646. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  78647. }
  78648. /**
  78649. * Option available in the Ascii Art Post Process.
  78650. */
  78651. export interface IAsciiArtPostProcessOptions {
  78652. /**
  78653. * The font to use following the w3c font definition.
  78654. */
  78655. font?: string;
  78656. /**
  78657. * The character set to use in the postprocess.
  78658. */
  78659. characterSet?: string;
  78660. /**
  78661. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78662. * This number is defined between 0 and 1;
  78663. */
  78664. mixToTile?: number;
  78665. /**
  78666. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78667. * This number is defined between 0 and 1;
  78668. */
  78669. mixToNormal?: number;
  78670. }
  78671. /**
  78672. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  78673. *
  78674. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78675. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  78676. */
  78677. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  78678. /**
  78679. * The font texture used to render the char in the post process.
  78680. */
  78681. private _asciiArtFontTexture;
  78682. /**
  78683. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78684. * This number is defined between 0 and 1;
  78685. */
  78686. mixToTile: number;
  78687. /**
  78688. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78689. * This number is defined between 0 and 1;
  78690. */
  78691. mixToNormal: number;
  78692. /**
  78693. * Instantiates a new Ascii Art Post Process.
  78694. * @param name the name to give to the postprocess
  78695. * @camera the camera to apply the post process to.
  78696. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  78697. */
  78698. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  78699. }
  78700. }
  78701. declare module BABYLON {
  78702. /** @hidden */
  78703. export var digitalrainPixelShader: {
  78704. name: string;
  78705. shader: string;
  78706. };
  78707. }
  78708. declare module BABYLON {
  78709. /**
  78710. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  78711. *
  78712. * It basically takes care rendering the font front the given font size to a texture.
  78713. * This is used later on in the postprocess.
  78714. */
  78715. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  78716. private _font;
  78717. private _text;
  78718. private _charSize;
  78719. /**
  78720. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78721. */
  78722. get charSize(): number;
  78723. /**
  78724. * Create a new instance of the Digital Rain FontTexture class
  78725. * @param name the name of the texture
  78726. * @param font the font to use, use the W3C CSS notation
  78727. * @param text the caracter set to use in the rendering.
  78728. * @param scene the scene that owns the texture
  78729. */
  78730. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78731. /**
  78732. * Gets the max char width of a font.
  78733. * @param font the font to use, use the W3C CSS notation
  78734. * @return the max char width
  78735. */
  78736. private getFontWidth;
  78737. /**
  78738. * Gets the max char height of a font.
  78739. * @param font the font to use, use the W3C CSS notation
  78740. * @return the max char height
  78741. */
  78742. private getFontHeight;
  78743. /**
  78744. * Clones the current DigitalRainFontTexture.
  78745. * @return the clone of the texture.
  78746. */
  78747. clone(): DigitalRainFontTexture;
  78748. /**
  78749. * Parses a json object representing the texture and returns an instance of it.
  78750. * @param source the source JSON representation
  78751. * @param scene the scene to create the texture for
  78752. * @return the parsed texture
  78753. */
  78754. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  78755. }
  78756. /**
  78757. * Option available in the Digital Rain Post Process.
  78758. */
  78759. export interface IDigitalRainPostProcessOptions {
  78760. /**
  78761. * The font to use following the w3c font definition.
  78762. */
  78763. font?: string;
  78764. /**
  78765. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78766. * This number is defined between 0 and 1;
  78767. */
  78768. mixToTile?: number;
  78769. /**
  78770. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78771. * This number is defined between 0 and 1;
  78772. */
  78773. mixToNormal?: number;
  78774. }
  78775. /**
  78776. * DigitalRainPostProcess helps rendering everithing in digital rain.
  78777. *
  78778. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78779. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  78780. */
  78781. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  78782. /**
  78783. * The font texture used to render the char in the post process.
  78784. */
  78785. private _digitalRainFontTexture;
  78786. /**
  78787. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78788. * This number is defined between 0 and 1;
  78789. */
  78790. mixToTile: number;
  78791. /**
  78792. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78793. * This number is defined between 0 and 1;
  78794. */
  78795. mixToNormal: number;
  78796. /**
  78797. * Instantiates a new Digital Rain Post Process.
  78798. * @param name the name to give to the postprocess
  78799. * @camera the camera to apply the post process to.
  78800. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  78801. */
  78802. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  78803. }
  78804. }
  78805. declare module BABYLON {
  78806. /** @hidden */
  78807. export var brickProceduralTexturePixelShader: {
  78808. name: string;
  78809. shader: string;
  78810. };
  78811. }
  78812. declare module BABYLON {
  78813. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  78814. private _numberOfBricksHeight;
  78815. private _numberOfBricksWidth;
  78816. private _jointColor;
  78817. private _brickColor;
  78818. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78819. updateShaderUniforms(): void;
  78820. get numberOfBricksHeight(): number;
  78821. set numberOfBricksHeight(value: number);
  78822. get numberOfBricksWidth(): number;
  78823. set numberOfBricksWidth(value: number);
  78824. get jointColor(): BABYLON.Color3;
  78825. set jointColor(value: BABYLON.Color3);
  78826. get brickColor(): BABYLON.Color3;
  78827. set brickColor(value: BABYLON.Color3);
  78828. /**
  78829. * Serializes this brick procedural texture
  78830. * @returns a serialized brick procedural texture object
  78831. */
  78832. serialize(): any;
  78833. /**
  78834. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  78835. * @param parsedTexture defines parsed texture data
  78836. * @param scene defines the current scene
  78837. * @param rootUrl defines the root URL containing brick procedural texture information
  78838. * @returns a parsed Brick Procedural BABYLON.Texture
  78839. */
  78840. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  78841. }
  78842. }
  78843. declare module BABYLON {
  78844. /** @hidden */
  78845. export var cloudProceduralTexturePixelShader: {
  78846. name: string;
  78847. shader: string;
  78848. };
  78849. }
  78850. declare module BABYLON {
  78851. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  78852. private _skyColor;
  78853. private _cloudColor;
  78854. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78855. updateShaderUniforms(): void;
  78856. get skyColor(): BABYLON.Color4;
  78857. set skyColor(value: BABYLON.Color4);
  78858. get cloudColor(): BABYLON.Color4;
  78859. set cloudColor(value: BABYLON.Color4);
  78860. /**
  78861. * Serializes this cloud procedural texture
  78862. * @returns a serialized cloud procedural texture object
  78863. */
  78864. serialize(): any;
  78865. /**
  78866. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  78867. * @param parsedTexture defines parsed texture data
  78868. * @param scene defines the current scene
  78869. * @param rootUrl defines the root URL containing cloud procedural texture information
  78870. * @returns a parsed Cloud Procedural BABYLON.Texture
  78871. */
  78872. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  78873. }
  78874. }
  78875. declare module BABYLON {
  78876. /** @hidden */
  78877. export var fireProceduralTexturePixelShader: {
  78878. name: string;
  78879. shader: string;
  78880. };
  78881. }
  78882. declare module BABYLON {
  78883. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  78884. private _time;
  78885. private _speed;
  78886. private _autoGenerateTime;
  78887. private _fireColors;
  78888. private _alphaThreshold;
  78889. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78890. updateShaderUniforms(): void;
  78891. render(useCameraPostProcess?: boolean): void;
  78892. static get PurpleFireColors(): BABYLON.Color3[];
  78893. static get GreenFireColors(): BABYLON.Color3[];
  78894. static get RedFireColors(): BABYLON.Color3[];
  78895. static get BlueFireColors(): BABYLON.Color3[];
  78896. get autoGenerateTime(): boolean;
  78897. set autoGenerateTime(value: boolean);
  78898. get fireColors(): BABYLON.Color3[];
  78899. set fireColors(value: BABYLON.Color3[]);
  78900. get time(): number;
  78901. set time(value: number);
  78902. get speed(): BABYLON.Vector2;
  78903. set speed(value: BABYLON.Vector2);
  78904. get alphaThreshold(): number;
  78905. set alphaThreshold(value: number);
  78906. /**
  78907. * Serializes this fire procedural texture
  78908. * @returns a serialized fire procedural texture object
  78909. */
  78910. serialize(): any;
  78911. /**
  78912. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  78913. * @param parsedTexture defines parsed texture data
  78914. * @param scene defines the current scene
  78915. * @param rootUrl defines the root URL containing fire procedural texture information
  78916. * @returns a parsed Fire Procedural BABYLON.Texture
  78917. */
  78918. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  78919. }
  78920. }
  78921. declare module BABYLON {
  78922. /** @hidden */
  78923. export var grassProceduralTexturePixelShader: {
  78924. name: string;
  78925. shader: string;
  78926. };
  78927. }
  78928. declare module BABYLON {
  78929. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  78930. private _grassColors;
  78931. private _groundColor;
  78932. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78933. updateShaderUniforms(): void;
  78934. get grassColors(): BABYLON.Color3[];
  78935. set grassColors(value: BABYLON.Color3[]);
  78936. get groundColor(): BABYLON.Color3;
  78937. set groundColor(value: BABYLON.Color3);
  78938. /**
  78939. * Serializes this grass procedural texture
  78940. * @returns a serialized grass procedural texture object
  78941. */
  78942. serialize(): any;
  78943. /**
  78944. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  78945. * @param parsedTexture defines parsed texture data
  78946. * @param scene defines the current scene
  78947. * @param rootUrl defines the root URL containing grass procedural texture information
  78948. * @returns a parsed Grass Procedural BABYLON.Texture
  78949. */
  78950. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  78951. }
  78952. }
  78953. declare module BABYLON {
  78954. /** @hidden */
  78955. export var marbleProceduralTexturePixelShader: {
  78956. name: string;
  78957. shader: string;
  78958. };
  78959. }
  78960. declare module BABYLON {
  78961. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  78962. private _numberOfTilesHeight;
  78963. private _numberOfTilesWidth;
  78964. private _amplitude;
  78965. private _jointColor;
  78966. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78967. updateShaderUniforms(): void;
  78968. get numberOfTilesHeight(): number;
  78969. set numberOfTilesHeight(value: number);
  78970. get amplitude(): number;
  78971. set amplitude(value: number);
  78972. get numberOfTilesWidth(): number;
  78973. set numberOfTilesWidth(value: number);
  78974. get jointColor(): BABYLON.Color3;
  78975. set jointColor(value: BABYLON.Color3);
  78976. /**
  78977. * Serializes this marble procedural texture
  78978. * @returns a serialized marble procedural texture object
  78979. */
  78980. serialize(): any;
  78981. /**
  78982. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  78983. * @param parsedTexture defines parsed texture data
  78984. * @param scene defines the current scene
  78985. * @param rootUrl defines the root URL containing marble procedural texture information
  78986. * @returns a parsed Marble Procedural BABYLON.Texture
  78987. */
  78988. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  78989. }
  78990. }
  78991. declare module BABYLON {
  78992. /** @hidden */
  78993. export var normalMapProceduralTexturePixelShader: {
  78994. name: string;
  78995. shader: string;
  78996. };
  78997. }
  78998. declare module BABYLON {
  78999. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79000. private _baseTexture;
  79001. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79002. updateShaderUniforms(): void;
  79003. render(useCameraPostProcess?: boolean): void;
  79004. resize(size: any, generateMipMaps: any): void;
  79005. get baseTexture(): BABYLON.Texture;
  79006. set baseTexture(texture: BABYLON.Texture);
  79007. /**
  79008. * Serializes this normal map procedural texture
  79009. * @returns a serialized normal map procedural texture object
  79010. */
  79011. serialize(): any;
  79012. /**
  79013. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79014. * @param parsedTexture defines parsed texture data
  79015. * @param scene defines the current scene
  79016. * @param rootUrl defines the root URL containing normal map procedural texture information
  79017. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79018. */
  79019. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79020. }
  79021. }
  79022. declare module BABYLON {
  79023. /** @hidden */
  79024. export var perlinNoiseProceduralTexturePixelShader: {
  79025. name: string;
  79026. shader: string;
  79027. };
  79028. }
  79029. declare module BABYLON {
  79030. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79031. time: number;
  79032. timeScale: number;
  79033. translationSpeed: number;
  79034. private _currentTranslation;
  79035. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79036. updateShaderUniforms(): void;
  79037. render(useCameraPostProcess?: boolean): void;
  79038. resize(size: any, generateMipMaps: any): void;
  79039. /**
  79040. * Serializes this perlin noise procedural texture
  79041. * @returns a serialized perlin noise procedural texture object
  79042. */
  79043. serialize(): any;
  79044. /**
  79045. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79046. * @param parsedTexture defines parsed texture data
  79047. * @param scene defines the current scene
  79048. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79049. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79050. */
  79051. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79052. }
  79053. }
  79054. declare module BABYLON {
  79055. /** @hidden */
  79056. export var roadProceduralTexturePixelShader: {
  79057. name: string;
  79058. shader: string;
  79059. };
  79060. }
  79061. declare module BABYLON {
  79062. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79063. private _roadColor;
  79064. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79065. updateShaderUniforms(): void;
  79066. get roadColor(): BABYLON.Color3;
  79067. set roadColor(value: BABYLON.Color3);
  79068. /**
  79069. * Serializes this road procedural texture
  79070. * @returns a serialized road procedural texture object
  79071. */
  79072. serialize(): any;
  79073. /**
  79074. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79075. * @param parsedTexture defines parsed texture data
  79076. * @param scene defines the current scene
  79077. * @param rootUrl defines the root URL containing road procedural texture information
  79078. * @returns a parsed Road Procedural BABYLON.Texture
  79079. */
  79080. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79081. }
  79082. }
  79083. declare module BABYLON {
  79084. /** @hidden */
  79085. export var starfieldProceduralTexturePixelShader: {
  79086. name: string;
  79087. shader: string;
  79088. };
  79089. }
  79090. declare module BABYLON {
  79091. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79092. private _time;
  79093. private _alpha;
  79094. private _beta;
  79095. private _zoom;
  79096. private _formuparam;
  79097. private _stepsize;
  79098. private _tile;
  79099. private _brightness;
  79100. private _darkmatter;
  79101. private _distfading;
  79102. private _saturation;
  79103. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79104. updateShaderUniforms(): void;
  79105. get time(): number;
  79106. set time(value: number);
  79107. get alpha(): number;
  79108. set alpha(value: number);
  79109. get beta(): number;
  79110. set beta(value: number);
  79111. get formuparam(): number;
  79112. set formuparam(value: number);
  79113. get stepsize(): number;
  79114. set stepsize(value: number);
  79115. get zoom(): number;
  79116. set zoom(value: number);
  79117. get tile(): number;
  79118. set tile(value: number);
  79119. get brightness(): number;
  79120. set brightness(value: number);
  79121. get darkmatter(): number;
  79122. set darkmatter(value: number);
  79123. get distfading(): number;
  79124. set distfading(value: number);
  79125. get saturation(): number;
  79126. set saturation(value: number);
  79127. /**
  79128. * Serializes this starfield procedural texture
  79129. * @returns a serialized starfield procedural texture object
  79130. */
  79131. serialize(): any;
  79132. /**
  79133. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79134. * @param parsedTexture defines parsed texture data
  79135. * @param scene defines the current scene
  79136. * @param rootUrl defines the root URL containing startfield procedural texture information
  79137. * @returns a parsed Starfield Procedural BABYLON.Texture
  79138. */
  79139. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79140. }
  79141. }
  79142. declare module BABYLON {
  79143. /** @hidden */
  79144. export var woodProceduralTexturePixelShader: {
  79145. name: string;
  79146. shader: string;
  79147. };
  79148. }
  79149. declare module BABYLON {
  79150. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79151. private _ampScale;
  79152. private _woodColor;
  79153. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79154. updateShaderUniforms(): void;
  79155. get ampScale(): number;
  79156. set ampScale(value: number);
  79157. get woodColor(): BABYLON.Color3;
  79158. set woodColor(value: BABYLON.Color3);
  79159. /**
  79160. * Serializes this wood procedural texture
  79161. * @returns a serialized wood procedural texture object
  79162. */
  79163. serialize(): any;
  79164. /**
  79165. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79166. * @param parsedTexture defines parsed texture data
  79167. * @param scene defines the current scene
  79168. * @param rootUrl defines the root URL containing wood procedural texture information
  79169. * @returns a parsed Wood Procedural BABYLON.Texture
  79170. */
  79171. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79172. }
  79173. }